/* === Eval AI — Light & Dark Theme === */

:root {
    --bg: #ffffff;
    --bg-secondary: #f8f9fa;
    --bg-tertiary: #f0f1f3;
    --border: #e2e5e9;
    --border-light: #eef0f2;
    --text: #1a1a1a;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --accent: #2563eb;
    --accent-hover: #1d4ed8;
    --accent-light: #eff6ff;
    --success: #16a34a;
    --success-bg: #f0fdf4;
    --danger: #dc2626;
    --danger-bg: #fef2f2;
    --radius: 0;
    --radius-sm: 0;
    --shadow: 0 1px 3px rgba(0,0,0,0.06);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.08);
}

/* Dark theme — system preference or manual toggle */
@media (prefers-color-scheme: dark) {
    :root:not([data-theme="light"]) {
        --bg: #0f1117;
        --bg-secondary: #1a1d27;
        --bg-tertiary: #22252f;
        --border: #2e3240;
        --border-light: #252836;
        --text: #e4e6eb;
        --text-secondary: #9ba1b0;
        --text-muted: #6b7280;
        --accent: #4f8ff7;
        --accent-hover: #6ba1ff;
        --accent-light: rgba(79,143,247,0.12);
        --success: #34d399;
        --success-bg: rgba(52,211,153,0.1);
        --danger: #f87171;
        --danger-bg: rgba(248,113,113,0.1);
        --shadow: 0 1px 3px rgba(0,0,0,0.3);
        --shadow-md: 0 2px 8px rgba(0,0,0,0.4);
    }
}

:root[data-theme="dark"] {
    --bg: #0f1117;
    --bg-secondary: #1a1d27;
    --bg-tertiary: #22252f;
    --border: #2e3240;
    --border-light: #252836;
    --text: #e4e6eb;
    --text-secondary: #9ba1b0;
    --text-muted: #6b7280;
    --accent: #4f8ff7;
    --accent-hover: #6ba1ff;
    --accent-light: rgba(79,143,247,0.12);
    --success: #34d399;
    --success-bg: rgba(52,211,153,0.1);
    --danger: #f87171;
    --danger-bg: rgba(248,113,113,0.1);
    --shadow: 0 1px 3px rgba(0,0,0,0.3);
    --shadow-md: 0 2px 8px rgba(0,0,0,0.4);
}

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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: var(--bg);
    padding: 20px;
    min-height: 100vh;
    color: var(--text);
    font-size: 14px;
    line-height: 1.5;
}

/* Navigation */
.top-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 24px;
    background: var(--bg);
    border-bottom: 1px solid var(--border);
    margin: -20px -20px 24px -20px;
}
.nav-brand {
    color: var(--text);
    font-weight: 700;
    font-size: 1em;
    letter-spacing: -0.3px;
}
.nav-links { display: flex; gap: 2px; }
.nav-link {
    padding: 6px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.875em;
    transition: all 0.15s;
}
.nav-link:hover { color: var(--text); background: var(--bg-secondary); }
.nav-link.active { color: var(--accent); background: var(--accent-light); }

.theme-toggle {
    background: transparent;
    border: 1px solid var(--border);
    color: var(--text-muted);
    padding: 5px 8px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 1em;
    line-height: 1;
    transition: all 0.15s;
    margin-left: 8px;
}
.theme-toggle:hover { color: var(--text); border-color: var(--text-muted); }

.container { max-width: 1400px; margin: 0 auto; }

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding: 0;
}

h1 { color: var(--text); font-size: 1.5em; font-weight: 600; letter-spacing: -0.3px; }

.controls { display: flex; gap: 8px; align-items: center; }

select, button {
    padding: 7px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--bg);
    color: var(--text);
    font-weight: 500;
    cursor: pointer;
    transition: all 0.15s;
    font-size: 0.875em;
    font-family: inherit;
}

select {
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='none' stroke='%239ca3af' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpolyline points='6 9 12 15 18 9'%3E%3C/polyline%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 32px;
}
select:focus { outline: none; border-color: var(--accent); }
select:hover { border-color: var(--accent); }

button:hover { border-color: var(--accent); color: var(--accent); }

button.primary {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}
button.primary:hover { background: var(--accent-hover); }

.timestamp { color: var(--text-muted); font-size: 0.85em; margin-top: 4px; }

/* Summary Cards */
.summary {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}
.summary-card {
    background: var(--bg);
    padding: 20px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}
.summary-card h3 {
    font-size: 0.75em;
    color: var(--text-muted);
    margin-bottom: 6px;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.summary-card .value {
    font-size: 1.75em;
    font-weight: 600;
    color: var(--text);
}

/* Metric Cards */
.metrics-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}
.metric-card {
    background: var(--bg);
    border-radius: var(--radius);
    padding: 18px;
    border: 1px solid var(--border);
}
.metric-card h3 {
    color: var(--text);
    margin-bottom: 10px;
    font-size: 0.9em;
    font-weight: 600;
}
.metric-score { font-size: 1.75em; font-weight: 600; margin-bottom: 10px; }
.metric-score.passed { color: var(--success); }
.metric-score.failed { color: var(--danger); }

