/* =========================================================================
   VFS Booking System — App styles
   Built on Bootstrap 5.3 (data-bs-theme handles dark/light tokens).
   ========================================================================= */

:root {
    --sidebar-w: 256px;
    --topbar-h: 60px;
    --brand: #4f46e5;
    --brand-rgb: 79, 70, 229;
    --radius: 12px;
}

[data-bs-theme="light"] {
    --app-bg: #f4f5fb;
    --surface: #ffffff;
    --surface-2: #f8f9fc;
    --sidebar-bg: #ffffff;
    --border: #e7e8f0;
    --muted: #6b7280;
}

[data-bs-theme="dark"] {
    --app-bg: #0e1016;
    --surface: #171a23;
    --surface-2: #1e222d;
    --sidebar-bg: #12141c;
    --border: #272b38;
    --muted: #9aa3b2;
    color-scheme: dark;
}

* { box-sizing: border-box; }

body {
    background: var(--app-bg);
    min-height: 100vh;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

/* ---- Shell layout ---- */
.app-shell { display: flex; min-height: 100vh; }

.app-main {
    flex: 1 1 auto;
    min-width: 0;
    margin-left: var(--sidebar-w);
    display: flex;
    flex-direction: column;
}

.app-content { padding: 24px; flex: 1; }

/* ---- Sidebar ---- */
.app-sidebar {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: var(--sidebar-w);
    background: var(--sidebar-bg);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    z-index: 1040;
    overflow-y: auto;
    transition: transform .25s ease;
}

.sidebar-brand {
    height: var(--topbar-h);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 20px;
    font-size: 1.15rem;
    font-weight: 700;
    border-bottom: 1px solid var(--border);
}
.sidebar-brand i { color: var(--brand); font-size: 1.4rem; }

.module-switch {
    display: flex;
    gap: 6px;
    padding: 14px 16px 6px;
}
.module-pill {
    flex: 1;
    text-align: center;
    padding: 7px 0;
    border-radius: 8px;
    font-size: .8rem;
    font-weight: 600;
    text-decoration: none;
    border: 1px solid var(--border);
    color: var(--muted);
    background: var(--surface-2);
}
.module-pill.active {
    background: var(--brand);
    color: #fff;
    border-color: var(--brand);
}
.module-pill.disabled { opacity: .5; pointer-events: none; }

.sidebar-nav { padding: 8px 12px 24px; }
.nav-section {
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: var(--muted);
    font-weight: 700;
    padding: 16px 12px 6px;
}
.sidebar-nav .nav-link {
    display: flex;
    align-items: center;
    gap: 11px;
    padding: 9px 12px;
    border-radius: 8px;
    color: var(--bs-body-color);
    font-size: .9rem;
    font-weight: 500;
    margin-bottom: 2px;
}
.sidebar-nav .nav-link i { font-size: 1.05rem; width: 20px; text-align: center; color: var(--muted); }
.sidebar-nav .nav-link:hover { background: var(--surface-2); }
.sidebar-nav .nav-link.active {
    background: rgba(var(--brand-rgb), .12);
    color: var(--brand);
    font-weight: 600;
}
.sidebar-nav .nav-link.active i { color: var(--brand); }

/* ---- Topbar ---- */
.app-topbar {
    height: var(--topbar-h);
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 20px;
    position: sticky;
    top: 0;
    z-index: 1030;
}
.topbar-spacer { flex: 1; }

.btn-icon {
    width: 40px; height: 40px;
    display: inline-flex; align-items: center; justify-content: center;
    border-radius: 9px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    color: var(--bs-body-color);
    font-size: 1.1rem;
}
.btn-icon:hover { background: var(--border); }

/* theme icons */
.theme-icon-light { display: none; }
[data-bs-theme="dark"] .theme-icon-dark { display: none; }
[data-bs-theme="dark"] .theme-icon-light { display: inline; }

.user-menu-btn {
    display: flex; align-items: center; gap: 10px;
    border: 1px solid var(--border);
    background: var(--surface-2);
    border-radius: 9px;
    padding: 5px 12px 5px 6px;
}
.user-avatar {
    width: 30px; height: 30px; border-radius: 7px;
    background: var(--brand); color: #fff;
    display: inline-flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: .85rem;
}
.user-meta { flex-direction: column; line-height: 1.1; text-align: left; }
.user-name { font-size: .85rem; font-weight: 600; }
.user-role { font-size: .72rem; color: var(--muted); }

/* ---- Cards / surfaces ---- */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
}
.page-head { margin-bottom: 20px; }
.page-head h1 { font-size: 1.5rem; font-weight: 700; margin: 0; }
.page-head .sub { color: var(--muted); font-size: .9rem; }

