:root {
    color-scheme: dark;
    --primary: #0ea5e9;
    --primary-hover: #0284c7;
    --bg-main: #020617;
    --bg-card: #0f172a;
    --bg-input: #1e293b;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --border: #334155;
    --success: #10b981;
    --danger: #ef4444;
    --glass: rgba(15, 23, 42, 0.8);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
}

.layout {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    padding: 2rem 1rem;
    position: fixed;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

.sidebar-nav {
    flex: 1;
    overflow-y: auto;
    margin-right: -0.5rem;
    padding-right: 0.5rem;
}

/* Custom scrollbar for sidebar */
.sidebar-nav::-webkit-scrollbar {
    width: 4px;
}
.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(14, 165, 233, 0.2);
    border-radius: 10px;
}
.sidebar-nav::-webkit-scrollbar-thumb:hover {
    background: rgba(14, 165, 233, 0.5);
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    margin-top: 1rem;
    background: var(--bg-card);
}

.sidebar-logo {
    font-size: 1.5rem;
    font-weight: 800;
    margin-bottom: 2rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: var(--primary);
}

.nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 0.5rem;
    transition: 0.2s;
    margin-bottom: 0.5rem;
}

.nav-link:hover, .nav-link.active {
    background: var(--bg-input);
    color: var(--text-main);
}

.nav-link.active {
    color: var(--primary);
}

.main-content {
    margin-left: 260px;
    flex: 1;
    padding: 2rem;
    min-width: 0;       /* prevents flex children from forcing overflow */
    overflow-x: hidden; /* table scroll stays inside .table-scroll, not the page */
}

.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 1.5rem;
    margin-bottom: 1.5rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
    min-width: 0; /* prevent card from growing with table content */
}

.btn {
    padding: 0.6rem 1.2rem;
    border-radius: 0.5rem;
    font-weight: 600;
    cursor: pointer;
    transition: 0.2s;
    border: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-primary {
    background: var(--primary);
    color: white;
}

.btn-primary:hover {
    background: var(--primary-hover);
}

.btn-outline {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
}

.btn-outline:hover {
    background: var(--bg-input);
    color: var(--text-main);
}

.input-group {
    margin-bottom: 1rem;
}

.input-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-size: 0.875rem;
    color: var(--text-muted);
}

.input-field {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border);
    padding: 0.75rem 1rem;
    border-radius: 0.5rem;
    color: var(--text-main);
    outline: none;
}

.input-field:focus {
    border-color: var(--primary);
}

select.input-field option {
    background-color: var(--bg-input);
    color: var(--text-main);
}

.table-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1rem;
    overflow: hidden;
    margin-top: 1rem;
}

.table-scroll {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table-scroll::-webkit-scrollbar {
    height: 5px;
}
.table-scroll::-webkit-scrollbar-track {
    background: var(--bg-input);
}
.table-scroll::-webkit-scrollbar-thumb {
    background: rgba(14, 165, 233, 0.4);
    border-radius: 10px;
}

table {
    width: 100%;
    min-width: 600px;
    border-collapse: separate;
    border-spacing: 0;
}

/* ── Filter Bar ─────────────────────────────── */
.filter-bar {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1rem;
    margin-bottom: 2rem;
    overflow: hidden;
}

.filter-bar-header {
    display: none; /* hidden on desktop */
}

.filter-bar-body {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    padding: 1.25rem;
    align-items: end;
}

/* Icon pill for active filter count */
.filter-icon-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.4rem;
    padding: 0.5rem 0.9rem;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 2rem;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 700;
    transition: all 0.2s;
    white-space: nowrap;
}
.filter-icon-btn:hover,
.filter-icon-btn.active {
    border-color: var(--primary);
    color: var(--primary);
    background: rgba(14, 165, 233, 0.08);
}
.filter-icon-btn .filter-badge {
    background: var(--primary);
    color: #fff;
    border-radius: 999px;
    font-size: 0.65rem;
    font-weight: 900;
    padding: 0.1rem 0.4rem;
    min-width: 1.2rem;
    text-align: center;
    line-height: 1.4;
}

th {
    text-align: left;
    padding: 1.25rem 1rem;
    color: var(--text-muted);
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
    background: rgba(255, 255, 255, 0.02);
}

td {
    padding: 1.25rem 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

tbody tr:last-child td {
    border-bottom: none;
}

tbody tr {
    transition: background 0.2s;
}

tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

.badge {
    padding: 0.25rem 0.5rem;
    border-radius: 0.25rem;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
}

.badge-success { background: rgba(16, 185, 129, 0.1); color: var(--success); }
.badge-danger { background: rgba(239, 68, 68, 0.1); color: var(--danger); }
.badge-primary { background: rgba(14, 165, 233, 0.1); color: var(--primary); }

.btn-danger {
    background: var(--danger);
    color: white;
}
.btn-danger:hover { background: #dc2626; }

/* Modal System */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    animation: fadeIn 0.15s ease;
}

.modal-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 1rem;
    padding: 2rem;
    width: 100%;
    max-width: 560px;
    max-height: 80vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
    animation: slideUp 0.2s ease;
}

