/* ============================================================================
   OLTERP SIS — design system
   Modern, light, efficient, WCAG 2.1 AA. Layered over Bootstrap 5 via tokens.
   Rebrand = change --accent (and its hover/active/soft) below; everything else
   derives from the token set. Uses the system font stack (no web-font download).
   ============================================================================ */

:root {
    color-scheme: light;

    /* ---- Brand / accent (change these to rebrand) ---- */
    --accent:          #4f46e5;  /* indigo-600 — 6.5:1 on white, AA for text & UI */
    --accent-hover:    #4338ca;  /* indigo-700 */
    --accent-active:   #3730a3;  /* indigo-800 */
    --accent-soft:     #eef2ff;  /* indigo-50 — selected/active surface tint */
    --accent-contrast: #ffffff;

    /* ---- Neutrals (slate) ---- */
    --surface:      #ffffff;   /* cards, sidebar */
    --surface-2:    #f8fafc;   /* page background */
    --surface-3:    #f1f5f9;   /* stripes, subtle fills */
    --border:       #e2e8f0;
    --border-strong:#cbd5e1;
    --text:         #0f172a;   /* slate-900 — 16:1 on white */
    --text-muted:   #475569;   /* slate-600 — 7:1, safe for secondary text */
    --text-subtle:  #64748b;   /* slate-500 — 4.6:1, large/label text only */

    /* ---- Status (dark text on soft fill = AA) ---- */
    --success: #15803d; --success-soft: #dcfce7; --success-border: #bbf7d0;
    --danger:  #b91c1c; --danger-soft:  #fee2e2; --danger-border:  #fecaca;
    --warning: #a16207; --warning-soft: #fef9c3; --warning-border: #fde68a;
    --info:    #0369a1; --info-soft:    #e0f2fe; --info-border:    #bae6fd;

    --focus: #4f46e5;

    --radius:      10px;
    --radius-sm:   7px;
    --radius-pill: 999px;
    --shadow-sm: 0 1px 2px rgba(15,23,42,.06), 0 1px 3px rgba(15,23,42,.05);
    --shadow:    0 6px 20px rgba(15,23,42,.08);
    --ring:      0 0 0 3px rgba(79,70,229,.30);

    /* ---- Map Bootstrap's own variables onto the tokens ---- */
    --bs-body-color: var(--text);
    --bs-body-bg: var(--surface-2);
    --bs-border-color: var(--border);
    --bs-link-color: var(--accent);
    --bs-link-hover-color: var(--accent-hover);
    --bs-link-color-rgb: 79,70,229;
    --bs-border-radius: var(--radius-sm);
    --bs-font-sans-serif: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif;
}

html, body {
    font-family: var(--bs-font-sans-serif);
    color: var(--text);
    background-color: var(--surface-2);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* ---------------------------------------------------------------- Typography */
h1, .h1 { font-size: 1.6rem; }
h2, .h2 { font-size: 1.35rem; }
h1, h2, h3, h4, h5, h6 {
    color: var(--text);
    font-weight: 650;
    letter-spacing: -0.01em;
}
p.text-secondary, .text-secondary { color: var(--text-muted) !important; }
a { color: var(--accent); text-underline-offset: 2px; }
a:hover { color: var(--accent-hover); }

/* ---------------------------------------------- Accessibility: focus + skip */
/* One consistent, high-contrast keyboard focus ring everywhere. */
*:focus-visible {
    outline: 2px solid var(--focus);
    outline-offset: 2px;
    border-radius: 4px;
}
/* Kill the template's invisible white-on-white focus shadow. */
.btn:focus, .btn:active:focus, .btn-link.nav-link:focus,
.form-control:focus, .form-check-input:focus, .form-select:focus {
    box-shadow: none;
}
.btn:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; box-shadow: none; }
.form-control:focus, .form-select:focus {
    border-color: var(--accent);
    box-shadow: var(--ring);
}
.form-check-input:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }

/* Skip-to-content link — first tab stop, visible only when focused. */
.skip-link {
    position: absolute;
    left: 12px;
    top: -80px;
    z-index: 2000;
    background: var(--surface);
    color: var(--accent);
    font-weight: 600;
    padding: 0.55rem 1rem;
    border: 1px solid var(--border-strong);
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow);
    transition: top 0.15s ease;
}
.skip-link:focus { top: 12px; }

