/* vCrew OCC — design tokens ported 1:1 from the EFB app for a consistent look */

:root {
    /* ── Brand blues (identical to EFB) ─────────────────────────── */
    --b1:          #154B96;
    --b2:          #2160B8;
    --b3:          #4A84D8;
    --bg:          #E8EFF8;
    --card:        #FFFFFF;
    --input-bg:    #F1F5FC;
    --row-sub:     #F5F8FD;
    --border:      #D0DFF0;
    --border-row:  #EBF1FA;
    --t1:          #0B1B3D;
    --t2:          #2D4470;
    --t3:          #7A8FA8;
    --green:       #16A34A;
    --green-bg:    #F0FDF4;
    --red:         #DC2626;
    --red-bg:      #FEF2F2;
    --amber:       #D97706;
    --amber-bg:    #FFFBEB;
    --header-grad: linear-gradient(90deg, #154B96 0%, #2160B8 100%);
    --shadow:      0 1px 3px rgba(21,75,150,0.08), 0 4px 16px rgba(21,75,150,0.07);
    --sidebar-w:   232px;

    /* ── OFDM landing grade colours (ported from EFB, Logbook report viewer) ────── */
    --grade-perfect: #16A34A;
    --grade-regular: #2563EB;
    --grade-firm:    #D97706;
    --grade-rough:   #EA580C;
    --grade-hard:    #DC2626;

    /* ── OFDM severity colours ───────────────────────────────────────────────── */
    --sev-passed:   #16A34A;
    --sev-info:     #0891B2;
    --sev-caution:  #D97706;
    --sev-warning:  #EA580C;
    --sev-critical: #DC2626;
    --sev-failed:   #DC2626;
}

/* ── DARK MODE ────────────────────────────────────────────────────────────── */
body.dark-mode {
    --bg:         #060F1C;
    --card:       #0D1B30;
    --input-bg:   #091524;
    --row-sub:    #091524;
    --border:     #1A3A60;
    --border-row: #132A4A;
    --t1:         #D0E4FF;
    --t2:         #94A3B8;
    --t3:         #64748B;
    --shadow:     0 1px 3px rgba(0,0,0,0.4), 0 4px 16px rgba(0,0,0,0.35);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { height: 100%; touch-action: manipulation; -webkit-text-size-adjust: 100%; }

body {
    font-family: 'IBM Plex Sans', 'Helvetica Neue', sans-serif;
    font-size: 13px; background: var(--bg); color: var(--t1);
    line-height: 1.4; height: 100%; -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

.screen { width: 100%; min-height: 100svh; }
.hidden { display: none !important; }

/* ── LOADING OVERLAY ──────────────────────────────────────────────────── */
#loading-overlay {
    position: fixed; inset: 0; z-index: 9999;
    background: rgba(232,239,248,0.75); backdrop-filter: blur(4px);
    display: flex; align-items: center; justify-content: center;
}
.loading-spinner {
    width: 32px; height: 32px;
    border: 3px solid var(--border);
    border-top-color: var(--b2);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── ERROR BANNER ─────────────────────────────────────────────────────── */
#error-banner {
    position: fixed; top: 0; left: 0; right: 0; z-index: 9998;
    background: var(--red); color: #fff;
    padding: 10px 16px; font-size: 12px; font-weight: 600;
    text-align: center; transform: translateY(-100%);
    transition: transform 0.25s ease;
}
#error-banner.visible { transform: translateY(0); }

/* ── LOGIN ────────────────────────────────────────────────────────────── */
#screen-login {
    display: flex; align-items: center; justify-content: center;
    min-height: 100svh;
    background: linear-gradient(145deg, #C4D8EE 0%, #E8EFF8 55%);
}
.login-card {
    background: var(--card); border: 1px solid var(--border);
    border-radius: 14px; padding: 40px; width: 360px;
    box-shadow: 0 8px 32px rgba(21,75,150,0.13);
}
.login-logo {
    text-align: center; margin-bottom: 8px;
    font-size: 26px; font-weight: 700; color: var(--b1); letter-spacing: 3px;
}
.login-subtitle {
    text-align: center; font-size: 10px; color: var(--t3);
    letter-spacing: 2.5px; text-transform: uppercase; margin-bottom: 32px;
}
.login-card label {
    display: block; font-size: 10px; font-weight: 600; color: var(--t3);
    margin-bottom: 5px; text-transform: uppercase; letter-spacing: 0.1em;
}
.login-card input {
    width: 100%; padding: 10px 14px;
    background: var(--input-bg); border: 1.5px solid var(--border);
    border-radius: 8px; color: var(--t1);
    font-size: 13px; font-family: 'IBM Plex Mono', monospace; margin-bottom: 16px;
    transition: border-color 0.15s, box-shadow 0.15s;
}
.login-card input:focus { outline: none; border-color: var(--b2); box-shadow: 0 0 0 3px rgba(33,96,184,0.14); }
.btn-login {
    width: 100%; padding: 12px; background: var(--header-grad);
    color: #fff; border: none; border-radius: 8px;
    font-size: 13px; font-weight: 700; letter-spacing: 0.06em;
    cursor: pointer; transition: opacity 0.2s; font-family: inherit;
}
.btn-login:active { opacity: 0.82; }
.login-error { color: var(--red); font-size: 11px; margin-top: 10px; text-align: center; min-height: 16px; }

/* ── BUTTONS ──────────────────────────────────────────────────────────── */
.btn-sm {
    padding: 5px 13px; font-size: 10px; border: none; border-radius: 9999px;
    cursor: pointer; font-weight: 700; letter-spacing: 0.07em; text-transform: uppercase;
    transition: opacity 0.15s; font-family: inherit;
}
.btn-logout { background: var(--red-bg); color: var(--red); border: 1.5px solid #FECACA; }
.btn-logout:active { opacity: 0.8; }
body.dark-mode .btn-logout {
    background: rgba(220,38,38,0.12) !important;
    color: #F87171 !important;
    border: 1.5px solid rgba(220,38,38,0.3) !important;
}

.btn-theme {
    background: var(--input-bg); color: var(--t2);
    border: 1.5px solid var(--border);
    display: inline-flex; align-items: center; justify-content: center;
    width: 32px; height: 32px; padding: 0; border-radius: 9999px;
    cursor: pointer; transition: border-color 0.15s, color 0.15s;
}
.btn-theme:hover { border-color: var(--b3); color: var(--b2); }

/* ── APP SHELL (topbar nav + main content) ────────────────────────────── */
#app-shell { display: flex; flex-direction: column; min-height: 100svh; }

.topnav {
    background: var(--card); border-bottom: 1px solid var(--border);
    display: flex; align-items: center; gap: 20px;
    padding: 10px 22px; position: sticky; top: 0;
    /* Leaflet's own panes/controls (#occ-map) reach z-index 1000, so the nav — and its
       mobile dropdown, which shares this stacking context — must sit above that. */
    z-index: 1200;
    box-shadow: 0 2px 8px rgba(21,75,150,0.06);
    padding-top: max(10px, env(safe-area-inset-top));
}

.topnav-brand { display: flex; align-items: center; gap: 10px; flex-shrink: 0; }
.sidebar-brand-mark {
    width: 34px; height: 34px; border-radius: 9px;
    background: var(--header-grad); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 12px; font-weight: 800; letter-spacing: -0.02em; flex-shrink: 0;
}
.sidebar-brand-text { line-height: 1.25; }
.sidebar-brand-title {
    font-size: 13px; font-weight: 800; color: var(--b1); letter-spacing: 0.04em;
}
.sidebar-brand-sub {
    font-size: 9px; color: var(--t3); letter-spacing: 0.12em; text-transform: uppercase;
}

.topnav-items { display: flex; align-items: center; gap: 2px; flex: 1; min-width: 0; }
.topnav-item {
    display: flex; align-items: center; gap: 7px; white-space: nowrap;
    padding: 8px 12px; border-radius: 8px;
    background: none; border: none; cursor: pointer;
    color: var(--t2); font-size: 12px; font-weight: 600;
    font-family: inherit; text-align: left;
    transition: background 0.15s, color 0.15s;
    -webkit-tap-highlight-color: transparent;
}
.topnav-item:hover { background: var(--row-sub); color: var(--t1); }
.topnav-item.active { background: #EFF6FF; color: var(--b2); }
body.dark-mode .topnav-item.active { background: rgba(33,96,184,0.18); color: #8FC0FF; }
.side-nav-icon { width: 17px; height: 17px; flex-shrink: 0; display: flex; align-items: center; justify-content: center; }
.side-nav-icon svg { width: 100%; height: 100%; }

.topnav-actions { display: flex; align-items: center; gap: 12px; flex-shrink: 0; margin-left: auto; }
.topnav-user-text { line-height: 1.25; text-align: right; }
.sidebar-user-name {
    font-size: 11px; font-weight: 700; color: var(--t1);
    font-family: 'IBM Plex Mono', monospace; letter-spacing: 0.03em;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis; max-width: 160px;
}
.sidebar-user-role { font-size: 9px; color: var(--t3); text-transform: uppercase; letter-spacing: 0.08em; }
.dash-avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--header-grad); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-size: 11px; font-weight: 700; flex-shrink: 0;
}

.hamburger-btn {
    display: none; background: none; border: none; cursor: pointer;
    color: var(--t2); padding: 4px; line-height: 1;
}
.hamburger-btn svg { width: 22px; height: 22px; display: block; }

/* ── MAIN CONTENT ─────────────────────────────────────────────────────── */
.main-content-full {
    flex: 1; display: flex; flex-direction: column; min-width: 0;
}

.page-title {
    font-size: 18px; font-weight: 800; color: var(--t1); letter-spacing: -0.01em;
    margin-bottom: 18px;
}

.content-area { flex: 1; padding: 22px; overflow-x: hidden; }
.content-section {}

.empty-section {
    display: flex; flex-direction: column; align-items: center; justify-content: center;
    min-height: 320px; color: var(--t3); text-align: center; gap: 6px;
}
.empty-section-icon { font-size: 34px; opacity: 0.35; margin-bottom: 4px; }
.empty-section-title { font-size: 14px; font-weight: 700; color: var(--t2); }
.empty-section-sub { font-size: 11.5px; }

/* ── RESPONSIVE: collapse the horizontal nav into a dropdown menu ────── */
/* 1180px (not 980px) — 7 nav items + logo + actions need more room than that
   to lay out in one row without shrinking below their nowrap text width and
   overlapping; confirmed this happens at 1024px (iPad landscape). */
@media (max-width: 1180px) {
    .topnav-items {
        display: none; position: absolute; top: 100%; left: 0; right: 0;
        flex-direction: column; align-items: stretch; gap: 2px;
        background: var(--card); border-bottom: 1px solid var(--border);
        box-shadow: 0 12px 24px rgba(0,0,0,0.12); padding: 8px; z-index: 1200;
    }
    .topnav-items.open { display: flex; }
    .topnav-item { padding: 10px 12px; }
    .topnav-user-text { display: none; }
    .hamburger-btn { display: inline-flex; }
}
