/* =====================================================
   POULTRYPRO - COMPLETE LIGHT THEME (v3.0)
   Professional ERP Design | Clean & Modern
   ===================================================== */

/* Inter font family locally hosted */
@font-face {
    font-family: 'Inter';
    src: url('assets/fonts/Inter-400.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Inter';
    src: url('assets/fonts/Inter-500.ttf') format('truetype');
    font-weight: 500;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Inter';
    src: url('assets/fonts/Inter-600.ttf') format('truetype');
    font-weight: 600;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Inter';
    src: url('assets/fonts/Inter-700.ttf') format('truetype');
    font-weight: 700;
    font-style: normal;
    font-display: swap;
}
@font-face {
    font-family: 'Inter';
    src: url('assets/fonts/Inter-800.ttf') format('truetype');
    font-weight: 800;
    font-style: normal;
    font-display: swap;
}

/* ── Design Tokens ──────────────────────────────────── */
:root {
    --primary:       #3e60d5;
    --primary-dark:  #3453ba;
    --primary-light: rgba(62, 96, 213, 0.1);
    --success:       #10b981;
    --success-light: #d1fae5;
    --danger:        #ff5b5b;
    --danger-light:  #fee2e2;
    --warning:       #f9b922;
    --warning-light: #fff3cd;
    --info:          #39afd1;

    --bg:       #f1f3fa;
    --surface:  #ffffff;
    --border:   #eef2f7;
    --border-2: #dee2e6;

    --text:      #313a46;
    --text-2:    #6c757d;
    --text-muted:#98a6ad;

    --sidebar-bg:    #3F497F;
    --sidebar-text:  #cbd5e1;
    --sidebar-hover: rgba(255,255,255,0.1);
    --sidebar-active:#ffffff;

    --radius-sm: 4px;
    --radius:    6px;
    --radius-lg: 10px;

    --shadow-xs: 0 1px 2px rgba(15,23,42,0.06);
    --shadow-sm: 0 2px 6px 0 rgba(154,161,171,.1);
    --shadow:    0 0 35px 0 rgba(154,161,171,.15);
    --shadow-lg: 0 5px 20px 0 rgba(154,161,171,.2);

    /* ── Responsive Layout Tokens ── */
    --sidebar-w: 260px;
    --topbar-h: 50px;
    --content-p: 20px;
}

/* ── Reset ──────────────────────────────────────────── */
html { overflow-y: auto; } /* Standard vertical scroll */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Inter', system-ui, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    min-height: 100dvh;
    overflow-y: auto;
}

/* Force Inter font globally for all interactive elements and inputs */
input, select, textarea, button, optgroup, option {
    font-family: 'Inter', system-ui, -apple-system, sans-serif !important;
}

/* Reserve space for icons to prevent layout shift */
[data-feather] {
    width: 18px;
    height: 18px;
    display: inline-block;
    vertical-align: middle;
}

/* ── Layout ─────────────────────────────────────────── */
.app-container { display: flex; min-height: 100vh; min-height: 100dvh; width: 100%; max-width: 100vw; overflow-x: hidden; }

/* ── Sidebar ─────────────────────────────────────────── */
.sidebar {
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    height: 100dvh;
    z-index: 1050;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.2) transparent;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s ease, left 0.3s ease;
    overscroll-behavior: contain;
    z-index: 11000;
}

/* ── Main Content & Topbar ─────────────────────────── */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-w);
    padding: var(--content-p);
    padding-top: calc(var(--topbar-h) + var(--content-p));
    padding-bottom: 40px;
    transition: margin-left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    min-width: 0; /* Crucial: allows flex child to be smaller than its content, enabling horizontal scroll in children */
}

.topbar {
    position: fixed;
    top: 0;
    right: 0;
    left: var(--sidebar-w);
    height: var(--topbar-h);
    background: #465ED7;
    z-index: 10000;
    isolation: isolate; /* Creates own stacking context, breaks free from parent */
    padding: 0 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1), right 0.3s ease;
}

