/* ==========================================================================
   Exam Access System - institutional theme
   Brand colours come from the settings page (--brand / --accent).
   ========================================================================== */
:root {
    --brand: #0b4f6c;
    --accent: #c9a227;
    --brand-dark: color-mix(in srgb, var(--brand) 78%, #000);
    --brand-soft: color-mix(in srgb, var(--brand) 9%, #fff);
    --ink: #1c2733;
    --muted: #667085;
    --line: #e4e8ee;
    --surface: #ffffff;
    --canvas: #f4f6f9;
    --success: #12805c;
    --danger: #b42318;
    --radius: 14px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .05), 0 8px 24px rgba(16, 24, 40, .06);
    --font-display: "Iowan Old Style", "Palatino Linotype", Palatino, Georgia, "Times New Roman", serif;
    --font-body: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

body {
    font-family: var(--font-body);
    color: var(--ink);
    background: var(--canvas);
    -webkit-font-smoothing: antialiased;
}

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

/* ---- Buttons ------------------------------------------------------------ */
.btn { border-radius: 999px; font-weight: 600; }
.btn-sm { padding-inline: .9rem; }
.btn-brand {
    background: var(--brand); border-color: var(--brand); color: #fff;
}
.btn-brand:hover, .btn-brand:focus-visible, .btn-brand:active {
    background: var(--brand-dark) !important; border-color: var(--brand-dark) !important; color: #fff !important;
}
.btn-brand:disabled { background: var(--brand); border-color: var(--brand); color: #fff; opacity: .65; }
.btn-outline-brand { border-color: color-mix(in srgb, var(--brand) 40%, #fff); color: var(--brand); background: #fff; }
.btn-outline-brand:hover, .btn-outline-brand:focus-visible { background: var(--brand-soft); border-color: var(--brand); color: var(--brand-dark); }
.btn-light { background: #f1f3f6; border-color: #f1f3f6; }

.form-control, .form-select, .input-group-text { border-radius: 10px; border-color: #d5dae2; }
.form-control:focus, .form-select:focus, .form-check-input:focus {
    border-color: var(--brand);
    box-shadow: 0 0 0 .2rem color-mix(in srgb, var(--brand) 18%, transparent);
}
.form-check-input:checked { background-color: var(--brand); border-color: var(--brand); }
.form-label { font-weight: 600; font-size: .9rem; margin-bottom: .35rem; }

/* ---- Brand mark --------------------------------------------------------- */
.brand-monogram {
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--brand); color: #fff;
    font-family: var(--font-display); font-weight: 700; letter-spacing: .04em;
    border-radius: 50%;
    box-shadow: inset 0 0 0 3px rgba(255, 255, 255, .22), 0 0 0 2px var(--accent);
}

/* ==========================================================================
   Candidate portal (mobile first)
   ========================================================================== */
.portal-body { background: var(--canvas); min-height: 100vh; }
.portal-band {
    position: absolute; inset: 0 0 auto 0; height: 250px; z-index: 0;
    background:
        radial-gradient(120% 140% at 85% -20%, color-mix(in srgb, var(--accent) 38%, transparent) 0, transparent 55%),
        linear-gradient(160deg, var(--brand) 0%, var(--brand-dark) 100%);
    border-bottom: 4px solid var(--accent);
}
.portal-wrap {
    position: relative; z-index: 1;
    max-width: 460px; margin: 0 auto; padding: 28px 16px 32px;
}
.portal-wrap-wide { max-width: 560px; }
.portal-brand { text-align: center; color: #fff; margin-bottom: 20px; }
.portal-logo { width: 84px; height: 84px; object-fit: contain; font-size: 1.7rem; }
img.portal-logo { background: #fff; border-radius: 18px; padding: 8px; box-shadow: var(--shadow); }
.portal-brand-name { font-family: var(--font-display); font-size: 1.25rem; font-weight: 700; margin-top: 12px; line-height: 1.25; }
.portal-brand-tagline { font-size: .82rem; letter-spacing: .12em; text-transform: uppercase; opacity: .85; margin-top: 4px; }
.portal-card {
    background: var(--surface); border-radius: 20px; padding: 26px 22px 22px;
    box-shadow: 0 12px 40px rgba(16, 24, 40, .14);
}
.portal-title { font-family: var(--font-display); font-size: 1.45rem; font-weight: 700; color: var(--brand-dark); margin: 0 0 6px; text-wrap: balance; }
.portal-subtitle { color: var(--muted); margin-bottom: 18px; font-size: .97rem; }
.portal-session {
    background: var(--brand-soft); color: var(--brand-dark); font-weight: 600; font-size: .88rem;
    border-radius: 10px; padding: 9px 12px; margin-bottom: 18px;
}
.portal-note { color: var(--muted); font-size: .8rem; text-align: center; margin: 16px 0 0; }
.portal-footer { text-align: center; color: var(--muted); font-size: .78rem; margin-top: 20px; line-height: 1.7; }
.portal-state { text-align: center; padding: 10px 0; }
.portal-state-icon { font-size: 2.6rem; color: var(--accent); display: block; margin-bottom: 8px; }
.portal-card .btn-lg { padding-block: .8rem; font-size: 1.05rem; }
.portal-card .input-group-text { background: var(--brand-soft); color: var(--brand); border-right: 0; }
@media (min-width: 576px) {
    .portal-wrap { padding-top: 48px; }
    .portal-card { padding: 34px 32px 28px; }
}

/* ==========================================================================
   Administration
   ========================================================================== */
.admin-body { min-height: 100vh; }
.admin-sidebar {
    position: fixed; inset: 0 auto 0 0; width: 264px; z-index: 1040;
    background: linear-gradient(180deg, var(--brand-dark) 0%, color-mix(in srgb, var(--brand) 60%, #000) 100%);
    color: #fff; display: flex; flex-direction: column;
    border-right: 3px solid var(--accent);
    transition: transform .2s ease;
}
.sidebar-brand {
    display: flex; align-items: center; gap: 12px; padding: 20px 18px;
    color: #fff; text-decoration: none; border-bottom: 1px solid rgba(255, 255, 255, .12);
}
.sidebar-logo { width: 44px; height: 44px; flex: none; object-fit: contain; font-size: .95rem; }
img.sidebar-logo { background: #fff; border-radius: 10px; padding: 4px; }
.sidebar-brand-name { display: block; font-family: var(--font-display); font-weight: 700; font-size: .98rem; line-height: 1.2; }
.sidebar-brand-sub { display: block; font-size: .7rem; letter-spacing: .12em; text-transform: uppercase; opacity: .7; margin-top: 2px; }
.sidebar-nav { padding: 14px 12px; flex: 1; overflow-y: auto; }
.sidebar-section { font-size: .68rem; letter-spacing: .14em; text-transform: uppercase; opacity: .55; padding: 6px 10px 8px; }
.sidebar-link {
    display: flex; align-items: center; gap: 12px; padding: 10px 12px; margin-bottom: 2px;
    color: rgba(255, 255, 255, .82); text-decoration: none; border-radius: 10px;
    font-size: .93rem; font-weight: 500; background: none; border: 0; text-align: left;
}
.sidebar-link i { font-size: 1.05rem; width: 20px; text-align: center; }
.sidebar-link:hover { background: rgba(255, 255, 255, .09); color: #fff; }
.sidebar-link.active { background: #fff; color: var(--brand-dark); font-weight: 700; box-shadow: inset 3px 0 0 var(--accent); }
.sidebar-logout { padding: 12px; border-top: 1px solid rgba(255, 255, 255, .12); margin: 0; }
.sidebar-backdrop { display: none; position: fixed; inset: 0; background: rgba(16, 24, 40, .45); z-index: 1035; }
.sidebar-backdrop.show { display: block; }

.admin-main { margin-left: 264px; min-height: 100vh; display: flex; flex-direction: column; }
.admin-topbar {
    display: flex; align-items: center; gap: 12px; padding: 16px 28px;
    background: var(--surface); border-bottom: 1px solid var(--line); position: sticky; top: 0; z-index: 1020;
}
.admin-title { font-family: var(--font-display); font-size: 1.35rem; font-weight: 700; color: var(--brand-dark); margin: 0; }
.admin-subtitle { color: var(--muted); font-size: .85rem; }
.admin-user { display: flex; align-items: center; gap: 10px; }
.admin-user-avatar {
    width: 38px; height: 38px; border-radius: 50%; background: var(--brand-soft); color: var(--brand);
    display: flex; align-items: center; justify-content: center; font-weight: 700;
}
.admin-user-name { font-weight: 600; font-size: .88rem; line-height: 1.2; }
.admin-user-role { font-size: .74rem; color: var(--muted); }
.admin-content { padding: 24px 28px; flex: 1; }
.admin-footer { padding: 14px 28px; color: var(--muted); font-size: .78rem; border-top: 1px solid var(--line); background: var(--surface); }

@media (max-width: 991.98px) {
    .admin-sidebar { transform: translateX(-100%); }
    .admin-sidebar.open { transform: none; }
    .admin-main { margin-left: 0; }
    .admin-topbar, .admin-content, .admin-footer { padding-inline: 16px; }
    .admin-title { font-size: 1.15rem; }
}

/* ---- Panels & cards ------------------------------------------------------ */
.panel { background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow); }
.form-panel { max-width: 860px; }
.panel-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 16px; }
.panel-head h2 { font-size: 1.02rem; font-weight: 700; margin: 0; color: var(--ink); }
.panel-foot { margin-top: 14px; padding-top: 12px; border-top: 1px solid var(--line); font-size: .85rem; color: var(--muted); }
.toolbar { display: flex; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }

.stat-card {
    background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
    padding: 18px; display: flex; align-items: center; gap: 14px; box-shadow: var(--shadow); height: 100%;
    border-top: 3px solid var(--tone);
    --tone: var(--brand);
}
.stat-icon {
    width: 48px; height: 48px; border-radius: 12px; flex: none;
    display: flex; align-items: center; justify-content: center; font-size: 1.35rem;
    color: var(--tone); background: color-mix(in srgb, var(--tone) 11%, #fff);
}
.stat-value { font-size: 1.7rem; font-weight: 700; line-height: 1.1; font-variant-numeric: tabular-nums; }
.stat-label { color: var(--muted); font-size: .84rem; }
.stat-success, .mini-success { --tone: var(--success); }
.stat-danger, .mini-danger { --tone: var(--danger); }
.stat-accent, .mini-accent { --tone: color-mix(in srgb, var(--accent) 75%, #000); }
.stat-muted, .mini-muted { --tone: #7a8597; }
.stat-primary, .mini-primary { --tone: var(--brand); }
@media (max-width: 575.98px) {
    .stat-card { flex-direction: column; align-items: flex-start; gap: 8px; padding: 14px; }
    .stat-value { font-size: 1.4rem; }
}

.mini-stat { --tone: var(--brand); border: 1px solid var(--line); border-left: 4px solid var(--tone); border-radius: 10px; padding: 10px 14px; background: #fff; }
.mini-value { font-size: 1.4rem; font-weight: 700; color: var(--tone); line-height: 1.1; font-variant-numeric: tabular-nums; }
.mini-label { font-size: .8rem; color: var(--muted); }
.mini-stat.mini-success { --tone: var(--success); }
.mini-stat.mini-danger { --tone: var(--danger); }
.mini-stat.mini-accent { --tone: color-mix(in srgb, var(--accent) 75%, #000); }
.mini-stat.mini-muted { --tone: #7a8597; }

.badge-soft { display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .76rem; font-weight: 700; white-space: nowrap; }
.badge-soft-success { background: #e3f4ed; color: #0c6245; }
.badge-soft-danger { background: #fde8e6; color: #9d1c12; }
.badge-soft-warning { background: #fdf1d3; color: #7a5200; }
.badge-soft-muted { background: #eceff3; color: #556070; }

/* ---- Tables --------------------------------------------------------------- */
.table { --bs-table-bg: transparent; font-size: .9rem; }
.table thead th {
    font-size: .74rem; letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
    border-bottom: 1px solid var(--line); font-weight: 700; white-space: nowrap;
}
.table td { border-color: #eef1f5; }
div.dt-container div.dt-search input, div.dt-container div.dt-length select { border-radius: 10px; }
.page-link { color: var(--brand); }
.active > .page-link, .page-link.active { background: var(--brand); border-color: var(--brand); }
div.dt-container .dt-layout-row { margin-block: .5rem; }
div.dt-container .dt-layout-table { overflow-x: auto; }

/* ---- Dashboard chart ------------------------------------------------------ */
.legend { font-size: .78rem; color: var(--muted); }
.dot { display: inline-block; width: 9px; height: 9px; border-radius: 50%; margin-right: 4px; }
.dot-success, .bar-success { background: var(--success); }
.dot-danger, .bar-danger { background: #e2705f; }
.bars { display: flex; align-items: flex-end; gap: 10px; height: 210px; }
.bar-col { flex: 1; display: flex; flex-direction: column; align-items: center; height: 100%; }
.bar-stack { flex: 1; width: 100%; max-width: 38px; display: flex; flex-direction: column; justify-content: flex-end; gap: 2px; background: #f3f5f8; border-radius: 8px; overflow: hidden; }
.bar { width: 100%; min-height: 0; }
.bar-total { font-size: .78rem; font-weight: 700; margin-top: 6px; font-variant-numeric: tabular-nums; }
.bar-label { font-size: .72rem; color: var(--muted); }

/* ---- Import ---------------------------------------------------------------- */
.dropzone {
    display: flex; flex-direction: column; align-items: center; text-align: center;
    border: 2px dashed color-mix(in srgb, var(--brand) 35%, #fff); border-radius: var(--radius);
    background: var(--brand-soft); padding: 26px 18px; cursor: pointer;
}
.dropzone > i { font-size: 2.2rem; color: var(--brand); }
.dropzone-title { font-weight: 700; }
.dropzone-hint { font-size: .82rem; color: var(--muted); }
.mode-choice { background: #f8f9fb; border: 1px solid var(--line); border-radius: 12px; padding: 14px 16px; }

/* ---- QR codes -------------------------------------------------------------- */
.qr-card { display: flex; gap: 18px; flex-wrap: wrap; }
.qr-preview { flex: none; width: 190px; padding: 10px; border: 1px solid var(--line); border-radius: 12px; background: #fff; align-self: flex-start; }
.qr-preview img { width: 100%; height: auto; display: block; }
.qr-body { flex: 1; min-width: 240px; }
.qr-name { font-size: 1.05rem; font-weight: 700; margin: 0 0 4px; }
.qr-url { font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace; font-size: .78rem; color: var(--muted); word-break: break-all; margin-bottom: 10px; }
.qr-meta { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: .82rem; color: var(--muted); }

.logo-preview { width: 72px; height: 72px; flex: none; display: flex; align-items: center; justify-content: center; border: 1px solid var(--line); border-radius: 12px; background: #fff; }
.logo-preview-img { width: 56px; height: 56px; object-fit: contain; font-size: 1.1rem; }

/* ==========================================================================
   Printable A4 sheet
   ========================================================================== */
.print-body { background: #dfe3ea; margin: 0; padding: 24px 12px; font-family: var(--font-body); color: var(--ink); }
.print-actions { max-width: 210mm; margin: 0 auto 14px; display: flex; gap: 8px; }
.print-btn {
    border: 0; border-radius: 999px; padding: 10px 22px; font-weight: 700; font-size: .95rem; cursor: pointer;
    background: var(--brand); color: #fff; text-decoration: none; font-family: inherit;
}
.print-btn-light { background: #fff; color: var(--ink); }
.a4-sheet {
    width: 210mm; max-width: 100%; min-height: 297mm; margin: 0 auto; background: #fff; box-sizing: border-box;
    padding: 18mm 18mm 14mm; display: flex; flex-direction: column; align-items: center; text-align: center;
    box-shadow: 0 10px 40px rgba(16, 24, 40, .2);
}
.a4-header { display: flex; align-items: center; gap: 14px; align-self: stretch; text-align: left; }
.a4-logo { width: 22mm; height: 22mm; object-fit: contain; font-size: 1.5rem; flex: none; }
.a4-brand { font-family: var(--font-display); font-size: 17pt; font-weight: 700; color: var(--brand-dark); line-height: 1.2; }
.a4-tagline { font-size: 9pt; letter-spacing: .14em; text-transform: uppercase; color: var(--muted); margin-top: 2px; }
.a4-rule { align-self: stretch; height: 3px; margin: 7mm 0 12mm; background: linear-gradient(90deg, var(--brand) 0 70%, var(--accent) 70% 100%); }
.a4-title { font-family: var(--font-display); font-size: 24pt; color: var(--brand-dark); margin: 0 0 3mm; }
.a4-session { font-size: 12pt; font-weight: 600; color: var(--ink); margin-bottom: 4mm; }
.a4-qr { width: 100mm; height: 100mm; padding: 4mm; border: 1.2mm solid var(--brand); border-radius: 6mm; margin: 8mm 0 5mm; box-sizing: border-box; }
.a4-qr img { width: 100%; height: 100%; display: block; }
.a4-scan { font-size: 12pt; font-weight: 700; color: var(--brand-dark); margin-bottom: 9mm; }
.a4-steps { text-align: left; font-size: 11.5pt; line-height: 1.55; max-width: 150mm; margin: 0 0 7mm; padding-left: 7mm; }
.a4-steps li { margin-bottom: 2.5mm; }
.a4-note { font-size: 9.5pt; color: var(--muted); max-width: 150mm; border-top: 1px solid var(--line); padding-top: 4mm; }
.a4-footer { margin-top: auto; padding-top: 8mm; font-size: 8.5pt; color: var(--muted); font-family: ui-monospace, Menlo, Consolas, monospace; }

@page { size: A4; margin: 0; }
@media print {
    .no-print { display: none !important; }
    .print-body { background: #fff; padding: 0; }
    .a4-sheet { box-shadow: none; width: 210mm; height: 297mm; min-height: 0; }
    * { -webkit-print-color-adjust: exact; print-color-adjust: exact; }
}
