/* ==========================================================================
   Probex School attendance portal
   Bootstrap 5.3 is loaded first; this file layers the school's identity on top.
   Palette: forest ink, pale sage paper, white panels, pencil yellow as the one accent.
   Type: Bricolage Grotesque (headings, numbers), Figtree (everything else).
   ========================================================================== */

:root {
    --forest-950: #07201a;
    --forest-900: #0a2e1f;
    --forest-800: #11402c;
    --forest-700: #185a3b;
    --forest-600: #1f7a4e;
    --sage-50: #f5f7f3;
    --sage-100: #eaefe8;
    --sage-200: #dde5da;
    --sage-300: #c3cfbf;
    --pencil: #f1c40f;
    --pencil-deep: #d9ad00;
    --pencil-soft: #fbf0b8;
    --ink: #13211a;
    --ink-soft: #55655b;
    --in: #1d8a53;
    --in-soft: #dcf1e5;
    --out: #b4492f;
    --out-soft: #f8e3dc;
    --sidebar-w: 264px;

    --font-body: 'Figtree', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-display: 'Bricolage Grotesque', 'Figtree', system-ui, sans-serif;

    /* Bootstrap overrides */
    --bs-body-font-family: var(--font-body);
    --bs-body-color: var(--ink);
    --bs-body-bg: var(--sage-100);
    --bs-primary: var(--forest-700);
    --bs-primary-rgb: 24, 90, 59;
    --bs-link-color: var(--forest-700);
    --bs-link-hover-color: var(--forest-900);
    --bs-border-color: var(--sage-200);
    --bs-border-radius: 8px;
    --bs-secondary-color: var(--ink-soft);
}

*,
*::before,
*::after { box-sizing: border-box; }

body {
    font-family: var(--font-body);
    font-size: 0.95rem;
    line-height: 1.55;
    color: var(--ink);
    background: var(--sage-100);
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-display);
    letter-spacing: -0.01em;
    color: var(--forest-900);
}

:focus-visible {
    outline: 3px solid var(--pencil);
    outline-offset: 2px;
    border-radius: 4px;
}

.tnum { font-variant-numeric: tabular-nums; }
.mono { font-family: ui-monospace, SFMono-Regular, Menlo, monospace; font-size: 0.85em; }

/* --------------------------------------------------------------------------
   Shell
   -------------------------------------------------------------------------- */

.sidebar {
    position: fixed;
    inset: 0 auto 0 0;
    width: var(--sidebar-w);
    background: var(--forest-900);
    color: #fff;
    display: flex;
    flex-direction: column;
    padding: 22px 14px 16px;
    z-index: 1040;
    transition: transform 0.25s ease;
}

.sidebar::after {
    content: '';
    position: absolute;
    top: 0; right: 0; bottom: 0;
    width: 4px;
    background: var(--pencil);
}

.brand {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 0 10px 20px;
    text-decoration: none;
    color: #fff;
}
.brand img { width: 42px; height: 42px; object-fit: contain; border-radius: 8px; background: rgba(255,255,255,.08); padding: 3px; }
.brand-name { font-family: var(--font-display); font-weight: 700; font-size: 1.15rem; line-height: 1.1; letter-spacing: -0.01em; }
.brand-sub { font-size: 0.75rem; color: rgba(255,255,255,.6); line-height: 1.2; margin-top: 2px; }

.nav-scroll { flex: 1; overflow-y: auto; padding: 4px 0; }

.nav-group { margin-bottom: 18px; }
.nav-group-label {
    font-size: 0.75rem;
    font-weight: 600;
    color: rgba(255,255,255,.45);
    padding: 0 12px 6px;
}

