/* Adapted from occm/html_report.py CSS */
* { box-sizing: border-box; }
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0; padding: 0;
    background: #f5f5f5; color: #333;
}
.container { max-width: 1200px; margin: 0 auto; padding: 20px; }
header {
    background: #1a237e; color: white; padding: 24px 0;
    margin-bottom: 24px;
}
header .container { display: flex; justify-content: space-between; align-items: center; }
header h1 { margin: 0; font-size: 1.5em; font-weight: 500; }
header .meta { font-size: 0.9em; opacity: 0.85; text-align: right; }
a { color: #1a237e; }

/* Cards */
.card {
    background: white; border-radius: 8px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.12);
    padding: 20px; margin-bottom: 20px;
}
.card h2 {
    margin-top: 0; color: #1a237e; font-size: 1.2em;
    border-bottom: 2px solid #e8eaf6; padding-bottom: 8px;
}

/* Stats */
.stats { display: flex; gap: 16px; flex-wrap: wrap; margin-bottom: 20px; }
.stat-box {
    background: #e8eaf6; border-radius: 6px; padding: 12px 20px;
    min-width: 120px; text-align: center;
}
.stat-box .value { font-size: 1.8em; font-weight: 700; color: #1a237e; }
.stat-box .label { font-size: 0.8em; color: #666; margin-top: 4px; }
.stat-box.warn { background: #fff3e0; }
.stat-box.warn .value { color: #e65100; }
.stat-box.error { background: #ffebee; }
.stat-box.error .value { color: #d32f2f; }
.stat-box.ok { background: #e8f5e9; }
.stat-box.ok .value { color: #2e7d32; }

/* Tables */
table { width: 100%; border-collapse: collapse; font-size: 0.85em; }
th {
    background: #1a237e; color: white; padding: 10px 12px;
    text-align: left; font-weight: 500; position: sticky; top: 0;
}
td { padding: 8px 12px; border-bottom: 1px solid #e0e0e0; }
tr:hover { background: #f5f5f5; }
td.missing { background: #fff9c4; }
td.llm-filled { background: #e3f2fd; }
.scroll-table { overflow-x: auto; }

/* Processing log timeline */
.step { border-left: 4px solid #ccc; padding: 12px 16px; margin-bottom: 8px; margin-left: 8px; }
.step.success { border-left-color: #4caf50; }
.step.partial { border-left-color: #ff9800; }
.step.failed { border-left-color: #f44336; }
.step.skipped { border-left-color: #9e9e9e; }
.step-header { display: flex; justify-content: space-between; align-items: center; }
.step-method { font-weight: 600; font-size: 1em; }
.step-status {
    display: inline-block; padding: 2px 10px; border-radius: 4px;
    font-weight: 600; font-size: 0.8em; text-transform: uppercase; color: white;
}
.step-status.success { background: #4caf50; }
.step-status.partial { background: #ff9800; }
.step-status.failed { background: #f44336; }
.step-status.skipped { background: #9e9e9e; }
.step-detail { font-size: 0.9em; color: #555; margin-top: 6px; }
.step-mapping { font-size: 0.82em; color: #666; margin-top: 4px; }
.step-mapping code { background: #f0f0f0; padding: 1px 4px; border-radius: 3px; }

/* Raw preview */
.raw-preview {
    background: #fafafa; border: 1px solid #e0e0e0; border-radius: 4px;
    padding: 10px; font-family: monospace; font-size: 0.78em;
    max-height: 200px; overflow-y: auto; white-space: pre-wrap;
    margin-top: 8px; display: none;
}
.raw-preview.show { display: block; }
.toggle-btn {
    background: none; border: none; color: #1a237e; cursor: pointer;
    font-size: 0.82em; padding: 0; text-decoration: underline;
}

/* Upload form */
.upload-area {
    border: 2px dashed #bbb; border-radius: 8px; padding: 40px;
    text-align: center; cursor: pointer; transition: border-color 0.2s;
}
.upload-area:hover { border-color: #1a237e; }
.upload-area input[type="file"] { display: none; }
.upload-area .hint { color: #888; font-size: 0.9em; margin-top: 8px; }

.options-group { margin: 16px 0; }
.options-group label { display: block; margin: 6px 0; font-size: 0.9em; }
.options-group input[type="checkbox"] { margin-right: 6px; }

.json-editor {
    width: 100%; min-height: 200px; font-family: monospace; font-size: 0.82em;
    border: 1px solid #ccc; border-radius: 4px; padding: 10px;
}

.btn {
    display: inline-block; padding: 10px 24px; border-radius: 6px;
    border: none; cursor: pointer; font-size: 0.95em; font-weight: 500;
    color: white; background: #1a237e; transition: background 0.2s;
}
.btn:hover { background: #283593; }
.btn-secondary { background: #546e7a; }
.btn-secondary:hover { background: #607d8b; }
.btn-danger { background: #d32f2f; }
.btn-danger:hover { background: #c62828; }

details summary { cursor: pointer; color: #1a237e; font-weight: 500; }
details summary:hover { text-decoration: underline; }

/* Loading indicator */
.loading {
    display: flex; align-items: center; gap: 12px;
    margin-top: 16px; color: #1a237e; font-size: 0.95em;
}
.spinner {
    width: 22px; height: 22px;
    border: 3px solid #e8eaf6; border-top-color: #1a237e;
    border-radius: 50%; animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

footer { text-align: center; color: #999; font-size: 0.8em; padding: 20px 0; }