/* ---- Stat cards ---- */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
    gap: 16px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    display: flex;
    align-items: center;
    gap: 16px;
}
.stat-icon {
    width: 48px; height: 48px; border-radius: 11px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 1.4rem;
}
.stat-icon.is-total   { background: rgba(var(--brand-rgb), .14); color: var(--brand); }
.stat-icon.is-pending { background: rgba(245, 158, 11, .16); color: #f59e0b; }
.stat-icon.is-booked  { background: rgba(16, 185, 129, .16); color: #10b981; }
.stat-icon.is-failed  { background: rgba(239, 68, 68, .16); color: #ef4444; }
.stat-icon.is-live    { background: rgba(16, 185, 129, .14); color: #10b981; }
.stat-meta .stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1; }
.stat-meta .stat-label { color: var(--muted); font-size: .82rem; margin-top: 4px; }

/* Dashboard left-column: stat cards stacked, growing to match chart height */
.stat-stack { display: flex; flex-direction: column; gap: 16px; }
.stat-stack .stat-card { flex: 1 1 auto; }

/* ---- Tables ---- */
.table-wrap { overflow-x: auto; }
.table > :not(caption) > * > * { padding: .7rem .85rem; }
.table thead th {
    font-size: .72rem; text-transform: uppercase; letter-spacing: .04em;
    color: var(--muted); border-bottom: 1px solid var(--border);
}

/* ---- Login ---- */
.auth-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 24px;
    background:
        radial-gradient(900px 500px at 100% 0%, rgba(var(--brand-rgb), .18), transparent 60%),
        var(--app-bg);
}
.auth-card {
    width: 100%; max-width: 410px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 32px;
    box-shadow: 0 18px 50px rgba(0,0,0,.12);
}
.auth-brand { display: flex; align-items: center; gap: 10px; font-size: 1.3rem; font-weight: 700; margin-bottom: 4px; }
.auth-brand i { color: var(--brand); font-size: 1.6rem; }
.captcha-box {
    display: flex; align-items: center; gap: 10px;
}
.captcha-canvas {
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--surface-2);
    cursor: pointer;
}

.auth-theme-toggle {
    position: fixed; top: 18px; right: 18px;
}

/* ---- Misc ---- */
.sidebar-backdrop {
    position: fixed; inset: 0;
    background: rgba(0,0,0,.45);
    z-index: 1035;
    display: none;
}
.placeholder-card {
    max-width: 560px; margin: 40px auto; text-align: center;
    padding: 48px 32px;
}
.placeholder-card .bi { font-size: 3rem; color: var(--brand); }

/* ---- Settings tabs ---- */
.settings-tabs .nav-link {
    color: var(--bs-body-color);
    border: 1px solid var(--border);
    background: var(--surface);
    font-size: .88rem;
}
.settings-tabs .nav-link.active { background: var(--brand); border-color: var(--brand); color: #fff; }
.settings-tabs .nav-link:not(.active):hover { background: var(--surface-2); }

/* ---- OTP log scroll ---- */
.otp-log-scroll { max-height: 320px; overflow-y: auto; }
.otp-log-scroll thead th {
    position: sticky; top: 0; z-index: 1;
    background: var(--surface);
}

/* ---- Detail definition lists ---- */
.detail-dl dt { font-weight: 600; color: var(--muted); font-size: .85rem; padding: 5px 0; }
.detail-dl dd { padding: 5px 0; margin-bottom: 0; font-size: .9rem; }
.detail-dl dt, .detail-dl dd { border-bottom: 1px solid var(--border); }
.detail-dl dt:last-of-type, .detail-dl dd:last-of-type { border-bottom: 0; }

.live-dot {
    width: 8px; height: 8px; border-radius: 50%;
    background: #10b981; display: inline-block;
    animation: pulse 1.6s infinite;
}
@keyframes pulse { 0%,100%{opacity:1;} 50%{opacity:.3;} }

/* ---- Responsive ---- */
@media (max-width: 991.98px) {
    .app-main { margin-left: 0; }
    .app-sidebar { transform: translateX(-100%); }
    .app-sidebar.open { transform: translateX(0); }
    body.sidebar-open .sidebar-backdrop { display: block; }
    .stat-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 575.98px) {
    .app-content { padding: 16px; }
    .stat-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
}