/* ------------------------------------------------------------------ Buttons */
.btn {
    border-radius: var(--radius-sm);
    font-weight: 500;
    transition: background-color .12s ease, border-color .12s ease, color .12s ease;
}
.btn-primary {
    --bs-btn-bg: var(--accent); --bs-btn-border-color: var(--accent);
    --bs-btn-hover-bg: var(--accent-hover); --bs-btn-hover-border-color: var(--accent-hover);
    --bs-btn-active-bg: var(--accent-active); --bs-btn-active-border-color: var(--accent-active);
    --bs-btn-disabled-bg: var(--accent); --bs-btn-disabled-border-color: var(--accent);
    color: #fff;
}
.btn-outline-primary {
    --bs-btn-color: var(--accent); --bs-btn-border-color: var(--border-strong);
    --bs-btn-hover-bg: var(--accent); --bs-btn-hover-border-color: var(--accent);
    --bs-btn-hover-color: #fff;
}
.btn-outline-secondary {
    --bs-btn-color: var(--text-muted); --bs-btn-border-color: var(--border-strong);
    --bs-btn-hover-bg: var(--surface-3); --bs-btn-hover-color: var(--text);
    --bs-btn-hover-border-color: var(--border-strong);
}
/* Outline status buttons: Bootstrap's defaults use the bright status colours as
   text (fails AA on white). Use the dark AA-contrast tokens instead. */
.btn-outline-success {
    --bs-btn-color: var(--success); --bs-btn-border-color: var(--success-border);
    --bs-btn-hover-bg: var(--success); --bs-btn-hover-color: #fff; --bs-btn-hover-border-color: var(--success);
}
.btn-outline-danger {
    --bs-btn-color: var(--danger); --bs-btn-border-color: var(--danger-border);
    --bs-btn-hover-bg: var(--danger); --bs-btn-hover-color: #fff; --bs-btn-hover-border-color: var(--danger);
}
.btn-outline-warning {
    --bs-btn-color: var(--warning); --bs-btn-border-color: var(--warning-border);
    --bs-btn-hover-bg: var(--warning); --bs-btn-hover-color: #fff; --bs-btn-hover-border-color: var(--warning);
}
.btn-outline-info {
    --bs-btn-color: var(--info); --bs-btn-border-color: var(--info-border);
    --bs-btn-hover-bg: var(--info); --bs-btn-hover-color: #fff; --bs-btn-hover-border-color: var(--info);
}

/* -------------------------------------------------------------------- Cards */
.card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    box-shadow: var(--shadow-sm);
}
.card-header {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    font-weight: 600;
}
.card.border-primary { border-color: var(--accent) !important; }
.shadow-sm { box-shadow: var(--shadow-sm) !important; }

/* ------------------------------------------------------------------- Tables */
.table {
    --bs-table-bg: transparent;
    --bs-table-striped-bg: var(--surface-3);
    --bs-table-striped-color: var(--text);
    color: var(--text);
    border-color: var(--border);
    margin-bottom: 0;
}
.table > thead th {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--text-subtle);
    font-weight: 600;
    border-bottom: 1px solid var(--border);
    white-space: nowrap;
}
.table > tbody > tr > td, .table > tbody > tr > th { border-color: var(--border); }
.table > tbody > tr { transition: background-color .1s ease; }
.table > tbody > tr:hover > * { background-color: var(--accent-soft); }
.table-responsive { border-radius: var(--radius); }

/* ------------------------------------------------------------------ Badges */
.badge { font-weight: 600; border-radius: var(--radius-pill); padding: 0.36em 0.72em; font-size: 0.72rem; }
.badge.bg-secondary { background-color: var(--surface-3) !important; color: var(--text-muted) !important; }
.badge.bg-success   { background-color: var(--success-soft) !important; color: var(--success) !important; }
.badge.bg-danger    { background-color: var(--danger-soft)  !important; color: var(--danger)  !important; }
.badge.bg-warning   { background-color: var(--warning-soft) !important; color: var(--warning) !important; }
.badge.bg-info      { background-color: var(--info-soft)    !important; color: var(--info)    !important; }

/* ------------------------------------------------------------------ Alerts */
.alert { border-radius: var(--radius); border: 1px solid transparent; }
.alert-success { background: var(--success-soft); color: var(--success); border-color: var(--success-border); }
.alert-danger  { background: var(--danger-soft);  color: var(--danger);  border-color: var(--danger-border); }
.alert-warning { background: var(--warning-soft); color: var(--warning); border-color: var(--warning-border); }
.alert-info    { background: var(--info-soft);    color: var(--info);    border-color: var(--info-border); }
.alert .alert-heading { color: inherit; font-weight: 700; }

