/* =====================================================================
   GWPTC E-School -- institutional theme
   Palette: white / light gray surfaces, deep navy navigation,
            teal primary actions, restrained amber highlights.
   ===================================================================== */

:root {
    --navy-900: #0f1e33;
    --navy-800: #16283f;
    --navy-700: #1d3552;
    --slate-600: #41556b;
    --slate-400: #8798ab;
    --line: #e3e8ef;
    --surface: #ffffff;
    --surface-2: #f6f8fb;
    --surface-3: #eef2f7;
    --teal-600: #0f766e;
    --teal-500: #14918a;
    --teal-050: #e7f6f4;
    --amber-500: #d99a1a;
    --amber-050: #fdf5e3;
    --text: #1f2b3a;
    --muted: #67788c;
    --radius: 10px;
    --shadow-sm: 0 1px 2px rgba(15, 30, 51, .06), 0 1px 3px rgba(15, 30, 51, .05);
    --shadow-md: 0 4px 14px rgba(15, 30, 51, .08);
    --sidebar-w: 260px;
}

* { box-sizing: border-box; }

body {
    font-family: "Segoe UI", system-ui, -apple-system, "Helvetica Neue", Arial, "Noto Sans Ethiopic", sans-serif;
    color: var(--text);
    background: var(--surface-2);
    margin: 0;
}

.text-teal { color: var(--teal-600) !important; }

.btn-teal {
    background: var(--teal-600);
    border-color: var(--teal-600);
    color: #fff;
}
.btn-teal:hover, .btn-teal:focus {
    background: var(--teal-500);
    border-color: var(--teal-500);
    color: #fff;
}

.placement-results-search {
    border-color: var(--teal-500);
    animation: placement-search-glow 1.8s ease-in-out infinite alternate;
}
@keyframes placement-search-glow {
    from { box-shadow: 0 0 0 .12rem rgba(20, 145, 138, .16), 0 0 5px rgba(20, 145, 138, .18); }
    to { box-shadow: 0 0 0 .2rem rgba(20, 145, 138, .3), 0 0 13px rgba(20, 145, 138, .38); }
}
@media (prefers-reduced-motion: reduce) {
    .placement-results-search {
        animation: none;
        box-shadow: 0 0 0 .16rem rgba(20, 145, 138, .25), 0 0 10px rgba(20, 145, 138, .3);
    }
}

.notched-field {
    position: relative;
    padding-top: .4rem;
}
.notched-field > .notched-label {
    position: absolute;
    z-index: 2;
    top: .04rem;
    left: 1rem;
    margin: 0;
    padding: 0 .3rem;
    color: var(--muted);
    background: var(--surface);
    font-size: .74rem;
    line-height: 1;
    white-space: nowrap;
}
.notched-field > .form-control,
.notched-field > .form-select {
    min-height: 3rem;
    padding-top: .65rem;
    border: 1px solid var(--slate-400);
    border-radius: 7px;
}
.notched-field:focus-within > .notched-label { color: var(--teal-600); }
.notched-field:focus-within > .form-control,
.notched-field:focus-within > .form-select {
    border-color: var(--teal-500);
    box-shadow: 0 0 0 .16rem rgba(20, 145, 138, .16);
}
.notched-choice {
    min-width: 0;
    margin: 0;
    padding: .7rem .65rem .35rem;
    border: 1px solid var(--slate-400);
    border-radius: 7px;
}
.notched-choice > legend {
    float: none;
    width: auto;
    margin: 0 0 0 .25rem;
    padding: 0 .3rem;
    color: var(--muted);
    background: var(--surface);
    font-size: .74rem;
    line-height: 1;
}

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

