/* ================================================================
   School Portal theme: the one set of colours, fonts and shapes.
   Loaded first by the front office (templates/base.html) and by the
   Django admin (templates/admin/base.html), so both look the same.
   Values follow the approved design canvas (indigo on slate).
   Besides the tokens, it holds the one style both sides share: scrollbars.
   ================================================================ */
:root {
    /* Brand: indigo */
    --primary: #4F46E5;          /* buttons, selected items */
    --primary-dark: #4338CA;     /* hover, links */
    --primary-darker: #3730A3;
    --primary-light: #EEF2FF;    /* pale tint behind highlighted panels */
    --primary-200: #C7D2FE;      /* focus rings, soft borders */
    --primary-300: #A5B4FC;

    /* Slate neutrals */
    --slate-50: #F8FAFC;
    --slate-100: #F1F5F9;
    --slate-200: #E2E8F0;
    --slate-300: #CBD5E1;
    --slate-400: #94A3B8;
    --slate-500: #64748B;
    --slate-600: #475569;
    --slate-700: #334155;
    --slate-800: #1E293B;
    --slate-900: #0F172A;

    /* Status: strong text colour and a pale background for each */
    --success: #10B981;  --success-text: #047857; --success-bg: #DCFCE7;
    --warning: #F59E0B;  --warning-text: #B45309; --warning-bg: #FEF3C7;
    --danger:  #EF4444;  --danger-text:  #B91C1C; --danger-bg:  #FEE2E2;
    --accent: var(--primary);

    /* Surfaces and text */
    --bg: var(--slate-50);
    --bg-main: var(--slate-50);
    --bg-card: #FFFFFF;
    --bg-surface: #FFFFFF;
    --surface: #FFFFFF;
    --bg-hover: var(--slate-100);
    --border: var(--slate-200);
    --text: var(--slate-900);
    --text-primary: var(--slate-900);
    --text-secondary: var(--slate-500);
    --secondary: var(--slate-500);

    /* Sidebar (front office and admin) */
    --bg-sidebar: var(--slate-800);
    --bg-sidebar-hover: var(--slate-700);
    --text-sidebar: var(--slate-300);
    --text-sidebar-active: #FFFFFF;
    --text-sidebar-label: var(--slate-400);

    /* Shape and depth */
    --radius: 0.75rem;     /* cards */
    --radius-sm: 0.5rem;   /* buttons, inputs */
    --focus-ring: 0 0 0 3px rgba(79, 70, 229, 0.18);
    --shadow: 0 1px 3px rgba(15, 23, 42, 0.06), 0 1px 2px rgba(15, 23, 42, 0.04);
    --shadow-md: 0 4px 6px rgba(15, 23, 42, 0.05), 0 2px 4px rgba(15, 23, 42, 0.03);
    --shadow-lg: 0 10px 15px rgba(15, 23, 42, 0.08), 0 4px 6px rgba(15, 23, 42, 0.04);

    /* Layout shared by the front office and the admin, so moving between them
       does not make the header or sidebar jump */
    --header-height: 60px;
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 68px;
    --sidebar-scrollbar: rgba(255, 255, 255, 0.18);
    --sidebar-scrollbar-hover: rgba(255, 255, 255, 0.32);

    /* Type */
    --font-body: 'Inter', system-ui, -apple-system, 'Segoe UI', sans-serif;
    --font-heading: 'Outfit', 'Inter', system-ui, sans-serif;
}

/* ---- Dark theme ---------------------------------------------------------------
   The front office only: templates/base.html sets html[data-theme="dark"] from the
   switch beside the user menu (remembered in this browser). Administration and the
   print pages stay light. The slate scale is turned round, so a page that uses the
   tokens (slate-50 behind, slate-900 for text, slate-200 for lines) needs nothing
   of its own; the dark side menu keeps its own colours. */