/* ------------------------------------------------------------------- Forms */
.form-control, .form-select {
    border-color: var(--border-strong);
    border-radius: var(--radius-sm);
    color: var(--text);
}
.form-control::placeholder { color: var(--text-subtle); }
.form-label { font-weight: 500; color: var(--text-muted); font-size: 0.875rem; margin-bottom: 0.3rem; }
.input-group-text { background: var(--surface-3); border-color: var(--border-strong); color: var(--text-muted); }

.content { padding-top: 1.5rem; padding-bottom: 3rem; }
h1:focus { outline: none; }

/* Inline code (verification codes etc.) — Bootstrap's default pink fails AA on white. */
code {
    color: #9d174d;
    background: var(--surface-3);
    padding: 0.1em 0.35em;
    border-radius: 4px;
}

/* -------------------------------------------------- Validation (preserved) */
.valid.modified:not([type=checkbox]) { outline: 1px solid var(--success); }
.invalid { outline: 1px solid var(--danger); }
.validation-message { color: var(--danger); font-size: 0.85rem; }
.darker-border-checkbox.form-check-input { border-color: var(--border-strong); }

.form-floating > .form-control-plaintext::placeholder, .form-floating > .form-control::placeholder {
    color: var(--bs-secondary-color);
    text-align: end;
}
.form-floating > .form-control-plaintext:focus::placeholder, .form-floating > .form-control:focus::placeholder {
    text-align: start;
}