.app-sidebar {
    width: var(--sidebar-w);
    flex: 0 0 var(--sidebar-w);
    background: var(--navy-900);
    color: #cbd6e3;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: 1.15rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.sidebar-brand i { font-size: 1.6rem; color: var(--teal-500); }
.brand-name { display: block; font-weight: 700; color: #fff; letter-spacing: .02em; }
.brand-sub { display: block; font-size: .72rem; text-transform: uppercase; letter-spacing: .14em; color: var(--slate-400); }

.sidebar-nav { padding: .75rem .6rem 1rem; flex: 1; }
.nav-group-label {
    font-size: .68rem;
    text-transform: uppercase;
    letter-spacing: .13em;
    color: var(--slate-400);
    padding: 1rem .7rem .4rem;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .55rem .7rem;
    border-radius: 8px;
    color: #cbd6e3;
    text-decoration: none;
    font-size: .92rem;
    margin-bottom: 2px;
}
.nav-item i { width: 1.15rem; text-align: center; opacity: .85; }
a.nav-item:hover { background: rgba(255, 255, 255, .07); color: #fff; }
.nav-item.active {
    background: linear-gradient(90deg, rgba(20, 145, 138, .28), rgba(20, 145, 138, .06));
    color: #fff;
    box-shadow: inset 3px 0 0 var(--teal-500);
}
.nav-item-future { opacity: .5; cursor: not-allowed; }
.future-tag {
    margin-left: auto;
    font-size: .6rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    background: rgba(217, 154, 26, .18);
    color: var(--amber-500);
    border-radius: 20px;
    padding: .05rem .45rem;
    font-style: normal;
}
.sidebar-footer {
    padding: .8rem 1.25rem 1.1rem;
    border-top: 1px solid rgba(255, 255, 255, .08);
    font-size: .75rem;
    color: var(--slate-400);
}

.app-main { flex: 1; min-width: 0; display: flex; flex-direction: column; }

.app-topbar {
    display: flex;
    align-items: center;
    gap: 1rem;
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    padding: .85rem 1.5rem;
    position: sticky;
    top: 0;
    z-index: 20;
}
.topbar-title { font-size: 1.05rem; font-weight: 600; margin: 0; }
.topbar-actions { margin-left: auto; display: flex; align-items: center; gap: .75rem; }

.role-chip {
    display: inline-flex;
    align-items: center;
    gap: .4rem;
    font-size: .78rem;
    padding: .3rem .65rem;
    border-radius: 20px;
    background: var(--surface-3);
    color: var(--slate-600);
    white-space: nowrap;
}
.role-chip.role-super_admin { background: var(--teal-050); color: var(--teal-600); }
.role-chip.role-department_head { background: var(--amber-050); color: #8a6100; }

.app-content { padding: 1.5rem; flex: 1; }
.app-footer {
    padding: .9rem 1.5rem;
    border-top: 1px solid var(--line);
    font-size: .8rem;
    color: var(--muted);
    background: var(--surface);
}

/* ---------- Page furniture ---------------------------------------- */
.page-head {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}
.page-title { font-size: 1.45rem; font-weight: 650; margin: 0 0 .15rem; }
.page-subtitle { color: var(--muted); margin: 0; font-size: .9rem; }
.section-heading {
    font-size: .76rem;
    text-transform: uppercase;
    letter-spacing: .12em;
    color: var(--muted);
    margin: 1.6rem 0 .75rem;
}

.status-pill {
    display: inline-flex;
    align-items: center;
    gap: .45rem;
    padding: .35rem .8rem;
    border-radius: 22px;
    font-size: .82rem;
    font-weight: 600;
}
.status-pill i { font-size: .5rem; }
.status-open,
.status-active { background: var(--teal-050); color: var(--teal-600); }
.status-closed { background: #fdecec; color: #b3261e; }
.status-draft,
.status-inactive { background: #eef1f4; color: #5b6b7a; }
.status-scheduled,
.status-executed,
.status-published,
.status-awaiting_allocation,
.status-registered,
.status-allocated,
.status-eligible { background: var(--teal-050); color: var(--teal-600); }
.status-pending_review,
.status-pending_assignment,
.status-pending { background: var(--amber-050); color: #9a6c00; }
.status-cancelled,
.status-ineligible,
.status-unallocated { background: #fdecec; color: #b3261e; }

/* ---------- Admission / student application statuses ---------------- */
.status-application_approved,
.status-verified { background: var(--teal-050); color: var(--teal-600); }
.status-not_started,
.status-uploaded { background: #eef1f4; color: #5b6b7a; }
.status-application_pending,
.status-application_under_review { background: var(--amber-050); color: #9a6c00; }
.status-application_resubmit { background: #fff3e0; color: #b26a00; }
.status-application_rejected,
.status-rejected { background: #fdecec; color: #b3261e; }

/* ---------- Cards -------------------------------------------------- */
.card {
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
}
.card-header {
    background: var(--surface);
    border-bottom: 1px solid var(--line);
    font-weight: 600;
    font-size: .92rem;
    display: flex;
    align-items: center;
    gap: .5rem;
}
.cycle-name { font-size: 1.1rem; font-weight: 600; }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(230px, 1fr));
    gap: 1rem;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 1rem 1.1rem;
    display: flex;
    align-items: center;
    gap: .9rem;
    box-shadow: var(--shadow-sm);
}
.stat-icon {
    width: 44px;
    height: 44px;
    flex: 0 0 44px;
    border-radius: 10px;
    display: grid;
    place-items: center;
    font-size: 1.2rem;
    background: var(--surface-3);
    color: var(--slate-600);
}
.stat-value { font-size: 1.5rem; font-weight: 700; line-height: 1.1; }
.stat-label { font-size: .82rem; color: var(--muted); }

.tone-structure .stat-icon { background: #eaf1ff; color: #2f5fb3; }
.tone-staff .stat-icon { background: var(--amber-050); color: #9a6c00; }
.tone-classes .stat-icon { background: var(--teal-050); color: var(--teal-600); }
.tone-system .stat-icon { background: #f0ecff; color: #5b46b8; }
.tone-primary .stat-icon { background: #eaf1ff; color: #2f5fb3; }
.tone-success .stat-icon { background: #e7f7ee; color: #1d7a45; }
.tone-warning .stat-icon { background: var(--amber-050); color: #9a6c00; }
.tone-danger .stat-icon { background: #fdecec; color: #b3261e; }
.tone-info .stat-icon { background: #e8f4fb; color: #1d6b93; }

.empty-chart, .empty-state {
    text-align: center;
    padding: 2.2rem 1rem;
    color: var(--muted);
}
.empty-chart i, .empty-state i { font-size: 2.4rem; color: var(--slate-400); display: block; margin-bottom: .6rem; }

.alert-stack { margin-bottom: 1rem; }
.alert-stack .alert { display: flex; align-items: center; gap: .6rem; }

/* ---------- Capacity bars (used from Phase 3 onward) ---------------- */
.capacity-bar { height: 8px; border-radius: 20px; background: var(--surface-3); overflow: hidden; }
.capacity-bar > span { display: block; height: 100%; background: var(--teal-500); }
.capacity-bar.warn > span { background: var(--amber-500); }
.capacity-bar.full > span { background: #b3261e; }

/* ---------- Report tiles ------------------------------------------- */
.report-tile {
    display: flex;
    gap: .9rem;
    padding: 1rem 1.1rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    text-decoration: none;
    color: inherit;
    height: 100%;
    transition: border-color .15s ease, box-shadow .15s ease;
}
.report-tile:hover { border-color: var(--teal-500); box-shadow: var(--shadow); }
.report-tile-icon {
    flex: 0 0 auto;
    width: 42px; height: 42px;
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    background: var(--teal-050); color: var(--teal-600);
    font-size: 1.2rem;
}
.report-tile-title { font-weight: 600; }
.report-tile-text { color: var(--muted); font-size: .84rem; }
.report-table thead th { white-space: nowrap; font-size: .82rem; }
.audit-json {
    background: var(--surface-2);
    border: 1px solid var(--line);
    border-radius: 8px;
    padding: .75rem 1rem;
    font-size: .8rem;
    white-space: pre-wrap;
    word-break: break-word;
    max-height: 320px;
    overflow: auto;
}

/* ---------- Error pages -------------------------------------------- */
.error-page { text-align: center; padding: 3rem 1rem; max-width: 620px; margin: 0 auto; }
.error-icon { font-size: 3rem; color: var(--slate-400); }
.error-code { font-size: 3.4rem; font-weight: 800; color: var(--navy-800); line-height: 1; }
.error-title { font-size: 1.3rem; margin: .5rem 0; }
.error-message { color: var(--muted); margin-bottom: 1.5rem; }

/* ---------- Sidebar behaviour on small screens ---------------------- */
.sidebar-toggle { font-size: 1.4rem; color: var(--navy-800); text-decoration: none; }
.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(15, 30, 51, .45);
    z-index: 30;
}
@media (max-width: 991.98px) {
    .app-sidebar {
        position: fixed;
        left: 0;
        top: 0;
        z-index: 40;
        transform: translateX(-100%);
        transition: transform .2s ease;
    }
    body.sidebar-open .app-sidebar { transform: translateX(0); }
    body.sidebar-open .sidebar-backdrop { display: block; }
}

/* ---------- Authentication screens ---------------------------------- */
.auth-shell { background: var(--surface-2); }
.auth-grid { display: grid; grid-template-columns: 1.05fr .95fr; min-height: 100vh; }
.auth-aside {
    background: linear-gradient(155deg, var(--navy-900) 0%, var(--navy-700) 70%, #1a4a4a 100%);
    color: #d7e2ee;
    display: flex;
    align-items: center;
    padding: 3rem;
}
.auth-aside-inner { max-width: 480px; margin: 0 auto; }
.auth-logo { font-size: 2.6rem; color: var(--teal-500); }
img.auth-logo { height: 72px; width: auto; border-radius: 12px; background: #fff; padding: 4px; }
.auth-aside h1 { font-size: 1.75rem; color: #fff; margin: 1rem 0 .35rem; }
.tracking { letter-spacing: .16em; color: var(--slate-400) !important; }
.auth-points { list-style: none; padding: 0; margin: 0 0 1.5rem; }
.auth-points li { display: flex; gap: .6rem; align-items: flex-start; padding: .3rem 0; font-size: .94rem; }
.auth-points i { color: var(--teal-500); margin-top: .15rem; }
.auth-note { font-size: .8rem; color: var(--slate-400); border-top: 1px solid rgba(255,255,255,.1); padding-top: 1rem; }

.auth-panel { display: flex; flex-direction: column; align-items: center; justify-content: center; padding: 2.5rem 1.5rem; }
.auth-card {
    width: 100%;
    max-width: 420px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: var(--shadow-md);
    padding: 2rem 1.9rem;
}
.auth-footnote { color: var(--muted); font-size: .78rem; margin-top: 1.25rem; text-align: center; }

@media (max-width: 900px) {
    .auth-grid { grid-template-columns: 1fr; }
    .auth-aside { display: none; }
}

/* --- Ethiopian / Gregorian date-time picker ------------------------- */
.ethcal { position: relative; }
.ethcal-mode { min-width: 3.4rem; font-weight: 600; letter-spacing: .02em; }
.ethcal-popup {
    position: absolute;
    z-index: 1080;
    top: calc(100% + .35rem);
    left: 0;
    width: 19rem;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    padding: .75rem;
}
.ethcal-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: .35rem; }
.ethcal-nav-btn {
    border: 0;
    background: var(--surface-3);
    color: var(--text);
    border-radius: 6px;
    width: 1.9rem;
    height: 1.9rem;
    line-height: 1;
    font-size: 1.1rem;
    cursor: pointer;
}
.ethcal-title { font-weight: 600; font-size: .92rem; }
.ethcal-weekdays,
.ethcal-days { display: grid; grid-template-columns: repeat(7, 1fr); gap: 2px; }
.ethcal-weekdays span {
    text-align: center;
    font-size: .7rem;
    color: var(--muted);
    padding: .2rem 0;
    text-transform: uppercase;
}
.ethcal-day {
    border: 0;
    background: transparent;
    border-radius: 6px;
    padding: .35rem 0;
    font-size: .82rem;
    color: var(--text);
    cursor: pointer;
}
.ethcal-day:hover:not(.is-empty) { background: var(--teal-050); }
.ethcal-day.is-selected { background: var(--teal-600); color: #fff; font-weight: 600; }
.ethcal-day.is-empty { cursor: default; }
.ethcal-actions { display: flex; align-items: center; justify-content: space-between; margin-top: .6rem; }

@media print {
    .app-sidebar, .app-topbar, .app-footer, .sidebar-backdrop, .no-print { display: none !important; }
    .app-content { padding: 0; }
    body { background: #fff; }
}

/* =====================================================================
   Compact institutional header (dashboard redesign palette)
   The variables live here so both the shell and dashboard pages share
   one source of truth for brand colours.
   ===================================================================== */
:root {
    --brand-primary: #159ED4;
    --brand-navy: #1E293B;
    --brand-cyan-050: #EAF8FC;
    --brand-bg: #F7FAFC;
    --brand-card: #FFFFFF;
    --brand-green: #00C995;
    --brand-orange: #FFA500;
    --brand-border: #E7EDF3;
    --brand-text: #64748B;
    --brand-success: #16A34A;
    --brand-warning: #F59E0B;
    --brand-error: #DC2626;
}

.app-topbar {
    min-height: 58px;
    padding: .4rem 1.5rem;
    gap: 1rem;
    box-shadow: 0 1px 0 rgba(30, 41, 59, .04);
}
.topbar-heading { display: flex; align-items: center; gap: .7rem; min-width: 0; }
.topbar-logo { height: 32px; width: auto; border-radius: 8px; }
.topbar-logo-fallback {
    width: 32px; height: 32px; border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--brand-cyan-050); color: var(--brand-primary);
}
.topbar-heading-text { display: flex; flex-direction: column; line-height: 1.15; min-width: 0; }
.topbar-college {
    font-size: .7rem; text-transform: uppercase; letter-spacing: .05em;
    color: var(--brand-text); white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.topbar-title { font-size: .98rem; font-weight: 600; margin: 0; color: var(--brand-navy); }

.topbar-icon-btn {
    position: relative; border: 0; background: transparent; color: var(--brand-navy);
    width: 38px; height: 38px; border-radius: 10px;
    display: inline-flex; align-items: center; justify-content: center; font-size: 1.15rem;
}
.topbar-icon-btn:hover, .topbar-icon-btn:focus-visible { background: var(--brand-cyan-050); color: var(--brand-primary); }
.topbar-icon-btn:focus-visible { outline: 2px solid var(--brand-primary); outline-offset: 2px; }
.notification-badge {
    position: absolute; top: 3px; right: 3px;
    min-width: 17px; height: 17px; padding: 0 4px; border-radius: 9px;
    background: var(--brand-error); color: #fff; font-size: .66rem; font-weight: 700;
    display: inline-flex; align-items: center; justify-content: center;
}
.notification-menu { width: min(360px, 92vw); padding: 0; overflow: hidden; }
.notification-menu-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: .65rem .9rem; border-bottom: 1px solid var(--brand-border);
    font-size: .85rem; font-weight: 600; color: var(--brand-navy);
}
.notification-empty {
    display: flex; flex-direction: column; align-items: center; gap: .4rem;
    padding: 1.5rem 1rem; text-align: center; color: var(--brand-text); font-size: .85rem;
}
.notification-empty i { font-size: 1.5rem; opacity: .6; }
.notification-item {
    display: flex; gap: .6rem; padding: .7rem .9rem;
    border-bottom: 1px solid var(--brand-border);
    color: inherit; text-decoration: none;
}
.notification-item:last-child { border-bottom: 0; }
.notification-item:hover { background: var(--brand-bg); }
.notification-item.unread { background: var(--brand-cyan-050); }
.notification-dot { flex: 0 0 auto; width: 8px; height: 8px; border-radius: 50%; margin-top: .35rem; }
.notification-body { display: flex; flex-direction: column; min-width: 0; }
.notification-title { font-size: .85rem; font-weight: 600; color: var(--brand-navy); }
.notification-text { font-size: .8rem; color: var(--brand-text); }
.notification-time { font-size: .72rem; color: var(--brand-text); opacity: .8; }

.topbar-account {
    display: flex; align-items: center; gap: .5rem;
    border: 0; background: transparent; padding: .3rem .5rem; border-radius: 10px;
    color: var(--brand-navy);
}
.topbar-account:hover, .topbar-account:focus-visible { background: var(--brand-cyan-050); }
.topbar-account-avatar { font-size: 1.25rem; color: var(--brand-primary); }
.topbar-account-name { font-size: .88rem; font-weight: 600; }

@media (max-width: 575.98px) {
    .topbar-college, .topbar-account-name { display: none; }
    .app-topbar { padding: .4rem 1rem; gap: .5rem; }
}

/* ---------- Manual section builder (responsive) --------------------- */
.section-manual .pool-table-wrap {
    /* On small screens the fixed max-height fights the viewport, so let the
       wrapper use the available height and keep horizontal scrolling. */
    -webkit-overflow-scrolling: touch;
}
.section-manual .pool-table {
    width: 100%;
}
.section-manual .pool-table th,
.section-manual .pool-table td {
    white-space: nowrap;
}
.section-manual .pool-table td:nth-child(3) {
    /* Applicant name is the only column allowed to wrap. */
    white-space: normal;
    min-width: 10rem;
}
.section-manual .page-head-actions {
    display: flex;
    flex-wrap: wrap;
    gap: .5rem;
}

@media (max-width: 767.98px) {
    .section-manual .pool-table-wrap {
        max-height: 60vh !important;
    }
    .section-manual .card-header {
        flex-wrap: wrap;
        gap: .4rem;
    }
    .section-manual .card-header .badge {
        width: 100%;
        text-align: left;
        white-space: normal;
        line-height: 1.5;
    }
    .section-manual .pool-table th,
    .section-manual .pool-table td {
        padding: .4rem .35rem;
        font-size: .85rem;
    }
    .section-manual .pool-table th:nth-child(1),
    .section-manual .pool-table td:nth-child(1) {
        width: auto;
    }
    /* Keep the action buttons full-width on phones so they are easy to tap. */
    .section-manual form .d-flex.gap-2 > .btn {
        flex: 1 1 auto;
        justify-content: center;
    }
}

@media (max-width: 575.98px) {
    .section-manual .page-head-actions {
        width: 100%;
    }
    .section-manual .page-head-actions .btn {
        width: 100%;
        justify-content: center;
    }
    .section-manual .pool-table th,
    .section-manual .pool-table td {
        font-size: .8rem;
    }
    .section-manual .pool-table td:nth-child(3) {
        min-width: 8rem;
    }
}

/* ---------- Sidebar More group collapse ----------------------------- */
.nav-group-toggle {
    display: flex; align-items: center; justify-content: space-between; width: 100%;
    background: transparent; border: 0; color: inherit;
    padding: .35rem .9rem .25rem; margin-top: .4rem; cursor: pointer;
}
.nav-group-toggle .nav-group-label {
    padding: 0;
}
.nav-group-toggle i {
    transition: transform .2s ease; font-size: .8rem;
}
.nav-group-toggle[aria-expanded=\"true\"] i {
    transform: rotate(180deg);
}
.nav-group-items {
    display: flex; flex-direction: column;
}
.nav-group-collapsed {
    display: none;
}
