﻿/* ===================================================
   esm-student.css  --  ESM Student Portal Theme
   Same class names/structure AND same core colour
   identity as esm-theme.css (admin) -- the portal uses
   admin's blue accent palette throughout, just with its
   own Lexend/Inter type (a K-12-friendly reading-proficiency
   font pairing) instead of admin's Cabinet Grotesk/IBM Plex
   Sans. A warm coral accent (--coral/--coral-soft) is kept
   as a secondary accent for urgency/energy highlights only.
   Change ONLY the :root variables below to retheme
   the student portal independently from admin.
   =================================================== */

/* -- CSS Variables ----------------------------------- */
:root {
    /* Lexend: designed for reading proficiency -- a genuine fit for a
       K-12 student-facing surface, not just a different-looking font.
       Inter: a clean, highly legible workhorse for body copy/tables. */
    --font-heading: 'Lexend', sans-serif;
    --font-body:    'Inter', sans-serif;
    --text-2xs: 11px;
    --text-xs:  12px;
    --text-sm:  13px;
    --text-base:14px;
    --text-md:  15px;
    --text-lg:  17px;

    /* -- Brand colours -- edit these to retheme --
       Matches admin's blue accent identity exactly, with a warm
       coral kept only as a secondary accent for urgency/energy. */
    --bg:            #f5f9ff;
    --surface:       #ffffff;
    --surface-alt:   #eef5fc;
    --panel:         #ffffff;
    --border:        #d7e3f3;
    --divider:       #e3edf8;
    --accent:        #1c4a96;
    --accent-soft:   #e8f3fb;
    --accent-strong: #005a9e;
    --coral:         #f0653e;
    --coral-soft:    #fee4da;
    --text:          #1b1b1b;
    --text-soft:     #4b5664;
    --text-faint:    #6d7b8a;
    --danger:        #d13438;
    --shadow-sm:     0 1px 2px rgba(0,0,0,.06);
    --shadow-md:     0 8px 24px rgba(28,74,150,.12);
    --radius-xs:     4px;
    --radius-sm:     6px;
    --radius-md:     9px;
    --radius-lg:     14px;
}

[data-theme='dark'] {
    --bg:            #0f172a;
    --surface:       #111827;
    --surface-alt:   #172036;
    --panel:         #111827;
    --border:        #22324d;
    --divider:       #1f2d45;
    --accent:        #4aa3ff;
    --accent-soft:   rgba(74,163,255,.15);
    --accent-strong: #8cc8ff;
    --coral:         #ff8a65;
    --coral-soft:    rgba(255,138,101,.15);
    --text:          #eaf2ff;
    --text-soft:     #b6c4d6;
    --text-faint:    #7f90a8;
    --danger:        #ff6b6b;
    --shadow-sm:     0 1px 2px rgba(0,0,0,.35);
    --shadow-md:     0 10px 28px rgba(0,0,0,.42);
    color-scheme: dark;
}

/* -- Reset ------------------------------------------- */
*, *::before, *::after { box-sizing: border-box; }
html { scroll-behavior: smooth; }
img, svg { max-width: 100%; display: block; }
a { text-decoration: none; color: inherit; }

