﻿:root {
    --brand-primary: #4338CA;
    --brand-primary-dark: #3730A3;
    --brand-accent: #0D9488;
    --surface: #F8FAFC;
    --card-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --card-shadow-hover: 0 10px 24px rgba(15,23,42,0.10), 0 2px 6px rgba(15,23,42,0.06);
    --radius-lg: 14px;

    /* Validated categorical palette (fixed order - do not reorder/cycle arbitrarily).
       Used to color-code groups (batches, joining years, etc.) consistently app-wide. */
    --cat-1: #2a78d6; --cat-1-soft: #eaf2fc; /* blue */
    --cat-2: #008300; --cat-2-soft: #e6f3e6; /* green */
    --cat-3: #e87ba4; --cat-3-soft: #fceef3; /* magenta */
    --cat-4: #eda100; --cat-4-soft: #fdf3e0; /* yellow */
    --cat-5: #1baf7a; --cat-5-soft: #e6f7f0; /* aqua */
    --cat-6: #eb6834; --cat-6-soft: #fdeee7; /* orange */
    --cat-7: #4a3aa7; --cat-7-soft: #ede9fb; /* violet */
    --cat-8: #e34948; --cat-8-soft: #fbe9e9; /* red */

    /* Status palette - reserved for state (good/warning/serious/critical), never reused as a series color */
    --status-good: #0ca30c;
    --status-warning: #fab219;
    --status-serious: #ec835a;
    --status-critical: #d03b3b;
}
body {
    font-family: 'Inter', sans-serif;
    background-color: var(--surface);
}
.navbar-brand {
    font-weight: 700;
    letter-spacing: -0.02em;
}
.app-navbar {
    background: linear-gradient(90deg, var(--brand-primary), var(--brand-primary-dark));
}
.card {
    border: none;
    border-radius: var(--radius-lg);
    box-shadow: var(--card-shadow);
    transition: box-shadow .2s ease, transform .2s ease;
}
.card.card-hover:hover {
    box-shadow: var(--card-shadow-hover);
    transform: translateY(-2px);
}
.stat-card {
    border-radius: var(--radius-lg);
    padding: 1.25rem 1.5rem;
    color: #fff;
    box-shadow: var(--card-shadow);
}
.stat-card .stat-number {
    font-size: 2rem;
    font-weight: 700;
    line-height: 1;
}
.stat-card .stat-icon {
    font-size: 1.75rem;
    opacity: 0.85;
}
.bg-brand { background-color: var(--brand-primary); }
.btn-brand {
    background-color: var(--brand-primary);
    color: #fff;
    border: none;
    transition: background-color .15s ease, transform .1s ease;
}
.btn-brand:hover {
    background-color: var(--brand-primary-dark);
    color: #fff;
}
.btn-brand:active { transform: translateY(1px); }

