/* =========================
   1. RESET / BASE
========================= */
*,
*::before,
*::after {
    box-sizing: border-box;
}

html {
    font-size: 16px;
}

body {
    margin: 0;
    min-height: 100vh;
    font-family: Inter, Arial, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    transition: background-color 0.2s ease, color 0.2s ease;
}

button,
input,
textarea,
select {
    font: inherit;
}

a {
    color: inherit;
    text-decoration: none;
}

ul {
    margin: 0;
    padding: 0;
    list-style: none;
}

/* =========================
   2. THEME: LIGHT
========================= */
body.theme-light {
    --bg-primary: #f3f6fb;
    --bg-secondary: #ffffff;
    --bg-tertiary: #eef2f8;
    --bg-hover: #e8eef7;
    --bg-active: #dbe7f6;

    --sidebar-bg: rgba(255, 255, 255, 0.95);
    --sidebar-border: rgba(15, 23, 42, 0.08);

    --card-bg: rgba(255, 255, 255, 0.96);
    --card-border: rgba(15, 23, 42, 0.08);

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;

    --accent: #2563eb;
    --accent-soft: rgba(37, 99, 235, 0.1);
    --accent-border: rgba(37, 99, 235, 0.25);

    --success: #059669;
    --danger: #dc2626;
    --warning: #d97706;

    --shadow-lg: 0 10px 35px rgba(15, 23, 42, 0.08);
    --shadow-md: 0 6px 20px rgba(15, 23, 42, 0.06);
}

/* =========================
   3. THEME: DARK
========================= */
body.theme-dark {
    --bg-primary: #0b1220;
    --bg-secondary: #111827;
    --bg-tertiary: #172033;
    --bg-hover: #1d2940;
    --bg-active: #24324d;

    --sidebar-bg: rgba(12, 19, 32, 0.94);
    --sidebar-border: rgba(255, 255, 255, 0.06);

    --card-bg: rgba(17, 24, 39, 0.92);
    --card-border: rgba(255, 255, 255, 0.07);

    --text-primary: #e5edf8;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --accent: #3b82f6;
    --accent-soft: rgba(59, 130, 246, 0.14);
    --accent-border: rgba(59, 130, 246, 0.35);

    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;

    --shadow-lg: 0 10px 35px rgba(0, 0, 0, 0.35);
    --shadow-md: 0 6px 20px rgba(0, 0, 0, 0.24);
}

/* =========================
   4. APP SHELL / LAYOUT
========================= */
.app-shell {
    min-height: 100vh;
    background:
            radial-gradient(circle at top right, rgba(59, 130, 246, 0.08), transparent 24%),
            linear-gradient(180deg, var(--bg-primary), var(--bg-primary));
}

.layout {
    margin-left: 280px;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* =========================
   5. SIDEBAR
========================= */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 280px;
    height: 100vh;
    background: var(--sidebar-bg);
    border-right: 1px solid var(--sidebar-border);
    backdrop-filter: blur(18px);
    box-shadow: var(--shadow-md);
    display: flex;
    flex-direction: column;
    z-index: 100;
}

.sidebar__header {
    padding: 22px 20px 18px;
    border-bottom: 1px solid var(--sidebar-border);
}

.sidebar__nav {
    flex: 1;
    overflow-y: auto;
    padding: 18px 12px;
}

.sidebar__footer {
    padding: 16px 12px 20px;
    border-top: 1px solid var(--sidebar-border);
}