.modal-content.modal-lg { max-width: 720px; }

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-header h3 {
    font-weight: 800;
    font-size: 1.25rem;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1.5rem;
    line-height: 1;
}
.modal-close:hover { color: var(--text-main); }

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.75rem;
    margin-top: 1.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border);
}

@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes slideUp { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: translateY(0); } }

/* Checkbox */
.checkbox-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.5rem;
}



.checkbox-label input[type="checkbox"] {
    accent-color: var(--primary);
    width: 16px;
    height: 16px;
}

/* Pagination Styles */
.pagination {
    display: flex;
    list-style: none;
    padding: 0;
    gap: 0.25rem;
    align-items: center;
}

.page-item .page-link {
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 36px;
    height: 36px;
    padding: 0 0.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    color: var(--text-muted);
    text-decoration: none;
    border-radius: 0.5rem;
    font-size: 0.875rem;
    transition: all 0.2s;
}

.page-item.active .page-link {
    background: var(--primary);
    border-color: var(--primary);
    color: white;
    font-weight: 700;
}

.page-item:not(.active):not(.disabled) .page-link:hover {
    border-color: var(--primary);
    color: var(--text-main);
    background: var(--bg-input);
}

.page-item.disabled .page-link {
    opacity: 0.3;
    cursor: not-allowed;
}

.dashboard-grid {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.summary-card {
    text-align: center;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 0.25rem;
    min-height: 110px;
    padding: 1.25rem;
}

.summary-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: var(--text-muted);
    font-weight: 800;
    letter-spacing: 0.1em;
}

.summary-value {
    font-size: 2rem;
    font-weight: 900;
}

/* Mobile Responsive Adjustments */

/* Tablet and below (<= 1024px) */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        z-index: 1000;
        box-shadow: 10px 0 30px rgba(0,0,0,0.5);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
        padding: 1rem;
        padding-top: 5rem;
    }

    .mobile-header {
        display: flex !important;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        height: 4rem;
        background: var(--bg-card);
        border-bottom: 1px solid var(--border);
        z-index: 900;
        align-items: center;
        padding: 0 1rem;
        justify-content: space-between;
        backdrop-filter: blur(10px);
    }

    .sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.6);
        backdrop-filter: blur(4px);
        z-index: 950;
    }

    .sidebar-overlay.show {
        display: block;
    }

    .dashboard-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 1rem !important;
    }

    .summary-card {
        min-height: 100px;
        padding: 1rem;
    }
}

/* Specific Mobile Fixes (<= 640px) */
@media (max-width: 640px) {
    .table-container {
        margin-left: 0;
        margin-right: 0;
        border-radius: 0.75rem;
    }

    table {
        min-width: 560px;
    }

    .card {
        padding: 1rem 0.85rem !important;
    }

    .checkout-form { padding: 1rem; }

    /* ── Filter bar collapses behind an icon row ── */
    .filter-bar-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0.85rem 1rem;
        border-bottom: 1px solid transparent;
        transition: border-color 0.2s;
    }

    .filter-bar-header.open {
        border-bottom-color: var(--border);
    }

    .filter-bar-title {
        font-size: 0.75rem;
        font-weight: 800;
        text-transform: uppercase;
        letter-spacing: 0.07em;
        color: var(--text-muted);
    }

    .filter-bar-actions {
        display: flex;
        gap: 0.5rem;
        align-items: center;
    }

    .filter-bar-body {
        display: none;
        padding: 1rem;
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .filter-bar-body.open {
        display: grid;
    }
}

/* Small phones (<= 480px) */
@media (max-width: 480px) {
    .dashboard-grid {
        display: grid !important;
        grid-template-columns: 1fr !important; /* Stacked: 1 column, 4 rows */
        grid-template-rows: auto !important;
        gap: 1rem !important;
        width: 100% !important;
        box-sizing: border-box !important;
    }
    
    .summary-card {
        min-width: 0 !important;
        min-height: 100px !important;
        padding: 1.25rem !important;
        box-sizing: border-box !important;
    }
    
    .summary-value {
        font-size: 2.25rem !important;
    }
    
    .summary-label {
        font-size: 0.8rem !important;
    }
}

.mobile-header {
    display: none;
}

#sidebar-toggle {
    background: none;
    border: none;
    color: var(--text-main);
    cursor: pointer;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Responsive Utilities */
@media (max-width: 767px) {
    .d-md-none {
        display: block !important;
    }
    .d-none {
        display: none !important;
    }
}
@media (min-width: 768px) {
    .d-none {
        display: block !important;
    }
    .d-md-none {
        display: none !important;
    }
    .d-none.d-md-block {
        display: block !important;
    }
}