.nav-item-x {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    margin-bottom: 2px;
    border-radius: 8px;
    color: rgba(255,255,255,.78);
    text-decoration: none;
    font-weight: 500;
    position: relative;
    transition: background 0.15s ease, color 0.15s ease;
}
.nav-item-x i { font-size: 1.05rem; width: 20px; text-align: center; }
.nav-item-x:hover { background: rgba(255,255,255,.07); color: #fff; }
.nav-item-x.active {
    background: rgba(255,255,255,.1);
    color: #fff;
    font-weight: 600;
}
.nav-item-x.active::before {
    content: '';
    position: absolute;
    left: -14px; top: 8px; bottom: 8px;
    width: 4px;
    border-radius: 0 4px 4px 0;
    background: var(--pencil);
}
.nav-count {
    margin-left: auto;
    background: var(--pencil);
    color: var(--forest-900);
    font-size: 0.72rem;
    font-weight: 700;
    padding: 1px 8px;
    border-radius: 999px;
}

.user-chip {
    border-top: 1px solid rgba(255,255,255,.12);
    padding-top: 14px;
    margin-top: 8px;
}
.user-chip-row { display: flex; align-items: center; gap: 10px; padding: 0 6px 12px; min-width: 0; }
.avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    object-fit: cover;
    flex: none;
    background: var(--sage-200);
}
.avatar-ini {
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--pencil); color: var(--forest-900);
    font-family: var(--font-display); font-weight: 700; font-size: 0.85rem;
}
.user-chip .who { min-width: 0; }
.user-chip .who strong { display: block; font-size: 0.88rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-chip .who span { display: block; font-size: 0.75rem; color: rgba(255,255,255,.55); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.btn-signout {
    width: 100%;
    background: transparent;
    border: 1px solid rgba(255,255,255,.25);
    color: #fff;
    font-weight: 600;
    border-radius: 8px;
    padding: 8px 12px;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    transition: background 0.15s ease, border-color 0.15s ease;
}
.btn-signout:hover { background: rgba(255,255,255,.1); border-color: rgba(255,255,255,.5); color: #fff; }

.topbar {
    display: none;
    position: sticky; top: 0;
    z-index: 1030;
    align-items: center; gap: 12px;
    background: var(--forest-900);
    color: #fff;
    padding: 10px 16px;
    border-bottom: 3px solid var(--pencil);
}
.topbar .brand { padding: 0; }
.topbar .brand img { width: 34px; height: 34px; }
.topbar-toggle {
    margin-left: auto;
    background: transparent; border: 1px solid rgba(255,255,255,.3);
    color: #fff; width: 40px; height: 40px; border-radius: 8px; font-size: 1.3rem;
}
.sidebar-scrim { display: none; }

.app-main {
    margin-left: var(--sidebar-w);
    padding: 34px clamp(18px, 3.2vw, 48px) 60px;
    min-height: 100vh;
    max-width: 1500px;
}

@media (max-width: 991.98px) {
    .topbar { display: flex; }
    .sidebar { transform: translateX(-100%); }
    body.nav-open .sidebar { transform: none; box-shadow: 0 0 40px rgba(0,0,0,.4); }
    body.nav-open .sidebar-scrim { display: block; position: fixed; inset: 0; background: rgba(7,32,26,.55); z-index: 1035; }
    .app-main { margin-left: 0; padding-top: 22px; }
}

@media (prefers-reduced-motion: reduce) {
    * { transition: none !important; animation: none !important; scroll-behavior: auto !important; }
}

/* --------------------------------------------------------------------------
   Page heading + panels
   -------------------------------------------------------------------------- */

.page-head {
    display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between;
    gap: 14px 24px;
    margin-bottom: 24px;
}
.page-head h1 { font-size: clamp(1.6rem, 2.6vw, 2.1rem); font-weight: 800; margin: 0; line-height: 1.1; }
.page-head p { margin: 6px 0 0; color: var(--ink-soft); max-width: 60ch; }
.page-head .actions { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

.panel {
    background: #fff;
    border: 1px solid var(--sage-200);
    border-radius: 10px;
}
.panel-pad { padding: 22px; }
.panel-head {
    display: flex; align-items: center; justify-content: space-between; gap: 12px;
    padding: 16px 22px;
    border-bottom: 1px solid var(--sage-200);
}
.panel-head h2, .panel-head h3 { font-size: 1.05rem; font-weight: 700; margin: 0; }
.panel-foot { padding: 14px 22px; border-top: 1px solid var(--sage-200); display: flex; flex-wrap: wrap; gap: 10px; align-items: center; justify-content: space-between; }
.muted { color: var(--ink-soft); }
.small-muted { color: var(--ink-soft); font-size: 0.82rem; }

/* Stats: plain numbers on a ruled strip, not a card grid */
.stat-strip {
    display: flex; flex-wrap: wrap;
    background: #fff;
    border: 1px solid var(--sage-200);
    border-radius: 10px;
    margin-bottom: 22px;
}
.stat-strip .stat { flex: 1 1 180px; padding: 16px 22px; border-right: 1px solid var(--sage-200); min-width: 0; }
.stat-strip .stat:last-child { border-right: 0; }
.stat .num { font-family: var(--font-display); font-weight: 800; font-size: 1.8rem; line-height: 1.1; color: var(--forest-900); }
.stat .lbl { color: var(--ink-soft); font-size: 0.85rem; }
@media (max-width: 575.98px) {
    .stat-strip .stat { flex-basis: 50%; border-bottom: 1px solid var(--sage-200); }
}

/* --------------------------------------------------------------------------
   Gate pass: current status of a student (the memorable element)
   -------------------------------------------------------------------------- */

.pass-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 16px; }
.pass {
    background: #fff;
    border: 1px solid var(--sage-200);
    border-radius: 10px;
    overflow: hidden;
}
.pass-band {
    position: relative;
    display: flex; align-items: center; justify-content: space-between;
    padding: 18px 18px 14px;
    color: #fff;
}
.pass-band::before {
    content: '';
    position: absolute; top: 7px; left: 50%;
    width: 38px; height: 8px; margin-left: -19px;
    border-radius: 8px;
    background: rgba(0,0,0,.28);
    box-shadow: inset 0 1px 2px rgba(0,0,0,.35);
}
.pass.is-in .pass-band { background: var(--in); }
.pass.is-out .pass-band { background: var(--forest-800); }
.pass-state { font-family: var(--font-display); font-weight: 800; font-size: 1.9rem; line-height: 1; letter-spacing: 0.01em; }
.pass-state small { display: block; font-family: var(--font-body); font-weight: 500; font-size: 0.75rem; opacity: .85; letter-spacing: 0; margin-top: 4px; }
.pass-body { padding: 14px 18px 16px; display: flex; gap: 12px; align-items: center; }
.pass-body .avatar { width: 44px; height: 44px; }
.pass-name { font-weight: 700; line-height: 1.2; }
.pass-meta { font-size: 0.82rem; color: var(--ink-soft); }

/* --------------------------------------------------------------------------
   Ledger tables
   -------------------------------------------------------------------------- */

.table-wrap { overflow-x: auto; }
.ledger { width: 100%; margin: 0; border-collapse: collapse; }
.ledger th {
    background: var(--sage-50);
    color: var(--ink-soft);
    font-size: 0.8rem;
    font-weight: 600;
    text-align: left;
    padding: 11px 16px;
    border-bottom: 1px solid var(--sage-200);
    white-space: nowrap;
}
.ledger td { padding: 12px 16px; border-bottom: 1px solid var(--sage-100); vertical-align: middle; }
.ledger tbody tr:hover td { background: #fbfcfa; }
.ledger .day-row td {
    background: var(--sage-50);
    font-family: var(--font-display);
    font-weight: 700;
    color: var(--forest-800);
    padding: 9px 16px;
    border-bottom: 1px solid var(--sage-200);
    border-top: 1px solid var(--sage-200);
}
.ledger .time { font-weight: 700; font-variant-numeric: tabular-nums; }
.ledger .empty-cell { text-align: center; padding: 48px 16px; color: var(--ink-soft); }
.cell-user { display: flex; align-items: center; gap: 12px; min-width: 0; }
.cell-user .name { font-weight: 700; line-height: 1.25; }
.cell-user .sub { color: var(--ink-soft); font-size: 0.82rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; max-width: 260px; }

.pill {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 3px 11px;
    border-radius: 999px;
    font-weight: 700; font-size: 0.78rem;
    white-space: nowrap;
}
.pill-in { background: var(--in-soft); color: #0f6a3b; }
.pill-out { background: var(--out-soft); color: #8d3420; }
.pill-neutral { background: var(--sage-100); color: var(--ink-soft); }
.pill-gold { background: var(--pencil-soft); color: #6b5500; }

/* --------------------------------------------------------------------------
   Forms and buttons
   -------------------------------------------------------------------------- */

.form-label { font-weight: 600; font-size: 0.85rem; margin-bottom: 5px; color: var(--ink); }
.form-control, .form-select {
    border-color: var(--sage-300);
    border-radius: 8px;
    padding: 9px 12px;
    background-color: #fff;
}
.form-control:focus, .form-select:focus {
    border-color: var(--forest-600);
    box-shadow: 0 0 0 3px rgba(31,122,78,.2);
}
.form-check-input:checked { background-color: var(--forest-700); border-color: var(--forest-700); }
.form-text { color: var(--ink-soft); }

.btn { font-weight: 600; border-radius: 8px; padding: 8px 16px; }
.btn-sm { padding: 5px 12px; font-size: 0.85rem; }
.btn-primary {
    --bs-btn-bg: var(--forest-800);
    --bs-btn-border-color: var(--forest-800);
    --bs-btn-hover-bg: var(--forest-700);
    --bs-btn-hover-border-color: var(--forest-700);
    --bs-btn-active-bg: var(--forest-900);
    --bs-btn-active-border-color: var(--forest-900);
    --bs-btn-disabled-bg: var(--forest-800);
    --bs-btn-disabled-border-color: var(--forest-800);
}
.btn-accent {
    background: var(--pencil); color: var(--forest-900); border: 1px solid var(--pencil);
}
.btn-accent:hover { background: var(--pencil-deep); border-color: var(--pencil-deep); color: var(--forest-900); }
.btn-ghost {
    background: #fff; border: 1px solid var(--sage-300); color: var(--ink);
}
.btn-ghost:hover { background: var(--sage-50); border-color: var(--forest-600); color: var(--forest-900); }
.btn-danger-ghost { background: #fff; border: 1px solid #e8c4bb; color: var(--out); }
.btn-danger-ghost:hover { background: var(--out-soft); border-color: var(--out); color: #8d3420; }

.filters { display: flex; flex-wrap: wrap; gap: 12px; align-items: flex-end; }
.filters .field { flex: 1 1 180px; min-width: 0; }
.filters .field-wide { flex: 2 1 260px; }
.filters .field-btns { flex: 0 0 auto; display: flex; gap: 8px; }

/* Alerts */
.alert {
    display: flex; align-items: flex-start; gap: 12px;
    border: 0; border-left: 4px solid; border-radius: 8px;
    padding: 12px 16px; margin-bottom: 18px;
    font-weight: 500;
}
.alert i { margin-top: 2px; }
.alert .btn-close { margin-left: auto; padding: 14px; }
.alert-success { background: var(--in-soft); border-color: var(--in); color: #0c5430; }
.alert-danger { background: var(--out-soft); border-color: var(--out); color: #7c2d1b; }
.alert-warning { background: var(--pencil-soft); border-color: var(--pencil-deep); color: #5f4b00; }
.alert-info { background: #e3eef6; border-color: #3b82b4; color: #1d4a6b; }

/* Pagination */
.pagination { gap: 4px; margin: 0; flex-wrap: wrap; }
.pagination .page-link {
    border: 1px solid var(--sage-200); border-radius: 8px !important;
    color: var(--forest-800); font-weight: 600; min-width: 36px; text-align: center; padding: 6px 10px;
}
.pagination .page-link:hover { background: var(--sage-50); }
.pagination .page-item.active .page-link { background: var(--forest-800); border-color: var(--forest-800); color: #fff; }
.pagination .page-item.disabled .page-link { color: var(--sage-300); background: #fff; }

/* Tabs */
.tabs-x {
    display: flex; flex-wrap: wrap; gap: 4px;
    border-bottom: 1px solid var(--sage-300);
    margin-bottom: 22px;
    padding: 0; list-style: none;
}
.tabs-x .nav-link {
    border: 0; border-bottom: 3px solid transparent;
    border-radius: 0;
    color: var(--ink-soft); font-weight: 600;
    padding: 10px 16px; margin-bottom: -1px;
    background: transparent;
}
.tabs-x .nav-link:hover { color: var(--forest-900); }
.tabs-x .nav-link.active { color: var(--forest-900); border-bottom-color: var(--pencil); background: transparent; }
.tabs-x .count { background: var(--pencil); color: var(--forest-900); border-radius: 999px; font-size: 0.72rem; padding: 1px 8px; margin-left: 6px; font-weight: 700; }

/* --------------------------------------------------------------------------
   Home + news
   -------------------------------------------------------------------------- */

.home-grid { display: grid; grid-template-columns: minmax(0, 1.7fr) minmax(320px, 1fr); gap: 22px; align-items: start; }
@media (max-width: 1199.98px) { .home-grid { grid-template-columns: 1fr; } }

.video-frame { background: #000; border-radius: 10px; overflow: hidden; aspect-ratio: 16 / 9; }
.video-frame video { width: 100%; height: 100%; object-fit: cover; display: block; }

.news-list { max-height: 640px; overflow-y: auto; }
.news-item { display: flex; gap: 14px; padding: 16px 22px; border-bottom: 1px solid var(--sage-100); text-decoration: none; color: inherit; }
.news-item:last-child { border-bottom: 0; }
.news-item:hover { background: var(--sage-50); }
.news-item img { width: 84px; height: 84px; object-fit: cover; border-radius: 8px; flex: none; }
.news-item .date { font-size: 0.78rem; color: var(--ink-soft); font-weight: 600; }
.news-item h3 { font-size: 1rem; font-weight: 700; margin: 2px 0 4px; line-height: 1.3; }
.news-item p { margin: 0; color: var(--ink-soft); font-size: 0.88rem; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }

.feed-card { display: flex; gap: 20px; padding: 18px; }
.feed-card .thumb { width: 190px; height: 128px; object-fit: cover; border-radius: 8px; flex: none; }
.feed-card h2 { font-size: 1.2rem; font-weight: 700; margin: 4px 0 6px; line-height: 1.25; }
.feed-card h2 a { text-decoration: none; color: var(--forest-900); }
.feed-card h2 a:hover { text-decoration: underline; text-decoration-color: var(--pencil); text-underline-offset: 4px; text-decoration-thickness: 3px; }
.feed-card .excerpt { color: var(--ink-soft); margin: 0 0 10px; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
@media (max-width: 575.98px) {
    .feed-card { flex-direction: column; }
    .feed-card .thumb { width: 100%; height: 170px; }
}

.article { max-width: 78ch; margin: 0 auto; }
.article-hero { width: 100%; max-height: 420px; object-fit: cover; border-radius: 10px 10px 0 0; display: block; }
.article-body { font-size: 1.05rem; line-height: 1.75; }
.article-body h1, .article-body h2, .article-body h3 { margin: 1.4em 0 .5em; }
.article-body p { margin-bottom: 1em; }
.article-body ul, .article-body ol { padding-left: 1.4em; margin-bottom: 1em; }
.article-title { font-size: clamp(1.8rem, 3.4vw, 2.6rem); font-weight: 800; line-height: 1.1; }

.empty {
    text-align: center;
    padding: 44px 20px;
    color: var(--ink-soft);
}
.empty i { font-size: 2rem; color: var(--sage-300); display: block; margin-bottom: 8px; }
.empty strong { display: block; color: var(--ink); margin-bottom: 2px; }

.legend { display: flex; flex-wrap: wrap; gap: 8px; }
.legend span { background: #fff; border: 1px solid var(--sage-200); border-radius: 999px; padding: 3px 12px 3px 4px; font-size: 0.82rem; display: inline-flex; align-items: center; gap: 8px; }
.legend b { background: var(--forest-800); color: #fff; width: 22px; height: 22px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; font-size: 0.75rem; }

.sticky-form { position: sticky; top: 22px; }
@media (max-width: 1199.98px) { .sticky-form { position: static; } }

/* OneSignal prompt button */
.onesignal-customlink-container { display: inline-block; }
.onesignal-customlink-container .onesignal-customlink-button,
.onesignal-customlink-container a,
.onesignal-customlink-container button {
    background: var(--pencil) !important; color: var(--forest-900) !important;
    font-family: var(--font-body) !important; font-weight: 700 !important; font-size: 0.85rem !important;
    padding: 8px 14px !important; border-radius: 8px !important; border: 0 !important;
    text-decoration: none !important; cursor: pointer !important;
}

/* --------------------------------------------------------------------------
   Login
   -------------------------------------------------------------------------- */

body.login-page { background: #fff; min-height: 100vh; }
.login-split { display: grid; grid-template-columns: minmax(0, 1.05fr) minmax(0, 1fr); min-height: 100vh; }
.login-art {
    position: relative;
    background:
        repeating-linear-gradient(0deg, transparent 0 47px, rgba(255,255,255,.06) 47px 48px),
        var(--forest-900);
    color: #fff;
    padding: clamp(28px, 5vw, 64px);
    display: flex; flex-direction: column; justify-content: space-between;
    overflow: hidden;
}
.login-art::after {
    content: '';
    position: absolute; right: 0; top: 0; bottom: 0; width: 8px;
    background: var(--pencil);
}
.login-art .brand { padding: 0; }
.login-art h2 {
    color: #fff;
    font-size: clamp(2.2rem, 4.6vw, 3.8rem);
    font-weight: 800;
    line-height: 1.02;
    max-width: 14ch;
    margin: 0 0 18px;
}
.login-art p { color: rgba(255,255,255,.75); max-width: 40ch; font-size: 1.05rem; margin: 0; }
.login-art .foot { font-size: 0.82rem; color: rgba(255,255,255,.5); }
.login-form-side { display: flex; align-items: center; justify-content: center; padding: 32px 24px; background: var(--sage-50); }
.login-box { width: 100%; max-width: 400px; }
.login-box h1 { font-size: 1.9rem; font-weight: 800; margin-bottom: 4px; }
.login-box .logo-mobile { display: none; width: 56px; height: 56px; object-fit: contain; margin-bottom: 14px; }
.pw-wrap { position: relative; }
.pw-wrap .form-control { padding-right: 44px; }
.pw-toggle { position: absolute; right: 4px; top: 4px; bottom: 4px; width: 38px; border: 0; background: transparent; color: var(--ink-soft); border-radius: 6px; }
.pw-toggle:hover { color: var(--forest-900); background: var(--sage-100); }
@media (max-width: 899.98px) {
    .login-split { grid-template-columns: 1fr; }
    .login-art { display: none; }
    .login-box .logo-mobile { display: block; }
}
