/* Youth CBDC Scholarship portal — small layer on top of Materialize 1.0.0 */
:root {
    --brand-red: #b71c1c;
    --brand-green: #1b5e20;
    --ink: #212121;
    --muted: #555;
}

body {
    font-family: 'Noto Sans Bengali', 'Noto Sans', system-ui, sans-serif;
    color: var(--ink);
    background: #f6f7f9;
    display: flex;
    min-height: 100vh;
    flex-direction: column;
}

main { flex: 1 0 auto; }

/* Noto Sans Bengali everywhere, including form controls (Materialize resets them to the system font). */
body,
input,
select,
textarea,
button,
.btn,
.btn-large,
.btn-small,
.btn-flat {
    font-family: 'Noto Sans Bengali', 'Noto Sans', system-ui, sans-serif;
}

.skip-link {
    position: absolute;
    left: -999px;
    top: 0;
    background: #fff;
    padding: 8px 12px;
    z-index: 2000;
}
.skip-link:focus { left: 8px; }

a:focus-visible, button:focus-visible, input:focus-visible, select:focus-visible, textarea:focus-visible {
    outline: 3px solid #ffb300;
    outline-offset: 2px;
}

/* Navigation */
nav.public-nav { background: var(--brand-red); }
nav .brand { display: flex; align-items: center; gap: 10px; height: 64px; font-size: 1.15rem; white-space: nowrap; }
nav .brand-img { height: 44px; width: 44px; object-fit: contain; background: #fff; border-radius: 50%; padding: 2px; }
nav .brand-text { font-weight: 600; }
nav ul a { font-size: 1rem; }
.sidenav @media (max-width: 600px) {
    nav .brand { height: 56px; font-size: .95rem; left: 12px; transform: none; }
    nav .brand-img { height: 38px; width: 38px; }
    nav.public-nav .brand-text { max-width: 230px; overflow: hidden; text-overflow: ellipsis; }
}

/* Flash messages */
.flash { padding: 12px 16px; border-radius: 6px; margin: 16px 0; font-size: 1rem; border-left: 6px solid; background: #fff; }
.flash-success { border-color: #2e7d32; background: #e8f5e9; }
.flash-warning { border-color: #ef6c00; background: #fff3e0; }
.flash-error { border-color: #c62828; background: #ffebee; }

/* Forms */
.form-field { margin-bottom: 18px; }
.form-field > label { display: block; font-size: 1rem; color: var(--ink); font-weight: 600; margin-bottom: 4px; }
.form-field .hint { color: var(--muted); font-size: .9rem; }
.form-field input[type=text], .form-field input[type=email], .form-field input[type=password], .form-field input[type=tel],
.form-field input[type=number], .form-field input[type=datetime-local], .form-field textarea {
    margin-bottom: 4px;
}
.form-field select.browser-default { border: 1px solid #9e9e9e; border-radius: 4px; height: 3rem; }
.form-field textarea { border: 1px solid #9e9e9e; border-radius: 4px; min-height: 90px; padding: 8px; font-family: inherit; }
.required-mark { color: #c62828; }
.field-error { display: block; color: #c62828; font-size: .95rem; margin-top: 2px; }
.has-error input, .has-error select, .has-error textarea { border-color: #c62828 !important; }
[type="checkbox"] + span:not(.lever), [type="radio"] + span { color: var(--ink); font-size: 1rem; }
.honeypot { position: absolute !important; left: -10000px !important; width: 1px; height: 1px; overflow: hidden; }

/* Public site */
.public-main { padding: 12px 0 32px; }
.hero { text-align: center; padding: 32px 12px 24px; }
.hero-logo { width: 150px; height: 150px; object-fit: contain; }
.hero h1 { font-size: 1.9rem; font-weight: 700; color: var(--brand-red); margin: 12px 0 4px; }
.hero .motto { color: var(--brand-green); font-size: 1.15rem; font-weight: 600; }
.cta-primary.btn-large {
    height: auto; line-height: 1.4; padding: 18px 26px; font-size: 1.35rem; font-weight: 700;
    white-space: normal; border-radius: 10px; background: var(--brand-green); max-width: 100%;
}
.cta-primary.btn-large:hover, .cta-primary.btn-large:focus { background: #2e7d32; }
.section-card { background: #fff; border-radius: 10px; padding: 20px 22px; margin: 18px 0; box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.section-card h2 { font-size: 1.45rem; margin: 0 0 12px; font-weight: 700; }
.step-list .collection-item { font-size: 1.05rem; }
.action-buttons .btn, .action-buttons .btn-large { margin: 6px 8px 6px 0; }
.result-match { border-left: 6px solid var(--brand-green); }
.congrats { background: #e8f5e9; border: 2px solid #2e7d32; border-radius: 8px; padding: 12px 16px; font-size: 1.1rem; margin-top: 10px; }
.public-footer { background: #263238; }
.public-footer a { color: #ffe082; }
.public-footer .footer-copyright { padding-bottom: calc(50px + env(safe-area-inset-bottom, 0px)); }
.footer-copyright-inner { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 4px 16px; }
.footer-title { font-size: 1.2rem; margin: 0 0 8px; font-weight: 700; }
.info-table td, .info-table th { padding: 8px 10px; }

/* Status badges */
.status-badge { display: inline-block; padding: 2px 10px; border-radius: 12px; color: #fff; font-size: .9rem; white-space: nowrap; }

/* Admin */
.admin-main { padding: 16px 24px 40px; max-width: 1400px; margin: 0 auto; width: 100%; }
.admin-main:focus { outline: none; }
.admin-main h1 { font-size: 1.8rem; margin: 8px 0 16px; font-weight: 600; }
.admin-main h2 { font-size: 1.3rem; margin: 0 0 12px; font-weight: 600; }
.page-actions { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 12px; }
.page-head { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: center; gap: 8px; }
.stat-card { background: #fff; border-radius: 8px; padding: 16px; box-shadow: 0 1px 3px rgba(0,0,0,.12); margin-bottom: 12px; }
.stat-card .stat-value { font-size: 2rem; font-weight: 700; }
.stat-card .stat-label { color: var(--muted); }
.table-wrap { overflow-x: auto; background: #fff; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.table-wrap table { min-width: 720px; }
.table-wrap th, .table-wrap td { padding: 8px 10px; vertical-align: top; }
.filters { background: #fff; padding: 12px 16px 4px; border-radius: 8px; margin-bottom: 12px; box-shadow: 0 1px 3px rgba(0,0,0,.12); }
.filters .form-field { margin-bottom: 8px; }
.bulk-bar { background: #eceff1; padding: 10px 14px; border-radius: 8px; margin: 12px 0; }
.bulk-bar .form-field { margin-bottom: 6px; }
.empty-state { text-align: center; padding: 32px 12px; color: var(--muted); }
.panel { background: #fff; padding: 16px 18px; border-radius: 8px; box-shadow: 0 1px 3px rgba(0,0,0,.12); margin-bottom: 16px; }
.detail-list { display: grid; grid-template-columns: max-content 1fr; gap: 6px 16px; margin: 0; }
.detail-list dt { font-weight: 600; color: var(--muted); }
.detail-list dd { margin: 0; word-break: break-word; }
.muted { color: var(--muted); }
.btn-small-inline { margin: 2px 0; }
.login-card { max-width: 420px; margin: 40px auto; }
@media (max-width: 600px) {
    .admin-main { padding: 12px 12px 32px; }
    .detail-list { grid-template-columns: 1fr; }
    .detail-list dt { margin-top: 6px; }
}

/* ---------- Admin shell: left sidebar + drawer ---------- */
:root { --sidebar-width: 264px; --sidebar-bg: #1f2a30; --sidebar-fg: #cfd8dc; --topbar-h: 56px; }

.admin-sidebar {
    position: fixed; top: 0; bottom: 0; left: 0; z-index: 1001;
    width: var(--sidebar-width); max-width: 86vw;
    display: flex; flex-direction: column;
    background: var(--sidebar-bg); color: var(--sidebar-fg);
    transition: transform .25s ease, visibility .25s;
}
.sidebar-brand { display: flex; align-items: center; justify-content: space-between; padding: 14px 12px 14px 16px; border-bottom: 1px solid rgba(255,255,255,.08); }
.sidebar-brand-link { display: flex; align-items: center; gap: 10px; color: #fff; }
.sidebar-brand-link strong { display: block; font-size: 1.05rem; line-height: 1.2; }
.sidebar-brand-link small { display: block; color: #b0bec5; font-size: .82rem; }
.sidebar-logo { width: 42px; height: 42px; object-fit: contain; background: #fff; border-radius: 50%; padding: 2px; }
.sidebar-close { display: none; background: none; border: 0; color: #fff; cursor: pointer; padding: 6px; border-radius: 50%; }
.sidebar-close:hover { background: rgba(255,255,255,.1); }

.admin-sidebar nav.sidebar-nav {
    flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain;
    height: auto; line-height: normal; background: transparent; box-shadow: none; color: inherit; padding: 6px 0 12px;
}
/* Neutralise Materialize's global top-bar `nav` styles inside the sidebar. */
.admin-sidebar nav.sidebar-nav ul li { float: none; padding: 0; }
.admin-sidebar nav.sidebar-nav ul a { padding: 9px 12px; font-size: .98rem; color: var(--sidebar-fg); }
.admin-sidebar nav.sidebar-nav ul a:hover { background: rgba(255,255,255,.07); color: #fff; }
.admin-sidebar nav.sidebar-nav ul a.is-active { background: #b71c1c; color: #fff; }
.admin-sidebar nav.sidebar-nav i.material-icons { display: inline-block; height: auto; line-height: 1; float: none; }
.sidebar-heading { margin: 14px 18px 4px; font-size: .72rem; letter-spacing: .08em; text-transform: uppercase; color: #78909c; font-weight: 600; }
.sidebar-nav ul { margin: 0; }
.sidebar-link {
    display: flex; align-items: center; gap: 14px; width: calc(100% - 16px); margin: 1px 8px; padding: 9px 12px;
    border-radius: 8px; color: var(--sidebar-fg); font-size: .98rem; line-height: 1.3;
    background: none; border: 0; cursor: pointer; text-align: left; font-family: inherit;
}
.sidebar-link i.material-icons { font-size: 21px; color: #90a4ae; }
.sidebar-link:hover { background: rgba(255,255,255,.07); color: #fff; }
.sidebar-link.is-active { background: #b71c1c; color: #fff; font-weight: 600; }
.sidebar-link.is-active i.material-icons { color: #fff; }
.sidebar-link:focus-visible { outline: 3px solid #ffb300; outline-offset: -3px; }
.sidebar-footer { border-top: 1px solid rgba(255,255,255,.08); padding: 10px 0 12px; }
.sidebar-user { display: flex; align-items: center; gap: 10px; padding: 4px 20px 8px; min-width: 0; }
.sidebar-user i.material-icons { font-size: 30px; color: #90a4ae; }
.sidebar-user span { min-width: 0; }
.sidebar-user strong { display: block; color: #fff; font-size: .92rem; }
.sidebar-user small { display: block; color: #90a4ae; font-size: .8rem; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sidebar-logout:hover { background: rgba(198,40,40,.35); }

.admin-shell { margin-left: var(--sidebar-width); min-height: 100vh; display: flex; flex-direction: column; transition: margin-left .25s ease; }
.admin-topbar {
    position: sticky; top: 0; z-index: 900; height: var(--topbar-h);
    display: flex; align-items: center; gap: 8px; padding: 0 16px 0 8px;
    background: #fff; box-shadow: 0 1px 3px rgba(0,0,0,.12);
}
.topbar-toggle { background: none; border: 0; cursor: pointer; width: 44px; height: 44px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center; color: #37474f; }
.topbar-toggle:hover { background: #eceff1; }
.topbar-title { flex: 1 1 auto; font-size: 1.1rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-user { display: inline-flex; align-items: center; gap: 6px; color: var(--muted); }

.admin-overlay { position: fixed; inset: 0; z-index: 1000; background: rgba(0,0,0,.45); opacity: 0; visibility: hidden; transition: opacity .25s ease, visibility .25s; }

/* Desktop: sidebar docked, toggle collapses it (remembered per browser). */
@media (min-width: 993px) {
    .sidebar-collapsed .admin-sidebar { transform: translateX(-100%); visibility: hidden; }
    .sidebar-collapsed .admin-shell { margin-left: 0; }
}

/* Tablet & mobile: off-canvas drawer. */
@media (max-width: 992px) {
    .admin-sidebar { transform: translateX(-100%); visibility: hidden; box-shadow: 0 0 24px rgba(0,0,0,.35); }
    .admin-shell { margin-left: 0; }
    .sidebar-close { display: inline-flex; }
    /* Visibility flips instantly on open so focus can move into the drawer; it stays delayed on close for the slide-out. */
    .drawer-open .admin-sidebar { transform: translateX(0); visibility: visible; transition: transform .25s ease, visibility 0s; }
    .drawer-open .admin-overlay { opacity: 1; visibility: visible; }
    .drawer-open body { overflow: hidden; }
}

@media (prefers-reduced-motion: reduce) {
    .admin-sidebar, .admin-shell, .admin-overlay { transition: none; }
}

.admin-guest-main { max-width: 460px; margin: 48px auto; padding: 0 16px; width: 100%; }
.admin-guest-brand { display: flex; align-items: center; justify-content: center; gap: 12px; margin-bottom: 16px; font-size: 1.3rem; font-weight: 600; }
.admin-guest-brand img { width: 56px; height: 56px; object-fit: contain; }

@media print {
    .admin-sidebar, .admin-topbar, .admin-overlay, .skip-link { display: none !important; }
    .admin-shell { margin-left: 0 !important; }
}

/* ---------- Audit log ---------- */
.event-badge { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px 2px 6px; border-radius: 14px; color: #fff; font-size: .85rem; white-space: nowrap; }
.event-badge i.material-icons { font-size: 16px; }
.change-list { margin: 0; padding: 0; list-style: none; }
.change-list li { padding: 2px 0; line-height: 1.45; }
.change-list .change-field { font-weight: 600; }
.change-from { color: #b71c1c; text-decoration: line-through; text-decoration-thickness: 1px; }
.change-to { color: #1b5e20; font-weight: 600; }
.change-arrow { color: var(--muted); margin: 0 4px; }
.change-tag { display: inline-block; font-size: .72rem; text-transform: uppercase; letter-spacing: .04em; padding: 0 6px; margin-left: 4px; border-radius: 8px; background: #eceff1; color: #455a64; vertical-align: middle; }
.audit-time small { display: block; color: var(--muted); }

@media (max-width: 760px) {
    .audit-table { min-width: 0 !important; }
    .audit-table thead { position: absolute; left: -10000px; }
    .audit-table tr { display: block; border-bottom: 1px solid #e0e0e0; padding: 8px 4px; }
    .audit-table td { display: block; border: 0; padding: 3px 8px !important; }
    .audit-table td[data-label]::before { content: attr(data-label); display: block; font-size: .75rem; text-transform: uppercase; color: var(--muted); letter-spacing: .04em; }
}

/* Admin edit page: exam result section */
.exam-result-fieldset { border: 1px solid #cfd8dc; border-radius: 8px; padding: 8px 16px 0; margin: 8px 0 20px; }
.exam-result-fieldset legend { padding: 0 6px; font-weight: 600; font-size: 1.05rem; }

/* Public registration: "already registered" notice */
.duplicate-alert p { margin: 0 0 10px; line-height: 1.6; }
.duplicate-alert .btn { margin-top: 2px; }

/* ---------- Searchable select (public/js/combobox.js) ---------- */
.cbx-native { display: none !important; }
.cbx { position: relative; }
.cbx-trigger {
    display: flex; align-items: center; gap: 8px; width: 100%; min-height: 3rem; padding: 8px 8px 8px 12px;
    border: 1px solid #9e9e9e; border-radius: 4px; background: #fff; color: var(--ink);
    font: inherit; font-size: 1rem; line-height: 1.4; text-align: left; cursor: pointer;
}
.cbx-trigger:hover { border-color: #616161; }
/* Materialize paints every focused <button> teal; keep the picker looking like a field. */
.cbx-trigger:focus { background-color: #fff; }
.cbx-clear:focus, .cbx-close:focus { background-color: transparent; }
.cbx-trigger:focus-visible, .cbx.is-open .cbx-trigger { border-color: #1565c0; box-shadow: 0 0 0 2px rgba(21, 101, 192, .25); outline: none; }
.cbx-trigger.is-placeholder .cbx-value { color: #757575; }
.cbx-value { flex: 1 1 auto; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.cbx-chevron { flex: none; color: #616161; transition: transform .15s ease; }
.cbx.is-open .cbx-chevron { transform: rotate(180deg); }
.has-error .cbx-trigger { border-color: #c62828; }

.cbx-panel {
    position: absolute; z-index: 60; top: calc(100% + 4px); left: 0; right: 0;
    display: flex; flex-direction: column; background: #fff;
    border: 1px solid #cfd8dc; border-radius: 8px; box-shadow: 0 8px 24px rgba(0, 0, 0, .18); overflow: hidden;
}
.cbx-panel[hidden] { display: none; }
.cbx-header { display: none; }
.cbx-search { display: flex; align-items: center; gap: 6px; padding: 8px 8px 8px 12px; border-bottom: 1px solid #eceff1; }
.cbx-search-icon { color: #757575; flex: none; }
.cbx-input {
    flex: 1 1 auto; min-width: 0; height: 2.6rem; padding: 0 4px; margin: 0;
    border: 0; outline: none; background: transparent; font: inherit; font-size: 16px; color: var(--ink);
    -webkit-appearance: none; appearance: none;
}
.cbx-input::-webkit-search-cancel-button { -webkit-appearance: none; display: none; }
.cbx-clear, .cbx-close {
    flex: none; display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px;
    border: 0; border-radius: 50%; background: none; color: #757575; cursor: pointer;
}
.cbx-clear:hover, .cbx-close:hover { background: #eceff1; }
.cbx-clear[hidden] { display: none; }
.cbx-meta { padding: 6px 14px; font-size: .85rem; color: var(--muted); background: #fafafa; border-bottom: 1px solid #eceff1; }
.cbx-list { list-style: none; margin: 0; padding: 4px 0; max-height: 320px; overflow-y: auto; overscroll-behavior: contain; outline: none; }
.cbx-list[hidden] { display: none; }
.cbx-option {
    display: flex; align-items: center; gap: 10px; min-height: 44px; padding: 10px 14px;
    font-size: 1rem; line-height: 1.45; cursor: pointer; border-bottom: 1px solid #f5f5f5;
}
.cbx-option-text { flex: 1 1 auto; min-width: 0; overflow-wrap: anywhere; }
.cbx-option mark { background: #fff59d; color: inherit; padding: 0; border-radius: 2px; }
.cbx-option .cbx-check { visibility: hidden; color: #2e7d32; flex: none; }
.cbx-option.is-selected { font-weight: 600; }
.cbx-option.is-selected .cbx-check { visibility: visible; }
.cbx-option.is-active { background: #e3f2fd; }
.cbx-option:active { background: #bbdefb; }
.cbx-option--empty { color: var(--muted); font-style: italic; }
.cbx-empty { padding: 20px 16px; color: var(--muted); text-align: center; line-height: 1.6; }
.cbx-empty[hidden] { display: none; }

/* Phones: full-screen search sheet. */
@media (max-width: 600px) {
    .cbx-panel {
        position: fixed; z-index: 2000; inset: 0; top: 0; height: 100vh; height: 100dvh;
        border: 0; border-radius: 0; box-shadow: none;
    }
    .cbx-header {
        display: flex; align-items: center; justify-content: space-between; gap: 8px;
        padding: 6px 6px 6px 16px; background: var(--brand-red, #b71c1c); color: #fff;
    }
    .cbx-title { font-size: 1.05rem; font-weight: 600; }
    .cbx-close { color: #fff; width: 44px; height: 44px; }
    .cbx-close:hover { background: rgba(255, 255, 255, .15); }
    .cbx-search { padding: 10px 8px 10px 14px; background: #fff; box-shadow: 0 1px 3px rgba(0, 0, 0, .08); }
    .cbx-input { height: 2.9rem; font-size: 17px; }
    .cbx-list { flex: 1 1 auto; max-height: none; -webkit-overflow-scrolling: touch; padding-bottom: 24px; }
    .cbx-option { min-height: 52px; padding: 12px 16px; font-size: 1.05rem; }
    .cbx-trigger { min-height: 3.2rem; }
}
html.cbx-locked, html.cbx-locked body { overflow: hidden; }

/* Pagination: Materialize styles every <nav> as the coloured top bar, so reset it here. */
nav.pager { height: auto; line-height: normal; background: transparent; box-shadow: none; color: var(--ink); margin: 16px 0 8px; }
nav.pager .pagination { display: flex; flex-wrap: wrap; align-items: center; gap: 4px; margin: 0; }
nav.pager .pagination li { float: none; height: auto; display: inline-flex; border-radius: 6px; }
nav.pager .pagination li a, nav.pager .pagination li span {
    display: inline-flex; align-items: center; justify-content: center; min-width: 40px; height: 40px; padding: 0 10px;
    border: 1px solid #cfd8dc; border-radius: 6px; background: #fff; color: var(--ink); font-size: 1rem; line-height: 1;
}
nav.pager .pagination li a:hover { background: #eceff1; }
nav.pager .pagination li.active a { background: var(--brand-red, #b71c1c); border-color: var(--brand-red, #b71c1c); color: #fff; font-weight: 600; }
nav.pager .pagination li.disabled span { color: #b0bec5; border-color: #eceff1; }
nav.pager .pagination li i.material-icons { font-size: 22px; line-height: 1; height: auto; float: none; }
