:root {
    --color-bg: #000000;
    --color-surface-low: #2B2B2B;
    --color-surface-high: #4A4A4A;
    --color-primary: #2F5EF5;
    --color-text: #FFFFFF;
    --sidebar-width: 250px;
    --sidebar-collapsed-width: 60px;
    --navbar-height: 56px;
}

[data-bs-theme="dark"] {
    --bs-body-bg: var(--color-bg);
    --bs-body-color: var(--color-text);
    --bs-primary: var(--color-primary);
    --bs-primary-rgb: 47, 94, 245;
    --bs-link-color: var(--color-primary);
    --bs-link-hover-color: #5A80F7;
}

body {
    min-height: 100vh;
}

/* NAVBAR */
.navbar.fixed-top {
    z-index: 1030;
}

/* SIDEBAR */
.sidebar {
    position: fixed;
    top: var(--navbar-height);
    left: 0;
    width: var(--sidebar-width);
    height: calc(100vh - var(--navbar-height));
    background-color: var(--color-surface-low);
    overflow-y: auto;
    overflow-x: hidden;
    z-index: 1020;
    transition: width 0.2s ease, transform 0.2s ease;
    transform: translateX(0);
}

.sidebar.collapsed {
    width: var(--sidebar-collapsed-width);
}

.sidebar-nav {
    list-style: none;
    padding: 0.75rem 0;
    margin: 0;
}

.sidebar-nav li a {
    display: flex;
    align-items: center;
    padding: 0.65rem 1rem;
    color: var(--color-text);
    text-decoration: none;
    white-space: nowrap;
    transition: background-color 0.15s;
    gap: 0.75rem;
}

.sidebar-nav li a:hover {
    background-color: var(--color-surface-high);
}

.sidebar-nav li a.active {
    background-color: var(--color-primary);
    color: #fff;
}

.sidebar-nav li a i {
    font-size: 1.15rem;
    width: 24px;
    flex-shrink: 0;
    text-align: center;
}

.sidebar-nav li a span {
    overflow: hidden;
    transition: opacity 0.15s;
    opacity: 1;
}

.sidebar.collapsed .sidebar-nav li a span {
    opacity: 0;
    width: 0;
}

.sidebar.collapsed .sidebar-nav li a {
    justify-content: center;
    padding: 0.65rem 0;
}

.sidebar-header {
    padding: 1rem 1rem 0.25rem;
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: var(--color-surface-high);
    white-space: nowrap;
    overflow: hidden;
    transition: opacity 0.15s;
}

.sidebar.collapsed .sidebar-header {
    opacity: 0;
    height: 0;
    padding: 0;
    margin: 0;
}

.sidebar-divider {
    border-top: 1px solid var(--color-surface-high);
    margin: 0.5rem 1rem;
}

/* Collapsible subnav */
.sidebar-subnav {
    list-style: none;
    padding: 0;
    margin: 0;
    display: none;
    background-color: rgba(0,0,0,0.15);
}

.sidebar-subnav li a {
    padding: 0.35rem 1rem 0.35rem 2.25rem;
    font-size: 0.82rem;
    gap: 0.5rem;
}

.sidebar-subnav li a i {
    font-size: 0.85rem;
    width: 18px;
}

.sidebar-toggle {
    display: flex;
    align-items: center;
    padding: 0.55rem 1rem;
    color: var(--color-text);
    text-decoration: none;
    white-space: nowrap;
    transition: background-color 0.15s;
    gap: 0.75rem;
    cursor: pointer;
    font-weight: 500;
}

.sidebar-toggle:hover {
    background-color: var(--color-surface-high);
}

.sidebar-toggle i:first-child {
    font-size: 1.15rem;
    width: 24px;
    flex-shrink: 0;
    text-align: center;
}

.sidebar-chevron {
    font-size: 0.7rem !important;
    width: auto !important;
    transition: transform 0.2s;
}

.sidebar-toggle.open .sidebar-chevron {
    transform: rotate(180deg);
}

.sidebar.collapsed .sidebar-divider {
    margin: 0.5rem 0.5rem;
}

/* AUTH PAGES — VERTICAL CENTER */
.auth-center {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: calc(100vh - var(--navbar-height) - 4rem);
    width: 100%;
}

.auth-card {
    width: 100%;
    max-width: 400px;
}

/* MAIN CONTENT */
main {
    padding-top: var(--navbar-height);
    padding-bottom: 56px;
    min-height: 100vh;
}

main.sidebar-active {
    margin-left: var(--sidebar-width);
    transition: margin-left 0.2s ease;
}

body.sidebar-collapsed main.sidebar-active {
    margin-left: var(--sidebar-collapsed-width);
}

/* FOOTER */
.main-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 1019;
    text-align: center;
    padding: 0.5rem;
    font-size: 0.875rem;
    background-color: var(--color-surface-low);
    border-top: 1px solid var(--color-surface-high);
    color: var(--color-text);
}

main.sidebar-active + .main-footer {
    left: var(--sidebar-width);
    transition: left 0.2s ease;
}

body.sidebar-collapsed main.sidebar-active + .main-footer {
    left: var(--sidebar-collapsed-width);
}

@media (max-width: 991.98px) {
    main.sidebar-active + .main-footer {
        left: 0 !important;
    }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.2s ease;
    }

    main.sidebar-active {
        margin-left: 0 !important;
    }
}

/* ============================================================
   DESKTOP COMPACT MODE (default on desktop)
   ============================================================ */
