/* ==========================================================================
   SchoolOS design system
   A single stylesheet shared by every layout (app / guest / print)
   so the product looks like one coherent piece of software instead of a
   stack of ad-hoc <style> blocks. Built on top of Bootstrap 5 utilities.
   ========================================================================== */

:root {
    --brand-50:  #eef4ff;
    --brand-100: #dbe7ff;
    --brand-500: #3b5bdb;
    --brand-600: #2f4ec2;
    --brand-700: #26409e;
    --brand-900: #16204f;

    --ink-900: #101828;
    --ink-700: #344054;
    --ink-500: #667085;
    --ink-300: #d0d5dd;
    --ink-100: #f2f4f7;
    --ink-50:  #f9fafb;

    --success: #12855a;
    --danger:  #d92d20;
    --warning: #b54708;

    /* A single warm accent, used sparingly (the login hero, and a couple of
       highlight moments) so it reads as a deliberate choice rather than
       every icon or button on the page competing for attention. */
    --accent-500: #d3a94e;

    /* A small rotating palette for stat cards / category chips, so the
       dashboard and reports read as lively rather than monochrome, while
       everything else (buttons, links, nav) still anchors on --brand. */
    --hue-blue:   #3b5bdb;
    --hue-purple: #7c4dff;
    --hue-green:  #12855a;
    --hue-orange: #e8760c;
    --hue-pink:   #d6336c;
    --hue-teal:   #0f9488;

    --surface: #ffffff;
    --canvas:  #f6f7fb;
    --border:  #e6e8f0;

    /* Every icon in the product renders in exactly one color -- no
       multi-color emoji/icon sets. See resources/views/partials/icons.php. */
    --icon-color: var(--ink-500);
    --icon-color-active: var(--brand-600);
    --icon-color-inverse: #ffffff;

    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
    --shadow-md: 0 4px 12px rgba(16, 24, 40, .08);

    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

* { box-sizing: border-box; }
img, svg:not(.icon) { max-width: 100%; height: auto; }

html, body { height: 100%; overflow-x: hidden; }

body {
    font-family: var(--font-sans);
    background: var(--canvas);
    color: var(--ink-900);
    -webkit-font-smoothing: antialiased;
    font-size: clamp(14px, 1vw + 11px, 16px);
}

a { color: var(--brand-600); }

/* ---- Icons: single color, sized consistently, never tinted per-item ---- */
.icon {
    display: inline-block;
    width: 1.1em;
    height: 1.1em;
    vertical-align: -0.2em;
    color: var(--icon-color);
    stroke: currentColor;
    fill: none;
    flex-shrink: 0;
}
.icon-sm { width: .95em; height: .95em; }
.icon-lg { width: 1.5em; height: 1.5em; }

/* ---- Shell layout (app; parents use it too) ------------------------------------- */
.app-shell { min-height: 100vh; }

.app-sidebar {
    width: 260px;
    flex-shrink: 0;
    background: linear-gradient(180deg, var(--brand-900) 0%, #1a2361 100%);
    color: #e8ecff;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 1040;
    transition: transform .2s ease;
}
.app-sidebar .brand {
    display: flex;
    align-items: center;
    gap: .6rem;
    padding: 1.1rem 1.25rem;
    color: #fff;
    font-weight: 700;
    letter-spacing: .01em;
    text-decoration: none;
    border-bottom: 1px solid rgba(255,255,255,.08);
}
.app-sidebar .brand .icon { width: 1.4em; height: 1.4em; color: #fff; }
.app-sidebar nav { padding: .75rem; overflow-y: auto; }
.app-sidebar nav a {
    display: flex;
    align-items: center;
    gap: .65rem;
    color: #c3cbf0;
    text-decoration: none;
    padding: .55rem .75rem;
    border-radius: var(--radius-sm);
    font-size: .92rem;
    margin-bottom: 2px;
}
.app-sidebar nav a .icon { color: #9aa4e0; }
.app-sidebar nav a:hover { background: rgba(255,255,255,.08); color: #fff; }
.app-sidebar nav a.active { background: linear-gradient(90deg, var(--brand-500), var(--hue-purple)); color: #fff; box-shadow: 0 2px 8px rgba(59,91,219,.35); }
.app-sidebar nav a.active .icon { color: #fff; }
.app-sidebar .sidebar-section-label {
    text-transform: uppercase;
    font-size: .68rem;
    letter-spacing: .08em;
    color: #7c86c2;
    padding: .9rem .9rem .3rem;
}

/* .app-sidebar is position:fixed (out of flow), so inside the .app-shell
   flex row, .app-main is the ONLY in-flow flex item. Without an explicit
   flex-grow it only shrinks to fit its content (topbar buttons / a narrow
   card), leaving the rest of the viewport as bare canvas background --
   the "app doesn't reach the edge of the screen" bug. flex: 1 forces it to
   consume all remaining width, and min-width: 0 stops long unbreakable
   content (wide tables, etc.) from blowing the flex item back out again. */
.app-main { margin-left: 260px; min-height: 100vh; display: flex; flex-direction: column; flex: 1 1 auto; min-width: 0; width: calc(100% - 260px); }

/* ---- Platform-admin sidebar: visually distinct from a school's sidebar
   so it's never mistaken for a tenant account (item 1 / item 3). ---- */
.app-sidebar-platform { background: #0b1030; }
.app-sidebar-platform .brand { flex-wrap: wrap; }
.platform-tag {
    font-size: .62rem; text-transform: uppercase; letter-spacing: .06em;
    background: var(--brand-500); color: #fff; padding: .1rem .45rem;
    border-radius: 999px; font-weight: 700;
}

/* Small pending-count badges next to sidebar links (Admissions, Results). */
.nav-badge {
    display: inline-block; margin-left: .35rem; font-size: .7rem; font-weight: 700;
    background: var(--danger, #dc3545); color: #fff; border-radius: 999px;
    padding: .05rem .4rem; line-height: 1.3; vertical-align: middle;
}

.topbar-search {
    position: relative; display: flex; align-items: center;
}
.topbar-search .icon { position: absolute; left: .7rem; width: 1rem; height: 1rem; color: var(--ink-500); pointer-events: none; }
.topbar-search input {
    border: 1px solid var(--border); border-radius: var(--radius-md);
    background: var(--surface-muted, #f4f6f9); padding: .4rem .75rem .4rem 2rem;
    font-size: .85rem; width: 260px; max-width: 40vw;
}
.topbar-search input:focus { outline: none; border-color: var(--brand-500); background: var(--surface); }

.app-topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: .7rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 1020;
}
.app-topbar .sidebar-toggle {
    display: none;
    border: 1px solid var(--border);
    background: var(--surface);
    border-radius: var(--radius-sm);
    padding: .4rem .55rem;
}
.app-content { padding: 1.5rem; flex: 1; max-width: 1680px; width: 100%; margin: 0 auto; }

.sidebar-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(16,24,40,.45);
    z-index: 1030;
}

/* ---- Cards / surfaces -------------------------------------------------- */
.card { border: 1px solid var(--border); border-radius: var(--radius-md); box-shadow: var(--shadow-sm); }
.card .card-body { padding: 1.25rem; }
.stat-card { border-radius: var(--radius-md); border: 1px solid var(--border); background: var(--surface); padding: 1.1rem 1.25rem; }
.stat-card .stat-label { font-size: .78rem; color: var(--ink-500); text-transform: uppercase; letter-spacing: .04em; }
.stat-card .stat-value { font-size: 1.6rem; font-weight: 700; color: var(--ink-900); }
.stat-card .stat-icon {
    width: 2.4rem; height: 2.4rem;
    border-radius: var(--radius-sm);
    background: var(--brand-50);
    display: flex; align-items: center; justify-content: center;
}
.stat-card .stat-icon .icon { color: var(--brand-600); width: 1.3em; height: 1.3em; }

/* Rotating color variants for stat-card icons -- see stat_card() in
   dashboard/index.php, which cycles through these automatically so no
   individual view has to pick colors by hand. */
.stat-icon-blue   { background: #e8ecfd; } .stat-icon-blue .icon   { color: var(--hue-blue); }
.stat-icon-purple { background: #f1ebff; } .stat-icon-purple .icon { color: var(--hue-purple); }
.stat-icon-green  { background: #e3f6ee; } .stat-icon-green .icon  { color: var(--hue-green); }
.stat-icon-orange { background: #fdedde; } .stat-icon-orange .icon { color: var(--hue-orange); }
.stat-icon-pink   { background: #fbe6ee; } .stat-icon-pink .icon   { color: var(--hue-pink); }
.stat-icon-teal   { background: #e0f5f3; } .stat-icon-teal .icon   { color: var(--hue-teal); }

/* A thin colored top edge so stat cards read as distinct little modules
   rather than four identical gray boxes. */
.stat-card { position: relative; overflow: hidden; }
.stat-card::before {
    content: ''; position: absolute; top: 0; left: 0; right: 0; height: 3px;
    background: var(--brand-500);
}
.stat-card:has(.stat-icon-purple)::before { background: var(--hue-purple); }
.stat-card:has(.stat-icon-green)::before  { background: var(--hue-green); }
.stat-card:has(.stat-icon-orange)::before { background: var(--hue-orange); }
.stat-card:has(.stat-icon-pink)::before   { background: var(--hue-pink); }
.stat-card:has(.stat-icon-teal)::before   { background: var(--hue-teal); }

.alert-item {
    display: flex; align-items: flex-start; gap: .75rem;
    padding: .75rem .9rem; border-radius: var(--radius-sm);
    border: 1px solid var(--border); background: var(--ink-50);
    text-decoration: none; color: inherit; margin-bottom: .5rem;
}
.alert-item:hover { border-color: var(--brand-500); background: var(--brand-50); }
.alert-item .icon { color: var(--warning); margin-top: .1rem; }

.badge { font-weight: 600; }

/* Responsive tables: scroll horizontally on narrow screens instead of
   breaking the layout (item 6). Wrap any <table> with <div class="table-scroll"> */
.table-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-scroll table { min-width: 640px; }

.btn { border-radius: var(--radius-sm); }
.btn-primary { background: linear-gradient(135deg, var(--brand-500), var(--brand-700)); border-color: var(--brand-600); }
.btn-primary:hover { background: linear-gradient(135deg, var(--brand-600), var(--brand-900)); border-color: var(--brand-700); }
.btn-success { background: linear-gradient(135deg, #16a374, var(--hue-green)); border-color: var(--hue-green); }
.btn .icon { margin-right: .35rem; }

/* Colorful badges -- used for status pills across admissions, subscriptions,
   fee claims, etc. Purely additive utility classes; existing bg-* Bootstrap
   badges are untouched. */
.badge-blue   { background: var(--hue-blue);   color: #fff; }
.badge-purple { background: var(--hue-purple); color: #fff; }
.badge-green  { background: var(--hue-green);  color: #fff; }
.badge-orange { background: var(--hue-orange); color: #fff; }
.badge-pink   { background: var(--hue-pink);   color: #fff; }
.badge-teal   { background: var(--hue-teal);   color: #fff; }

/* ---- Mobile ------------------------------------------------------------ */
@media (max-width: 991.98px) {
    .app-sidebar { transform: translateX(-100%); }
    .app-sidebar.open { transform: translateX(0); }
    .app-main { margin-left: 0; width: 100%; }
    .app-topbar .sidebar-toggle { display: inline-flex; align-items: center; justify-content: center; }
    .sidebar-backdrop.open { display: block; }
    .app-content { padding: 1rem; }
}

@media (max-width: 575.98px) {
    .stat-card .stat-value { font-size: 1.3rem; }
    .app-topbar { padding: .6rem .85rem; }
    .card .card-body { padding: 1rem; }
    h4 { font-size: 1.15rem; }
}

/* Very small phones (older/cheap Android devices, ~320-390px wide) --
   tighten everything one more notch so forms, stat cards and buttons never
   force horizontal scrolling or clip. */
@media (max-width: 399.98px) {
    .app-content { padding: .75rem; }
    .card .card-body { padding: .85rem; }
    .stat-card { padding: .85rem 1rem; }
    .stat-card .stat-value { font-size: 1.15rem; }
    .stat-card .stat-icon { width: 2rem; height: 2rem; }
    .btn { padding: .45rem .7rem; font-size: .88rem; }
    h4 { font-size: 1.05rem; }
    .topbar-search input { width: 100%; max-width: none; }
}

/* ---- Guest / auth pages ------------------------------------------------ */
.auth-shell {
    min-height: 100vh;
    display: flex;
}
.auth-hero {
    flex: 1 1 46%;
    background: linear-gradient(160deg, var(--brand-900) 0%, var(--hue-purple) 120%);
    color: #fff;
    align-items: center;
    justify-content: center;
    padding: 4rem;
    position: relative;
    overflow: hidden;
}
.auth-hero::before {
    content: '';
    position: absolute;
    width: 640px; height: 640px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,.08);
    top: -220px; right: -220px;
}
.auth-hero::after {
    content: '';
    position: absolute;
    width: 420px; height: 420px;
    border-radius: 50%;
    border: 1px solid rgba(255,255,255,.06);
    bottom: -160px; left: -120px;
}
.auth-hero-inner { max-width: 440px; position: relative; z-index: 1; }
.auth-hero-mark { display: flex; align-items: center; gap: .5rem; font-weight: 700; font-size: 1.1rem; margin-bottom: 2.5rem; color: #fff; }
.auth-hero-mark .icon { color: var(--accent-500); width: 1.5em; height: 1.5em; }
.auth-hero-inner h1 { font-size: clamp(1.5rem, 2.6vw + .8rem, 2.1rem); font-weight: 800; line-height: 1.2; margin-bottom: 1rem; letter-spacing: -.01em; }
.auth-hero-inner p { color: rgba(255,255,255,.78); font-size: 1rem; line-height: 1.6; margin-bottom: 2rem; }
.auth-hero-list { list-style: none; padding: 0; margin: 0; display: flex; flex-direction: column; gap: .85rem; }
.auth-hero-list li { display: flex; align-items: center; gap: .65rem; font-size: .92rem; color: rgba(255,255,255,.92); }
.auth-hero-list .icon { color: var(--accent-500); flex-shrink: 0; }

.auth-panel {
    flex: 1 1 54%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--canvas);
    padding: 2rem 1.5rem;
}
.auth-card { width: 100%; max-width: 380px; background: var(--surface); border-radius: var(--radius-lg); box-shadow: var(--shadow-md); padding: 2.25rem; }
@media (max-width: 399.98px) {
    .auth-panel { padding: 1.25rem .85rem; }
    .auth-card { padding: 1.5rem 1.25rem; }
}
.auth-brand { display: flex; align-items: center; justify-content: center; gap: .5rem; margin-bottom: 1.5rem; font-weight: 700; font-size: 1.2rem; color: var(--brand-700); }
.auth-brand .icon { width: 1.6em; height: 1.6em; }

/* (The old parent-portal topbar/bottom-nav styles were removed: parents now use the same sidebar shell as every other role.) */

/* ---- Print ---------------------------------------------------------- */
@media print {
    .no-print { display: none !important; }
    body { background: #fff; padding: 0; }
}

/* Whole-row links (e.g. Lesson Plans list) */
tr.clickable-row { cursor: pointer; }
