/* Exam module: printable sheets (Pages/Print), the public result page and the mark entry grid. */

:root {
    /* Malayalam first, then Arabic for student names; the browser falls back per glyph. */
    --sheet-font: "Noto Sans Malayalam", "Nirmala UI", "Kartika", "Noto Naskh Arabic", "Traditional Arabic", "Segoe UI", Arial, sans-serif;
}

/* ---------- Print shell: grey desk, white A4 sheets, toolbar hidden on paper ---------- */
.print-shell {
    background: #e9ecef;
    min-height: 100vh;
    padding: 16px 8px 40px;
}

.print-toolbar {
    position: sticky;
    top: 8px;
    z-index: 10;
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    justify-content: space-between;
    max-width: 210mm;
    margin: 0 auto 12px;
    padding: 8px 12px;
    background: #fff;
    border-radius: 6px;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .15);
}

.sheet-page {
    width: 210mm;
    max-width: 100%;
    min-height: 297mm;
    margin: 0 auto 12px;
    padding: 10mm;
    background: #fff;
    color: #000;
    box-shadow: 0 1px 4px rgba(0, 0, 0, .15);
    font-family: var(--sheet-font);
    font-size: 11pt;
    line-height: 1.3;
}

.sheet-page * {
    color: #000;
}

.sheet-empty {
    max-width: 210mm;
    margin: 40px auto;
    padding: 24px;
    background: #fff;
    border-radius: 6px;
    text-align: center;
}

/* ---------- Sheet header (board, exam, title, centre) ---------- */
.sheet-head {
    text-align: center;
    margin-bottom: 4mm;
}

.sheet-board {
    font-size: 17pt;
    font-weight: 700;
}

.sheet-address {
    font-size: 11pt;
    font-weight: 600;
}

.sheet-exam {
    font-size: 11pt;
    font-weight: 600;
}

.sheet-title-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 4mm;
    margin-top: 2mm;
}

.sheet-title {
    display: inline-block;
    border: 1.5px solid #000;
    padding: 1mm 5mm;
    font-size: 14pt;
    font-weight: 700;
}

.class-pill {
    display: inline-block;
    background: #000;
    color: #fff !important;
    border-radius: 50%;
    padding: 2mm 6mm;
    font-weight: 700;
    white-space: nowrap;
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
}

.box-label {
    display: inline-block;
    border: 1.5px solid #000;
    padding: 0.5mm 2mm;
    font-weight: 700;
    white-space: nowrap;
}

.sheet-center-line {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    gap: 2mm 6mm;
    font-size: 10pt;
    font-weight: 600;
    margin: 3mm 0 2mm;
}

/* ---------- Sheet tables ---------- */
.sheet-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 10pt;
}

.sheet-table th,
.sheet-table td {
    border: 1px solid #000;
    padding: 1mm 1.5mm;
    vertical-align: middle;
}

.sheet-table th {
    text-align: center;
    font-weight: 700;
    font-size: 9pt;
}

.sheet-table thead {
    display: table-header-group;
}

.sheet-table tr {
    break-inside: avoid;
    page-break-inside: avoid;
}

.sheet-table .num {
    text-align: center;
    white-space: nowrap;
}

.sheet-table .name {
    font-size: 11pt;
    min-width: 45mm;
}

.sheet-table .fail {
    font-weight: 700;
}

.sheet-table.tall td {
    height: 8mm;
}

.sheet-note {
    margin-top: 5mm;
    text-align: center;
    font-weight: 600;
}

.sheet-signatures {
    margin-top: 8mm;
    display: grid;
    grid-template-columns: 2fr 1fr 1fr;
    gap: 5mm 6mm;
    font-weight: 600;
    font-size: 10pt;
}

.sheet-signatures .dots {
    border-bottom: 1px dotted #000;
    display: inline-block;
    min-width: 25mm;
}

.sheet-provisional {
    border: 1.5px dashed #000;
    text-align: center;
    font-weight: 700;
    padding: 1mm;
    margin-bottom: 3mm;
}

/* ---------- Hall tickets: 2 x 4 cards per A4 page ---------- */
.ht-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    grid-auto-rows: 61mm;
    gap: 7mm 8mm;
}

.ht-card {
    border: 2px solid #000;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    break-inside: avoid;
    page-break-inside: avoid;
}

.ht-top {
    padding: 2mm 3mm;
    text-align: center;
    flex: 0 0 auto;
}

.ht-board {
    font-weight: 700;
    font-size: 10.5pt;
}

.ht-exam {
    display: inline-block;
    font-weight: 600;
    font-size: 9.5pt;
    border-bottom: 1px solid #000;
    margin-bottom: 1.5mm;
}

.ht-ids {
    display: flex;
    align-items: center;
    justify-content: space-between;
    text-align: left;
}

.ht-ids .box-label {
    display: block;
    width: fit-content;
    margin-bottom: -1.5px;
    font-size: 10pt;
}

.ht-ids .box-label b {
    font-size: 12pt;
}

.ht-tag {
    font-size: 7.5pt;
    letter-spacing: .08em;
    text-transform: uppercase;
    text-align: center;
    font-weight: 700;
}

.ht-bottom {
    border-top: 2px solid #000;
    padding: 2mm 3mm;
    flex: 1 1 auto;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 1mm;
    font-size: 11pt;
    font-weight: 600;
}

.ht-bottom bdi {
    font-weight: 700;
    font-size: 12.5pt;
}

/* ---------- Viva sheet: two register-number columns per page ---------- */
.viva-table td.gap,
.viva-table th.gap {
    border-top: none;
    border-bottom: none;
    width: 3mm;
    padding: 0;
}

/* ---------- Mark entry grid ---------- */
.mark-grid input.mark-input {
    width: 5.5rem;
    text-align: center;
}

.mark-grid tr.dirty > td:first-child {
    box-shadow: inset 3px 0 0 var(--primary-color, #0d6efd);
}

.mark-grid td,
.mark-grid th {
    vertical-align: middle;
}

/* ---------- Public result page ---------- */
.result-card {
    font-family: var(--sheet-font);
}

.result-card .result-status {
    font-size: 1.25rem;
    font-weight: 700;
}

/* Students mostly open the result on a phone: tighter cells so the four-column table fits without a side scroll. */
@media (max-width: 575.98px) {
    .result-card .card-body {
        padding: 1rem !important;
    }

    .result-card .table th,
    .result-card .table td {
        padding: 0.3rem 0.35rem;
        font-size: 0.9rem;
    }
}

@media print {
    @page {
        size: A4;
        margin: 10mm;
    }

    html,
    body {
        background: #fff !important;
    }

    .no-print,
    .scrollToTop,
    #apiloader,
    #responsive-overlay {
        display: none !important;
    }

    .print-shell {
        background: none;
        padding: 0;
    }

    .sheet-page {
        width: auto;
        min-height: 0;
        margin: 0;
        padding: 0;
        box-shadow: none;
        break-after: page;
        page-break-after: always;
    }

    .sheet-page:last-child {
        break-after: auto;
        page-break-after: auto;
    }

    .result-print-area {
        margin: 0 !important;
        max-width: none !important;
    }

    .result-print-area .card {
        box-shadow: none !important;
        border: 1px solid #000 !important;
    }
}
