/* ================================
   LOGIN LAYOUT
================================ */

.login-layout {
    min-height: 100vh;
    display: flex;
}

/* ================================
   LEFT PANEL (BRANDING)
================================ */

/* Fixed dark brand chrome — same tokens as the sidebar, deliberately never
   inverts to a light panel in dark mode. This used --text/--primary-bg/
   --border-color before, which are semantic text/tint/border tokens that
   flip meaning between themes; --text in particular goes from near-black
   to near-white in dark mode, which turned this into a light panel with
   near-invisible low-contrast text on top of it. */
.login-left {
    width: 42%;
    background: linear-gradient(160deg, var(--sidebar-bg-start), var(--sidebar-bg-end));
    display: flex;
    align-items: center;
    justify-content: center;
}

.brand-wrapper {
    text-align: center;
    padding: 48px;
}

.brand-logo {
    width: 140px;
    margin-bottom: 24px;
}

.brand-name {
    color: var(--sidebar-color);
    font-size: 2.2rem;
    font-weight: 600;
    margin-bottom: 10px;
}

.brand-subtitle {
    color: var(--sidebar-text-muted);
    font-size: 1rem;
    letter-spacing: 0.04em;
}

/* ================================
   RIGHT PANEL (LOGIN)
================================ */

.login-right {
    width: 58%;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-form-wrapper {
    width: 100%;
    max-width: 420px;
    padding: 48px;
}

/* ================================
   LOGIN HEADINGS
================================ */

.welcome-title {
    font-size: 2rem;
    color: var(--text);
    margin-bottom: 8px;
}

.welcome-subtitle {
    color: var(--text-muted);
    margin-bottom: 48px;
}

/* ================================
   PASSWORD TOGGLE
================================ */

.password-wrapper {
    position: relative;
}

.password-toggle {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-muted);
    transition: color 0.2s ease;
}

.password-toggle:hover {
    color: var(--text);
}

.password-toggle svg {
    width: 20px;
    height: 20px;
}

/* ================================
   DASHBOARD LAYOUT
================================ */

.dashboard-layout {
    display: flex;
    min-height: 100vh;
}

