/* Sure Key Examinations Board – application styles (on top of Bootstrap 4) */

:root {
    --brand: #f2ae27;
    --brand-dark: #c98a0f;
    --brand-soft: #fdf3dc;
    --ink: #1b2437;
    --sidebar: #17213a;
    --sidebar-ink: #c4cbe0;
    --muted: #6b7280;
    --bg: #f4f5f9;
    --card: #ffffff;
    --border: #e4e7ee;
    --success: #15803d;
    --danger: #c62828;
    --info: #1d4ed8;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
    --sidebar-width: 248px;
}

html, body { height: 100%; }

body {
    background: var(--bg);
    color: var(--ink);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    font-size: 14px;
    -webkit-font-smoothing: antialiased;
}

a { color: #a86f00; }
a:hover { color: var(--brand-dark); }

.icon { flex: none; vertical-align: -0.2em; }

/* ---------- Shell ---------- */

.sidebar {
    position: fixed; inset: 0 auto 0 0;
    width: var(--sidebar-width);
    background: var(--sidebar);
    color: var(--sidebar-ink);
    display: flex; flex-direction: column;
    z-index: 1040;
    transition: transform .2s ease;
}

.sidebar-brand {
    display: flex; align-items: center; gap: 12px;
    padding: 18px 20px;
    color: #fff; text-decoration: none;
    border-bottom: 1px solid rgba(255, 255, 255, .06);
}
.sidebar-brand:hover { color: #fff; text-decoration: none; }
.sidebar-brand img { width: 40px; height: 40px; border-radius: 8px; background: #fff; padding: 3px; object-fit: contain; }
.sidebar-brand strong { display: block; font-size: 15px; letter-spacing: .2px; }
.sidebar-brand small { display: block; color: var(--sidebar-ink); font-size: 11px; opacity: .8; }

.sidebar-nav { flex: 1; overflow-y: auto; padding: 12px 0 20px; }
.sidebar-nav .nav-section {
    padding: 16px 20px 6px;
    font-size: 10.5px; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
    color: #7c87a6;
}
.sidebar-nav a {
    display: flex; align-items: center; gap: 12px;
    margin: 1px 10px; padding: 9px 12px;
    color: var(--sidebar-ink); border-radius: 8px;
    text-decoration: none; font-weight: 500;
}
.sidebar-nav a:hover { background: rgba(255, 255, 255, .06); color: #fff; }
.sidebar-nav a.active { background: var(--brand); color: #1b1300; }
.sidebar-nav a.active .icon { color: #1b1300; }

.sidebar-footer {
    padding: 14px 20px; font-size: 12px;
    border-top: 1px solid rgba(255, 255, 255, .06);
}
.sidebar-footer a { color: var(--sidebar-ink); }

.main { margin-left: var(--sidebar-width); min-height: 100vh; display: flex; flex-direction: column; }

.topbar {
    position: sticky; top: 0; z-index: 1030;
    height: 60px;
    display: flex; align-items: center; gap: 12px;
    padding: 0 24px;
    background: rgba(255, 255, 255, .92);
    backdrop-filter: blur(6px);
    border-bottom: 1px solid var(--border);
}
.topbar .menu-toggle { display: none; }
.topbar .org { font-weight: 600; color: var(--muted); }
.topbar .user-menu { margin-left: auto; }
.topbar .user-menu .btn { display: flex; align-items: center; gap: 10px; }
.avatar {
    width: 32px; height: 32px; border-radius: 50%;
    display: inline-flex; align-items: center; justify-content: center;
    background: var(--brand-soft); color: var(--brand-dark); font-weight: 700; font-size: 13px;
}

.content { padding: 24px; flex: 1; }
.app-footer { padding: 16px 24px; color: var(--muted); font-size: 12px; border-top: 1px solid var(--border); background: #fff; }
.app-footer a { color: var(--muted); }

.impersonation-bar {
    background: #fff4d6; border-bottom: 1px solid #f3d27a;
    padding: 8px 24px; display: flex; align-items: center; gap: 12px; font-size: 13px;
}

.sidebar-backdrop { display: none; }

@media (max-width: 991.98px) {
    .sidebar { transform: translateX(-100%); }
    body.sidebar-open .sidebar { transform: none; }
    body.sidebar-open .sidebar-backdrop {
        display: block; position: fixed; inset: 0; background: rgba(15, 23, 42, .4); z-index: 1035;
    }
    .main { margin-left: 0; }
    .topbar { padding: 0 16px; }
    .topbar .menu-toggle { display: inline-flex; }
    .topbar .org { display: none; }
    .content { padding: 16px; }
}

/* ---------- Page header ---------- */

.page-head {
    display: flex; flex-wrap: wrap; align-items: flex-end; justify-content: space-between; gap: 12px;
    margin-bottom: 20px;
}
.page-head h1 { font-size: 22px; font-weight: 700; margin: 0; }
.page-head .subtitle { color: var(--muted); margin-top: 4px; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; }

.breadcrumbs { font-size: 12px; color: var(--muted); margin-bottom: 4px; }
.breadcrumbs a { color: var(--muted); }

/* ---------- Cards ---------- */

.card {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    margin-bottom: 20px;
}
.card-header {
    background: #fff; border-bottom: 1px solid var(--border);
    padding: 14px 20px;
    display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap;
}
.card-header h2, .card-header h3 { font-size: 15px; font-weight: 600; margin: 0; }
.card-header:first-child { border-radius: var(--radius) var(--radius) 0 0; }
.card-body { padding: 20px; }

.stat {
    display: flex; align-items: center; gap: 16px;
    padding: 18px 20px; background: #fff;
    border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
    height: 100%;
}
.stat .stat-icon {
    width: 46px; height: 46px; border-radius: 12px;
    display: flex; align-items: center; justify-content: center;
    background: var(--brand-soft); color: var(--brand-dark);
}
.stat .stat-icon.blue { background: #e7efff; color: var(--info); }
.stat .stat-icon.green { background: #e3f6ea; color: var(--success); }
.stat .stat-icon.red { background: #fde8e8; color: var(--danger); }
.stat .value { font-size: 24px; font-weight: 700; line-height: 1.1; }
.stat .label { color: var(--muted); font-size: 12.5px; }

.empty-state { text-align: center; padding: 48px 20px; color: var(--muted); }
.empty-state .icon { color: #c2c8d6; margin-bottom: 10px; }
.empty-state h3 { font-size: 16px; color: var(--ink); }

/* ---------- Buttons & forms ---------- */

.btn { border-radius: 8px; font-weight: 500; display: inline-flex; align-items: center; gap: 6px; }
.btn-sm { padding: .3rem .6rem; }
.btn-brand { background: var(--brand); border-color: var(--brand); color: #1b1300; }
.btn-brand:hover, .btn-brand:focus { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }
.btn-light { background: #fff; border-color: var(--border); }
.btn-light:hover { background: #f3f4f6; }
.btn-icon { padding: .3rem .45rem; }

.form-control, .custom-select { border-radius: 8px; border-color: #d6dae3; }
.form-control:focus, .custom-select:focus { border-color: var(--brand); box-shadow: 0 0 0 .2rem rgba(242, 174, 39, .2); }
label { font-weight: 500; font-size: 13px; margin-bottom: 4px; }
.form-text { font-size: 12px; }
.required::after { content: " *"; color: var(--danger); }

.filter-bar {
    display: flex; flex-wrap: wrap; align-items: flex-end; gap: 12px;
    padding: 16px 20px; background: #fff;
    border: 1px solid var(--border); border-radius: var(--radius); box-shadow: var(--shadow);
    margin-bottom: 20px;
}
.filter-bar .form-group { margin: 0; min-width: 170px; flex: 1 1 170px; }
.filter-bar .form-group.wide { flex: 2 1 260px; }
.filter-bar .filter-actions { display: flex; gap: 8px; }

.modal-content { border-radius: var(--radius); border: 0; }
.modal-header { border-bottom-color: var(--border); }
.modal-footer { border-top-color: var(--border); }

/* ---------- Tables ---------- */

.table { color: var(--ink); margin-bottom: 0; }
.table thead th {
    background: #f8f9fc; color: #4b5563;
    font-size: 11.5px; font-weight: 600; text-transform: uppercase; letter-spacing: .04em;
    border-bottom: 1px solid var(--border); border-top: 0; white-space: nowrap;
}
.table td { vertical-align: middle; border-top-color: #eef0f4; }
.table-hover tbody tr:hover { background: #fffaf0; }
.table .num, .table th.num { text-align: center; }
.table-sm td, .table-sm th { padding: .4rem .5rem; }
.table tfoot td, .table tfoot th { font-weight: 700; background: #f8f9fc; }
.table-compact { font-size: 12.5px; }

.thumb { width: 38px; height: 38px; border-radius: 8px; object-fit: cover; background: #f1f2f6; }
.thumb-lg { width: 64px; height: 64px; border-radius: 12px; object-fit: contain; background: #fff; border: 1px solid var(--border); }

.badge { font-weight: 600; padding: .35em .6em; border-radius: 6px; }
.badge-soft { background: #eef1f6; color: #374151; }
.badge-brand { background: var(--brand-soft); color: #8a5a00; }
.div-badge { min-width: 34px; display: inline-block; text-align: center; }
.div-1 { background: #dcfce7; color: #166534; }
.div-2 { background: #dbeafe; color: #1e40af; }
.div-3 { background: #fef3c7; color: #92400e; }
.div-4 { background: #ffedd5; color: #9a3412; }
.div-U { background: #fee2e2; color: #991b1b; }
.div-X { background: #e5e7eb; color: #374151; }

.progress { height: 8px; border-radius: 999px; background: #eef0f4; }
.progress-bar { background: var(--brand); }

.stacked-bar { display: flex; height: 14px; border-radius: 999px; overflow: hidden; background: #eef0f4; }
.stacked-bar span { display: block; height: 100%; }
.legend { display: flex; flex-wrap: wrap; gap: 14px; font-size: 12px; color: var(--muted); }
.legend i { display: inline-block; width: 10px; height: 10px; border-radius: 3px; margin-right: 5px; vertical-align: -1px; }
.bg-div-1 { background: #22c55e; } .bg-div-2 { background: #3b82f6; } .bg-div-3 { background: #f59e0b; }
.bg-div-4 { background: #f97316; } .bg-div-U { background: #ef4444; } .bg-div-X { background: #9ca3af; }

/* DataTables tweaks */
.dataTables_wrapper .dataTables_filter input { border-radius: 8px; border: 1px solid #d6dae3; padding: 4px 10px; margin-left: 6px; }
.dataTables_wrapper .dt-buttons .btn { margin-right: 6px; }
.dataTables_wrapper .dataTables_info { color: var(--muted); font-size: 12px; }
.dt-toolbar { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 10px; padding: 12px 16px; }
.dataTables_wrapper .dataTables_filter { margin: 0; }
.dataTables_wrapper .row { margin: 0; }
.page-item.active .page-link { background: var(--brand); border-color: var(--brand); color: #1b1300; }
.page-link { color: #8a5a00; }

/* Select2 */
.select2-container--default .select2-selection--single,
.select2-container--default .select2-selection--multiple { border-color: #d6dae3; border-radius: 8px; min-height: calc(1.5em + .75rem + 2px); }
.select2-container--default .select2-selection--single .select2-selection__rendered { line-height: calc(1.5em + .75rem); }
.select2-container--default .select2-selection--single .select2-selection__arrow { height: calc(1.5em + .75rem); }
.select2-container--default .select2-results__option--highlighted[aria-selected] { background: var(--brand); color: #1b1300; }
.select2-container { width: 100% !important; }

/* ---------- Mark entry ---------- */

.marks-grid td.mark-cell { padding: 4px; min-width: 92px; }
.mark-input-wrap { position: relative; }
.mark-input {
    width: 100%; text-align: center; font-weight: 600;
    border: 1px solid #d6dae3; border-radius: 6px; padding: 6px 4px 6px 4px;
}
.mark-input:focus { outline: none; border-color: var(--brand); box-shadow: 0 0 0 .15rem rgba(242, 174, 39, .25); }
.mark-input.is-saving { border-color: #93c5fd; background: #f0f7ff; }
.mark-input.is-saved { border-color: #86efac; background: #f0fdf4; }
.mark-input.is-error { border-color: #fca5a5; background: #fef2f2; }
.mark-grade { position: absolute; right: 6px; top: 50%; transform: translateY(-50%); font-size: 10px; color: var(--muted); pointer-events: none; }
.save-status { font-size: 12.5px; color: var(--muted); min-height: 20px; }
.save-status.error { color: var(--danger); }
.sticky-col { position: sticky; left: 0; background: #fff; z-index: 1; }

/* ---------- Guest pages (login, parent portal, licence) ---------- */

.guest {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    padding: 32px 16px;
    background: radial-gradient(1200px 600px at 10% -10%, #fff3d6 0, transparent 60%), radial-gradient(900px 500px at 110% 110%, #e8edff 0, transparent 55%), var(--bg);
}
.guest-card {
    width: 100%; max-width: 440px;
    background: #fff; border-radius: 16px; border: 1px solid var(--border);
    box-shadow: 0 20px 45px rgba(16, 24, 40, .08);
    padding: 32px;
}
.guest-card.wide { max-width: 860px; }
.guest-brand { text-align: center; margin-bottom: 24px; }
.guest-brand img { width: 72px; height: 72px; object-fit: contain; }
.guest-brand h1 { font-size: 18px; font-weight: 700; margin: 12px 0 2px; }
.guest-brand p { color: var(--muted); margin: 0; }
.guest-links { text-align: center; margin-top: 18px; font-size: 13px; color: var(--muted); }

/* ---------- Printable documents (broadsheet, certificates) ---------- */

.doc-header { display: flex; align-items: center; justify-content: space-between; gap: 20px; }
.doc-header .doc-org { text-align: right; font-size: 12.5px; }
.doc-header .doc-org h4 { font-size: 14px; font-weight: 700; text-transform: uppercase; margin-bottom: 4px; }
.doc-header .doc-meta p { margin: 0 0 2px; font-size: 13px; }
.doc-header img.doc-logo { width: 96px; height: 96px; object-fit: contain; }

.summary-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(110px, 1fr)); gap: 10px; }
.summary-grid .cell { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; background: #fafbfd; }
.summary-grid .cell .k { font-size: 11px; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.summary-grid .cell .v { font-size: 18px; font-weight: 700; }

.certificate {
    background: #fef6dc; border: 6px double #d9a441; border-radius: 6px;
    padding: 28px 32px; margin: 0 auto 28px; max-width: 900px; color: #111;
}
.certificate .cert-header { text-align: center; }
.certificate .cert-header img { max-width: 100%; }
.certificate .cert-intro { display: grid; grid-template-columns: 1fr 140px; gap: 20px; align-items: center; margin: 18px 0; }
.certificate .cert-intro p { font-size: 13.5px; text-align: center; margin-bottom: 8px; }
.certificate .cert-photo { width: 130px; height: 130px; object-fit: cover; border: 3px solid #fff; box-shadow: 0 0 0 1px #d9a441; }
.certificate .cert-results { background: #fce59a; border-radius: 6px; padding: 18px 22px; }
.certificate .cert-results h5 { text-transform: uppercase; font-weight: 700; font-size: 14px; }
.certificate .cert-candidate { display: grid; grid-template-columns: 2fr 1fr 1fr 1.4fr; gap: 10px; text-transform: uppercase; font-weight: 600; margin: 12px 0; }
.certificate .cert-row { display: grid; grid-template-columns: 1fr 1fr; padding: 5px 0; border-bottom: 1px dashed rgba(0, 0, 0, .12); text-transform: uppercase; }
.certificate .cert-total { display: grid; grid-template-columns: 1fr 1fr; margin-top: 18px; text-align: center; font-weight: 700; text-transform: uppercase; }

.page-break { break-after: page; page-break-after: always; }

@media print {
    @page { margin: 10mm; }
    body { background: #fff; font-size: 11px; }
    .sidebar, .topbar, .app-footer, .impersonation-bar, .no-print, .filter-bar,
    .dt-buttons, .dataTables_filter, .dataTables_info, .dataTables_paginate, .dataTables_length, .alert { display: none !important; }
    .main { margin: 0; }
    .content { padding: 0; }
    .card { box-shadow: none; border: 0; margin: 0; }
    .card-body { padding: 0; }
    .table-responsive { overflow: visible; }
    .table thead th { background: #eee !important; -webkit-print-color-adjust: exact; print-color-adjust: exact; }
    .certificate, .certificate .cert-results, [class*="div-"], .bg-div-1, .bg-div-2, .bg-div-3, .bg-div-4, .bg-div-U, .bg-div-X {
        -webkit-print-color-adjust: exact; print-color-adjust: exact;
    }
    .certificate { margin: 0 auto; }
    a[href]::after { content: none !important; }
}