/* =========================
   6. BRANDING
========================= */
.brand,
.mobile-brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.brand-mark {
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: grid;
    place-items: center;
    background: linear-gradient(135deg, var(--accent), #06b6d4);
    color: #ffffff;
    font-size: 1rem;
    font-weight: 800;
    box-shadow: var(--shadow-md);
}

.brand-text {
    display: flex;
    flex-direction: column;
}

.brand-title {
    font-size: 1rem;
    font-weight: 700;
    line-height: 1.1;
    color: var(--text-primary);
}

.brand-subtitle {
    margin-top: 3px;
    font-size: 0.78rem;
    color: var(--text-secondary);
}

/* =========================
   7. NAVIGATION
========================= */
.nav-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.nav-item {
    width: 100%;
}

.nav-link,
.submenu-link,
.theme-switcher {
    width: 100%;
    min-height: 46px;
    border: 1px solid transparent;
    border-radius: 14px;
    background: transparent;
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 14px;
    cursor: pointer;
    transition:
            background-color 0.18s ease,
            color 0.18s ease,
            border-color 0.18s ease,
            transform 0.18s ease;
}

.nav-link:hover,
.submenu-link:hover,
.theme-switcher:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.nav-link.is-active,
.submenu-link.is-active {
    background: var(--accent-soft);
    color: var(--text-primary);
    border-color: var(--accent-border);
}

.nav-link--button {
    justify-content: space-between;
}

.nav-link__left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.nav-link__icon {
    width: 18px;
    text-align: center;
    color: var(--text-muted);
    font-size: 0.95rem;
}

.nav-link__text {
    font-weight: 500;
    letter-spacing: -0.01em;
}

.nav-link__arrow {
    color: var(--text-muted);
    transition: transform 0.2s ease;
}

.nav-link--button.is-active .nav-link__arrow {
    transform: rotate(180deg);
}

/* =========================
   8. SUBMENU
========================= */
.submenu {
    margin-top: 4px;
    max-height: 0;
    overflow: hidden;
    opacity: 0;
    transition:
            max-height 0.25s ease,
            opacity 0.2s ease;
}

.submenu.is-open {
    max-height: 420px;
    opacity: 1;
}

.submenu-item {
    margin-top: 6px;
}

.submenu-link {
    min-height: 42px;
    padding-left: 46px;
    font-size: 0.95rem;
}

/* =========================
   9. THEME SWITCHERS
========================= */
.theme-switcher {
    justify-content: flex-start;
}

.theme-switcher__icon {
    width: 18px;
    text-align: center;
    color: var(--text-muted);
}

.theme-switcher__text {
    font-weight: 500;
}

.theme-icon-btn {
    width: 42px;
    height: 42px;
    border: 1px solid var(--card-border);
    border-radius: 12px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    display: none;
    align-items: center;
    justify-content: center;
    cursor: pointer;
}

/* =========================
   10. PAGE HEADER
========================= */
.page-header {
    height: 84px;
    padding: 0 32px;
    border-bottom: 1px solid var(--card-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(255, 255, 255, 0.01);
    backdrop-filter: blur(10px);
}

.page-title {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.02em;
}

.page-subtitle {
    margin: 6px 0 0;
    color: var(--text-secondary);
    font-size: 0.95rem;
}

.status-chip {
    height: 40px;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    padding: 0 14px;
    border-radius: 999px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 10px var(--success);
}

/* =========================
   11. PAGE CONTENT
========================= */
.page-content {
    flex: 1;
    padding: 24px 32px 32px;
}

.content-placeholder {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.content-placeholder__card,
.dashboard-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 20px;
    box-shadow: var(--shadow-lg);
}

.content-placeholder__card {
    padding: 24px;
}

.content-placeholder__card h2 {
    margin: 0 0 10px;
    font-size: 1.25rem;
    letter-spacing: -0.02em;
}

.content-placeholder__card p {
    margin: 0;
    color: var(--text-secondary);
    line-height: 1.6;
}

.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 20px;
}

.dashboard-card {
    min-height: 132px;
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.dashboard-card__label {
    color: var(--text-secondary);
    font-size: 0.92rem;
}

.dashboard-card__value {
    font-size: 1.85rem;
    font-weight: 700;
    letter-spacing: -0.03em;
}

.dashboard-card__meta {
    color: var(--text-muted);
    font-size: 0.88rem;
}

/* =========================
   12. MOBILE TOPBAR
========================= */
.mobile-topbar {
    display: none;
    height: 64px;
    padding: 0 16px;
    border-bottom: 1px solid var(--card-border);
    background: var(--sidebar-bg);
    backdrop-filter: blur(18px);
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 90;
}

.icon-btn {
    width: 42px;
    height: 42px;
    border: 1px solid var(--card-border);
    border-radius: 12px;
    background: var(--bg-secondary);
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 4px;
    padding: 0 10px;
    cursor: pointer;
    flex-shrink: 0;
}

.icon-btn span {
    display: block;
    width: 100%;
    height: 2px;
    background: var(--text-primary);
    border-radius: 999px;
}

.sidebar-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(2, 6, 23, 0.5);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    z-index: 95;
}

.sidebar-backdrop.is-visible {
    opacity: 1;
    visibility: visible;
}

/* =========================
   13. RESPONSIVE
========================= */
@media (max-width: 1100px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 900px) {
    .mobile-topbar {
        display: flex;
    }

    .theme-icon-btn {
        display: inline-flex;
    }

    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.22s ease;
    }

    .sidebar.is-open {
        transform: translateX(0);
    }

    .layout {
        margin-left: 0;
        min-height: calc(100vh - 64px);
    }

    .page-header {
        min-height: 76px;
        height: auto;
        padding: 16px 20px;
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }

    .page-content {
        padding: 20px;
    }
}

@media (max-width: 640px) {
    .page-title {
        font-size: 1.25rem;
    }

    .page-subtitle {
        font-size: 0.88rem;
    }

    .content-placeholder__card,
    .dashboard-card {
        border-radius: 16px;
    }

    .status-chip {
        width: 100%;
        justify-content: center;
    }
}

.auth-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: grid;
    place-items: center;
    padding: 20px;
    background:
            radial-gradient(circle at top right, rgba(59, 130, 246, 0.18), transparent 28%),
            rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(10px);
}

.auth-modal {
    width: min(420px, 100%);
    padding: 28px;
    border-radius: 24px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    box-shadow: var(--shadow-lg);
    color: var(--text-primary);
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 24px;
}

