/* =============================================
   ROOT VARIABLES
   ============================================= */
:root {
    --page: #eef4ff;
    --surface: rgba(255,255,255,.94);
    --surface-strong: #ffffff;
    --line: rgba(30,41,59,.10);
    --accent: #2563eb;
    --accent-2: #7c3aed;
    --cyan: #06b6d4;
    --text: #0f172a;
    --muted: #64748b;
    --soft: #f8fafc;
}

/* =============================================
   BASE
   ============================================= */
* { letter-spacing: -.01em; box-sizing: border-box; }

body {
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
    background:
        radial-gradient(circle at 10% 0%, rgba(37,99,235,.18), transparent 28%),
        radial-gradient(circle at 90% 5%, rgba(124,58,237,.14), transparent 28%),
        linear-gradient(180deg, #f8fbff 0%, var(--page) 100%);
    color: var(--text);
}

a { color: var(--accent); text-decoration: none; }
a:hover { color: #1d4ed8; }

svg { max-width: 100%; max-height: 100%; }

/* =============================================
   APP SHELL
   ============================================= */
.app-shell {
    display: flex;
    min-height: 100vh;
    width: 100%;
}

/* =============================================
   SIDEBAR PANEL
   ============================================= */
.sidebar-panel {
    position: sticky;
    top: 0;
    height: 100vh;
    width: 230px;
    min-width: 230px;
    background: #ffffff;
    border-right: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    transition: width .28s ease, min-width .28s ease;
    overflow: hidden;
    z-index: 200;
    flex-shrink: 0;
    box-shadow: 2px 0 20px rgba(30,41,59,.06);
}

/* Logo */
.sidebar-logo {
    padding: 18px 16px 14px;
    border-bottom: 1px solid var(--line);
    flex-shrink: 0;
}
.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
}
.sidebar-brand-text {
    font-size: 15px;
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    transition: opacity .2s ease, width .28s ease;
}

/* Nav scroll area */
.sidebar-nav {
    flex: 1;
    padding: 12px 8px;
    display: flex;
    flex-direction: column;
    gap: 2px;
    overflow-y: auto;
    overflow-x: hidden;
}
.sidebar-nav::-webkit-scrollbar { width: 3px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb { background: var(--line); border-radius: 10px; }

/* Section labels */
.nav-section-label {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .07em;
    color: var(--muted);
    padding: 10px 10px 3px;
    white-space: nowrap;
    transition: opacity .2s ease;
    margin-top: 4px;
    display: block;
}
.nav-section-label:first-child { margin-top: 0; }

/* Sidebar links */
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 10px;
    border-radius: 10px;
    font-size: 13.5px;
    font-weight: 600;
    color: #475569;
    text-decoration: none;
    white-space: nowrap;
    transition: background .15s ease, color .15s ease, transform .15s ease;
    background: none;
    border: none;
    width: 100%;
    cursor: pointer;
    text-align: left;
    line-height: 1.4;
}
.sidebar-link i {
    font-size: 17px;
    width: 20px;
    text-align: center;
    flex-shrink: 0;
    transition: color .15s ease;
}
.sidebar-link span {
    transition: opacity .2s ease;
    overflow: hidden;
    white-space: nowrap;
}
.sidebar-link:hover {
    background: rgba(37,99,235,.07);
    color: var(--accent);
    transform: translateX(2px);
}
.sidebar-link.active {
    background: rgba(37,99,235,.10);
    color: var(--accent);
    border: 1px solid rgba(37,99,235,.18);
}
.sidebar-link.active i { color: var(--accent); }
.sidebar-logout { color: #dc2626 !important; }
.sidebar-logout:hover { background: rgba(220,38,38,.07) !important; color: #dc2626 !important; transform: none !important; }

/* Footer */
.sidebar-footer {
    padding: 10px 8px 14px;
    border-top: 1px solid var(--line);
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex-shrink: 0;
}
.sidebar-footer form { width: 100%; margin: 0; }

/* Collapse toggle button */
.sidebar-collapse-btn {
    position: absolute;
    right: -13px;
    top: 72px;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    background: #ffffff;
    border: 1px solid var(--line);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 300;
    box-shadow: 0 2px 8px rgba(30,41,59,.10);
    transition: background .15s ease;
    margin-right: 10px;
}
.sidebar-collapse-btn i {
    font-size: 13px;
    color: var(--muted);
    transition: transform .28s ease;
}
.sidebar-collapse-btn:hover { background: #f1f5f9; }

/* =============================================
   SIDEBAR — COLLAPSED STATE
   ============================================= */
.sidebar-panel.collapsed {
    width: 62px;
    min-width: 62px;
}
.sidebar-panel.collapsed .sidebar-brand-text,
.sidebar-panel.collapsed .sidebar-link span,
.sidebar-panel.collapsed .nav-section-label {
    opacity: 0;
    width: 0;
    pointer-events: none;
}
.sidebar-panel.collapsed .sidebar-link {
    justify-content: center;
    padding: 9px;
    gap: 0;
}
.sidebar-panel.collapsed .sidebar-link i { width: auto; }
.sidebar-panel.collapsed .sidebar-logo { padding: 18px 13px 14px; }
.sidebar-panel.collapsed .sidebar-collapse-btn i { transform: rotate(180deg); }

/* =============================================
   MAIN WRAPPER
   ============================================= */
.main-wrapper {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* Top bar */
.main-topbar {
    height: 56px;
    padding: 0 20px;
    background: rgba(255,255,255,.94);
    border-bottom: 1px solid var(--line);
    display: flex;
    align-items: center;
    gap: 12px;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(12px);
    box-shadow: 0 2px 12px rgba(30,41,59,.05);
}
.topbar-hamburger {
    display: none;
    background: none;
    border: none;
    font-size: 20px;
    color: var(--muted);
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    line-height: 1;
    transition: background .15s, color .15s;
}
.topbar-hamburger:hover { background: rgba(37,99,235,.07); color: var(--accent); }
.topbar-title {
    font-size: 14px;
    font-weight: 700;
    color: var(--text);
    flex: 1;
}
.topbar-right { display: flex; align-items: center; gap: 8px; }
.topbar-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(37,99,235,.10);
    border: 1px solid rgba(37,99,235,.18);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
    font-weight: 700;
    color: var(--accent);
    flex-shrink: 0;
}

/* Main content area */
.main-content {
    flex: 1;
    padding: 1.5rem 1.75rem;
    max-width: 1440px;
    width: 100%;
}

/* Mobile backdrop */
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15,23,42,.45);
    z-index: 199;
    backdrop-filter: blur(2px);
}
.sidebar-backdrop.show { display: block; }

/* =============================================
   PUBLIC NAV (guests only)
   ============================================= */
.nav-shell {
    background: rgba(255,255,255,.94);
    border-bottom: 1px solid var(--line);
    backdrop-filter: blur(16px);
    box-shadow: 0 10px 30px rgba(30,41,59,.07);
}
.navbar-brand { color: #0f172a; }
.nav-link { color: #475569; font-weight: 600; }
.nav-link:hover { color: var(--accent); }

/* =============================================
   BUTTONS
   ============================================= */
.btn { font-weight: 700; }
.btn-gradient {
    border: 0;
    color: white;
    background: linear-gradient(135deg, var(--accent), var(--accent-2) 55%, var(--cyan));
    box-shadow: 0 14px 30px rgba(37,99,235,.24);
    transition: transform .2s ease, box-shadow .2s ease;
}
.btn-gradient:hover {
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 20px 40px rgba(37,99,235,.28);
}

/* =============================================
   UTILITY
   ============================================= */
.text-muted { color: var(--muted) !important; }
.text-info { color: #0891b2 !important; }
.border-secondary { border-color: var(--line) !important; }
.badge-soft { background: rgba(37,99,235,.08); border: 1px solid rgba(37,99,235,.16); color: #1d4ed8; }

/* =============================================
   GLASS CARD
   ============================================= */
.glass {
    background: linear-gradient(145deg, rgba(255,255,255,.98), rgba(248,250,252,.90));
    border: 1px solid var(--line);
    box-shadow: 0 18px 55px rgba(30,41,59,.08);
    backdrop-filter: blur(14px);
    border-radius: 24px;
    color: var(--text);
}
.alert.glass { color: var(--text); border-color: rgba(30,41,59,.10); }
.alert.glass strong, .alert.glass li { color: var(--text); }
.alert.glass.alert-info    { background: linear-gradient(145deg, rgba(14,165,233,.14),  rgba(255,255,255,.94)); }
.alert.glass.alert-success { background: linear-gradient(145deg, rgba(34,197,94,.14),   rgba(255,255,255,.94)); }
.alert.glass.alert-warning { background: linear-gradient(145deg, rgba(245,158,11,.16),  rgba(255,255,255,.94)); }
.alert.glass.alert-danger  { background: linear-gradient(145deg, rgba(239,68,68,.16),   rgba(255,255,255,.94)); }

/* =============================================
   HERO
   ============================================= */
.hero-title {
    font-size: clamp(2.45rem, 6vw, 5.25rem);
    line-height: .96;
    color: var(--text);
    font-weight: 900;
}

/* =============================================
   PAGE HEADING
   ============================================= */
.page-heading { gap: 1rem; padding: .25rem 0; }
.page-heading h1 { font-weight: 850; }

/* =============================================
   STAT CARDS
   ============================================= */
.stat-card { position: relative; overflow: hidden; min-height: 132px; }
.stat-card::before {
    content: '';
    position: absolute; inset: 0;
    background: linear-gradient(135deg, rgba(37,99,235,.09), transparent 55%);
    pointer-events: none;
}
.stat-card::after {
    content: '';
    position: absolute; inset: auto -30px -40px auto;
    width: 124px; height: 124px; border-radius: 50%;
    background: rgba(6,182,212,.14);
}
.stat-card .display-6 { position: relative; z-index: 1; color: #0f172a; }

/* =============================================
   TABLES
   ============================================= */
.table-responsive { border-radius: 18px; border: 1px solid rgba(30,41,59,.08); background: #fff; }
.table { margin-bottom: 0; color: var(--text); }
.table th { color: #475569; font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap; background: #f8fafc; }
.table td { color: var(--text); vertical-align: middle; }
.table td, .table th { padding: .9rem 1rem; }
.table-hover tbody tr:hover { background: rgba(37,99,235,.055); }
.table code { color: #1d4ed8; font-weight: 700; }

/* =============================================
   FORMS
   ============================================= */
.form-control, .form-select { background-color: #fff; border-color: rgba(30,41,59,.16); color: var(--text); border-radius: 12px; }
.form-select option, .form-select optgroup { background-color: #fff; color: var(--text); }
.form-select option:checked { background: #dbeafe; color: var(--text); }
.form-control:focus, .form-select:focus { background-color: #fff; color: var(--text); border-color: #38bdf8; box-shadow: 0 0 0 .25rem rgba(14,165,233,.15); }
.form-control::placeholder { color: #94a3b8; }

/* =============================================
   ADMIN SHELL (legacy grid kept for sub-pages)
   ============================================= */
.admin-shell { display: grid; gap: 1.5rem; }
.admin-menu-card { position: sticky; top: 82px; z-index: 20; }
.admin-menu-head { gap: 1rem; }
.admin-menu {
    display: grid;
    grid-template-columns: repeat(7, minmax(0, 1fr));
    gap: .65rem;
    margin-top: 1rem;
}
.admin-menu-link {
    display: flex; flex-direction: column; gap: .12rem;
    min-height: 70px; padding: .9rem 1rem;
    border: 1px solid rgba(30,41,59,.10); border-radius: 18px;
    background: rgba(248,250,252,.86); color: #334155;
    transition: .2s ease;
}
.admin-menu-link span { font-weight: 800; color: #0f172a; }
.admin-menu-link small { color: var(--muted); font-weight: 650; }
.admin-menu-link:hover, .admin-menu-link.active {
    transform: translateY(-2px);
    border-color: rgba(37,99,235,.26);
    background: linear-gradient(145deg, rgba(37,99,235,.11), rgba(255,255,255,.96));
    box-shadow: 0 12px 26px rgba(37,99,235,.11);
}
.admin-menu.collapse:not(.show) { display: none; }
.admin-menu.collapse.show { display: grid; }

/* =============================================
   ACTIVITY LIST
   ============================================= */
.activity-list { display: grid; gap: .75rem; }
.activity-item {
    position: relative;
    padding: .9rem 1rem .9rem 2.6rem;
    border: 1px solid rgba(30,41,59,.08); border-radius: 18px;
    background: linear-gradient(145deg, rgba(255,255,255,.98), rgba(248,250,252,.92));
    box-shadow: 0 8px 22px rgba(30,41,59,.045);
}
.activity-item::before {
    content: '';
    position: absolute; left: .95rem; top: 1.08rem;
    width: .74rem; height: .74rem; border-radius: 50%;
    background: linear-gradient(135deg, var(--accent), var(--cyan));
    box-shadow: 0 0 0 4px rgba(37,99,235,.10);
}
.activity-item strong { display: block; color: #0f172a; margin-bottom: .15rem; }
.activity-meta { color: var(--muted); font-size: .875rem; line-height: 1.45; overflow-wrap: anywhere; }

/* =============================================
   EMPTY STATE
   ============================================= */
.empty-state {
    padding: 1rem; color: var(--muted); text-align: center;
    border: 1px dashed rgba(30,41,59,.16); border-radius: 16px;
    background: rgba(248,250,252,.72);
}

/* =============================================
   ADMIN CONTENT OVERFLOW GUARD
   ============================================= */
.admin-content, [role="main"] { min-width: 0; max-width: 100%; }

/* =============================================
   PAGINATION + SVG ICONS
   ============================================= */
nav[role="navigation"] { width: 100%; }
nav[role="navigation"] svg { width: 16px !important; height: 16px !important; display: inline-block; vertical-align: middle; }
nav[role="navigation"] .flex { display: flex; }
nav[role="navigation"] .items-center { align-items: center; }
nav[role="navigation"] .justify-between { justify-content: space-between; }
nav[role="navigation"] .inline-flex { display: inline-flex; }
nav[role="navigation"] .relative { position: relative; }
nav[role="navigation"] a, nav[role="navigation"] span { line-height: 1.2; }
nav[role="navigation"] .flex.justify-between { margin-top: 12px; }

/* =============================================
   RESPONSIVE BREAKPOINTS
   ============================================= */

/* Large desktop */
@media (max-width: 1200px) {
    .admin-menu { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}

/* Tablet / small desktop — switch sidebar to slide-over */
@media (max-width: 991px) {
    .sidebar-panel {
        position: fixed;
        top: 0; left: 0;
        height: 100vh;
        transform: translateX(-100%);
        transition: transform .28s ease;
        width: 230px !important;
        min-width: 230px !important;
        box-shadow: 4px 0 24px rgba(15,23,42,.14);
    }
    .sidebar-panel.mobile-open {
        transform: translateX(0);
    }
    /* Always show text on mobile regardless of desktop collapsed state */
    .sidebar-panel .sidebar-brand-text,
    .sidebar-panel .sidebar-link span,
    .sidebar-panel .nav-section-label {
        opacity: 1 !important;
        width: auto !important;
        pointer-events: auto !important;
    }
    .sidebar-panel .sidebar-link {
        justify-content: flex-start !important;
        padding: 9px 10px !important;
        gap: 10px !important;
    }
    .sidebar-panel .sidebar-link i { width: 20px !important; }
    .sidebar-panel .sidebar-logo { padding: 18px 16px 14px !important; }
    .sidebar-collapse-btn { display: none; }

    .topbar-hamburger { display: flex !important; }

    .admin-menu-card { position: static; }
    .admin-menu { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    .main-content { padding: 1rem; }
}

/* Mobile */
@media (max-width: 767px) {
    body { background-size: auto; }
    .glass { border-radius: 18px; box-shadow: 0 12px 34px rgba(30,41,59,.08); }
    .glass.p-4 { padding: 1rem !important; }
    .glass.p-3 { padding: .85rem !important; }
    .hero-title { font-size: clamp(2.05rem, 12vw, 3.1rem); }
    .display-6 { font-size: 1.8rem; }
    .page-heading { align-items: stretch !important; }
    .page-heading > * { width: 100%; }
    .page-heading .btn { width: 100%; }
    .stat-card { min-height: 112px; }
    .stat-card::after { width: 88px; height: 88px; }
    .table { min-width: 720px; font-size: .92rem; }
    .table td, .table th { padding: .72rem .75rem; }
    .activity-item { padding: .82rem .85rem .82rem 2.25rem; border-radius: 14px; }
    .activity-item::before { left: .8rem; }
    .modal-dialog { margin: 1rem; }
}

@media (max-width: 640px) {
    nav[role="navigation"] .flex.justify-between { margin-top: 10px; }
}

@media (max-width: 575px) {
    .main-content { padding: .75rem; }
}

@media (max-width: 520px) {
    .admin-menu { grid-template-columns: 1fr; }
    .admin-menu-link { min-height: auto; padding: .82rem .9rem; }
}

@media (max-width: 420px) {
    .main-content { padding: .6rem; }
    .btn, .form-control, .form-select { min-height: 44px; }
}