/* OMR Scanner — base styles */
:root {
    --bg: #f8f9fa;
    --surface: #ffffff;
    --text: #1a1a2e;
    --muted: #6c757d;
    --accent: #2563eb;
    --accent-light: #dbeafe;
    --danger: #dc3545;
    --danger-light: #f8d7da;
    --success: #198754;
    --success-light: #d1e7dd;
    --radius: 8px;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
}

.omr-app {
    max-width: 1100px;
    margin: 0 auto;
    padding: 2rem 1.5rem;
}

h1 { margin-bottom: 1.5rem; font-size: 1.75rem; }
h2 { margin: 1.5rem 0 0.75rem; font-size: 1.25rem; color: var(--muted); }

/* Tabs */
.tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 2rem;
    border-bottom: 2px solid #dee2e6;
    padding-bottom: 0.5rem;
}
.tabs button {
    padding: 0.5rem 1rem;
    border: none;
    background: transparent;
    cursor: pointer;
    font-size: 0.95rem;
    border-radius: var(--radius) var(--radius) 0 0;
    transition: background 0.15s;
}
.tabs button:hover { background: var(--accent-light); }
.tabs button:disabled { color: var(--muted); cursor: default; }

/* File upload */
.file-upload {
    border: 2px dashed #ced4da;
    border-radius: var(--radius);
    padding: 2rem;
    text-align: center;
    cursor: pointer;
    transition: border-color 0.2s, background 0.2s;
    position: relative;
}
.file-upload:hover, .file-upload.dragging {
    border-color: var(--accent);
    background: var(--accent-light);
}
.file-upload input[type="file"] {
    position: absolute;
    inset: 0;
    opacity: 0;
    cursor: pointer;
}

/* Sheet preview */
.sheet-preview {
    background: var(--surface);
    border: 1px solid #dee2e6;
    border-radius: var(--radius);
    padding: 1rem;
    margin-bottom: 1.5rem;
}
.preview-frame {
    max-height: 500px;
    overflow: auto;
    border: 1px solid #eee;
    margin-bottom: 1rem;
}
.preview-frame svg {
    width: 100%;
    height: auto;
}
.sheet-preview button {
    background: var(--accent);
    color: white;
    border: none;
    padding: 0.6rem 1.5rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.95rem;
}
.sheet-preview button:hover { opacity: 0.9; }

/* Progress bar */
.progress-bar { margin: 1rem 0; }
.progress-track {
    height: 12px;
    background: #e9ecef;
    border-radius: 6px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    background: var(--accent);
    border-radius: 6px;
    transition: width 0.3s ease;
}
.progress-label {
    display: block;
    margin-top: 0.4rem;
    font-size: 0.85rem;
    color: var(--muted);
}

/* Results table */
.results-table {
    overflow-x: auto;
    margin-top: 1rem;
}
.results-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}
.results-table th, .results-table td {
    padding: 0.5rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid #dee2e6;
}
.results-table th {
    background: var(--bg);
    font-weight: 600;
    position: sticky;
    top: 0;
}
.results-table tr.flagged {
    background: var(--danger-light);
}
.results-table tr.ok:hover {
    background: var(--success-light);
}
.answers-cell {
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.85rem;
    letter-spacing: 0.5px;
}
.streaming-indicator {
    text-align: center;
    color: var(--accent);
    padding: 1rem;
    animation: pulse 1.5s infinite;
}
@keyframes pulse {
    0%, 100% { opacity: 0.5; }
    50% { opacity: 1; }
}

/* Upload hint sub-text */
.upload-hint {
    font-size: 0.8rem;
    color: var(--muted);
    margin-top: 0.25rem;
}
.file-upload.reading {
    border-color: var(--accent);
    background: var(--accent-light);
    cursor: wait;
}

/* Compact upload strip shown while queue is active */
.queue-upload-row {
    margin-bottom: 1.5rem;
}
.queue-upload-row .file-upload {
    padding: 1rem 2rem;
}

/* Queue list */
.queue-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.queue-item {
    background: var(--surface);
    border: 1px solid #dee2e6;
    border-radius: var(--radius);
    overflow: hidden;
}

.queue-item-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.6rem 1rem;
    gap: 1rem;
}

