/* Custom CSS overrides or additions */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

body {
    font-family: 'Inter', sans-serif;
}

/* Scrollbar styling for a cleaner look */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
.dark ::-webkit-scrollbar-thumb {
    background: #475569;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}
.dark ::-webkit-scrollbar-thumb:hover {
    background: #334155;
}

/* Active navigation link styling */
.nav-link.active {
    background-color: #eff6ff; /* blue-50 */
    color: #2563eb; /* blue-600 */
}
.dark .nav-link.active {
    background-color: #1e3a8a; /* blue-900 */
    color: #bfdbfe; /* blue-200 */
}

/* ══════════════════════════════════════════════════════
   MOBILE SIDEBAR DRAWER
   ══════════════════════════════════════════════════════ */

/* Desktop: sidebar is always visible, no special positioning */
@media (min-width: 768px) {
    .sidebar-drawer {
        position: relative;
        transform: none !important;
        z-index: auto;
    }
    .sidebar-overlay { display: none !important; }
}

/* Mobile: sidebar slides in from the left as a fixed overlay */
@media (max-width: 767px) {
    .sidebar-drawer {
        position: fixed;
        top: 0;
        left: 0;
        height: 100%;
        z-index: 50;
        transform: translateX(-100%);
        transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
        box-shadow: 4px 0 24px rgba(0,0,0,0.18);
    }
    .sidebar-drawer.mobile-open {
        transform: translateX(0);
    }
}

/* Semi-transparent backdrop */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 49;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(2px);
    transition: opacity 0.25s ease;
    opacity: 0;
}
.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

/* ══════════════════════════════════════════════════════
   CARD-TABLE PATTERN  (mobile list views)
   On screens < 640px, turn each <tr> into a stacked card.
   ══════════════════════════════════════════════════════ */
@media (max-width: 639px) {
    .card-table thead { display: none; }

    .card-table tbody tr {
        display: block;
        border: 1px solid #e2e8f0;
        border-radius: 12px;
        margin-bottom: 10px;
        padding: 12px 14px;
        background: #fff;
        box-shadow: 0 1px 3px rgba(0,0,0,0.06);
    }
    .dark .card-table tbody tr {
        border-color: #374151;
        background: #1f2937;
        box-shadow: 0 1px 3px rgba(0,0,0,0.25);
    }
    .card-table tbody tr:hover {
        background: #f0f9ff;
    }
    .dark .card-table tbody tr:hover {
        background: #1e3a5f;
    }

    .card-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 5px 0;
        border: none !important;
        font-size: 0.875rem;
    }
    .card-table td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 0.75rem;
        color: #6b7280;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        flex-shrink: 0;
        margin-right: 8px;
    }
    .dark .card-table td::before {
        color: #9ca3af;
    }

    /* Hide less-critical columns on mobile via data-hide-mobile */
    .card-table td[data-hide-mobile="true"] {
        display: none;
    }

    /* Action buttons cell — full width, right-aligned */
    .card-table td.actions-cell {
        justify-content: flex-end;
        padding-top: 10px;
        border-top: 1px solid #e2e8f0 !important;
        margin-top: 6px;
    }
    .dark .card-table td.actions-cell {
        border-top-color: #374151 !important;
    }
    .card-table td.actions-cell::before { display: none; }
}

/* ══════════════════════════════════════════════════════
   TOUCH TARGET SIZING
   ══════════════════════════════════════════════════════ */
@media (max-width: 767px) {
    button, a.nav-link, select, input[type="checkbox"] {
        min-height: 44px;
    }
    .nav-link {
        min-height: 44px;
        display: flex;
        align-items: center;
    }
    /* Exception: small inline icon buttons should not be forced tall */
    button.icon-btn { min-height: unset; }
}

/* ══════════════════════════════════════════════════════
   INVOICE ITEM ROW — MOBILE
   Each item in the invoice items list becomes a card
   ══════════════════════════════════════════════════════ */
@media (max-width: 639px) {
    .inv-items-table thead { display: none; }
    .inv-items-table tbody tr {
        display: block;
        border: 1px solid #e2e8f0;
        border-radius: 10px;
        margin-bottom: 10px;
        padding: 10px 12px;
        background: #fff;
    }
    .dark .inv-items-table tbody tr {
        border-color: #374151;
        background: #1f2937;
    }
    .inv-items-table td {
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 4px 0;
        border: none !important;
        font-size: 0.875rem;
    }
    .inv-items-table td::before {
        content: attr(data-label);
        font-weight: 600;
        font-size: 0.72rem;
        color: #6b7280;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        flex-shrink: 0;
        margin-right: 8px;
    }
    .dark .inv-items-table td::before { color: #9ca3af; }
    .inv-items-table td:last-child {
        justify-content: flex-end;
        padding-top: 8px;
        border-top: 1px solid #e2e8f0 !important;
        margin-top: 4px;
    }
    .dark .inv-items-table td:last-child { border-top-color: #374151 !important; }
    .inv-items-table td:last-child::before { display: none; }
}

/* ══════════════════════════════════════════════════════
   MISC RESPONSIVE HELPERS
   ══════════════════════════════════════════════════════ */
@media (max-width: 639px) {
    /* Page headers: stack title and action button vertically */
    .page-header {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 10px;
    }
    .page-header h2 { font-size: 1.25rem; }

    /* Filter bars: allow wrapping */
    .filter-bar {
        flex-wrap: wrap;
        gap: 8px;
    }

    /* Full-width select/input inside filter bars */
    .filter-bar select,
    .filter-bar input[type="text"],
    .filter-bar input[type="date"] {
        width: 100%;
    }
}