.metric-details { display: grid; grid-template-columns: 1fr 1fr; gap: 6px; font-size: 0.85em; }
.metric-details p { color: var(--text-secondary); }

/* Charts */
.charts {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}
.chart-container {
    background: var(--bg);
    border-radius: var(--radius);
    padding: 20px;
    border: 1px solid var(--border);
}
.chart-container h2 {
    color: var(--text);
    margin-bottom: 16px;
    font-size: 1em;
    font-weight: 600;
}

.section-title {
    color: var(--text);
    margin: 24px 0 16px 0;
    font-size: 1.1em;
    font-weight: 600;
}

/* Table */
.table-wrapper {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    background: var(--bg);
}
table { width: 100%; border-collapse: collapse; background: var(--bg); }
thead { background: var(--bg-secondary); border-bottom: 1px solid var(--border); }
th {
    color: var(--text-secondary);
    padding: 12px 16px;
    text-align: center;
    font-weight: 600;
    font-size: 0.8em;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}
td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--border-light);
    font-size: 0.875em;
    vertical-align: top;
    color: var(--text);
    text-align: left;
}
tr:hover { background: var(--bg-secondary); }

.test-number { color: var(--text-muted); font-weight: 600; min-width: 40px; }
.query-cell, .response-cell { max-width: 400px; line-height: 1.6; }
.query-cell { color: var(--text); font-weight: 500; }
.response-cell { color: var(--text-secondary); }

.status-badge {
    display: inline-block;
    padding: 3px 10px;
    border-radius: 0;
    font-size: 0.75em;
    font-weight: 600;
}
.status-badge.passed { background: var(--success-bg); color: var(--success); }
.status-badge.failed { background: var(--danger-bg); color: var(--danger); }

.view-details-btn {
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--border);
    padding: 5px 12px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.8em;
    transition: all 0.15s;
    font-weight: 500;
}
.view-details-btn:hover { background: var(--accent-light); border-color: var(--accent); }

/* Modal */
.modal {
    display: none;
    position: fixed;
    z-index: 1000;
    left: 0; top: 0;
    width: 100%; height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.4);
}
.modal-content {
    background: var(--bg);
    margin: 32px auto;
    padding: 0;
    border-radius: var(--radius);
    width: 90%;
    max-width: 1100px;
    max-height: 88vh;
    overflow: hidden;
    box-shadow: 0 8px 30px rgba(0,0,0,0.12);
    border: 1px solid var(--border);
}
.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 28px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-secondary);
}
.modal-header h2 { color: var(--text); margin: 0; font-size: 1.15em; font-weight: 600; }
.modal-header .test-status { display: flex; align-items: center; gap: 10px; }
.modal-body { padding: 28px; overflow-y: auto; max-height: calc(88vh - 72px); }

.close {
    color: var(--text-muted);
    font-size: 24px;
    font-weight: 400;
    cursor: pointer;
    transition: color 0.15s;
    line-height: 1;
    margin-left: 16px;
}
.close:hover { color: var(--danger); }

.detail-layout { display: grid; grid-template-columns: 1fr 360px; gap: 20px; }

.detail-section {
    margin-bottom: 16px;
    padding: 16px;
    background: var(--bg-secondary);
    border-radius: var(--radius);
    border: 1px solid var(--border-light);
}
.detail-section h3 {
    color: var(--text-secondary);
    margin-bottom: 10px;
    font-size: 0.75em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.detail-section .content { color: var(--text); line-height: 1.7; font-size: 0.9em; }
.detail-section .see-all {
    color: var(--accent);
    cursor: pointer;
    font-size: 0.85em;
    margin-top: 6px;
    display: inline-block;
}
.detail-section .see-all:hover { text-decoration: underline; }
.detail-section pre {
    background: var(--bg-tertiary);
    padding: 14px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    font-size: 0.8em;
    line-height: 1.6;
    border: 1px solid var(--border-light);
    color: var(--text);
}

.metrics-panel { position: sticky; top: 0; }

.metric-result-item {
    padding: 14px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    margin-bottom: 8px;
    cursor: pointer;
    transition: all 0.15s;
}
.metric-result-item:hover { border-color: var(--accent); box-shadow: var(--shadow); }
.metric-result-item.passed { border-left: 3px solid var(--success); }
.metric-result-item.failed { border-left: 3px solid var(--danger); }

.metric-result-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 6px; }
.metric-name { font-weight: 600; color: var(--text); display: flex; align-items: center; gap: 6px; }
.metric-icon { font-size: 1.1em; }
.metric-icon.passed { color: var(--success); }
.metric-icon.failed { color: var(--danger); }

.metric-score-display { font-weight: 600; font-size: 0.9em; }
.metric-score-display.passed { color: var(--success); }
.metric-score-display.failed { color: var(--danger); }