@media (min-width: 992px) {
    body.sidebar-active:not(.density-comfortable) {
        font-size: 14px;
    }

    /* Compact navbar */
    body.sidebar-active:not(.density-comfortable) .navbar {
        --bs-navbar-padding-y: 0.25rem;
        min-height: 42px;
    }

    body.sidebar-active:not(.density-comfortable) :root {
        --navbar-height: 42px;
    }

    /* Compact sidebar */
    body.sidebar-active:not(.density-comfortable) .sidebar-nav li a {
        padding: 0.4rem 0.85rem;
        gap: 0.6rem;
    }

    body.sidebar-active:not(.density-comfortable) .sidebar-toggle {
        padding: 0.4rem 0.85rem;
        gap: 0.5rem;
        font-size: 0.82rem;
    }

    body.sidebar-active:not(.density-comfortable) .sidebar-subnav li a {
        padding: 0.25rem 0.85rem 0.25rem 2rem;
        font-size: 0.75rem;
    }

    body.sidebar-active:not(.density-comfortable) .sidebar-nav li a i {
        font-size: 1rem;
        width: 20px;
    }

    body.sidebar-active:not(.density-comfortable) .sidebar-header {
        padding: 0.6rem 0.85rem 0.15rem;
        font-size: 0.65rem;
    }

    /* Compact cards */
    body.sidebar-active:not(.density-comfortable) .card-body {
        padding: 0.85rem;
    }

    body.sidebar-active:not(.density-comfortable) .card-header {
        padding: 0.55rem 0.85rem;
        font-size: 0.85rem;
    }

    body.sidebar-active:not(.density-comfortable) .card {
        margin-bottom: 0.75rem;
    }

    /* Compact tables */
    body.sidebar-active:not(.density-comfortable) .table {
        --bs-table-font-size: 0.8rem;
        --bs-table-line-height: 1.2;
    }

    body.sidebar-active:not(.density-comfortable) .table > :not(caption) > * > * {
        padding: 0.35rem 0.5rem;
    }

    body.sidebar-active:not(.density-comfortable) .table-sm > :not(caption) > * > * {
        padding: 0.25rem 0.4rem;
    }

    /* Compact forms */
    body.sidebar-active:not(.density-comfortable) .form-control,
    body.sidebar-active:not(.density-comfortable) .form-select {
        padding: 0.25rem 0.5rem;
        font-size: 0.85rem;
    }

    body.sidebar-active:not(.density-comfortable) .form-label {
        margin-bottom: 0.2rem;
        font-size: 0.85rem;
    }

    body.sidebar-active:not(.density-comfortable) .mb-1 { margin-bottom: 0.25rem !important; }
    body.sidebar-active:not(.density-comfortable) .mb-2 { margin-bottom: 0.4rem !important; }
    body.sidebar-active:not(.density-comfortable) .mb-3 { margin-bottom: 0.6rem !important; }
    body.sidebar-active:not(.density-comfortable) .mb-4 { margin-bottom: 0.85rem !important; }
    body.sidebar-active:not(.density-comfortable) .mt-3 { margin-top: 0.6rem !important; }
    body.sidebar-active:not(.density-comfortable) .mt-4 { margin-top: 0.85rem !important; }

    /* Compact headings */
    body.sidebar-active:not(.density-comfortable) h1 { font-size: 1.4rem; }
    body.sidebar-active:not(.density-comfortable) h2 { font-size: 1.2rem; }
    body.sidebar-active:not(.density-comfortable) h3 { font-size: 1.05rem; }
    body.sidebar-active:not(.density-comfortable) h4 { font-size: 0.95rem; }
    body.sidebar-active:not(.density-comfortable) h5 { font-size: 0.9rem; }

    /* Compact buttons */
    body.sidebar-active:not(.density-comfortable) .btn {
        padding: 0.25rem 0.6rem;
        font-size: 0.85rem;
    }

    body.sidebar-active:not(.density-comfortable) .btn-sm {
        padding: 0.2rem 0.45rem;
        font-size: 0.78rem;
    }

    /* Compact badges */
    body.sidebar-active:not(.density-comfortable) .badge {
        font-size: 0.7em;
        padding: 0.25em 0.5em;
    }

    /* Compact pagination */
    body.sidebar-active:not(.density-comfortable) .page-link {
        padding: 0.25rem 0.5rem;
        font-size: 0.8rem;
    }

    /* Compact alerts */
    body.sidebar-active:not(.density-comfortable) .alert {
        padding: 0.5rem 0.75rem;
        font-size: 0.85rem;
        margin-bottom: 0.6rem;
    }

    /* Compact progress bars */
    body.sidebar-active:not(.density-comfortable) .progress {
        height: 4px;
    }

    /* Compact dropdowns */
    body.sidebar-active:not(.density-comfortable) .dropdown-menu {
        font-size: 0.85rem;
    }

    body.sidebar-active:not(.density-comfortable) .dropdown-item {
        padding: 0.3rem 0.75rem;
    }

    /* Compact footer */
    body.sidebar-active:not(.density-comfortable) .main-footer {
        padding: 0.25rem;
        font-size: 0.75rem;
    }

    /* Admin dashboard stat cards */
    body.sidebar-active:not(.density-comfortable) .card-body .fs-4 {
        font-size: 1.1rem !important;
    }

    body.sidebar-active:not(.density-comfortable) .card-body .small {
        font-size: 0.72rem !important;
    }

    /* Container */
    body.sidebar-active:not(.density-comfortable) .container-fluid {
        padding-left: 1rem;
        padding-right: 1rem;
    }

    /* Row gaps */
    body.sidebar-active:not(.density-comfortable) .row.g-3 {
        --bs-gutter-y: 0.6rem;
    }

    body.sidebar-active:not(.density-comfortable) .row.g-4 {
        --bs-gutter-y: 0.75rem;
    }

    /* Compact textarea */
    body.sidebar-active:not(.density-comfortable) textarea.form-control {
        font-size: 0.85rem;
    }
}