html[data-theme="dark"] {
    color-scheme: dark;
    --primary: #6366F1;
    --primary-dark: #A5B4FC;
    --primary-darker: #C7D2FE;
    --primary-light: #1E1B4B;
    --primary-200: #3730A3;
    --primary-300: #4F46E5;

    --slate-50: #0B1220;
    --slate-100: #162033;
    --slate-200: #243044;
    --slate-300: #34425A;
    --slate-400: #55637A;
    --slate-500: #94A3B8;
    --slate-600: #A9B6C8;
    --slate-700: #CBD5E1;
    --slate-800: #E2E8F0;
    --slate-900: #F1F5F9;

    --success: #34D399;  --success-text: #6EE7B7; --success-bg: #06301F;
    --warning: #FBBF24;  --warning-text: #FCD34D; --warning-bg: #3A2A06;
    --danger:  #F87171;  --danger-text:  #FCA5A5; --danger-bg:  #3B1010;

    --bg: #0B1220;
    --bg-main: #0B1220;
    --bg-card: #111A2B;
    --bg-surface: #111A2B;
    --surface: #111A2B;
    --bg-hover: #1A2538;
    --border: #243044;
    --text: #E5E9F0;
    --text-primary: #E5E9F0;
    --text-secondary: #94A3B8;
    --secondary: #94A3B8;

    --bg-sidebar: #0A1020;
    --bg-sidebar-hover: #18223A;
    --text-sidebar: #CBD5E1;
    --text-sidebar-active: #FFFFFF;
    --text-sidebar-label: #7C8AA3;

    --focus-ring: 0 0 0 3px rgba(129, 140, 248, 0.35);
    --shadow: 0 1px 3px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.45);
    --shadow-lg: 0 10px 15px rgba(0, 0, 0, 0.55);
}
html[data-theme="dark"] body { background: var(--bg-main); color: var(--text-primary); }
html[data-theme="dark"] img:not([src$=".svg"]) { filter: brightness(.92); }

/* ---- Scrollbars (front office and admin) ------------------------------------
   Thin, rounded and quiet: slate on pages, faint white on the dark sidebars.
   Chrome, Edge and Safari draw the ::-webkit-scrollbar rules, which they ignore
   on any element that sets scrollbar-width or scrollbar-color, so those are
   reset there. Firefox has no such rules and gets the standard properties. */
::-webkit-scrollbar { width: 12px; height: 12px; }
::-webkit-scrollbar-track,
::-webkit-scrollbar-corner { background: transparent; }
::-webkit-scrollbar-thumb {
    background-color: var(--slate-300);
    border: 3px solid transparent;   /* a 6px bar with breathing room */
    border-radius: 999px;
    background-clip: padding-box;
}
::-webkit-scrollbar-thumb:hover { background-color: var(--slate-400); }

.sidebar-nav::-webkit-scrollbar,
.app-sidebar .sidebar-wrapper::-webkit-scrollbar { width: 10px; }
.sidebar-nav::-webkit-scrollbar-thumb,
.app-sidebar .sidebar-wrapper::-webkit-scrollbar-thumb { background-color: var(--sidebar-scrollbar); }
.sidebar-nav::-webkit-scrollbar-thumb:hover,
.app-sidebar .sidebar-wrapper::-webkit-scrollbar-thumb:hover { background-color: var(--sidebar-scrollbar-hover); }

@supports selector(::-webkit-scrollbar) {
    html,
    .sidebar-nav,
    .app-sidebar .sidebar-wrapper {
        scrollbar-width: auto;
        scrollbar-color: auto;
    }
}
@supports not selector(::-webkit-scrollbar) {
    html { scrollbar-width: thin; scrollbar-color: var(--slate-300) transparent; }
    .sidebar-nav,
    .app-sidebar .sidebar-wrapper { scrollbar-width: thin; scrollbar-color: var(--sidebar-scrollbar) transparent; }
}