/* ---- Group accent utilities: fixed categorical order, one hue per group ---- */
.cat-1-accent { border-left: 5px solid var(--cat-1); }
.cat-1-chip   { background: var(--cat-1-soft); color: var(--cat-1); }
.cat-1-solid  { background: var(--cat-1); color: #fff; }

.cat-2-accent { border-left: 5px solid var(--cat-2); }
.cat-2-chip   { background: var(--cat-2-soft); color: var(--cat-2); }
.cat-2-solid  { background: var(--cat-2); color: #fff; }

.cat-3-accent { border-left: 5px solid var(--cat-3); }
.cat-3-chip   { background: var(--cat-3-soft); color: #9c4e6d; }
.cat-3-solid  { background: var(--cat-3); color: #fff; }

.cat-4-accent { border-left: 5px solid var(--cat-4); }
.cat-4-chip   { background: var(--cat-4-soft); color: #8a6400; }
.cat-4-solid  { background: var(--cat-4); color: #fff; }

.cat-5-accent { border-left: 5px solid var(--cat-5); }
.cat-5-chip   { background: var(--cat-5-soft); color: var(--cat-5); }
.cat-5-solid  { background: var(--cat-5); color: #fff; }

.cat-6-accent { border-left: 5px solid var(--cat-6); }
.cat-6-chip   { background: var(--cat-6-soft); color: #a94a20; }
.cat-6-solid  { background: var(--cat-6); color: #fff; }

.cat-7-accent { border-left: 5px solid var(--cat-7); }
.cat-7-chip   { background: var(--cat-7-soft); color: var(--cat-7); }
.cat-7-solid  { background: var(--cat-7); color: #fff; }

.cat-8-accent { border-left: 5px solid var(--cat-8); }
.cat-8-chip   { background: var(--cat-8-soft); color: var(--cat-8); }
.cat-8-solid  { background: var(--cat-8); color: #fff; }

/* ---- Status badges: state only, always paired with an icon, never a bare color ---- */
.status-badge {
    display: inline-flex; align-items: center; gap: .35rem;
    padding: .3rem .65rem; border-radius: 999px; font-size: .78rem; font-weight: 600;
}
.status-good     { background: rgba(12,163,12,0.12); color: var(--status-good); }
.status-warning  { background: rgba(250,178,25,0.20); color: #8a6400; }
.status-serious  { background: rgba(236,131,90,0.20); color: #a94a20; }
.status-critical { background: rgba(208,59,59,0.14); color: var(--status-critical); }

/* ============================================================
   Shared page furniture
   One header, one filter bar and one empty state used by every
   screen, so pages stop each inventing their own spacing and a
   list with nothing in it always explains itself instead of
   showing a bare table with no rows.
   ============================================================ */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    flex-wrap: wrap;
    padding-bottom: .85rem;
    margin-bottom: 1.25rem;
    border-bottom: 1px solid #e5e9ef;
}
.page-title {
    margin: 0;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: #0f172a;
}
.page-subtitle {
    margin: .2rem 0 0;
    color: #64748b;
    font-size: .875rem;
    max-width: 62ch;
}

.filter-bar {
    display: flex;
    align-items: flex-end;
    gap: .75rem;
    flex-wrap: wrap;
    background: #fff;
    border: 1px solid #e8ecf1;
    border-radius: var(--radius-lg);
    padding: .85rem 1rem;
}
.form-label-sm {
    font-size: .7rem;
    font-weight: 700;
    letter-spacing: .05em;
    text-transform: uppercase;
    color: #94a3b8;
    margin-bottom: .2rem;
}

.empty-state {
    text-align: center;
    padding: 3rem 1.5rem;
    background: #fff;
    border: 1px dashed #d7dee7;
    border-radius: var(--radius-lg);
    color: #64748b;
}
.empty-state > .bi {
    font-size: 2.4rem;
    color: #cbd5e1;
    display: block;
    margin-bottom: .65rem;
}
.empty-state h6 {
    color: #334155;
    font-weight: 700;
    margin-bottom: .35rem;
}
.empty-state p {
    margin: 0 auto;
    max-width: 46ch;
    font-size: .875rem;
}

/* Quick-action tile: the "what do I do next" links on a role dashboard. */
.action-tile {
    display: flex;
    align-items: center;
    gap: .9rem;
    background: #fff;
    border: 1px solid #e8ecf1;
    border-radius: var(--radius-lg);
    padding: 1rem 1.15rem;
    height: 100%;
    text-decoration: none;
    color: inherit;
    transition: box-shadow .18s ease, transform .18s ease, border-color .18s ease;
}
.action-tile:hover {
    color: inherit;
    border-color: #d6dce6;
    box-shadow: var(--card-shadow-hover);
    transform: translateY(-2px);
}
.action-tile .at-icon {
    width: 44px; height: 44px; flex: none;
    border-radius: 12px;
    display: inline-flex; align-items: center; justify-content: center;
    font-size: 1.3rem;
}
.action-tile .at-title { font-weight: 700; font-size: .95rem; line-height: 1.2; color: #0f172a; }
.action-tile .at-sub { font-size: .8rem; color: #64748b; margin: .15rem 0 0; }
.action-tile .at-go { margin-left: auto; color: #cbd5e1; font-size: 1.1rem; }
.action-tile:hover .at-go { color: var(--brand-primary); }

.table thead th {
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.03em;
    color: #64748B;
    background: #F1F5F9;
    border-bottom: 2px solid #E2E8F0;
}
.table-striped > tbody > tr:nth-of-type(odd) > * {
    background-color: rgba(67, 56, 202, 0.025);
}
.table-hover > tbody > tr:hover > * {
    background-color: rgba(67, 56, 202, 0.05);
}
.app-footer {
    color: #94A3B8;
    font-size: 0.85rem;
}
.login-card {
    border-radius: var(--radius-lg);
}
.login-hero {
    background: linear-gradient(135deg, var(--brand-primary), var(--brand-accent));
    border-radius: var(--radius-lg) 0 0 var(--radius-lg);
    color: #fff;
}
.table-scroll {
    max-height: 420px;
    overflow: auto;
    border: 1px solid var(--bs-border-color, #dee2e6);
    border-radius: 8px;
}
.table-scroll.table-scroll-sm {
    max-height: 260px;
}
.table-scroll table {
    margin-bottom: 0;
}
.table-scroll thead th {
    position: sticky;
    top: 0;
    background: #fff;
    z-index: 1;
}

/* Text Books app: student x book checkbox matrix (Assign Requirements, Distribution) */
.book-matrix-wrap {
    overflow: auto;
    max-height: 70vh;
    border: 1px solid rgba(0,0,0,0.08);
    border-radius: 10px;
}
.book-matrix-table { border-collapse: separate; border-spacing: 0; }

.book-matrix-table thead th {
    background: linear-gradient(180deg, var(--brand-primary), var(--brand-primary-dark));
    color: #fff;
    position: sticky;
    top: 0;
    z-index: 2;
    font-weight: 600;
    vertical-align: bottom;
    text-align: center;
    white-space: normal;
    word-break: break-word;
    min-width: 100px;
    max-width: 140px;
    font-size: 0.85rem;
    padding: 0.5rem 0.4rem;
}
.book-matrix-table thead th:first-child {
    text-align: left;
    z-index: 3;
    background: var(--brand-primary-dark);
}

.book-matrix-table td:first-child,
.book-matrix-table th:first-child {
    position: sticky;
    left: 0;
    width: 170px;
    max-width: 170px;
    min-width: 170px;
    white-space: normal;
    word-break: break-word;
    font-size: 0.9rem;
    z-index: 1;
}
.book-matrix-table td:first-child { background: #fff; }

.book-matrix-table td { text-align: center; }

/* Colorful per-book column tinting, cycling through the 8-slot categorical palette.
   nth-child counts the sticky Student column as child 1, so book columns start at 2. */
.book-matrix-table tbody td:nth-child(8n+2) { background-color: var(--cat-1-soft); }
.book-matrix-table tbody td:nth-child(8n+3) { background-color: var(--cat-2-soft); }
.book-matrix-table tbody td:nth-child(8n+4) { background-color: var(--cat-3-soft); }
.book-matrix-table tbody td:nth-child(8n+5) { background-color: var(--cat-4-soft); }
.book-matrix-table tbody td:nth-child(8n+6) { background-color: var(--cat-5-soft); }
.book-matrix-table tbody td:nth-child(8n+7) { background-color: var(--cat-6-soft); }
.book-matrix-table tbody td:nth-child(8n+8) { background-color: var(--cat-7-soft); }
.book-matrix-table tbody td:nth-child(8n+9) { background-color: var(--cat-8-soft); }

.book-matrix-table tbody tr:hover td { filter: brightness(0.93); }

.book-matrix-table thead tr.cost-row th {
    position: static;
    background: var(--brand-primary);
    color: #fff;
    font-weight: 500;
    font-size: 0.8rem;
    text-align: center;
}
.book-matrix-table thead tr.cost-row th:first-child {
    position: sticky;
    left: 0;
    text-align: left;
    background: var(--brand-primary-dark);
}

/* ---------- Receipt printing (half-A4, dual copy) ---------- */
@media print {
    @page {
        size: A4;
        margin: 5mm;
    }
    body {
        background: #fff !important;
    }
    .receipt-copy {
        height: 130mm;
        overflow: hidden;
        page-break-inside: avoid;
    }
    .receipt-cut-line {
        border-top: 1px dashed #999;
        text-align: center;
        margin: 4mm 0;
    }
    .receipt-cut-line span {
        background: #fff;
        padding: 0 6px;
        font-size: 9px;
        color: #999;
        position: relative;
        top: -8px;
    }
}

/* ---------- Sidebar layout ---------- */
.app-shell {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 260px;
    flex-shrink: 0;
    background: linear-gradient(180deg, var(--brand-primary-dark), var(--brand-primary));
    color: #fff;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 1040;
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
}

.sidebar-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    z-index: 1039;
}

.sidebar-brand {
    padding: 1.1rem 1.25rem;
    font-weight: 700;
    font-size: 1.15rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.15);
    display: flex;
    align-items: center;
    gap: .5rem;
    color: #fff;
    text-decoration: none;
}

.sidebar-link {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: .7rem 1.25rem;
    color: rgba(255, 255, 255, 0.9);
    text-decoration: none;
    font-weight: 500;
    cursor: pointer;
}
.sidebar-link:hover { background: rgba(255, 255, 255, 0.08); color: #fff; }
.sidebar-link .bi-chevron-down { transition: transform 0.2s ease; font-size: .8rem; }
.sidebar-link[aria-expanded="true"] .bi-chevron-down { transform: rotate(180deg); }

.sidebar-submenu {
    list-style: none;
    margin: 0;
    padding: 0;
    background: rgba(0, 0, 0, 0.15);
}
.sidebar-submenu a {
    display: block;
    padding: .55rem 1.25rem .55rem 2.75rem;
    color: rgba(255, 255, 255, 0.75);
    text-decoration: none;
    font-size: .92rem;
}
.sidebar-submenu a:hover, .sidebar-submenu a.active {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

.main-area {
    flex-grow: 1;
    margin-left: 260px;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
.main-area > .container-fluid {
    flex: 1 0 auto;
}
.main-area > .app-footer {
    flex-shrink: 0;
}

/* ---------- Sidebar polish ---------- */
/* ---------- Sidebar polish ---------- */
.sidebar {
    overflow: hidden;
}
.sidebar-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.25) transparent;
}
.sidebar-scroll::-webkit-scrollbar { width: 6px; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.25); border-radius: 3px; }
.sidebar-scroll::-webkit-scrollbar-track { background: transparent; }

.sidebar-link {
    border-radius: 8px;
    margin: 2px 10px;
    width: calc(100% - 20px);
}
.sidebar-link.active {
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    box-shadow: inset 3px 0 0 var(--brand-accent);
}

.sidebar-submenu {
    margin: 0 10px 6px;
    border-radius: 8px;
    overflow: hidden;
}
.sidebar-submenu a {
    border-radius: 6px;
    margin: 2px 6px;
    width: calc(100% - 12px);
}
.sidebar-submenu a.active {
    box-shadow: inset 3px 0 0 var(--brand-accent);
    font-weight: 600;
}

.sidebar-brand .bi {
    background: rgba(255,255,255,0.15);
    padding: 6px;
    border-radius: 8px;
    font-size: 1.1rem;
}

.topbar {
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    padding: .65rem 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-toggle-btn { display: none; }

/* ---------- QB Drawing Tool ---------- */
.qbd-toolbar { display:flex; flex-direction:column; gap:10px; margin-bottom:10px; }
.qbd-menubar { display:flex; flex-wrap:wrap; align-items:center; gap:6px; padding:8px; background:#f8f9fa; border:1px solid #dee2e6; border-radius:6px; }
.qbd-menu-group { position:relative; }
.qbd-menu-toggle { font-weight:500; }
.qbd-dropdown-menu { max-height:340px; overflow-y:auto; min-width:200px; }
.qbd-tool-item { display:flex; align-items:center; gap:8px; cursor:pointer; }
.qbd-tool-item.active { background-color:#0d6efd; color:#fff; }
.qbd-tool-icon { font-size:0.95rem; display:inline-block; width:1.4em; text-align:center; }
.qbd-current-tool { margin-left:auto; font-size:0.78rem; padding:6px 10px; }
.qbd-option-row { display:flex; flex-wrap:wrap; align-items:center; gap:8px; padding:8px; background:#fff; border:1px solid #eee; border-radius:6px; }
.qbd-sep { width:1px; align-self:stretch; background:#e5e7eb; margin:0 2px; }
.qbd-hint kbd { background:#eef2ff; color:#4338ca; border:1px solid #c7d2fe; border-radius:4px; padding:0 4px; font-size:.7rem; }
.qbd-option-row label.small { display:inline-flex; align-items:center; gap:5px; white-space:nowrap; }
.qbd-canvas-wrap { position:relative; }
.qbd-canvas-wrap canvas { cursor:crosshair; }
.qbd-canvas-wrap canvas:focus { outline:2px solid var(--brand-primary); outline-offset:2px; }

/* Bulk Add: question details on the left, drawing board on the right. */
.qbb-split { display:grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap:16px; align-items:start; }
@media (max-width: 1199.98px) { .qbb-split { grid-template-columns: 1fr; } }
.qbb-pane { min-width:0; }
.qbb-pane-head {
    display:flex; align-items:center; justify-content:space-between; gap:.5rem;
    font-size:.72rem; font-weight:700; letter-spacing:.06em; text-transform:uppercase;
    color:#64748b; padding-bottom:.4rem; margin-bottom:.7rem; border-bottom:1px solid #e8ecf1;
}
.qbb-figure-pane { position:sticky; top:12px; background:#fbfcfd; border:1px solid #e8ecf1; border-radius:10px; padding:12px; }

@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.show { transform: translateX(0); }
    .main-area { margin-left: 0; }
    .sidebar-toggle-btn { display: inline-flex; }
    .sidebar-backdrop.show { display: block; }
}

/* ---------- Question Paper print layout (2-column questions, auto-flowing options) ---------- */
.qp-question { break-inside: avoid; margin-bottom: 14px; }
.qp-options div { margin-bottom: 2px; }
#questionColumns { columns: 2; column-gap: 24px; }

@media print {
    #paperSheet { border: none !important; }
    .qp-question { font-size: 0.85rem; margin-bottom: 8px; }
    #questionColumns { column-gap: 16px; }

    .container-fluid {
        padding: 0 !important;
    }
}

/* --------------------------------------------------------------------------
   Table filter box injected by static/js/ui_enhance.js, and the Choices.js
   dropdown skin so a searchable select still looks like a Bootstrap control.
   -------------------------------------------------------------------------- */
.tbl-filter { display: flex; align-items: center; gap: .6rem; margin-bottom: .6rem; }
.tbl-filter .input-group { max-width: 300px; }
.tbl-filter-count { white-space: nowrap; }
.tbl-filter-count.is-empty { color: var(--status-critical); }

.choices { margin-bottom: 0; }
.choices__inner {
    background: #fff;
    border: 1px solid #ced4da;
    border-radius: .375rem;
    min-height: calc(1.5em + .75rem + 2px);
    padding: .25rem .5rem;
    font-size: .95rem;
}
.choices.is-focused .choices__inner { border-color: var(--brand-primary); box-shadow: 0 0 0 .2rem rgba(67,56,202,.15); }
.choices__list--dropdown .choices__item--selectable.is-highlighted { background: var(--cat-7-soft); }
.choices__list--dropdown { border-color: #ced4da; border-radius: .375rem; }
.choices__input { background: #fff; margin-bottom: .25rem; }