.dashboard-main {
    flex: 1;
    /* min-width:0 lets this flex item shrink below its content's intrinsic width.
       Without it a wide child (tables, grids, long nowrap rows) forces the whole
       page to scroll horizontally instead of the child scrolling in its own box. */
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* School context banner — shown when system admin is managing a specific school */
.school-context-banner {
    background: var(--primary);
    color: var(--primary-border);
    padding: 6px 24px;
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 16px;
}

.school-context-banner strong {
    color: var(--text-inverse);
}

.school-context-exit {
    margin-left: auto;
    color: var(--warning-border);
    text-decoration: none;
    font-weight: 500;
}

.school-context-exit:hover {
    text-decoration: underline;
}

/* ================================
   SIDEBAR
================================ */

.sidebar {
    width: 260px;
    flex-shrink: 0;
    background: linear-gradient(180deg, var(--primary), var(--primary));
    color: var(--primary-bg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar-header {
    padding: 20px 24px;
    font-size: 1.4rem;
    font-weight: 600;
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.sidebar-nav {
    flex: 1;
    padding: 16px 0;
    overflow-y: auto;
}

/* ================================
   NAV ITEMS
================================ */

.nav-item {
    display: block;
    padding: 10px 24px;
    color: var(--primary-bg);
    text-decoration: none;
    font-size: 0.95rem;
}

.nav-item:hover {
    background-color: rgba(255, 255, 255, 0.08);
}

.nav-item.active {
    background-color: rgba(255, 255, 255, 0.18);
    font-weight: 600;
}

.nav-item.disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

/* ================================
   NAV SECTIONS (COLLAPSIBLE)
================================ */

.nav-section {
    margin-top: 12px;
}

.sign-out-btn {
    background-color: rgba(255, 255, 255, 0.15);
    color: #ffffff;
    padding: 8px 14px;
    border-radius: 6px;

    font-size: 0.85rem;
    font-weight: 600;
    text-decoration: none;

    transition: background-color 0.15s ease;
}

.sign-out-btn:hover {
    background-color: rgba(255, 255, 255, 0.25);
}

/* ── Theme toggle button (dark / light) ─────────────────────────────────── */
.theme-toggle-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;

    background-color: rgba(255, 255, 255, 0.12);
    color: #ffffff;
    padding: 7px 12px;
    border-radius: 6px;
    border: 1px solid rgba(255, 255, 255, 0.18);

    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    line-height: 1;
    white-space: nowrap;

    transition: background-color 0.15s ease, border-color 0.15s ease;
}

.theme-toggle-btn:hover {
    background-color: rgba(255, 255, 255, 0.22);
    border-color: rgba(255, 255, 255, 0.3);
}

.theme-toggle-btn svg {
    flex-shrink: 0;
}

/* Header language switch — a form so the choice is a POST; shares the theme
   toggle's look. */
.lang-switch {
    display: inline-flex;
    align-self: stretch;
    align-items: center;
    margin: 0;
}

/* Text-only, so without this it sits shorter than the icon buttons beside it —
   the theme toggle's height comes from its 18px icon. */
.lang-switch .theme-toggle-btn {
    min-height: calc(18px + 14px + 2px);
}

/* On narrow screens hide the text label, keep just the icon */
@media (max-width: 480px) {
    .theme-toggle-label { display: none; }
    .theme-toggle-btn   { padding: 7px 8px; }
}
/* Toggle button (Teaching, School Data, Settings) */
.nav-section-toggle {
    width: 100%;
    background: none;
    border: none;
    outline: none;

    padding: 10px 24px;

    display: flex;
    justify-content: space-between;
    align-items: center;

    font-size: 0.85rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;

    color: var(--sidebar-text-muted);
    cursor: pointer;
}

.nav-section-toggle:hover {
    background-color: rgba(255, 255, 255, 0.08);
    color: var(--sidebar-color);
}

/* Title text inside toggle */
.nav-section-title-text {
    pointer-events: none;
}

/* Chevron arrow */
.nav-section-arrow {
    flex-shrink: 0;
    width: 0;
    height: 0;

    border-left: 5px solid transparent;
    border-right: 5px solid transparent;
    border-top: 6px solid currentColor;

    transition: transform 0.2s ease;
}

/* Rotate arrow when expanded */
.nav-section-toggle[aria-expanded="true"] .nav-section-arrow {
    transform: rotate(180deg);
}

/* Collapsible container */
.nav-section-items {
    display: none;
}

.nav-section-items.open {
    display: block;
}

/* Indented items inside collapsible sections */
.nav-section-items .nav-item {
    padding-left: 36px;
}

/* ================================
   TOP BAR
================================ */

.dashboard-header {
    /* Fixed brand chrome — --header-bg-* never flips in dark mode (using
       --primary/--accent here turned the band bright blue on dark). */
    background: linear-gradient(90deg, var(--header-bg-start), var(--header-bg-end));
    color: var(--text-inverse);
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.date-time {
    font-size: 0.9rem;
}

/* ================================
   MAIN CONTENT AREA
================================ */

.dashboard-content {
    padding: 24px;
    /* Pair with .dashboard-main min-width:0 so page content stays within the
       viewport; wide tables/grids should carry their own overflow-x wrapper
       (e.g. .table-responsive) and scroll inside this box, not move the page. */
    min-width: 0;
}

/* Wrap any table/element wider than the content area so it scrolls inside its
   own box instead of widening the page. Usage: <div class="table-responsive">…</div> */
.table-responsive {
    width: 100%;
    overflow-x: auto;
}

/* ================================
   HAMBURGER BUTTON
================================ */

.hamburger {
    /* Shown on every width: ≤1100px it opens the slide-in drawer; on wide screens
       it collapses/hides the sidebar so the teacher gets full-width content
       (toggle persisted in localStorage — see layout.js). */
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 5px;
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    margin-right: 12px;
}

.header-home-btn {
    display: none;
    align-items: center;
    justify-content: center;
    color: var(--text-inverse);
    padding: 6px;
    margin-right: 8px;
    border-radius: 4px;
    line-height: 0;
    text-decoration: none;
    opacity: 0.85;
}

/* Brand wordmark in the header — hidden by default; revealed when the sidebar is
   collapsed on wide screens (the min-width:1101px rule above). "Rooi" inherits this
   white colour, "Pen" stays brand red, so it reads on the blue header. */
.header-brand {
    display: none;
    align-items: center;
    color: var(--text-inverse);
    text-decoration: none;
    line-height: 0;
    margin-right: 14px;
    font-size: 0.95rem;
}

.header-home-btn:hover {
    background: rgba(255, 255, 255, 0.12);
    opacity: 1;
}

.hamburger span {
    display: block;
    width: 22px;
    height: 2px;
    background: var(--white);
    border-radius: 2px;
    transition: transform 0.2s, opacity 0.2s;
}

/* Sidebar overlay backdrop */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
    z-index: 99;
}

.sidebar-overlay.visible {
    display: block;
}

/* ================================
   WIDE-SCREEN NAV COLLAPSE (>1100px)
   Deliberate hide of the sidebar to reclaim horizontal space. The hamburger
   toggles `.nav-collapsed` on the layout; the choice is remembered per browser.
   Scoped to wide screens so it never interferes with the ≤1100px drawer.
================================ */

@media (min-width: 1101px) {
    .dashboard-layout.nav-collapsed .sidebar {
        display: none;
    }
    /* With the sidebar hidden, surface the brand wordmark in the header — it fills
       the gap the sidebar header left and doubles as the way back to the dashboard. */
    .dashboard-layout.nav-collapsed .header-brand {
        display: inline-flex;
    }
}

/* ================================
   RESPONSIVE — TABLET (≤1100px)
================================ */

@media (max-width: 1100px) {

    /* Login: stack panels */
    .login-layout {
        flex-direction: column;
    }

    .login-left {
        display: none; /* hide branding panel on small screens */
    }

    .login-right {
        width: 100%;
        min-height: 100vh;
    }

    .login-form-wrapper {
        padding: 40px 24px;
    }

    /* Sidebar becomes a slide-in drawer */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100%;
        width: 260px;
        z-index: 100;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
    }

    .sidebar.open {
        transform: translateX(0);
    }

    /* Show hamburger and home buttons */
    .hamburger {
        display: flex;
    }

    .header-home-btn {
        display: inline-flex;
    }

    /* Reduce header padding */
    .dashboard-header {
        padding: 14px 16px;
    }

    .date-time {
        display: none; /* too much text on small screens */
    }

    .dashboard-content {
        padding: 16px;
    }

    .school-context-banner {
        padding: 6px 16px;
        font-size: 0.8rem;
    }
}

/* ================================
   RESPONSIVE — MOBILE (≤480px)
================================ */

@media (max-width: 480px) {

    .dashboard-header {
        padding: 12px 12px;
    }

    .welcome-text {
        display: none;
    }

    .dashboard-content {
        padding: 12px;
    }

    .page-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 8px;
    }
}

/* ================================
   RESPONSIVE — TABLES
================================ */

@media (max-width: 768px) {

    /* Wrap tables so they scroll horizontally */
    .data-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        white-space: nowrap;
    }

    .table-toolbar {
        flex-direction: column;
        align-items: stretch;
    }

    .toolbar-count {
        margin-left: 0;
    }
}