body {
    margin: 0;
    font-family: var(--font-body);
    font-size: var(--text-base);
    line-height: 1.4;
    color: var(--text);
    background: linear-gradient(180deg, #f6fbff 0%, #eef5fc 100%);
    /* Safety net against stray fixed-width elements pushing the page wider
       than the viewport on small screens -- never applied to table/scroll
       wrappers, which keep their own explicit overflow-x:auto. */
    overflow-x: hidden;
}

[data-theme='dark'] body {
    background: linear-gradient(180deg, #0b1220 0, #111827 100%);
}

/* -- App Shell (admin-style grid layout) -------------- */
.app-shell {
    display: grid;
    grid-template-columns: 220px minmax(0,1fr);
    grid-template-rows: 48px 1fr;
    min-height: 100vh;
    transition: grid-template-columns .18s ease;
}
.app-shell.is-collapsed {
    grid-template-columns: 56px minmax(0,1fr);
}
.app-shell > .topbar { grid-column: 1 / -1; grid-row: 1; }
.app-shell > .sidebar { grid-column: 1; grid-row: 2; }
.app-shell > .main    { grid-column: 2; grid-row: 2; }

/* -- Sidebar ------------------------------------------ */
.sidebar {
    position: sticky;
    top: 48px;
    height: calc(100vh - 48px);
    overflow-y: auto;
    overflow-x: hidden;
    background: linear-gradient(180deg, #f8fbff 0%, #edf5fd 100%);
    border-right: 1px solid var(--border);
    padding: 8px 8px 10px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    transition: padding .18s ease;
    z-index: 10020;
}
[data-theme='dark'] .sidebar {
    background: linear-gradient(180deg, #0f172a 0, #111827 100%);
}
.app-shell.is-collapsed .sidebar { padding-inline: 4px; }

.nav-scroll { flex: 1; overflow: hidden; }

/* -- Nav labels --------------------------------------- */
.nav-label {
    margin: 6px 4px 2px;
    font-size: var(--text-2xs);
    letter-spacing: .14em;
    text-transform: uppercase;
    color: var(--text-faint);
}
.app-shell.is-collapsed .nav-label { display: none; }

/* -- Nav list / items --------------------------------- */
.nav-list {
    list-style: none;
    padding: 0; margin: 0;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

svg.nav-icon {
    width: 15px !important; height: 15px !important;
    min-width: 15px !important; max-width: 15px !important;
    flex: 0 0 15px !important;
    display: inline-block; vertical-align: middle;
}

.nav-item a {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 8px;
    border-radius: var(--radius-sm);
    font-size: var(--text-sm);
    color: var(--text-soft);
    text-decoration: none;
    transition: background .12s, color .12s;
    white-space: nowrap;
    overflow: hidden;
}
.nav-item a span { min-width: 0; overflow: hidden; text-overflow: ellipsis; }
.nav-item:not(.is-active) a:hover {
    background: rgba(28,74,150,.08);
    color: var(--text);
}
.nav-item.is-active a {
    background: linear-gradient(90deg, rgba(28,74,150,.16), rgba(28,74,150,.05));
    color: var(--accent-strong);
    font-weight: 600;
    border-left: 3px solid var(--accent);
    padding-left: 5px;
}
[data-theme='dark'] .nav-item.is-active a {
    background: linear-gradient(90deg, rgba(74,163,255,.2), rgba(74,163,255,.06));
}

/* Collapsed: hide text labels */
.app-shell.is-collapsed .nav-item a span { display: none; }
.app-shell.is-collapsed .nav-item a {
    justify-content: center;
    padding: 8px 0;
    border-left: none !important;
}
.app-shell.is-collapsed .nav-item.is-active a {
    background: rgba(28,74,150,.15);
    border-radius: var(--radius-sm);
}

/* -- Nav footer --------------------------------------- */
.nav-footer {
    border-top: 1px solid var(--border);
    padding-top: 8px;
    margin-top: auto;
}
.nav-meta {
    font-size: var(--text-2xs);
    color: var(--text-faint);
    padding: 2px 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.app-shell.is-collapsed .nav-footer { display: none; }

/* -- Topbar ------------------------------------------- */
.topbar {
    position: sticky;
    top: 0;
    z-index: 10030;
    height: 48px;
    display: flex;
    align-items: center;
    background: var(--accent);
    box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
[data-theme='dark'] .topbar { background: #001233; }

.top-left {
    display: flex;
    align-items: center;
    height: 100%;
    gap: 0;
    flex-shrink: 0;
}

/* Hamburger */
.az-hamburger {
    width: 44px; height: 48px;
    border: none; background: transparent;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    color: rgba(255,255,255,.85);
    flex-shrink: 0;
}
.az-hamburger:hover { background: rgba(255,255,255,.12); color: #fff; }
.az-hamburger svg { width: 18px; height: 18px; }

/* Logo */
.az-logo {
    display: flex;
    align-items: center;
    gap: 7px;
    padding: 0 14px 0 4px;
    color: #fff;
    font-family: var(--font-heading);
    font-size: 13px;
    font-weight: 700;
    letter-spacing: .02em;
    white-space: nowrap;
    height: 100%;
    text-decoration: none;
}
.az-logo svg { flex-shrink: 0; }

.top-middle { flex: 1; display: flex; align-items: center; min-width: 0; overflow: hidden; }
.top-greeting {
    font-family: var(--font-heading);
    font-size: 13px;
    font-weight: 600;
    color: rgba(255,255,255,.95);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.top-greeting-date {
    margin-left: 8px;
    font-family: var(--font-body);
    font-size: 11px;
    font-weight: 400;
    color: rgba(255,255,255,.65);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
}
/* .top-greeting already shrinks/ellipsizes, but had no basis for HOW much
   space to concede — at narrow widths the unconstrained date pushed the
   whole page ~63px wider than the viewport. flex-shrink:0 here + shrink:1
   on the greeting lets the date keep its natural width as long as there's
   room, then both truncate together instead of overflowing the page. */
.top-greeting { flex-shrink: 1; min-width: 40px; }
/* The date/greeting were never the main overflow source: the topbar's real
   fixed-width content is 44px hamburger + logo + 5×40px icon buttons +
   avatar = ~437px, wider than a 375px viewport regardless of the greeting.
   Shrink the logo to icon-only and narrow the icon buttons below 480px so
   the fixed content actually fits, instead of just hiding the date. */
@media (max-width: 480px) {
    .top-greeting-date { display: none; }
    .az-logo-text { display: none; }
    .icon-btn { width: 32px; }
}

.top-right {
    display: flex;
    align-items: center;
    height: 100%;
    flex-shrink: 0;
}

/* Topbar icon button */
.icon-btn {
    width: 40px; height: 48px;
    border: none; background: transparent;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer;
    color: rgba(255,255,255,.85);
    position: relative;
    flex-shrink: 0;
}
.icon-btn:hover { background: rgba(255,255,255,.12); color: #fff; }
.icon-btn svg { width: 16px; height: 16px; }

/* -- Topbar popup panels ------------------------------ */
.topbar-feedback-wrap { position: relative; }

.feedback-badge {
    position: absolute;
    top: 7px; right: 6px;
    min-width: 14px; height: 14px;
    padding: 0 3px;
    border-radius: 999px;
    background: #ff6b35;
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    line-height: 14px;
    text-align: center;
}

.feedback-panel {
    position: absolute;
    right: 0; top: calc(100% + 6px);
    width: 280px;
    background: var(--panel);
    border: 1px solid var(--border);
    border-radius: 10px;
    /* var(--shadow-md) alone is too subtle here -- --panel and the page
       background are the same white/near-black, so a popover sitting
       directly over a same-colored card (dashboard tiles etc.) reads as
       part of the page instead of floating above it. A closer, darker
       shadow is what actually reads as "elevated" regardless of what's
       behind it. */
    box-shadow: 0 14px 34px rgba(0,0,0,.22), 0 2px 8px rgba(0,0,0,.10);
    padding: 4px;
    display: none;
    z-index: 9999;
}
/* right:0 is a physical property -- dir="rtl" does not auto-flip it the
   way it flips flexbox main-axis order. The topbar's icon row DOES
   auto-mirror under RTL (each wrap's on-screen position moves), but the
   panel still anchored to its own wrap's right edge, so on a desktop-width
   RTL page the panel's left edge went ~90px off-screen for icons that
   ended up near the viewport's left edge after mirroring (confirmed live:
   panel rect.x -87px). Anchor to the wrap's left edge instead so it tracks
   the mirrored position correctly regardless of viewport width. */
[dir="rtl"] .feedback-panel {
    right: auto;
    left: 0;
}
[data-theme='dark'] .feedback-panel {
    /* Shadow barely registers in dark mode -- --bg (#0f172a) and --panel
       (#111827) are nearly the same near-black navy, so a dark shadow on
       an already-dark page adds almost no visible contrast (unlike light
       mode, where a dark shadow on a white page reads clearly). What
       actually separates a floating panel from the page in a dark UI is a
       visibly lighter surface + a bright hairline edge, not the shadow. */
    background: var(--surface-alt);
    border-color: rgba(255,255,255,.14);
    box-shadow: 0 16px 40px rgba(0,0,0,.6), 0 0 0 1px rgba(255,255,255,.05);
}
.topbar-feedback-wrap.is-open .feedback-panel { display: block; }

.feedback-panel-head {
    display: flex; align-items: center; justify-content: space-between;
    gap: 8px;
    font-size: 10px; font-weight: 700; color: var(--text-faint);
    text-transform: uppercase; letter-spacing: .05em;
    padding: 6px 8px 5px;
    border-bottom: 1px solid var(--divider);
}
.feedback-panel-head a {
    font-size: var(--text-2xs); text-transform: none;
    letter-spacing: 0; font-weight: 600;
    color: var(--accent);
}
.feedback-panel-head a:hover { text-decoration: underline; }

.feedback-list {
    display: flex; flex-direction: column;
    max-height: 260px;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: var(--border) transparent;
}

/* -- User chip / menu --------------------------------- */
.user-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0 12px;
    height: 48px;
    cursor: pointer;
    color: #fff;
    position: relative;
    white-space: nowrap;
    border-left: 1px solid rgba(255,255,255,.18);
    margin-left: 2px;
}
.user-chip:hover { background: rgba(255,255,255,.1); }

.user-avatar {
    width: 28px; height: 28px;
    border-radius: 50%;
    background: rgba(255,255,255,.22);
    display: grid;
    place-items: center;
    font-family: var(--font-heading);
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    flex-shrink: 0;
    border: 1.5px solid rgba(255,255,255,.4);
}

.user-name {
    font-size: var(--text-xs);
    color: rgba(255,255,255,.9);
    max-width: 110px;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* User dropdown panel */
.admin-menu-panel {
    position: absolute;
    right: 0; top: calc(100% + 6px);
    width: 180px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    box-shadow: var(--shadow-md);
    padding: 4px;
    display: none;
    z-index: 9999;
}
.user-chip.is-open .admin-menu-panel { display: block; }

.admin-menu-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 7px 10px;
    font-size: var(--text-sm);
    color: var(--text-soft);
    border-radius: var(--radius-sm);
    text-decoration: none;
    transition: background .1s, color .1s;
}
.admin-menu-item:hover { background: var(--surface-alt); color: var(--text); }
.admin-menu-item svg { width: 13px; height: 13px; flex-shrink: 0; }
.admin-menu-divider { border: none; border-top: 1px solid var(--divider); margin: 3px 0; }

/* -- Main content area -------------------------------- */
.main {
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.content-scroll {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

/* Footer */
.st-footer {
    text-align: center;
    padding: 12px 20px;
    font-size: var(--text-xs);
    color: var(--text-faint);
    border-top: 1px solid var(--divider);
    background: var(--surface);
}
.st-footer a { color: var(--accent); }

/* -- Responsive --------------------------------------- */
@media (max-width: 900px) {
    /* Must match .app-shell.is-collapsed's specificity (0,2,0), not just
       .app-shell (0,1,0) -- the desktop collapsed-rail rule above otherwise
       always wins regardless of viewport, since equal-or-lower specificity
       loses even when this block comes later in the file. The server
       always renders is-collapsed on first paint (see main.master), so
       without this the "collapsed" 56px icon rail -- not the intended
       hidden/off-canvas drawer -- was the permanent mobile default. */
    .app-shell.is-collapsed {
        grid-template-columns: 0 minmax(0,1fr);
    }
    .app-shell.force-open {
        grid-template-columns: 220px minmax(0,1fr);
    }
    .app-shell.force-open > .sidebar {
        position: fixed;
        left: 0; top: 48px;
        width: 220px;
        z-index: 10025;
        box-shadow: 4px 0 20px rgba(0,0,0,.18);
    }
    .app-shell.force-open::before {
        content: '';
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,.3);
        z-index: 10024;
    }
    .user-name { display: none; }
}


/* -- Panels ------------------------------------------- */
.panel {
    background: var(--panel);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    padding: 8px 9px;
}

[data-theme='dark'] .panel { background: var(--surface); border-color: var(--border); }

.panel-success {
    background: #f0fdf4; border: 1px solid #86efac;
    border-radius: var(--radius-sm); color: #166534;
    padding: 10px 14px; font-size: var(--text-sm); margin-bottom: 14px;
}
.panel-danger {
    background: #fef2f2; border: 1px solid #fca5a5;
    border-radius: var(--radius-sm); color: #991b1b;
    padding: 10px 14px; font-size: var(--text-sm); margin-bottom: 14px;
}
.panel-info {
    background: var(--accent-soft); border: 1px solid rgba(28,74,150,.25);
    border-radius: var(--radius-sm); color: var(--accent-strong);
    padding: 10px 14px; font-size: var(--text-sm); margin-bottom: 14px;
}
.panel-warning {
    background: #fffbeb; border: 1px solid #fcd34d;
    border-radius: var(--radius-sm); color: #92400e;
    padding: 10px 14px; font-size: var(--text-sm); margin-bottom: 14px;
}
.panel-danger:empty,.panel-info:empty,
.panel-warning:empty,.panel-success:empty { display: none !important; }

[data-theme='dark'] .panel-danger  { background: rgba(239,68,68,.12); border-color: rgba(239,68,68,.3);  color: #f87171; }
[data-theme='dark'] .panel-info    { background: rgba(74,163,255,.1);  border-color: rgba(74,163,255,.2); color: var(--accent); }
[data-theme='dark'] .panel-warning { background: rgba(245,158,11,.12); border-color: rgba(245,158,11,.3); color: #fbbf24; }

/* -- Tables ------------------------------------------- */
.table-wrap {
    margin-top: 6px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--divider);
    overflow: hidden;
    background: var(--surface);
}

[data-theme='dark'] .table-wrap { background: var(--surface); border-color: var(--border); }

table {
    width: 100%;
    border-collapse: collapse;
    font-size: var(--text-xs);
}

thead { background: var(--surface-alt); }

th, td {
    padding: 8px 10px;
    border-bottom: 1px solid var(--divider);
    text-align: left;
}

th {
    font-weight: 600;
    color: var(--text-soft);
    font-size: var(--text-2xs);
    text-transform: uppercase;
    letter-spacing: .08em;
    white-space: nowrap;
}

tbody tr:hover { background: rgba(28,74,150,.05); }
tbody tr:last-child td { border-bottom: none; }

[data-theme='dark'] th, [data-theme='dark'] td { border-color: var(--divider); color: var(--text); }

/* -- Legacy layout helper classes ---------------------
   .box / .har / .hide are referenced across several older
   WebForms pages (holiday.aspx, submitAsgn.aspx, tutpage.aspx,
   view-asign.aspx, im-inbox.aspx, alerts.aspx, notices.aspx,
   updates.aspx, exam.aspx, library.aspx, addCalEvent.aspx,
   editCalEvent.aspx, tutpage.aspx) but their definitions lived
   only in the old default.css, which main.master stopped
   linking once esm-student.css/-forms.css took over. That left
   these classes with no effect at all: unstyled content panels,
   left-aligned "right aligned" icon cells, and headings meant to
   stay hidden showing up as visible, redundant text. Re-declared
   here, theme-aware, so every page using them gets its intended
   layout back automatically. -------------------------- */
.box {
    border: 1px solid var(--divider);
    background: var(--surface);
    padding: 10px;
    border-radius: var(--radius-sm);
}

.har {
    text-align: right;
}

.hide {
    display: none;
}

/* -- Shared page header ------------------------------- */
.dash-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 18px;
    gap: 12px;
    flex-wrap: wrap;
}

.dash-title {
    margin: 0;
    font-family: var(--font-heading);
    font-size: 20px;
    font-weight: 700;
    color: var(--text);
}

.dash-sub {
    margin: 2px 0 0;
    font-size: var(--text-xs);
    color: var(--text-faint);
}

.dash-header-actions {
    display: flex;
    gap: 8px;
    align-items: center;
}

.dash-page-icon {
    width: 36px; height: 36px;
    border-radius: var(--radius-sm);
    background: var(--accent-soft);
    display: grid;
    place-items: center;
    color: var(--accent);
    flex-shrink: 0;
}
.dash-page-icon svg { width: 18px; height: 18px; }

.dash-title-block {
    display: flex;
    align-items: center;
    gap: 10px;
}

/* -- Status pills ------------------------------------- */
.status-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: var(--text-2xs);
    border: 1px solid var(--divider);
    color: var(--text-soft);
}

/* -- Metrics ------------------------------------------ */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(4, minmax(0,1fr));
    gap: 6px;
    margin-top: 4px;
}

.metric {
    padding: 12px 14px;
    border-radius: var(--radius-sm);
    background: var(--surface);
    border: 1px solid var(--divider);
}

.metric-label {
    font-size: var(--text-2xs);
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: .09em;
    margin-bottom: 4px;
}

.metric-value {
    font-size: var(--text-lg);
    font-weight: 700;
    color: var(--text);
}

.metric-sub {
    font-size: var(--text-2xs);
    color: var(--text-soft);
    margin-top: 2px;
}

/* -- Dashboard hero / stat cards ---------------------- */
.hero-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px,1fr));
    gap: 14px;
    margin-bottom: 20px;
}

.stat-card {
    display: flex;
    gap: 14px;
    padding: 18px 16px;
    background: var(--panel);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    transition: transform .18s, box-shadow .18s;
    cursor: pointer;
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(28,74,150,.14);
}

.stat-icon { font-size: 28px; }
.stat-label { font-size: var(--text-xs); color: var(--text-faint); margin-bottom: 4px; }
.stat-value { font-size: var(--text-lg); font-weight: 700; }

/* -- Mini list ---------------------------------------- */
.mini-list {
    display: flex;
    flex-direction: column;
    gap: 3px;
    font-size: var(--text-xs);
}

.mini-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    padding: 4px 0;
    border-bottom: 1px dashed var(--divider);
    color: var(--text-soft);
}
.mini-row:last-child { border-bottom: none; }

/* -- Notice / dropdown list items --------------------- */
.dlist { list-style: none; padding: 0; margin: 0; }
.dlist li { border-bottom: 1px solid var(--divider); }
.dlist li:last-child { border-bottom: none; }
.dlist a {
    display: block;
    padding: 8px 14px;
    font-size: var(--text-xs);
    color: var(--text-soft);
    transition: background .1s;
}
.dlist a:hover { background: var(--surface-alt); color: var(--text); }
.dlist span { font-size: 10px; color: var(--text-faint); display: block; margin-top: 1px; }
.dlist a.unread { color: var(--text); font-weight: 700; position: relative; padding-left: 22px; }
.dlist a.unread::before { content: ""; position: absolute; left: 10px; top: 15px; width: 6px; height: 6px; border-radius: 50%; background: var(--accent); }

/* -- My Courses cards (dashboard) ----------------------
   Card-grid layout: each course gets its own tile with a
   subject-colored progress ring for the current grade,
   course name + teacher, and a footer row with an
   attendance pill (reuses the .grade-badge/g-hi/g-ok/
   g-warn/g-low/g-na classes + banding already defined for
   the Recent Grades panel in default.aspx) and a schedule
   icon-button link. cc-blue/green/amber/purple/coral cycle
   the same accent families already used by the KPI cards. */
.course-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 12px;
    padding: 14px;
}
.course-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 14px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: transform .15s ease, box-shadow .15s ease, border-color .15s ease;
}
.course-card:hover {
    transform: translateY(-3px);
    box-shadow: var(--shadow-md);
    border-color: var(--ring-color, var(--accent));
}
.course-card-head { display: flex; align-items: center; gap: 12px; }

/* Progress ring — conic-gradient donut showing the current grade %,
   colored by the card's subject accent (--ring-color, set per cc-*). */
.course-ring {
    --pct: 0;
    position: relative;
    width: 52px; height: 52px;
    border-radius: 50%;
    flex-shrink: 0;
    display: grid; place-items: center;
    background: conic-gradient(var(--ring-color, var(--accent)) calc(var(--pct) * 1%), var(--divider) 0);
}
.course-ring::before {
    content: '';
    position: absolute; inset: 5px;
    border-radius: 50%;
    background: var(--surface);
}
.course-ring span {
    position: relative;
    font-family: var(--font-heading);
    font-size: 12px;
    font-weight: 700;
    color: var(--text);
}

.course-card-info { min-width: 0; }
.course-card-info .course-name {
    font-size: var(--text-sm);
    font-weight: 700;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.course-card-info .course-teacher {
    font-size: var(--text-2xs);
    color: var(--text-faint);
    margin-top: 2px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Meta rows — weekly schedule + next test/exam, shown between the card
   header and footer only when that data actually exists for a course. */
.course-card-meta {
    display: flex;
    flex-direction: column;
    gap: 4px;
    font-size: var(--text-2xs);
    color: var(--text-soft);
}
.course-meta-row { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.course-meta-label {
    display: inline-block;
    min-width: 58px;
    font-weight: 600;
    color: var(--text-faint);
    text-transform: uppercase;
    letter-spacing: .04em;
    font-size: 9px;
    margin-right: 4px;
}
.course-meta-test .course-meta-label { color: var(--accent-strong); }
.course-meta-exam .course-meta-label { color: var(--coral); }

.course-card-foot {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    border-top: 1px solid var(--divider);
    padding-top: 10px;
}
.course-sched-btn {
    display: grid;
    place-items: center;
    width: 28px;
    height: 28px;
    border-radius: var(--radius-sm);
    background: var(--accent-soft);
    flex-shrink: 0;
    transition: background .12s;
}
.course-sched-btn:hover { background: var(--divider); }
.course-sched-btn img { width: 14px; height: 14px; }

/* Subject accent palette — cycles the same green/amber/purple/coral
   families the KPI cards + grade badges already use elsewhere. */
.course-card.cc-blue   { --ring-color: var(--accent-strong); }
.course-card.cc-green  { --ring-color: #059669; }
.course-card.cc-amber  { --ring-color: #d97706; }
.course-card.cc-purple { --ring-color: #7c3aed; }
.course-card.cc-coral  { --ring-color: var(--coral); }

/* -- Metrics responsive ------------------------------- */
@media (max-width: 900px) {
    .metrics-grid { grid-template-columns: repeat(2, minmax(0,1fr)); }
}

/* -- Sidebar tooltips (collapsed state) --------------- */
.nav-tooltip {
    position: fixed;
    background: #1e293b;
    color: #f1f5f9;
    font-size: 11px;
    font-weight: 500;
    padding: 5px 10px;
    border-radius: 5px;
    white-space: nowrap;
    pointer-events: none;
    z-index: 99999;
    opacity: 0;
    transform: translateX(-4px);
    transition: opacity .12s ease, transform .12s ease;
    box-shadow: 0 4px 12px rgba(0,0,0,.25);
}
.nav-tooltip::before {
    content: '';
    position: absolute;
    left: -4px;
    top: 50%;
    transform: translateY(-50%);
    border: 4px solid transparent;
    border-right-color: #1e293b;
    border-left: none;
}
.nav-tooltip.is-visible {
    opacity: 1;
    transform: translateX(0);
}
[data-theme='dark'] .nav-tooltip { background: #334155; }
[data-theme='dark'] .nav-tooltip::before { border-right-color: #334155; }

/* -- Admin-style page layout --------------------------- */
/* Was capped at max-width:1400px unconditionally, so on any laptop/desktop
   viewport wide enough that the sidebar+main area exceeds that (common once
   the sidebar collapses to its 56px icon rail), the page content stopped
   growing while .main kept its full width -- leaving a dead strip of bare
   background down the right edge instead of the content actually filling
   the space. Just fill .main's width; individual grids (kpi-row, dash-grid,
   etc.) already use their own responsive column tracks, so there's no need
   for an outer cap here. */
.page-wrap { padding: 16px 18px 28px; }

.page-header {
    display: flex; align-items: center; gap: 12px;
    margin-bottom: 18px; flex-wrap: wrap;
}
.page-icon {
    width: 38px; height: 38px;
    border-radius: var(--radius-sm);
    background: var(--accent-soft);
    display: grid; place-items: center;
    color: var(--accent); flex-shrink: 0;
}
.page-icon svg { width: 18px; height: 18px; }
.page-title { margin: 0; font-family: var(--font-heading); font-size: 19px; font-weight: 700; color: var(--text); }
.page-sub { margin: 2px 0 0; font-size: var(--text-xs); color: var(--text-faint); }

/* -- Global print safety net --------------------------
   Same fix applied to esm-theme.css (admin) -- mirrored here
   because the student portal is a separate stylesheet with
   its own .app-shell/.sidebar/.topbar/.content-scroll grid.

   .app-shell is `display:grid` with .sidebar/.topbar/.main as
   grid siblings, and .content-scroll inside .main is a flexed,
   `overflow-y:auto` pane sized to fill the viewport. None of
   that is print-safe: a page's own @media print block hiding
   just .sidebar/.topbar isn't enough -- with the grid still
   active, hidden grid items still occupy their track, and
   .content-scroll stays clipped to viewport height so only
   the on-screen scroll position of the content prints (this
   is what made rcard.aspx's report-card table look "hidden"
   in print -- everything past one screen-height of the page
   was silently cut off, not just visually smaller). Fixed
   globally here instead of relying on every student page to
   repeat the reset in its own inline <style>. */
@media print {
    .app-shell {
        display: block !important;
        min-height: 0 !important;
    }

    .sidebar,
    .topbar {
        display: none !important;
    }

    .main {
        display: block !important;
    }

    .content-scroll {
        overflow: visible !important;
        height: auto !important;
        max-height: none !important;
        padding: 0 !important;
    }

    /* Force light-theme colours regardless of the on-screen theme. Printing
       a dark UI wastes ink and is hard to read on paper — [data-theme='dark']
       otherwise persists straight into the print output since it's a JS-set
       attribute, not a media feature, and browsers don't clear it for print. */
    :root, [data-theme='dark'] {
        --bg: #ffffff !important;
        --surface: #ffffff !important;
        --surface-alt: #f5f7fa !important;
        --panel: #ffffff !important;
        --border: #d0d5dd !important;
        --divider: #e4e7ec !important;
        --text: #101828 !important;
        --text-soft: #344054 !important;
        --text-faint: #667085 !important;
        --shadow-sm: none !important;
        --shadow-md: none !important;
    }
    body { background: #ffffff !important; }

    /* Browsers strip background colours/gradients from print output by
       default to save ink — but on this portal, colour is how course-card
       rings, grade/attendance badges, and event dots CONVEY MEANING (a
       score band, a present/absent status), not just decoration. Losing it
       would make those elements print unreadable rather than just plain.
       print-color-adjust:exact keeps that information on paper. */
    .course-ring, .grade-badge, .kpi-icon, .today-period, .event-dot,
    .course-sched-btn, td.cal-p, td.cal-a, td.cal-h, td.cal-t, td.cal-l, td.cal-e,
    .cal-p-chip, .cal-a-chip, .p-chip, .a-chip, .h-chip, .t-chip, .l-chip, .e-chip,
    .gt-badge-yes, .gt-badge-no {
        print-color-adjust: exact !important;
        -webkit-print-color-adjust: exact !important;
    }

    /* Interactive-only chrome that means nothing on paper. */
    .course-sched-btn, .btn, button, .kpi-card:hover, a[href="schedule.aspx"] .course-sched-btn,
    .page-actions, .d-panel-head a, .nav-footer {
        box-shadow: none !important;
    }
}
.page-actions { margin-left: auto; display: flex; gap: 8px; align-items: center; }

/* -- Mobile card-reflow for data tables ---------------
   Classic ASP.NET GridView rendering has no <thead>/<tbody> -- the header
   is just the table's first <tr>, made of <th> cells, with data rows after
   it. esm-student-shell.js's enableMobileTableCards() detects that first
   row, copies each <th>'s text into a data-label attribute on the matching
   column's <td> in every data row, and marks the table
   .mobile-cards-ready -- this CSS then does the actual reflow: hide the
   header row, turn every remaining row into a card, and prefix each cell
   with its column label (via the data-label the JS just set) instead of
   relying on a column position that no longer exists once cells stack.
   Runs on every table.table / table.rc-table found on any student page
   automatically -- no per-page markup changes needed, and no dependency on
   a .gt-panel wrapper (some pages, e.g. notices.aspx, build a plain
   hand-written <table class="table"> inside a .panel instead of a
   GridView inside .gt-panel -- this still needs the same treatment).
   !important is used deliberately here, not out of laziness: at least a
   dozen pages redeclare .gt-panel/.gt-panel table locally (their own
   inline <style>, since .gt-panel has no single global source of truth --
   see the earlier per-page duplication this session kept re-discovering).
   Those local rules can land before or after this shared stylesheet in the
   rendered <head> depending on each page's own markup, so equal-specificity
   cascade order isn't reliable here -- this must win regardless. */
@media (max-width: 640px) {
    /* Selectors key off the .mobile-cards-ready marker class alone (not
       also table.table/table.rc-table/etc) -- JS already decides which
       tables qualify (see enableMobileTableCards in esm-student-shell.js),
       so the marker class is sufficient and doesn't need updating here
       every time a new page's table class gets added to that JS selector.
       The header row is marked explicitly by JS too (.mobile-card-header-row),
       not matched via :first-child -- a table with separate <thead>/<tbody>
       sections (hand-written tables like notices.aspx) has TWO rows that
       independently satisfy :first-child, one per section, which hid a
       real data row along with the header. */
    table.mobile-cards-ready tr.mobile-card-header-row {
        display: none !important;
    }
    table.mobile-cards-ready,
    table.mobile-cards-ready tr,
    table.mobile-cards-ready td {
        display: block !important;
        width: 100% !important;
    }
    table.mobile-cards-ready tr:not(.mobile-card-header-row) {
        padding: 10px 12px !important;
        border-bottom: 1px solid var(--divider);
    }
    table.mobile-cards-ready tr:not(.mobile-card-header-row):last-child {
        border-bottom: none;
    }
    table.mobile-cards-ready td {
        display: flex !important;
        justify-content: space-between;
        align-items: center;
        gap: 10px;
        text-align: right !important;
        border-bottom: none !important;
        padding: 4px 0 !important;
    }
    table.mobile-cards-ready td[data-label]::before {
        content: attr(data-label);
        font-weight: 600;
        color: var(--text-faint);
        font-size: var(--text-2xs);
        text-transform: uppercase;
        letter-spacing: .04em;
        text-align: left;
        flex-shrink: 0;
    }

    /* GridView pager rows (.mobile-card-pager-row, marked by JS) wrap
       their own nested <table> of page-number links -- the broad
       table.mobile-cards-ready tr/td selectors above are bare descendant
       selectors, so they reach through into that nested table too and
       block-ify its cells, stacking "1 2 3" vertically instead of
       leaving them in a row. Restore normal table layout for the whole
       pager subtree. */
    table.mobile-cards-ready tr.mobile-card-pager-row > td {
        display: block !important;
        text-align: left !important;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    table.mobile-cards-ready tr.mobile-card-pager-row td tr {
        display: table-row !important;
    }
    table.mobile-cards-ready tr.mobile-card-pager-row td td {
        display: table-cell !important;
        width: auto !important;
        text-align: center !important;
        padding: 4px 8px !important;
    }

    /* Topbar icon popups (alerts/notices/updates/messages) are positioned
       "right:0" relative to their OWN wrap div (.feedback-panel, fixed
       280px wide) -- fine on desktop where the icon cluster sits near the
       topbar's right edge with room to spare, but on a narrow viewport
       the leftmost icons (alerts) don't have 280px of room to their left,
       so the panel's left edge goes negative and the panel is partly
       off-screen. Anchor to the viewport instead of the triggering icon
       so it's correct regardless of which icon opened it. */
    .feedback-panel {
        position: fixed;
        top: 52px;
        left: 12px;
        right: 12px;
        width: auto;
        max-height: calc(100vh - 72px);
        overflow-y: auto;
    }

    /* A stronger shadow alone still isn't enough separation on a small
       screen where the panel sits directly over page content of the same
       color (e.g. a white dashboard card behind a white panel). Dim the
       page behind it, same pattern as the sidebar drawer's own backdrop
       (.app-shell.force-open::before) -- it's the one thing that reads as
       "floating above" regardless of what's underneath. Below the topbar's
       own z-index (10030) so the icons stay usable to switch popups. */
    .topbar-feedback-wrap.is-open::before {
        content: '';
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,.35);
        z-index: 9998;
    }
}

/* -- RTL (Arabic) ---------------------------------------
   Additive [dir="rtl"] overrides, not a parallel stylesheet or a
   logical-properties rewrite -- see the multilingual plan for why.
   main.master emits dir="<%=langdir%>" on <html>, resolved at login
   from the student's/school's configured language (ar-SA is the
   only RTL language in this round).

   The app-shell is CSS Grid with .sidebar pinned to grid-column:1 --
   dir="rtl" auto-mirrors that to the visual right for free, so most
   of the shell needs no explicit rule here. What's listed below is
   only the PHYSICAL-property cases (border-left/right, margin-left/
   right, text-align, position:fixed left/right, hardcoded transform
   offsets) that don't auto-flip with the grid. */

[dir="rtl"] .sidebar {
    border-right: none;
    border-left: 1px solid var(--border);
}
[dir="rtl"] .nav-item.is-active a {
    border-left: none;
    border-right: 3px solid var(--accent);
    padding-left: 0;
    padding-right: 5px;
}
[dir="rtl"] .top-greeting-date {
    margin-left: 0;
    margin-right: 8px;
}
[dir="rtl"] .user-chip {
    border-left: none;
    border-right: 1px solid rgba(255,255,255,.18);
    margin-left: 0;
    margin-right: 2px;
}
[dir="rtl"] .course-meta-label {
    margin-right: 0;
    margin-left: 4px;
}
[dir="rtl"] .page-actions {
    margin-left: 0;
    margin-right: auto;
}
/* Base table text alignment -- GridView output and hand-written
   tables alike. Numeric/date-heavy columns are a per-page judgment
   call, not blanket-flipped here; revisit if a specific report page
   reads oddly with plain text-align mirroring. */
[dir="rtl"] th, [dir="rtl"] td {
    text-align: right;
}
/* Collapsed-sidebar hover tooltip: the arrow triangle is a fixed
   physical shape (border-right-color creates a leftward-pointing
   arrow) -- flip which side has the colored border so the arrow
   points the other way. The tooltip's own left/top position is
   computed in JS (esm-student-shell.js's showTip) and is already
   RTL-aware there. */
[dir="rtl"] .nav-tooltip::before {
    left: auto;
    right: -4px;
    border-right-color: transparent;
    border-left-color: #1e293b;
}
[data-theme='dark'][dir="rtl"] .nav-tooltip::before {
    border-left-color: #334155;
}

@media (max-width: 900px) {
    /* Off-canvas drawer: position:fixed + left:0 (not a transform),
       so under RTL it needs to anchor to the opposite edge outright
       rather than flip a translateX direction. */
    [dir="rtl"] .app-shell.force-open > .sidebar {
        left: auto;
        right: 0;
        box-shadow: -4px 0 20px rgba(0,0,0,.18);
    }
}

@media (max-width: 640px) {
    /* Mobile card-reflow: justify-content:space-between on a flex row
       auto-reverses its main axis under RTL (label ends up on the
       right, value on the left) -- but the value's own text-align and
       the label::before's text-align are physical properties that
       don't follow that reversal automatically, so they need an
       explicit swap to match. */
    [dir="rtl"] table.mobile-cards-ready td {
        text-align: left !important;
    }
    [dir="rtl"] table.mobile-cards-ready td[data-label]::before {
        text-align: right;
    }
}