/* ---------------------------------------------------------- Error boundary */
.blazor-error-boundary {
    background: url(data:image/svg+xml;base64,PHN2ZyB3aWR0aD0iNTYiIGhlaWdodD0iNDkiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIG92ZXJmbG93PSJoaWRkZW4iPjxkZWZzPjxjbGlwUGF0aCBpZD0iY2xpcDAiPjxyZWN0IHg9IjIzNSIgeT0iNTEiIHdpZHRoPSI1NiIgaGVpZ2h0PSI0OSIvPjwvY2xpcFBhdGg+PC9kZWZzPjxnIGNsaXAtcGF0aD0idXJsKCNjbGlwMCkiIHRyYW5zZm9ybT0idHJhbnNsYXRlKC0yMzUgLTUxKSI+PHBhdGggZD0iTTI2My41MDYgNTFDMjY0LjcxNyA1MSAyNjUuODEzIDUxLjQ4MzcgMjY2LjYwNiA1Mi4yNjU4TDI2Ny4wNTIgNTIuNzk4NyAyNjcuNTM5IDUzLjYyODMgMjkwLjE4NSA5Mi4xODMxIDI5MC41NDUgOTIuNzk1IDI5MC42NTYgOTIuOTk2QzI5MC44NzcgOTMuNTEzIDI5MSA5NC4wODE1IDI5MSA5NC42NzgyIDI5MSA5Ny4wNjUxIDI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    border-radius: var(--radius);
}
.blazor-error-boundary::after { content: "An error has occurred."; }

/* --------------------------------------------- Respect reduced-motion pref */
/* ---- Rubrics: a criterion's levels side by side; the chosen one stands out by border, fill AND a tick ---- */
.rubric-criterion { margin-bottom: .9rem; }
.rubric-levels { display: grid; grid-template-columns: repeat(auto-fit, minmax(9.5rem, 1fr)); gap: .5rem; }
.rubric-level { display: block; width: 100%; border: 1px solid var(--border-strong); border-radius: var(--radius-sm);
    background: var(--surface); color: var(--text); padding: .5rem .6rem; font-size: .875rem; line-height: 1.35; }
.rubric-level .rubric-points { font-variant-numeric: tabular-nums; font-weight: 600; white-space: nowrap; }
button.rubric-level { cursor: pointer; text-align: left; }
button.rubric-level:hover { border-color: var(--accent); }
button.rubric-level:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.rubric-level.picked { border-color: var(--success); background: var(--success-soft); box-shadow: inset 0 0 0 1px var(--success); }
.rubric-level.picked::before { content: "\2713\00a0"; color: var(--success); font-weight: 700; }

/* ---- Similarity report: matched passages, one colour per source ---- */
.similarity-text { white-space: pre-wrap; font-size: .9rem; line-height: 1.6; max-height: 70vh; overflow-y: auto;
    border: 1px solid var(--border); border-radius: var(--radius-sm); padding: .75rem; background: var(--surface); }
.similarity-text mark { padding: 0 .1em; border-radius: 3px; color: var(--text); }
.sim-1 { background: #fde68a; } .sim-2 { background: #bfdbfe; } .sim-3 { background: #fbcfe8; }
.sim-4 { background: #bbf7d0; } .sim-5 { background: #ddd6fe; } .sim-0, .sim-6 { background: #fed7aa; }
.sim-swatch { display: inline-block; width: .9rem; height: .9rem; border-radius: 3px; vertical-align: -2px; margin-right: .3rem; }

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.001ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.001ms !important;
        scroll-behavior: auto !important;
    }
}

/* Privacy notices, answers and addresses keep the line breaks they were written with. */
.privacy-body { white-space: pre-line; }
.app-footer { border-top: 1px solid var(--bs-border-color); color: var(--bs-secondary-color); display: flex; gap: .5rem; flex-wrap: wrap; }

/* ---- Add to Home Screen (js/pwa.js): a card along the bottom of a phone screen, never covering the page's own end ---- */
.install-sheet {
    position: fixed; left: 12px; right: 12px; bottom: calc(12px + env(safe-area-inset-bottom, 0px));
    z-index: 1035;   /* over the page and its fixed bar, under any dialog */
    max-width: 30rem; margin-inline: auto;
    display: flex; gap: .75rem; align-items: flex-start;
    padding: .9rem 2.6rem .9rem .9rem;
    background: var(--surface); color: var(--text);
    border: 1px solid var(--border); border-radius: var(--radius);
    box-shadow: 0 10px 30px rgba(15,23,42,.18);
    animation: install-sheet-in .25s ease-out;
}
.install-sheet:focus { outline: none; }
.install-sheet:focus-visible { outline: 2px solid var(--focus); outline-offset: 2px; }
.install-sheet-icon { flex: none; width: 44px; height: 44px; border-radius: 10px; }
.install-sheet-body { min-width: 0; }
.install-sheet-title { font-size: 1rem; font-weight: 600; line-height: 1.3; margin: 0 0 .25rem; text-wrap: balance; }
.install-sheet-lead, .install-sheet-hint { font-size: .875rem; color: var(--text-muted); margin: 0 0 .4rem; }
.install-sheet-steps { font-size: .875rem; margin: 0 0 .55rem; padding-left: 1.2rem; }
.install-sheet-steps li + li { margin-top: .2rem; }
.install-ico { width: 1.15em; height: 1.15em; vertical-align: -.22em; margin: 0 .1em; color: var(--accent); }
.install-sheet-actions { display: flex; gap: .5rem; flex-wrap: wrap; }
.install-sheet-close { position: absolute; top: .65rem; right: .65rem; }
@keyframes install-sheet-in { from { transform: translateY(12px); opacity: 0; } to { transform: none; opacity: 1; } }
html.has-install-sheet body { padding-bottom: var(--install-sheet-space, 12rem); }
html.is-typing .install-sheet { display: none; }   /* the keyboard is up: never over the field being typed in */

/* The "Add to Home Screen" links show only where they can work: a phone or tablet, in the browser, not the installed app. */
html:not(.can-add-to-home) .install-app-item { display: none !important; }
.install-app-link { background: none; border: 0; padding: 0; color: var(--bs-link-color); text-decoration: underline; }


/* The eye in a password box (Components/Shared/PasswordEye.razor). */
.pw-field { position: relative; }
.pw-field > input, .form-floating > input.pw-input { padding-right: 2.75rem; }
.pw-eye {
    position: absolute; top: 0; right: 0; width: 2.6rem; height: 100%;
    display: flex; align-items: center; justify-content: center;
    border: 0; background: transparent; color: var(--bs-secondary-color, #6c757d); border-radius: 0 var(--bs-border-radius, .375rem) var(--bs-border-radius, .375rem) 0;
}
.pw-eye:hover { color: var(--bs-body-color, #212529); }
.pw-eye:focus-visible { outline: 2px solid var(--bs-primary, #0d6efd); outline-offset: -2px; }
/* In a floating-label field the container also holds the validation message, so the eye keeps to the input's height. */
.form-floating > .pw-eye { height: calc(3.5rem + 2px); z-index: 5; }
.pw-eye .pw-eye-shut, .pw-eye[aria-pressed="true"] .pw-eye-open { display: none; }
.pw-eye[aria-pressed="true"] .pw-eye-shut { display: inline; }