.metric-explanation { color: var(--text-secondary); font-size: 0.8em; line-height: 1.5; margin-bottom: 6px; }
.metric-meta {
    display: flex;
    justify-content: space-between;
    font-size: 0.75em;
    color: var(--text-muted);
    padding-top: 6px;
    border-top: 1px solid var(--border-light);
}

.info-row { display: grid; grid-template-columns: 130px 1fr; gap: 10px; margin-bottom: 6px; font-size: 0.85em; }
.info-label { color: var(--text-muted); font-weight: 500; }
.info-value { color: var(--text); }

.loading { text-align: center; padding: 60px; color: var(--text-muted); font-size: 1em; }
.no-data { text-align: center; padding: 80px 40px; color: var(--text-muted); }
.no-data h2 { color: var(--text); margin-bottom: 12px; font-weight: 600; }

/* Markdown */
.markdown-content { line-height: 1.7; color: var(--text); }
.markdown-content code {
    background: var(--bg-tertiary);
    padding: 2px 6px;
    border-radius: 0;
    font-size: 0.85em;
    color: var(--accent);
}
.markdown-content pre {
    background: var(--bg-tertiary);
    padding: 12px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    border: 1px solid var(--border-light);
}
.markdown-content pre code { background: none; padding: 0; color: inherit; }
.markdown-content a { color: var(--accent); text-decoration: none; }
.markdown-content a:hover { text-decoration: underline; }

.collapsible-content { max-height: 200px; overflow: hidden; position: relative; }
.collapsible-content.expanded { max-height: none; }
.collapsible-content:not(.expanded)::after {
    content: '';
    position: absolute;
    bottom: 0; left: 0; right: 0;
    height: 60px;
    background: linear-gradient(transparent, var(--bg-secondary));
    pointer-events: none;
}

.metric-view-details {
    background: transparent;
    color: var(--accent);
    border: 1px solid var(--border);
    padding: 3px 10px;
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: 0.75em;
    transition: all 0.15s;
    font-weight: 500;
    margin-top: 6px;
    display: inline-block;
}
.metric-view-details:hover { background: var(--accent-light); border-color: var(--accent); }

.metric-detail-modal {
    display: none;
    position: fixed;
    z-index: 1100;
    left: 0; top: 0;
    width: 100%; height: 100%;
    overflow: auto;
    background-color: rgba(0,0,0,0.4);
}
.metric-detail-content {
    background: var(--bg);
    margin: 32px auto;
    padding: 0;
    border-radius: var(--radius);
    width: 90%;
    max-width: 800px;
    max-height: 88vh;
    overflow: hidden;
    border: 1px solid var(--border);
    box-shadow: 0 8px 30px rgba(0,0,0,0.12);
}
.metric-detail-body { padding: 24px 28px; overflow-y: auto; max-height: calc(88vh - 72px); }
.metric-detail-section {
    margin-bottom: 16px;
    padding: 14px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-light);
}
.metric-detail-section h4 {
    color: var(--text-secondary);
    margin-bottom: 8px;
    font-size: 0.8em;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.metric-detail-section .content { color: var(--text); line-height: 1.6; font-size: 0.85em; }

.metric-detail-log {
    background: var(--bg-tertiary);
    padding: 12px;
    border-radius: var(--radius-sm);
    overflow-x: auto;
    font-family: 'SF Mono', 'Fira Code', monospace;
    font-size: 0.8em;
    line-height: 1.5;
    border: 1px solid var(--border-light);
    color: var(--text);
    white-space: pre-wrap;
    word-wrap: break-word;
}
.metric-detail-log .log-key { color: var(--accent); font-weight: 600; }

.dashboard-tabs {
    display: flex;
    gap: 0;
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}
.dashboard-tab {
    padding: 10px 20px;
    border: none;
    background: transparent;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.9em;
    cursor: pointer;
    border-bottom: 2px solid transparent;
    margin-bottom: -1px;
    transition: all 0.15s;
}
.dashboard-tab:hover { color: var(--text); }
.dashboard-tab.active {
    color: var(--accent);
    border-bottom-color: var(--accent);
}

.context-chunk {
    margin-bottom: 12px;
    padding: 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--accent);
}
.context-chunk-header { color: var(--accent); font-size: 0.8em; font-weight: 600; margin-bottom: 6px; }
.context-chunk-content { color: var(--text); line-height: 1.6; font-size: 0.85em; }

@media (max-width: 1200px) {
    .detail-layout { grid-template-columns: 1fr; }
    .metrics-panel { position: static; }
}
@media (max-width: 768px) {
    .charts { grid-template-columns: 1fr; }
    .metrics-grid { grid-template-columns: 1fr; }
    header { flex-direction: column; gap: 12px; align-items: flex-start; }
    .modal-content { width: 95%; margin: 16px auto; }
    .modal-body { padding: 16px; }
}