.queue-item-name {
    font-weight: 500;
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

.queue-item-status {
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.2rem 0.6rem;
    border-radius: 999px;
    white-space: nowrap;
}

.status-waiting    { background: #e9ecef; color: var(--muted); }
.status-processing { background: var(--accent-light); color: var(--accent); }
.status-done       { background: var(--success-light); color: var(--success); }
.status-error      { background: var(--danger-light); color: var(--danger); }

.queue-item .progress-bar {
    margin: 0;
    padding: 0 1rem 0.5rem;
}
.queue-item .progress-track { height: 6px; }

.queue-item .results-table {
    border-top: 1px solid #dee2e6;
    max-height: 320px;
    overflow-y: auto;
}

/* Export row */
.export-buttons {
    display: flex;
    gap: 0.75rem;
    margin-top: 1rem;
}
.export-buttons button {
    background: var(--accent);
    color: white;
    border: none;
    padding: 0.5rem 1.25rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.9rem;
}
.export-buttons button:hover { opacity: 0.9; }

/* Format hint */
.format-hint {
    background: var(--surface);
    border: 1px solid #dee2e6;
    border-radius: var(--radius);
    padding: 0.75rem 1rem;
    margin: 0.75rem 0;
    font-size: 0.85rem;
}
.format-hint-title {
    font-weight: 600;
    margin-bottom: 0.4rem;
}
.format-hint-table {
    border-collapse: collapse;
    margin-bottom: 0.5rem;
    font-size: 0.8rem;
}
.format-hint-table th,
.format-hint-table td {
    padding: 0.2rem 1rem 0.2rem 0;
    text-align: left;
}
.format-hint-table th {
    font-weight: 600;
    border-bottom: 1px solid #dee2e6;
}
.format-hint-table td {
    color: var(--muted);
}
.format-hint-note {
    color: var(--muted);
    font-size: 0.8rem;
    line-height: 1.4;
}
.format-hint-note em {
    font-style: normal;
    background: #f0f0f0;
    padding: 0.1rem 0.3rem;
    border-radius: 3px;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.75rem;
}

/* Excel upload */
.excel-upload {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}
.excel-upload-label {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    background: var(--surface);
    border: 1px solid #ced4da;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.9rem;
    transition: border-color 0.15s;
}
.excel-upload-label:hover { border-color: var(--accent); }
.excel-upload-label input[type="file"] { display: none; }
.excel-status { color: var(--success); font-size: 0.85rem; font-weight: 500; }
.excel-error { color: var(--danger); font-size: 0.85rem; }

/* Pupil list */
.pupil-list {
    background: var(--surface);
    border: 1px solid #dee2e6;
    border-radius: var(--radius);
    margin-bottom: 1rem;
    overflow: hidden;
}
.pupil-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 1rem;
    background: var(--bg);
    border-bottom: 1px solid #dee2e6;
}
.pupil-count { font-size: 0.9rem; font-weight: 500; }
.pupil-clear-btn {
    background: none;
    border: 1px solid #ced4da;
    border-radius: var(--radius);
    padding: 0.25rem 0.75rem;
    cursor: pointer;
    font-size: 0.8rem;
    color: var(--muted);
}
.pupil-clear-btn:hover { border-color: var(--danger); color: var(--danger); }
.pupil-list-table {
    max-height: 200px;
    overflow-y: auto;
}
.pupil-list-table table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}
.pupil-list-table th, .pupil-list-table td {
    padding: 0.3rem 0.75rem;
    text-align: left;
    border-bottom: 1px solid #f0f0f0;
}
.pupil-list-table th {
    background: var(--bg);
    font-weight: 600;
    position: sticky;
    top: 0;
}

/* Sheet actions row */
.sheet-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}
.pupil-sheet-info {
    font-size: 0.85rem;
    color: var(--muted);
}
.sheet-actions button {
    background: var(--accent);
    color: white;
    border: none;
    padding: 0.6rem 1.5rem;
    border-radius: var(--radius);
    cursor: pointer;
    font-size: 0.95rem;
}
.sheet-actions button:hover { opacity: 0.9; }
.sheet-actions button:disabled { opacity: 0.6; cursor: wait; }

/* Lock screen */
.lock-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 2rem 1rem;
    background: var(--bg);
}
.lock-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 2.5rem 2rem;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
    width: 100%;
    max-width: 360px;
    text-align: center;
}
.lock-card h1 { font-size: 1.4rem; margin-bottom: 0.5rem; }
.lock-card p { color: var(--muted); font-size: 0.95rem; margin-bottom: 1.5rem; }
.lock-card form { display: flex; flex-direction: column; gap: 0.75rem; }
.lock-card input {
    padding: 0.65rem 0.85rem;
    border: 1px solid #d1d5db;
    border-radius: var(--radius);
    font-size: 1rem;
    font-family: inherit;
    text-align: center;
    letter-spacing: 0.1em;
}
.lock-card input:focus {
    outline: none;
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-light);
}
.lock-card button {
    background: var(--accent);
    color: #fff;
    border: none;
    padding: 0.65rem 1rem;
    border-radius: var(--radius);
    font-size: 0.95rem;
    cursor: pointer;
}
.lock-card button:hover { opacity: 0.9; }
.lock-error {
    margin-top: 0.75rem !important;
    color: var(--danger) !important;
    font-size: 0.9rem !important;
}