.auth-brand h2 {
    margin: 0;
    font-size: 1.45rem;
}

.auth-brand p {
    margin: 4px 0 0;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.auth-field {
    display: block;
    margin-bottom: 16px;
}

.auth-field span {
    display: block;
    margin-bottom: 7px;
    color: var(--text-secondary);
    font-size: 0.9rem;
}

.auth-field input {
    width: 100%;
    border: 1px solid var(--card-border);
    border-radius: 14px;
    padding: 12px 14px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    outline: none;
}

.auth-field input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-soft);
}

.auth-submit {
    width: 100%;
    border: 0;
    border-radius: 14px;
    padding: 12px 16px;
    margin-top: 4px;
    cursor: pointer;
    background: var(--accent);
    color: #fff;
    font-weight: 700;
}

.auth-submit:hover {
    filter: brightness(1.05);
}

.auth-error {
    min-height: 20px;
    margin: 12px 0 0;
    color: var(--danger);
    font-size: 0.9rem;
}

.auth-overlay {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: grid;
    place-items: center;
    padding: 20px;
    background: rgba(0, 0, 0, 0.45);
    backdrop-filter: blur(10px);
}

.auth-modal {
    width: min(420px, 100%);
    padding: 28px;
    border-radius: 24px;
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    box-shadow: var(--shadow-lg);
    color: var(--text-primary);
}

.auth-brand {
    display: flex;
    align-items: center;
    gap: 14px;
    margin-bottom: 24px;
}

.auth-brand h2 {
    margin: 0;
}

.auth-brand p {
    margin: 4px 0 0;
    color: var(--text-secondary);
}

.auth-field {
    display: block;
    margin-bottom: 16px;
}

.auth-field span {
    display: block;
    margin-bottom: 7px;
    color: var(--text-secondary);
}

.auth-field input {
    width: 100%;
    border: 1px solid var(--card-border);
    border-radius: 14px;
    padding: 12px 14px;
    background: var(--bg-secondary);
    color: var(--text-primary);
    outline: none;
}

.auth-field input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 4px var(--accent-soft);
}

.auth-submit {
    width: 100%;
    border: 0;
    border-radius: 14px;
    padding: 12px 16px;
    background: var(--accent);
    color: white;
    font-weight: 700;
    cursor: pointer;
}

.auth-error {
    min-height: 20px;
    margin: 12px 0 0;
    color: var(--danger);
}

.sidebar {
    transition: width 0.25s ease, transform 0.25s ease;
}

.layout {
    transition: margin-left 0.25s ease;
}

.sidebar-collapse-btn {
    width: 32px;
    height: 32px;
    border: 1px solid var(--border-color, rgba(148, 163, 184, 0.25));
    border-radius: 10px;
    background: transparent;
    color: inherit;
    cursor: pointer;
    font-size: 22px;
    line-height: 1;
    display: grid;
    place-items: center;
}

.sidebar-collapse-btn:hover {
    background: rgba(148, 163, 184, 0.12);
}

@media (min-width: 901px) {
    body.sidebar-collapsed .sidebar {
        width: 76px;
    }

    body.sidebar-collapsed .layout {
        margin-left: 76px;
    }

    body.sidebar-collapsed .brand-text,
    body.sidebar-collapsed .nav-link__text,
    body.sidebar-collapsed .nav-link__arrow,
    body.sidebar-collapsed .theme-switcher__text {
        display: none;
    }

    body.sidebar-collapsed .sidebar__header {
        justify-content: center;
    }

    body.sidebar-collapsed .brand {
        justify-content: center;
    }

    body.sidebar-collapsed .nav-link {
        justify-content: center;
        padding-left: 0;
        padding-right: 0;
    }

    body.sidebar-collapsed .nav-link__left {
        justify-content: center;
    }



    body.sidebar-collapsed .sidebar__footer {
        align-items: center;
    }

    body.sidebar-collapsed .theme-switcher {
        justify-content: center;
        padding-left: 0;
        padding-right: 0;
    }
}

@media (max-width: 900px) {
    .sidebar-collapse-btn {
        display: none;
    }
}

.submenu-link__icon {
    display: none;
    width: 18px;
    text-align: center;
    color: var(--text-muted);
}

.submenu-link__text {
    display: inline;
}

.nav-link--button.is-open .nav-link__arrow {
    transform: rotate(180deg);
}

@media (min-width: 901px) {
    body.sidebar-collapsed .submenu {
        margin-top: 6px;
    }

    body.sidebar-collapsed .submenu.is-open {
        max-height: 260px;
        opacity: 1;
    }

    body.sidebar-collapsed .submenu-item {
        margin-top: 6px;
    }

    body.sidebar-collapsed .submenu-link {
        min-height: 38px;
        justify-content: center;
        padding-left: 0;
        padding-right: 0;
        border-radius: 12px;
    }

    body.sidebar-collapsed .submenu-link__icon {
        display: inline-block;
    }

    body.sidebar-collapsed .submenu-link__text {
        display: none;
    }
}