/* ===================================================================== keyboard use (js/keyboard.js) */
/* A clear ring on whatever has the keyboard focus (not on mouse clicks). */
a:focus-visible, button:focus-visible, summary:focus-visible, [role="button"]:focus-visible, [tabindex]:focus-visible,
input[type="checkbox"]:focus-visible, input[type="radio"]:focus-visible, .nav-link:focus-visible, .btn:focus-visible {
    outline: 2px solid var(--primary, #4F46E5) !important; outline-offset: 2px; border-radius: 4px;
}
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--primary-300, #A5B4FC); outline-offset: 1px; }
.sidebar .nav-link:focus-visible, .main-sidebar .nav-link:focus-visible { outline-color: #fff !important; outline-offset: -2px; }
/* The row picked with ↑ ↓ / j k on a list. */
tr.kb-row > td, .kb-row { background: var(--primary-light, #EEF2FF) !important; }
tr.kb-row > td:first-child { box-shadow: inset 3px 0 0 var(--primary, #4F46E5); }
/* Keys shown on screen. */
kbd { display: inline-block; min-width: 1.4em; padding: 0.05em 0.4em; border: 1px solid var(--slate-300, #CBD5E1); border-bottom-width: 2px;
      border-radius: 5px; background: var(--bg-card, #fff); font: 600 0.75rem/1.4 Inter, sans-serif; color: var(--slate-700, #334155); text-align: center; }
.kb-key-hint { margin-left: 0.35rem; opacity: .75; }
/* The key of a button or link, shown on it (js/keyboard.js showKeys). Only for people who use the keyboard
   (html.kb-on, set from their first shortcut on; the ? list turns it on or off), and then tiny and light,
   clearer on the button under the mouse or the focus. In the button's own colour, so it reads on filled
   and outline buttons alike. Icon buttons carry it on a corner. Hints about keys (.kb-only) follow it. */
html:not(.kb-on) .kb-key, html:not(.kb-on) .kb-only { display: none !important; }
kbd.kb-key { display: inline-flex; align-items: center; justify-content: center; min-width: 1.2em; height: 1.3em;
             margin: 0 0 0 0.4em; padding: 0 0.25em; border: 1px solid currentColor; border-radius: 3px; background: transparent;
             font: 500 0.58rem/1 Inter, sans-serif; letter-spacing: 0; text-transform: none; color: inherit; opacity: .38;
             vertical-align: middle; white-space: nowrap; flex-shrink: 0; box-shadow: none; pointer-events: none; }
:hover > kbd.kb-key, :focus-visible > kbd.kb-key { opacity: .75; }
kbd.kb-key-corner { position: absolute; top: -6px; right: -6px; margin: 0; min-width: 1.25em; height: 1.25em; padding: 0 0.2em;
                    background: var(--bg-card, #fff); color: var(--slate-400, #94A3B8); border-color: var(--slate-200, #E2E8F0); opacity: 1; font-size: 0.55rem; z-index: 1; }
/* "/" inside the search box it goes to (a list's search, or the top bar's). */
kbd.kb-key-field { position: absolute; right: 0.55rem; top: 50%; transform: translateY(-50%); margin: 0; background: var(--bg-card, #fff);
                   color: var(--slate-400, #94A3B8); border-color: var(--slate-200, #E2E8F0); opacity: 1; }
.topbar-find kbd.kb-key-field { right: 3.75rem; }
.admin-list-search { position: relative; display: inline-flex; align-items: center; }
html.kb-on .list-search:has(.kb-key-field) .form-control { padding-right: 2rem !important; }
html.kb-on .topbar-find:has(.kb-key-field) input { padding-right: 5.9rem !important; }
/* In the dark side menus: pushed to the right, faint. Hidden when the menu shows icons only. */
.sidebar .nav-link kbd.kb-key, .app-sidebar .nav-link kbd.kb-key { margin-left: auto; color: rgba(255, 255, 255, .5);
                                                                   border-color: rgba(255, 255, 255, .3); opacity: .6; }
.sidebar .nav-link:hover kbd.kb-key, .sidebar .nav-link.active kbd.kb-key,
.app-sidebar .nav-link:hover kbd.kb-key, .app-sidebar .nav-link.active kbd.kb-key { opacity: 1; }
.sidebar .nav-link kbd.kb-key + .nav-ext, .app-sidebar .nav-link kbd.kb-key + .nav-ext { margin-left: 0.35rem; }
.sidebar.collapsed .nav-link kbd.kb-key, body.sidebar-collapse .app-sidebar kbd.kb-key { display: none; }
/* The "show the keys" switch in the ? list. */
.kb-actions { align-items: center; gap: 0.75rem; }
.kb-show { margin-right: auto; display: inline-flex; align-items: center; gap: 0.4rem; font-size: 0.8rem; color: var(--slate-600, #475569); cursor: pointer; }
@media (hover: none) and (pointer: coarse) { kbd.kb-key { display: none !important; } }
@media print { kbd.kb-key { display: none !important; } }
/* The jump menu (Ctrl+K) and the shortcut list (?). */
.kb-layer { position: fixed; inset: 0; z-index: 20000; background: rgba(15, 23, 42, .45); display: flex; align-items: flex-start;
            justify-content: center; padding: 10vh 1rem 1rem; }
.kb-dialog { width: min(640px, 100%); max-height: 80vh; overflow: auto; background: var(--bg-card, #fff); border-radius: 14px;
             box-shadow: 0 25px 50px -12px rgba(0, 0, 0, .35); padding: 0.9rem 1rem; font: 0.875rem/1.45 Inter, sans-serif;
             color: var(--slate-900, #0F172A); }
.kb-dialog h2 { margin: 0 0 0.6rem; font: 600 1.05rem Outfit, Inter, sans-serif; }
.kb-dialog h3 { margin: 0 0 0.35rem; font: 600 0.72rem Inter, sans-serif; text-transform: uppercase; letter-spacing: .05em; color: var(--slate-500, #64748B); }
.kb-help { display: grid; grid-template-columns: repeat(auto-fit, minmax(240px, 1fr)); gap: 0.9rem 1.4rem; }
.kb-help dl { display: grid; grid-template-columns: auto 1fr; gap: 0.3rem 0.7rem; margin: 0; align-items: baseline; }
.kb-help dt { white-space: nowrap; } .kb-help dd { margin: 0; }
.kb-help .kb-path { grid-column: 1 / -1; } .kb-help .kb-path p { margin: 0; color: var(--slate-700, #334155); }
.kb-note { margin: 0.7rem 0 0; font-size: 0.78rem; color: var(--slate-500, #64748B); }
.kb-actions { display: flex; justify-content: flex-end; margin-top: 0.6rem; }
.kb-actions button { border: 1px solid var(--slate-300, #CBD5E1); background: var(--bg-card, #fff); color: inherit; border-radius: 8px; padding: 0.35rem 0.9rem; font: 600 0.8125rem Inter, sans-serif; cursor: pointer; }
.kb-search { display: block; }
.kb-search input { width: 100%; box-sizing: border-box; padding: 0.7rem 0.85rem; border: 1px solid var(--slate-300, #CBD5E1); border-radius: 10px;
                   font: 1rem Inter, sans-serif; background: var(--bg-card, #fff); color: inherit; }
.kb-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
.kb-list { list-style: none; margin: 0.5rem 0 0; padding: 0; }
.kb-list li { display: flex; align-items: center; gap: 0.6rem; padding: 0.5rem 0.6rem; border-radius: 8px; cursor: pointer; }
.kb-list li.is-on { background: var(--primary-light, #EEF2FF); }
.kb-list .kb-kind { flex: none; width: 4.2rem; font-size: 0.7rem; text-transform: uppercase; letter-spacing: .04em; color: var(--slate-500, #64748B); }
.kb-list .kb-label { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.kb-list .kb-hint { flex: none; }
.kb-list .kb-empty { color: var(--slate-500, #64748B); cursor: default; }
/* A section's pages (Alt + number): links, so Tab and Enter work as everywhere. */
.kb-section li { padding: 0; }
.kb-section a { flex: 1; display: flex; align-items: center; gap: 0.6rem; padding: 0.55rem 0.6rem; border-radius: 8px;
                color: inherit; text-decoration: none; }
.kb-section a:focus-visible { outline-offset: -2px; }
.kb-section .kb-kind { width: 2rem; }
.kb-dialog h2 kbd { margin-left: 0.4rem; vertical-align: middle; }
/* "Alt 2" on a side-menu section. */
.nav-group-head kbd.kb-key { margin-left: auto; color: rgba(255, 255, 255, .5); border-color: rgba(255, 255, 255, .3); opacity: .6; }
html.kb-on .nav-group-head kbd.kb-key + .nav-chevron { margin-left: 0.35rem; }
.sidebar.collapsed .nav-group-head kbd.kb-key { display: none; }
.kb-toast { position: fixed; left: 50%; bottom: 1.5rem; transform: translateX(-50%); z-index: 20001; padding: 0.55rem 1rem;
            border-radius: 10px; background: var(--slate-900, #0F172A); color: #fff; font: 600 0.8125rem Inter, sans-serif;
            box-shadow: 0 10px 25px -5px rgba(0, 0, 0, .3); }
@media print { .kb-layer, .kb-toast { display: none !important; } }

/* Type-to-search dropdowns (js/select-search.js): a text box over a hidden <select data-search>. */
.ss-wrap { position: relative; display: block; min-width: 10rem; }
.ss-native { position: absolute !important; width: 1px !important; height: 1px !important; opacity: 0; pointer-events: none; overflow: hidden; }
.ss-input { width: 100%; }
.ss-list { position: absolute; z-index: 40; left: 0; right: 0; top: calc(100% + 4px); max-height: 16rem; overflow-y: auto; margin: 0; padding: 4px; list-style: none;
           background: var(--bg-card, #fff); border: 1px solid var(--slate-200, #E2E8F0); border-radius: 10px; box-shadow: 0 8px 24px rgba(15, 23, 42, .14); }
.ss-list li { padding: 6px 10px; border-radius: 6px; font-size: 0.875rem; cursor: pointer; }
.ss-list li.is-active, .ss-list li:hover { background: var(--primary-light, #EEF2FF); color: var(--primary-darker, #3730A3); }
.ss-list li[aria-selected="true"] { font-weight: 600; }
.ss-list li.ss-none { color: var(--slate-500, #64748B); cursor: default; background: none; }

/* Messages of a page (templates/base.html block "messages"). */
.site-messages { display: flex; flex-direction: column; gap: 6px; margin: 0 0 0.9rem; }
.site-msg { margin: 0; padding: 0.55rem 0.8rem; border-radius: 8px; font-size: 0.875rem; background: var(--primary-light, #EEF2FF); color: var(--primary-darker, #3730A3); }
.site-msg.is-success { background: var(--success-bg, #ECFDF5); color: var(--success-text, #047857); }
.site-msg.is-warning { background: var(--warning-bg, #FFFBEB); color: var(--warning-text, #B45309); }
.site-msg.is-error { background: var(--danger-bg, #FEF2F2); color: var(--danger-text, #B91C1C); font-weight: 600; }