.page-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: #ffffff;
    margin: 0;
}

/* ── Typography ──────────────────────────────────────── */
h1 { font-size: clamp(1.1rem, 4vw, 1.25rem); font-weight: 800; color: var(--text);   line-height: 1.3; }
h2 { font-size: clamp(1rem, 3.5vw, 1.15rem); font-weight: 700; color: var(--text);   }
h3 { font-size: 0.95rem;    font-weight: 700; color: var(--text-2); }
h4 { font-size: 0.85rem;  font-weight: 700; color: var(--text-2); }
p  { color: var(--text-2); font-size: 0.85rem; }

.text-muted { color: var(--text-muted) !important; }

/* ── Cards ───────────────────────────────────────────── */
.card {
    background: var(--surface);
    border: none;
    border-radius: var(--radius);
    padding: 1.25rem;
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}

/* ── GLOBAL DARK-OVERRIDE ENGINE ─────────────────────── *
   Forces any embedded dark-mode colours from page-level
   <style> blocks to be replaced with light equivalents.  */

/* Force all generic divs/sections with dark bg to white */
.main-content div:not(.sidebar):not([class*="sidebar"]),
.main-content section,
.main-content article,
.main-content aside:not(.sidebar) {
    scrollbar-color: #cbd5e1 #f1f5f9;
}

/* Override common dark backgrounds used in embedded styles */
[style*="background: #f9fafb"],
[style*="background:#f9fafb"],
[style*="background-color: #f9fafb"],
[style*="background: #f8fafc"],
[style*="background: #ffffff"],
[style*="background:#ffffff"] {
    background: var(--surface) !important;
    color: var(--text) !important;
}

/* Fix any remaining dark text-on-dark from embedded styles */
.main-content [style*="color: #1e293b"],
.main-content [style*="color:#1e293b"] {
    color: var(--text) !important;
}