/* ── Copyright footer ──────────────────────────────────────────────────────── */
.app-footer {
    text-align: center;
    padding: 12px;
    font-size: 0.75rem;
    color: var(--text-muted, var(--text-faint));
    border-top: 1px solid var(--border-color, var(--border));
    margin-top: auto;
}

/* ── Header left cluster (was never defined — hamburger floated above the date).
   One centred row: [☰] [home] [date], matching Sign Out's vertical centre. ── */
.header-left {
    display: flex;
    align-items: center;
    gap: 6px;
    min-width: 0;
}

.header-left .date-time { margin-left: 10px; }

/* Give the hamburger a real hit-area + hover so it reads as a control */
.hamburger {
    padding: 10px;
    border-radius: 8px;
    transition: background 0.15s;
}
.hamburger:hover { background: rgba(255, 255, 255, 0.15); }

/* ================================
   PRINTING AN IN-APP PAGE
   --------------------------------
   Every screen in the app sits inside a 240px sidebar and a header bar, and
   nothing removed them for print. Chrome lays the page out at the paper's width
   and CLIPS whatever does not fit, so the right-hand end of every wide table
   came out of the printer cut off mid-word — the moderation Faults column and
   the J1 comments, but equally any other table in the app. The data was never
   missing; the layout lost it.

   This is deliberately in layout.css rather than in one feature's stylesheet:
   the shell is what causes it, so the shell is what fixes it, once, for every
   page. Standalone print templates do not extend this layout and are untouched.
================================ */

@media print {
    /* Navigation is not paper. */
    .sidebar,
    .dashboard-header,
    .school-context-banner,
    .notification-container,
    .session-timeout-modal {
        display: none !important;
    }

    .dashboard-layout { display: block; min-height: 0; }

    .dashboard-main {
        width: 100%;
        max-width: none;
        margin: 0;
        padding: 0;
        overflow: visible;
    }

    /* A control does nothing on paper, and a half-printed button reads as a
       defect in the document. Anything a reader could not act on comes off. */
    button,
    .btn,
    input[type="file"],
    input[type="submit"],
    .page-actions form,
    .hamburger {
        display: none !important;
    }

    /* A pane that scrolls on screen must print everything it holds, not the
       first screenful of it. */
    [class$="-scroll"],
    [class*="-scroll "],
    .table-wrap,
    .table-responsive {
        overflow: visible !important;
        max-height: none !important;
    }

    /* THE TRUNCATION ITSELF. A table sized by its content is wider than the
       page; fixed layout makes the columns share the width that exists, and
       long words break instead of running off the edge. */
    .data-table {
        width: 100% !important;
        table-layout: fixed;
        font-size: 0.72rem;
    }

    .data-table th,
    .data-table td {
        padding: 4px 6px;
        overflow-wrap: anywhere;
        word-break: break-word;
        vertical-align: top;
    }

    /* A row is a fault or a learner — splitting one across two pages costs the
       reader the line they were reading. */
    .data-table tr,
    .card {
        break-inside: avoid;
        page-break-inside: avoid;
    }

    .card {
        box-shadow: none;
        border: 1px solid var(--border);
        margin-bottom: 0.6rem;
    }

    /* Severity and status colours carry meaning, so they must survive the
       printer's default of dropping backgrounds. */
    * {
        -webkit-print-color-adjust: exact;
        print-color-adjust: exact;
    }
}
