/* OMR scan page layout */

.omr-scan-page {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    width: 100%;
}

.omr-scan-header {
    padding: 1rem 1.25rem;
}

/* Compact header actions: quiz dropdown + upload + start in one row. */
.omr-header-actions {
    flex: 1 1 auto;
    justify-content: flex-end;
}
.omr-header-quiz {
    max-width: 420px;
}
.omr-header-upload {
    position: relative;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    padding: 0.45rem 0.8rem;
    border: 1.5px dashed #90caf9;
    border-radius: 8px;
    background: linear-gradient(to bottom right, #f5f9ff 0%, #ffffff 100%);
    cursor: pointer;
    font-size: 0.8rem;
    font-weight: 600;
    color: #1976d2;
    white-space: nowrap;
    transition: border-color 0.15s, background 0.15s;
}
.omr-header-upload:hover {
    border-color: #1976d2;
    background: #eef5ff;
}
.omr-header-upload-icon {
    font-size: 1.1rem;
    display: inline-flex;
    align-items: center;
}
.omr-header-upload-text {
    line-height: 1;
}
.omr-header-upload-count {
    margin-left: 0.1rem;
}
.omr-header-scan-btn {
    white-space: nowrap;
}
.omr-header-files {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-top: 0.6rem;
    padding: 0.35rem 0.6rem;
    background: #f8fbff;
    border: 1px solid #e3e8f0;
    border-radius: 8px;
    font-size: 0.75rem;
    color: #1565c0;
    min-width: 0;
}
.omr-header-files-text {
    flex: 1 1 auto;
    min-width: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
@media (max-width: 640px) {
    .omr-header-actions {
        width: 100%;
        justify-content: stretch;
    }
    .omr-header-quiz {
        flex: 1 1 100% !important;
        max-width: none;
    }
}

.omr-scan-layout {
    display: grid;
    grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr) minmax(0, 1.2fr);
    gap: 1rem;
    align-items: start;
}

@media (max-width: 1024px) {
    .omr-scan-layout {
        grid-template-columns: 1fr;
    }
}

.omr-scan-left,
.omr-scan-mid,
.omr-scan-right {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-width: 0;
}

/* Shared panel rhythm for the scan workspace. */
.omr-panel {
    padding: 0.85rem 1rem;
    margin: 0;
}

/* Processed preview under the results list (left column). */
.omr-preview-card .omr-scan-image-wrapper {
    min-height: 160px;
    max-height: 320px;
}

/* Right column is the EditAnswers workspace. */
.omr-edit-card {
    display: flex;
    flex-direction: column;
    flex: 1 1 auto;
}

.omr-edit-head {
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #f0f0f0;
    margin-bottom: 0.1rem;
}

/* Results list — borderless rows, no boxes */
.omr-results-grid .rz-datatable,
.omr-results-grid .rz-datatable-table-wrapper,
.omr-results-grid table {
    border: none !important;
}
.omr-results-grid th,
.omr-results-grid td {
    border-left: none !important;
    border-right: none !important;
    border-top: none !important;
    padding-top: 0.3rem;
    padding-bottom: 0.3rem;
}
.omr-results-grid tbody tr {
    border-bottom: 1px solid #f1f1f1;
}
.omr-results-grid tbody tr:last-child {
    border-bottom: none;
}

/* Upload card — compact dropzone */
.omr-upload-card {
    border: 1px solid #e3e8f0;
}
.omr-upload-icon {
    color: #1976d2;
    font-size: 1.4rem;
    display: inline-flex;
    align-items: center;
}
.omr-dropzone-icon {
    font-size: 2rem;
}
.omr-dropzone {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 88px;
    padding: 0.7rem 0.8rem;
    border: 1.5px dashed #90caf9;
    border-radius: 10px;
    background: linear-gradient(to bottom right, #f5f9ff 0%, #ffffff 100%);
    cursor: pointer;
    transition: border-color 0.15s, background 0.15s;
}
.omr-dropzone:hover {
    border-color: #1976d2;
    background: #eef5ff;
}
.omr-dropzone-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    opacity: 0;
    cursor: pointer;
}
.omr-dropzone-input::file-selector-button {
    display: none;
}
.omr-dropzone-text {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.15rem;
    text-align: center;
    pointer-events: none;
}
.omr-dropzone-title {
    font-weight: 700;
    font-size: 0.85rem;
    color: #1976d2;
}
.omr-dropzone-hint {
    font-size: 0.7rem;
    color: #888;
}
.omr-file-list {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.3rem;
}
.omr-file-chip {
    max-width: 140px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.68rem;
    padding: 0.12rem 0.5rem;
    border-radius: 999px;
    background: #e3f2fd;
    border: 1px solid #90caf9;
    color: #1565c0;
}
.omr-file-more {
    font-size: 0.7rem;
    font-weight: 700;
    color: #555;
}
.omr-file-clear {
    margin-left: auto;
    border: none;
    background: transparent;
    color: #999;
    cursor: pointer;
    font-size: 1.1rem;
    line-height: 1;
}
.omr-file-clear:hover {
    color: #c62828;
}

.omr-scan-image-wrapper {
    background: linear-gradient(45deg, #f0f0f3 25%, transparent 25%),
                linear-gradient(-45deg, #f0f0f3 25%, transparent 25%),
                linear-gradient(45deg, transparent 75%, #f0f0f3 75%),
                linear-gradient(-45deg, transparent 75%, #f0f0f3 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0;
    background-color: #fafafa;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 200px;
    max-height: 520px;
}

.omr-scan-image {
    max-width: 100%;
    max-height: 300px;
    width: auto;
    height: auto;
    object-fit: contain;
    display: block;
}

.omr-zoomable {
    cursor: zoom-in;
}

.omr-zoomable:focus-visible {
    outline: 2px solid #1976d2;
    outline-offset: 2px;
}

.omr-scan-meta-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 0.75rem;
}

.omr-scan-meta-cell {
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    padding: 0.5rem 0.75rem;
    background: #f8f9fb;
    border-radius: 6px;
    border: 1px solid #ececf0;
}

.omr-scan-meta-cell .meta-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: #888;
    letter-spacing: 0.04em;
}

.omr-scan-meta-cell .meta-value {
    font-size: 1.1rem;
    font-weight: 600;
    color: #222;
}

.omr-answers-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(58px, 1fr));
    gap: 4px;
}

.omr-answers-grid .omr-answer-cell {
    display: grid;
    grid-template-rows: auto auto auto auto;
    gap: 2px;
    padding: 4px 2px;
    text-align: center;
    background: #fff;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    transition: background 0.15s, border-color 0.15s;
}

.omr-answers-grid .omr-answer-cell.is-marked {
    background: #e3f2fd;
    border-color: #1976d2;
}

.omr-answers-grid .omr-answer-cell.is-ambiguous {
    background: #fff4e3;
    border-color: #ff9800;
}

.omr-answers-grid .omr-answer-cell.is-correct {
    background: #e8f5e9;
    border-color: #2e7d32;
    border-left: 3px solid #2e7d32;
}

.omr-answers-grid .omr-answer-cell.is-wrong {
    background: #ffebee;
    border-color: #c62828;
    border-left: 3px solid #c62828;
}

.omr-answer-key.is-correct {
    color: #2e7d32;
    font-weight: 600;
}

.omr-answer-key.is-wrong {
    color: #c62828;
    font-weight: 600;
}

.omr-answers-grid .omr-answer-cell .omr-answer-num {
    font-size: 0.65rem;
    color: #888;
}

.omr-answers-grid .omr-answer-cell .omr-answer-letter {
    font-size: 1.1rem;
    font-weight: 700;
    color: #333;
}

.omr-answers-grid .omr-answer-cell.is-marked .omr-answer-letter {
    color: #1976d2;
}

.omr-answers-grid .omr-answer-cell.is-ambiguous .omr-answer-letter {
    color: #e65100;
}

.omr-answers-grid .omr-answer-cell .omr-answer-score {
    font-size: 0.65rem;
    color: #999;
}

.omr-answers-grid .omr-answer-cell .omr-answer-select {
    width: 100%;
    padding: 2px;
    font-size: 0.75rem;
    text-align: center;
    border: 1px solid #d0d0d0;
    border-radius: 3px;
    background: #fff;
}

.omr-scan-actions {
    margin-top: 0.75rem;
}

/* Template editor */
.ar-omr-editor .answer-key-preview {
    display: grid;
    grid-template-columns: repeat(15, minmax(36px, 1fr));
    gap: 4px;
    padding: 8px;
    background: #f9f9fb;
    border-radius: 8px;
}

.ar-omr-editor .answer-key-cell {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 6px 2px;
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.85rem;
    transition: background 0.15s;
}

.ar-omr-editor .answer-key-cell .answer-key-num {
    font-size: 0.65rem;
    color: #999;
}

.ar-omr-editor .answer-key-cell .answer-key-letter {
    font-weight: 600;
    color: #444;
}

.ar-omr-editor .answer-key-cell.is-marked {
    background: #e3f2fd;
    border-color: #1976d2;
}

.ar-omr-editor .answer-key-cell.is-marked .answer-key-letter {
    color: #1976d2;
}

.ar-omr-editor .bubble-preview-wrapper {
    background: #fff;
    border-radius: 8px;
    padding: 8px;
    overflow-x: auto;
    max-height: 600px;
    overflow-y: auto;
}

.ar-omr-editor .bubble-svg {
    display: block;
    min-width: 600px;
    width: 100%;
}

.ar-omr-editor textarea {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
}

.ar-omr-editor .rz-tabview > .rz-tabview-panels {
    background: transparent;
}

/* Template list (OmrTemplates) */
.omr-templates-page {
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

.omr-scan-cta-card {
    border: 2px dashed #1976d2;
    background: linear-gradient(to bottom right, #f5f9ff 0%, #ffffff 100%);
}

.omr-scan-cta-card .rz-text {
    color: #1976d2;
}

.omr-scan-file-input {
    width: 100%;
    padding: 0.5rem;
    border: 1px dashed #1976d2;
    border-radius: 6px;
    background: #fff;
    cursor: pointer;
}

.omr-scan-btn-primary {
    width: 100%;
    margin-top: 0.5rem;
    height: 56px;
    font-size: 1.1rem !important;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(25, 118, 210, 0.25);
}

.omr-scan-btn-primary:hover {
    box-shadow: 0 4px 12px rgba(25, 118, 210, 0.4);
}

.omr-templates-toolbar {
    padding: 1rem 1.25rem;
}

.omr-templates-grid {
    grid-template-columns: 1fr 4fr 1fr 1fr 1fr 2fr;
}

@media (max-width: 768px) {
    .omr-templates-grid {
        grid-template-columns: 1fr 1fr;
    }
}

/* Template editor wrapper */
.omr-editor-page {
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}
.omr-editor-header {
    padding: 1rem 1.25rem;
}

.omr-editor-section {
    margin-bottom: 1rem;
}

.omr-editor-tabs-card {
    padding: 0;
}

/* ---------- Offline result detail dialog (OfflineResultDetail) ---------- */
.ord-dialog {
    min-width: 0;
}

.ord-detail {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-width: 0;
}

.ord-head {
    display: flex;
    align-items: center;
    gap: 0.9rem;
    padding: 0.9rem 1rem;
    border-radius: 12px;
    background: linear-gradient(135deg, #1a237e 0%, #3949ab 60%, #5c6bc0 100%);
    color: #fff;
}

.ord-avatar {
    width: 52px;
    height: 52px;
    flex: 0 0 52px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.05rem;
    background: rgba(255, 255, 255, 0.18);
    border: 2px solid rgba(255, 255, 255, 0.55);
    letter-spacing: 0.02em;
}

.ord-head-main {
    min-width: 0;
    flex: 1 1 auto;
}

.ord-name {
    font-size: 1.15rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ord-sub {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    margin-top: 0.35rem;
}

.ord-pill {
    font-size: 0.72rem;
    padding: 0.15rem 0.55rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.16);
    border: 1px solid rgba(255, 255, 255, 0.25);
}

.ord-pill-dim {
    opacity: 0.85;
}

.ord-total {
    text-align: center;
    background: var(--rz-card-background-color, var(--rz-base-background-color, #fff));
    color: var(--rz-text-color, #1a237e);
    border: 1px solid var(--rz-border-color, transparent);
    border-radius: 12px;
    padding: 0.45rem 0.9rem;
    min-width: 110px;
}

.ord-total-num {
    font-size: 1.6rem;
    font-weight: 800;
    line-height: 1.1;
}

.ord-total-cap {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    opacity: 0.65;
}

.ord-total-sub {
    font-size: 0.72rem;
    font-weight: 600;
    color: var(--rz-success, #2e7d32);
}

.ord-left {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-width: 0;
}

.ord-img-card {
    border: 1px solid var(--rz-border-color, #e3e3e8);
    border-radius: 12px;
    background: var(--rz-card-background-color, var(--rz-base-background-color, #fff));
    overflow: hidden;
}

.ord-img-card.is-broken .ord-img-hint {
    display: none;
}

.ord-img-card.is-broken .ord-img-broken {
    display: block;
}

.ord-img-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    padding: 0.6rem 0.8rem;
    border-bottom: 1px solid var(--rz-border-color, #f0f0f3);
}

.ord-card-title {
    font-weight: 700;
    font-size: 0.85rem;
}

.ord-link {
    font-size: 0.75rem;
    font-weight: 600;
    text-decoration: none;
}

.ord-img {
    display: block;
    width: 100%;
    max-height: 78vh;
    object-fit: contain;
    background:
        linear-gradient(45deg, var(--rz-border-color, #f0f0f3) 25%, transparent 25%),
        linear-gradient(-45deg, var(--rz-border-color, #f0f0f3) 25%, transparent 25%),
        linear-gradient(45deg, transparent 75%, var(--rz-border-color, #f0f0f3) 75%),
        linear-gradient(-45deg, transparent 75%, var(--rz-border-color, #f0f0f3) 75%);
    background-size: 16px 16px;
    background-position: 0 0, 0 8px, 8px -8px, -8px 0;
    background-color: var(--rz-base-background-color, #fafafa);
    cursor: zoom-in;
}

.ord-img-hint {
    padding: 0.4rem 0.8rem 0.6rem;
    font-size: 0.7rem;
    color: var(--rz-text-secondary-color, #888);
}

.ord-img-broken {
    display: none;
    padding: 0.4rem 0.8rem 0.6rem;
    font-size: 0.75rem;
    color: var(--rz-danger, #c62828);
}

.ord-noimg {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.35rem;
    padding: 2rem 1rem;
    color: var(--rz-text-secondary-color, #666);
    text-align: center;
}

.ord-noimg-sub {
    font-size: 0.75rem;
    color: var(--rz-text-secondary-color, #999);
}

.ord-mini-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.5rem;
}

.ord-mini {
    border: 1px solid var(--rz-border-color, #e3e3e8);
    border-radius: 10px;
    background: var(--rz-card-background-color, var(--rz-base-background-color, #fff));
    padding: 0.55rem 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.15rem;
    text-align: center;
}

.ord-mini-label {
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--rz-text-secondary-color, #888);
}

.ord-mini-value {
    font-size: 1.15rem;
    font-weight: 800;
}

.ord-mini-value small {
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--rz-text-secondary-color, #888);
}

.ord-mini-value.ok {
    color: var(--rz-success, #2e7d32);
}

.ord-right {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    min-width: 0;
}

.ord-subjects {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 0.5rem;
}

@media (max-width: 1100px) {
    .ord-subjects {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }
}

@media (max-width: 640px) {
    .ord-subjects {
        grid-template-columns: repeat(2, minmax(0, 1fr));
    }
}

.ord-subj {
    border: 1px solid var(--rz-border-color, #e3e3e8);
    border-radius: 10px;
    background: var(--rz-card-background-color, var(--rz-base-background-color, #fff));
    padding: 0.55rem 0.6rem;
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.ord-subj-top {
    display: flex;
    align-items: baseline;
    justify-content: space-between;
    gap: 0.4rem;
}

.ord-subj-name {
    font-size: 0.72rem;
    font-weight: 700;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.ord-subj-score {
    font-size: 0.78rem;
    color: var(--rz-text-secondary-color, #555);
    white-space: nowrap;
}

.ord-bar {
    height: 6px;
    border-radius: 999px;
    background: var(--rz-base-200, var(--rz-border-color, #eef0f4));
    overflow: hidden;
}

.ord-bar-fill {
    height: 100%;
    border-radius: 999px;
}

.ord-bar-fill.is-good {
    background: var(--rz-success, #2e7d32);
}

.ord-bar-fill.is-mid {
    background: var(--rz-warning, #ef6c00);
}

.ord-bar-fill.is-bad {
    background: var(--rz-danger, #c62828);
}

.ord-subj-pct {
    font-size: 0.7rem;
    color: var(--rz-text-secondary-color, #888);
    text-align: right;
}

/* ---------- Mobile (student result view + toolbar) ---------- */
@media (max-width: 480px) {
    /* Header card: avatar + name + total no longer fit in one row. */
    .ord-head {
        flex-wrap: wrap;
        gap: 0.7rem;
        padding: 0.75rem;
    }
    .ord-avatar {
        width: 44px;
        height: 44px;
        flex-basis: 44px;
        font-size: 0.95rem;
    }
    .ord-head-main {
        flex: 1 1 calc(100% - 44px - 0.7rem);
    }
    .ord-name {
        font-size: 1rem;
    }
    /* Total block moves to its own full-width row instead of squeezing. */
    .ord-total {
        flex: 1 1 100%;
        min-width: 0;
        display: flex;
        align-items: baseline;
        justify-content: center;
        gap: 0.5rem;
        padding: 0.4rem 0.6rem;
    }
    .ord-total-num {
        font-size: 1.3rem;
    }
    /* Tighter stat cards so 3 columns fit a 360px screen. */
    .ord-mini-stats {
        gap: 0.4rem;
    }
    .ord-mini {
        padding: 0.45rem 0.35rem;
        min-width: 0;
    }
    .ord-mini-value {
        font-size: 1rem;
    }
    /* Quiz dropdown takes the full row instead of overflowing. */
    .omr-scan-toolbar .rz-dropdown {
        min-width: 0 !important;
        width: 100%;
        flex: 1 1 100%;
    }
}