/* ── Forms ───────────────────────────────────────────── */
.form-group  { margin-bottom: 0.9rem; }
.form-label  {
    display: block;
    margin-bottom: 0.3rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.form-control {
    width: 100%;
    padding: 0.6rem 1rem;
    background: #fff;
    border: 1px solid #cbd5e1;
    border-radius: var(--radius);
    color: var(--text);
    font-size: 0.9rem;
    font-family: 'Inter', sans-serif;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    -webkit-appearance: none;
    box-shadow: var(--shadow-xs);
}
.form-control:hover {
    border-color: #94a3b8;
}
.form-control:focus {
    outline: none;
    border-color: var(--primary);
    background: #fff;
    box-shadow: 0 0 0 3px rgba(62, 96, 213, 0.15);
    transform: translateY(-1px);
}
.form-control::placeholder { color: #94a3b8; }
select.form-control { cursor: pointer; background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E"); background-repeat: no-repeat; background-position: right 0.75rem center; background-size: 1rem; padding-right: 2.5rem; }

/* Hide arrows in number inputs globally */
input::-webkit-outer-spin-button,
input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }
input[type=number] { -moz-appearance: textfield; }

/* ── Buttons ─────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.45rem 1.1rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    font-family: 'Inter', sans-serif;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease;
    white-space: nowrap;
}
.btn-primary         { background: var(--primary);  color: #fff; border-color: var(--primary); }
.btn-primary:hover   { background: var(--primary-dark); border-color: var(--primary-dark); box-shadow: 0 2px 6px 0 rgba(62, 96, 213, 0.4); transform: translateY(-1px); }
.btn-success         { background: var(--success);  color: #fff; border-color: var(--success); }
.btn-danger          { background: var(--danger);   color: #fff; border-color: var(--danger); }
.btn-outline:hover   { background: var(--primary); color: #fff; }

.btn-sm {
    padding: 0.3rem 0.6rem;
    font-size: 0.75rem;
}

.btn-icon {
    width: 28px;
    height: 28px;
    padding: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    background: #f1f5f9;
    color: var(--text-2);
    border: 1px solid var(--border);
    cursor: pointer;
    transition: all 0.2s;
}
.btn-icon:hover {
    background: var(--primary-light);
    color: var(--primary);
    border-color: var(--primary);
}

/* ── Tables ──────────────────────────────────────────── */
.table-responsive { overflow-x: auto; border-radius: var(--radius); border: 1px solid var(--border); }

table  { width: 100%; border-collapse: collapse; background: var(--surface); }
thead  { background: #f8fafc; }

th {
    text-align: left;
    padding: 8px 12px;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-2);
    white-space: nowrap;
    background: #f1f5ff;
}
td {
    padding: 6px 12px;
    font-size: 0.82rem;
    color: var(--text-2);
    border-bottom: 1px solid #f1f5f9;
}
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover { background: #fafbff; }

/* ── Login / Auth ────────────────────────────────────── */
.auth-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #e0e7ff 0%, #f8fafc 60%, #dbeafe 100%);
}
.auth-card {
    width: 100%;
    max-width: 420px;
    padding: 2.5rem;
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
    background: #fff;
}

/* ── Sidebar Nav ─────────────────────────────────────── */
.nav-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 6px 20px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: all 0.2s ease;
}
.nav-item svg, .nav-item i { width: 18px; height: 18px; flex-shrink: 0; }
.nav-item:hover {
    color: #ffffff;
    background: rgba(255,255,255,0.08);
}
.nav-item.active {
    color: #ffffff;
    background: var(--primary);
    border-radius: 8px;
    font-weight: 600;
    margin: 0 10px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

.sidebar-brand {
    height: 70px;
    padding: 0 20px;
    font-size: 1.3rem;
    font-weight: 800;
    color: #ffffff;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    background: transparent;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    letter-spacing: -0.01em;
    flex-shrink: 0;
}

.brand-logo {
    width: 38px;
    height: 38px;
    object-fit: contain;
    filter: drop-shadow(0 2px 4px rgba(0,0,0,0.2));
}
.nav-section-label {
    padding: 12px 20px 6px;
    font-size: 0.65rem;
    color: rgba(255,255,255,0.4);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 700;
}

/* ── Sidebar Dropdowns ──────────────────────────────── */
.nav-dropdown {
    display: flex;
    flex-direction: column;
}

.nav-dropdown-btn {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 8px 20px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    border: none;
    background: transparent;
    width: 100%;
    text-align: left;
}
.nav-dropdown-btn:hover {
    color: #ffffff;
    background: rgba(255,255,255,0.08);
}
.nav-dropdown-btn svg:last-child {
    margin-left: auto;
    width: 14px;
    height: 14px;
    transition: transform 0.3s ease;
}
.nav-dropdown.open .nav-dropdown-btn svg:last-child {
    transform: rotate(180deg);
}
.nav-dropdown.open .nav-dropdown-btn {
    color: #fff;
    background: rgba(255,255,255,0.05);
}

.nav-sub-menu {
    display: none;
    flex-direction: column;
    background: rgba(0,0,0,0.15);
    padding: 4px 0;
}
.nav-dropdown.open .nav-sub-menu {
    display: flex;
}

.nav-sub-item {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    padding: 6px 20px 6px 48px;
    color: rgba(255,255,255,0.6);
    text-decoration: none;
    font-size: 0.825rem;
    transition: all 0.2s ease;
}
.nav-sub-item:hover {
    color: #ffffff;
}
.nav-sub-item.active {
    color: #ffffff;
    font-weight: 600;
}
.nav-sub-item i, .nav-sub-item svg { width: 14px !important; height: 14px !important; }


/* ── Animations ──────────────────────────────────────── */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
.animate-fade-in { animation: fadeIn 0.3s ease-out forwards; }

/* ── Status Badges / Chips ───────────────────────────── */
.badge, [class*="pm-chip"] {
    display: inline-flex;
    align-items: center;
    padding: 0.2rem 0.6rem;
    border-radius: 20px;
    font-size: 0.65rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ── Page-Specific Global Overrides ───────────────────── *
   These neutralise leftover dark backgrounds from embedded
   <style> blocks across retail_sales, b2b_sales, vouchers  */

/* POS Terminal overrides */
.premium-pos-container,
.pos-app,
.pos-terminal,
.pos-catalog,
.pos-header,
.pos-main-layout,
.terminal-card,
.menu-tile,
.ws-topbar,
.ws-grid-wrap,
.ws-footer,
.finance-container,
.voucher-terminal,
.terminal-card,
.ws-page,
.pos-grid {
    background: var(--surface) !important;
    color: var(--text) !important;
    border-color: var(--border) !important;
}

/* POS menu tiles */
.menu-tile {
    background: #f8fafc !important;
    border: 1px solid var(--border) !important;
    box-shadow: var(--shadow-xs) !important;
}
.menu-tile:hover {
    background: #f0f4ff !important;
    border-color: var(--primary) !important;
    transform: translateY(-3px) !important;
    box-shadow: var(--shadow) !important;
}
.tile-title { color: var(--text) !important; }
.tile-price-tag { color: var(--success) !important; }
.tile-stock-badge { background: #f1f5f9 !important; color: var(--text-muted) !important; border-color: var(--border) !important; }

/* POS inputs */
.premium-input, .g-inp, .item-ac-inp, .ws-cust-input {
    background: #f8fafc !important;
    border: 1px solid var(--border) !important;
    color: var(--text) !important;
    border-radius: 8px !important;
}
.premium-input:focus, .g-inp:focus, .item-ac-inp:focus {
    border-color: var(--primary) !important;
    background: #fff !important;
    box-shadow: 0 0 0 3px rgba(79,70,229,0.1) !important;
}

/* POS Total Display */
.terminal-total-card {
    background: linear-gradient(135deg, #f0fdf4 0%, #dcfce7 100%) !important;
    border: 2px solid #86efac !important;
    border-radius: 10px !important;
}
.total-label { color: var(--success) !important; }
.total-value { color: #15803d !important; text-shadow: none !important; }

/* POS payment options */
.pay-option, .pay-mode-box {
    background: #f8fafc !important;
    border: 1px solid var(--border) !important;
    color: var(--text-muted) !important;
    border-radius: 8px !important;
}
.pay-option:has(input:checked),
.pay-mode-item input:checked + .pay-mode-box {
    background: var(--primary-light) !important;
    color: var(--primary) !important;
    border-color: var(--primary) !important;
    box-shadow: 0 2px 8px rgba(79,70,229,0.15) !important;
}

/* POS Header */
.pos-header {
    background: #fff !important;
    border: 1px solid var(--border) !important;
    box-shadow: var(--shadow-sm) !important;
}
.pos-title, .terminal-label { color: var(--text) !important; }
.header-center-info { color: var(--text-muted) !important; }
.terminal-clock {
    background: #f1f5f9 !important;
    color: var(--text) !important;
    border-radius: 8px !important;
}

/* POS selected product area */
.selected-product-area, .terminal__selection {
    background: #f8fafc !important;
    border: 2px dashed var(--border-2) !important;
    border-radius: 10px !important;
}
.active-title, .selection__name { color: var(--text) !important; }
.product-label, .selection__label { color: var(--primary) !important; }
.item-placeholder p { color: var(--text-muted) !important; }

/* Wholesale grid */
.ws-grid thead tr, .ws-grid thead th {
    background: #f8fafc !important;
    color: var(--text-muted) !important;
    border-color: var(--border) !important;
}
.ws-grid tbody td { color: var(--text-2) !important; border-color: #f1f5f9 !important; }
.ws-grid tbody tr:hover { background: #fafbff !important; }
.ws-grid tbody td:first-child { background: #f8fafc !important; color: var(--primary) !important; }

/* Wholesale dropdown */
.ws-cust-dropdown, .item-dropdown, .item-ac-list {
    background: #fff !important;
    border: 1px solid var(--border) !important;
    box-shadow: var(--shadow-lg) !important;
}
.ws-cust-option, .item-opt, .item-ac-opt {
    color: var(--text-2) !important;
    border-bottom-color: #f1f5f9 !important;
}
.ws-cust-option:hover, .item-opt:hover, .item-ac-opt:hover,
.ws-cust-option.highlighted, .item-ac-opt.highlighted {
    background: var(--primary-light) !important;
    color: var(--primary) !important;
}

/* Search bar */
.menu-search-bar, .catalog__search { 
    background: #f8fafc !important;
    border: 1px solid var(--border) !important;
    border-radius: 8px !important;
}
.menu-search-bar input, .search__input {
    background: transparent !important;
    color: var(--text) !important;
}
.menu-search-bar input::placeholder, .search__input::placeholder { color: #94a3b8 !important; }
.menu-search-bar svg { color: var(--text-muted) !important; }

/* Tabs */
.premium-tab, .tab-btn {
    background: #f1f5f9 !important;
    border: 1px solid var(--border) !important;
    color: var(--text-muted) !important;
    border-radius: 8px !important;
}
.premium-tab.active, .tab-btn--active, .tab-btn[aria-selected="true"] {
    background: var(--primary) !important;
    color: #fff !important;
    border-color: var(--primary) !important;
    box-shadow: 0 4px 12px rgba(79,70,229,0.25) !important;
}

/* Finance / Voucher */
.finance-header {
    background: #fff !important;
    border: 1px solid var(--border) !important;
    box-shadow: var(--shadow-sm) !important;
}
.finance-title { color: var(--text) !important; }
.mode-toggle { background: #f1f5f9 !important; border: 1px solid var(--border) !important; }
.mode-btn { color: var(--text-muted) !important; }
.mode-btn.active { background: var(--primary) !important; color: #fff !important; }
.ws-cust-input, .premium-input.amount-large {
    color: var(--text) !important;
    background: #f8fafc !important;
}
.amount-large { color: var(--success) !important; }
.pay-mode-box svg { color: inherit !important; }

/* Wholesale footer */
.ws-footer {
    background: #f8fafc !important;
    border-top: 1px solid var(--border) !important;
    border-radius: 0 0 12px 12px !important;
}
.footer-tag { color: var(--text-muted) !important; }
.footer-pay-sel {
    background: #fff !important;
    border: 1px solid var(--border) !important;
    color: var(--text) !important;
    border-radius: 8px !important;
}
.footer-total-label { color: var(--text-muted) !important; }
.footer-total-amt { color: var(--success) !important; }

/* Wholesale top bar */
.ws-topbar {
    background: #fff !important;
    border: 1px solid var(--border) !important;
    border-radius: 12px 12px 0 0 !important;
}
.ws-brand { color: var(--text) !important; border-right-color: var(--border) !important; }
.ws-inv-pill { background: var(--primary-light) !important; border-color: rgba(99,102,241,0.2) !important; }
.ws-inv-label { color: var(--primary) !important; }
.ws-inv-value { color: var(--primary-dark) !important; }
.ws-date-pill { background: var(--success-light) !important; border-color: rgba(22,163,74,0.2) !important; }
.ws-date-text { color: var(--success) !important; }

/* Recent sections */
.ws-recent-hdr { color: var(--text-muted) !important; }
.pm-chip.credit { background: var(--warning-light) !important; color: var(--warning) !important; }
.pm-chip.cash   { background: var(--success-light) !important; color: var(--success) !important; }
.pm-chip.other  { background: var(--primary-light) !important; color: var(--primary) !important; }
.pm-chip.receipt{ background: var(--success-light) !important; color: var(--success) !important; border: 1px solid #86efac !important; }
.pm-chip.payment{ background: var(--danger-light)  !important; color: var(--danger)  !important; border: 1px solid #fca5a5 !important; }

/* ── Scrollbar ────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: #f1f5f9; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }

/* ── Responsive & Toggle Logic ──────────────────────── */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 10500; /* Between topbar and sidebar */
    display: none;
    backdrop-filter: blur(2px);
}

.btn-toggle {
    background: transparent;
    border: none;
    color: #fff;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: background 0.2s;
    position: relative;
    z-index: 10001;
}
.btn-toggle:hover { background: rgba(255,255,255,0.1); }

/* ── Tablet + Mobile: sidebar off-canvas (≤1100px) ─────────────── */
@media (max-width: 1100px) {
    :root { --sidebar-w: 0px; --content-p: 16px; }
    .sidebar { transform: translateX(-100%); width: 260px !important; }
    .main-content { margin-left: 0 !important; padding-top: calc(var(--topbar-h) + 16px); }
    .topbar { left: 0 !important; padding: 0 16px; }

    /* Toggle active state */
    body.sidebar-active { overflow: hidden !important; }
    body.sidebar-active .sidebar { transform: translateX(0); }
    body.sidebar-active .sidebar-overlay { display: block; }
}

/* ── Desktop: voluntary sidebar collapse ────────────────────────── */
@media (min-width: 1101px) {
    body.sidebar-collapsed { --sidebar-w: 0px; }
    body.sidebar-collapsed .sidebar { transform: translateX(-100%); }
    body.sidebar-collapsed .main-content { margin-left: 0; }
    body.sidebar-collapsed .topbar { left: 0; }
}

/* ── Tablet zone: content padding tweak (769–1100px) ────────────── */
@media (min-width: 769px) and (max-width: 1100px) {
    .main-content {
        padding-left: 12px;
        padding-right: 12px;
    }
    body { font-size: 0.8rem !important; }
    td { font-size: 0.75rem !important; }
    th { font-size: 0.65rem !important; }
}

@media (max-width: 768px) {
    /* Topbar */
    .page-title { font-size: 0.875rem; }
    .user-profile > div { max-width: min(28vw, 160px); }
    .user-profile > div > div { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }

    /* Report filter bars: let each input fill its row */
    .filter-group { flex: 1 1 calc(50% - 8px); min-width: 130px; }
    .filter-input { width: 100% !important; min-width: 0 !important; }
    .ws-cust-wrap { width: 100% !important; }
    .filter-actions { width: 100%; margin-left: 0 !important; justify-content: stretch; }
    .filter-actions .btn-report { flex: 1; justify-content: center; }

    /* Tables: add horizontal scroll cue */
    .table-responsive, .report-table-wrapper, .hms-card { -webkit-overflow-scrolling: touch; }
}

/* ── User Dropdown ──────────────────────────────────── */
.user-dropdown {
    position: relative;
    cursor: pointer;
    user-select: none;
}

.dropdown-menu {
    position: absolute;
    top: calc(100% + 15px);
    right: 0;
    width: auto;
    min-width: 200px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.15);
    display: none;
    flex-direction: column;
    padding: 8px 0;
    z-index: 1100;
    border: 1px solid rgba(0,0,0,0.05);
    animation: dropdownFade 0.2s ease-out;
    transform-origin: top right;
}

@keyframes dropdownFade {
    from { opacity: 0; transform: translateY(10px) scale(0.95); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.dropdown-menu.show {
    display: flex;
}

.dropdown-item {
    padding: 12px 20px;
    color: var(--text);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s;
    white-space: nowrap;
}

.dropdown-item:hover {
    background: var(--primary-light);
    color: var(--primary);
}

.dropdown-item svg {
    width: 16px;
    height: 16px;
    stroke-width: 2;
}

.dropdown-divider {
    height: 1px;
    background: var(--border);
    margin: 8px 0;
}

/* Arrow for dropdown */
.dropdown-menu::after {
    content: '';
    position: absolute;
    top: -6px;
    right: 20px;
    width: 12px;
    height: 12px;
    background: #fff;
    transform: rotate(45deg);
    border-top: 1px solid rgba(0,0,0,0.05);
    border-left: 1px solid rgba(0,0,0,0.05);
}

/* ── GLOBAL REPORT OPTIMIZATIONS (v3.5) ──────────────── */

/* High specificity (html body) to override internal <style> blocks in PHP files */
html body .report-filter-bar {
    display: flex !important;
    flex-wrap: wrap !important;
    gap: 12px !important;
    padding: 15px !important;
    align-items: flex-end !important;
    height: auto !important;
    background: #fff !important;
    border-radius: 8px !important;
    border: 1px solid #e2e8f0 !important;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05) !important;
    margin-bottom: 15px !important;
}

html body .filter-group {
    display: flex !important;
    flex-direction: column !important;
    gap: 4px !important;
    flex: 0 0 auto !important;
}

html body .filter-input {
    height: 34px !important;
    border: 1px solid #cbd5e1 !important;
    border-radius: 4px !important;
    padding: 0 8px !important;
    font-size: 12px !important;
    min-width: 140px !important;
}

html body .filter-actions {
    display: flex !important;
    gap: 8px !important;
    align-items: flex-end !important;
    margin-left: auto !important;
}

/* --- Mobile Specific Overrides (≤ 768px) --- */
@media (max-width: 768px) {
    html body .report-header-title {
        font-size: 16px !important;
        margin-bottom: 10px !important;
    }

    html body .report-filter-bar {
        padding: 12px !important;
        gap: 10px !important;
        border-radius: 10px !important;
    }

    /* Force filters to stack or grid-up */
    html body .filter-group {
        flex: 1 1 calc(50% - 5px) !important;
        min-width: 120px !important;
    }

    html body .filter-input {
        width: 100% !important;
        min-width: 0 !important;
    }

    /* Buttons row */
    html body .filter-actions {
        width: 100% !important;
        margin-left: 0 !important;
        margin-top: 5px !important;
        justify-content: space-between !important;
        display: flex !important;
    }

    html body .btn-report {
        flex: 1 !important;
        justify-content: center !important;
        height: 38px !important;
        font-size: 10px !important;
    }

    /* Master Toggle Header */
    #master-filter-toggle {
        display: flex !important;
        align-items: center !important;
        justify-content: space-between !important;
        background: #fff !important;
        padding: 10px 15px !important;
        border-radius: 8px !important;
        border: 1px solid #e2e8f0 !important;
        margin-bottom: 5px !important;
        cursor: pointer !important;
        box-shadow: 0 1px 3px rgba(0,0,0,0.05) !important;
    }

    #master-filter-toggle.sticky-header {
        position: sticky !important;
        top: 50px !important;
        z-index: 1002 !important;
        border-bottom: 2px solid #3b82f6 !important;
    }

    .filter-status-label {
        display: flex !important;
        align-items: center !important;
        gap: 8px !important;
        font-size: 12px !important;
        font-weight: 700 !important;
        color: #1e293b !important;
        text-transform: uppercase !important;
    }

    .btn-toggle-master {
        background: #f1f5f9 !important;
        border: none !important;
        padding: 4px !important;
        border-radius: 4px !important;
        color: #64748b !important;
        display: flex !important;
    }

    /* Master Toggle Active State (when expanded) */
    #master-filter-toggle.active {
        border-bottom-left-radius: 0 !important;
        border-bottom-right-radius: 0 !important;
        margin-bottom: 0 !important;
    }

    html body .report-filter-bar.master-collapsible:not(.master-collapsed) {
        border-top-left-radius: 0 !important;
        border-top-right-radius: 0 !important;
        border-top: none !important;
    }

    /* Collapsible States */
    html body .report-filter-bar.master-collapsible {
        transition: all 0.3s ease !important;
        overflow: hidden !important;
    }

    html body .report-filter-bar.master-collapsed {
        display: none !important;
    }


    /* Better Table UX on Mobile */
    html body .report-table-wrapper {
        border-radius: 8px !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
        width: 100% !important;
        border: 1px solid #e2e8f0 !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        margin-bottom: 20px !important;
    }

    html body .report-table th,
    html body .report-table td {
        padding-left: 12px !important;
        padding-right: 12px !important;
        white-space: nowrap !important;
    }
}
