/**
 * Results Page CSS - Table, Detail Views, Annotations
 */

/* ============================================
   RESULTS HEADER
   ============================================ */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.filters-row {
    display: flex;
    gap: 10px;
}

/* ============================================
   RESULTS TABLE
   ============================================ */
.results-table {
    background: var(--bg-card);
    border-radius: 14px;
    overflow: hidden;
}

.table-header {
    display: grid;
    grid-template-columns: 50px 1fr 180px 70px 70px 70px 80px 100px;
    padding: 14px 20px;
    background: var(--bg-warm);
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    font-family: 'DM Mono', monospace;
}

.table-row {
    display: grid;
    grid-template-columns: 50px 1fr 180px 70px 70px 70px 80px 100px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    align-items: center;
    cursor: pointer;
    transition: background 0.15s;
}

.table-row:hover {
    background: var(--bg-cream);
}

.table-row.expanded {
    background: var(--bg-cream);
}

.table-row:last-child {
    border-bottom: none;
}

/* Cell Styles */
.cell-subject {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 500;
}

.subject-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--accent-light);
    color: var(--accent);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    font-family: 'DM Mono', monospace;
    flex-shrink: 0;
}

.subject-info {
    display: flex;
    flex-direction: column;
    gap: 2px;
    min-width: 0;
}

.subject-name {
    font-size: 14px;
    font-weight: 500;
    color: var(--text);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.subject-meta {
    font-size: 11px;
    color: var(--text-muted);
    font-family: 'DM Mono', monospace;
}

.cell-scenario {
    font-size: 12px;
    color: var(--text-muted);
    font-family: 'DM Mono', monospace;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.score {
    font-weight: 600;
    font-family: 'DM Mono', monospace;
}

.score.high { color: var(--sage); }
.score.medium { color: var(--gold); }
.score.low { color: var(--accent); }

/* Row Actions */
.row-actions {
    display: flex;
    gap: 6px;
}

.row-action {
    padding: 6px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: transparent;
    font-family: inherit;
    font-size: 11px;
    cursor: pointer;
    transition: all 0.2s;
}

.row-action:hover {
    border-color: var(--accent);
    color: var(--accent);
}

/* ============================================
   RESULT DETAIL (Expandable)
   ============================================ */
.result-detail {
    display: none;
    padding: 20px;
    background: var(--bg-cream);
    border-bottom: 1px solid var(--border);
}

.result-detail.open {
    display: block;
}

.detail-grid {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 24px;
}

.detail-transcript {
    max-height: 70vh;
    overflow-y: auto;
}

.detail-sidebar {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.detail-section {
    background: var(--bg-card);
    border-radius: 10px;
    padding: 16px;
}

.detail-section-title {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    font-family: 'DM Mono', monospace;
    margin-bottom: 12px;
}

/* Metrics Display */
.detail-metrics {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.detail-metric {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.detail-metric-label {
    font-size: 12px;
    color: var(--text-muted);
}

.detail-metric-value {
    font-size: 16px;
    font-weight: 600;
}

.detail-metric-value.high { color: var(--sage); }
.detail-metric-value.medium { color: var(--gold); }
.detail-metric-value.low { color: var(--accent); }

/* Annotation Box */
.annotation-box {
    width: 100%;
    min-height: 80px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 12px;
    resize: vertical;
}

.annotation-box:focus {
    outline: none;
    border-color: var(--accent);
}

.detail-actions {
    display: flex;
    gap: 8px;
}

/* ============================================
   RED FLAG WORKSPACE
   ============================================ */
.flag-workspace {
    background: var(--bg-card);
    border-radius: 14px;
    padding: 24px;
    margin-top: 24px;
}

.flag-workspace-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.flag-workspace-title {
    font-size: 16px;
    font-weight: 500;
}

.flag-workspace-actions {
    display: flex;
    gap: 12px;
}

.flag-turns {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    margin-bottom: 20px;
}

.flag-turn {
    padding: 8px 16px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-cream);
    cursor: pointer;
    font-size: 12px;
    font-family: 'DM Mono', monospace;
    transition: all 0.2s;
}

.flag-turn:hover {
    border-color: var(--accent);
}

.flag-turn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: white;
}

.flag-turn.safe {
    border-color: var(--sage);
    background: var(--sage-light);
}

.flag-turn.warning {
    border-color: var(--gold);
    background: var(--gold-light);
}

.flag-turn.failure {
    border-color: var(--accent);
    background: var(--accent-light);
}

.flag-detail {
    background: var(--bg-cream);
    border-radius: 12px;
    padding: 20px;
}

.flag-verdict-btns {
    display: flex;
    gap: 8px;
    margin-bottom: 16px;
}

.verdict-btn {
    flex: 1;
    padding: 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: transparent;
    cursor: pointer;
    font-family: inherit;
    font-size: 12px;
    transition: all 0.2s;
}

.verdict-btn.safe:hover,
.verdict-btn.safe.active {
    background: var(--sage-light);
    border-color: var(--sage);
    color: var(--sage);
}

.verdict-btn.warning:hover,
.verdict-btn.warning.active {
    background: var(--gold-light);
    border-color: var(--gold);
    color: var(--gold);
}

.verdict-btn.failure:hover,
.verdict-btn.failure.active {
    background: var(--accent-light);
    border-color: var(--accent);
    color: var(--accent);
}

.flag-notes {
    width: 100%;
    min-height: 80px;
    padding: 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 13px;
    resize: vertical;
}

.flag-notes:focus {
    outline: none;
    border-color: var(--accent);
}

/* Keyboard shortcuts hint */
.keyboard-hint {
    margin-top: 12px;
    font-size: 11px;
    color: var(--text-light);
    font-family: 'DM Mono', monospace;
}

.keyboard-hint kbd {
    display: inline-block;
    padding: 2px 6px;
    background: var(--bg-warm);
    border-radius: 4px;
    font-size: 10px;
}

/* ============================================
   PILLAR SCORES (from ui.html)
   ============================================ */
.pillar-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 12px;
    margin-top: 12px;
}

.pillar-card {
    background: var(--bg-cream);
    border-radius: 10px;
    padding: 14px;
    text-align: center;
}

.pillar-value {
    font-size: 24px;
    font-weight: 600;
    font-family: 'DM Mono', monospace;
    margin-bottom: 4px;
}

.pillar-label {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted);
    font-family: 'DM Mono', monospace;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1000px) {
    .table-header,
    .table-row {
        grid-template-columns: 40px 1fr 120px 55px 55px 55px 70px 80px;
        font-size: 11px;
    }

    .detail-grid {
        grid-template-columns: 1fr;
    }

    .pillar-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 700px) {
    .table-header,
    .table-row {
        grid-template-columns: 1fr;
        gap: 8px;
    }

    .filters-row {
        flex-wrap: wrap;
    }

    .search-input {
        width: 100%;
    }
}

/* ============================================
   TURN SCORES (Per-turn metrics)
   ============================================ */
.turn-scores {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid var(--border);
}

.turn-score-badge {
    display: inline-flex;
    align-items: center;
    font-size: 11px;
    padding: 4px 10px;
    border-radius: 6px;
    background: var(--bg-warm);
    color: var(--text-muted);
    font-family: 'DM Mono', monospace;
}

.turn-score-badge.failure {
    background: var(--accent-light);
    color: var(--accent);
}

.turn-score-badge.success {
    background: var(--sage-light);
    color: var(--sage);
}

/* ============================================
   PILLAR SCORE COLORS
   ============================================ */
.pillar-value.high { color: var(--sage); }
.pillar-value.medium { color: var(--gold); }
.pillar-value.low { color: var(--accent); }

/* ============================================
   EXPANDED DETAIL VISUAL SEPARATION
   ============================================ */
.result-detail.open {
    display: block;
    border-left: 3px solid var(--accent);
    margin-left: 20px;
    margin-right: 20px;
    border-radius: 0 14px 14px 0;
}

/* ============================================
   TRANSCRIPT TURN STYLING
   ============================================ */
.transcript-turn {
    padding: 16px;
    background: var(--bg-card);
    border-radius: 10px;
    margin-bottom: 12px;
}

.turn-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.turn-speaker {
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-family: 'DM Mono', monospace;
}

.turn-speaker.patient { color: var(--accent); }
.turn-speaker.ai { color: var(--sage); }

.turn-text {
    font-size: 13px;
    line-height: 1.6;
    color: var(--text);
}

.turn-audio {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    padding: 8px 12px;
    background: var(--bg-warm);
    border-radius: 8px;
}

.audio-btn {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    border: none;
    background: var(--accent);
    color: white;
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.2s, background 0.2s;
}

.audio-btn:hover {
    transform: scale(1.05);
    background: var(--accent-hover);
}

.audio-btn.playing {
    background: var(--sage);
}

.audio-wave {
    display: flex;
    align-items: center;
    gap: 2px;
    flex: 1;
}

.wave-bar {
    width: 3px;
    background: var(--border);
    border-radius: 2px;
    transition: background 0.2s;
}

.annotation-badge {
    font-size: 9px;
    padding: 2px 8px;
    border-radius: 10px;
    text-transform: uppercase;
    font-weight: 600;
}

.annotation-badge.green {
    background: var(--sage-light);
    color: var(--sage);
}

.annotation-badge.yellow {
    background: var(--gold-light);
    color: var(--gold);
}

.annotation-badge.red {
    background: var(--accent-light);
    color: var(--accent);
}

.flag-turn-preview {
    background: var(--bg-card);
    padding: 12px;
    border-radius: 8px;
    margin-bottom: 12px;
    font-size: 13px;
    line-height: 1.5;
}

/* ============================================
   CALIBRATION UI - Judge Calibration Controls
   ============================================ */

/* Calibration badge in table */
.calibration-badge {
    font-size: 10px;
    padding: 4px 8px;
    border-radius: 10px;
    font-family: 'DM Mono', monospace;
    white-space: nowrap;
}

.calibration-badge.done {
    background: var(--sage-light);
    color: var(--sage);
}

.calibration-badge.partial {
    background: var(--gold-light);
    color: var(--gold);
}

.calibration-badge.pending {
    background: var(--bg-warm);
    color: var(--text-muted);
}

/* Turn status indicator */
.turn-status {
    margin-left: auto;
    font-size: 11px;
    font-family: 'DM Mono', monospace;
}

.turn-status.judged {
    color: var(--sage);
}

.turn-status.pending {
    color: var(--text-light);
}

/* Judgment section container */
.judgment-section {
    background: var(--bg-cream);
    border-radius: 10px;
    padding: 16px;
    margin-top: 12px;
}

.judgment-section.active {
    background: var(--accent-light);
    border: 1px solid var(--accent);
}

.judgment-section-title {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-light);
    font-family: 'DM Mono', monospace;
    margin-bottom: 12px;
}

/* Judgment row layout */
.judgment-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.judgment-row:last-of-type {
    margin-bottom: 0;
}

.judgment-label {
    font-size: 13px;
    color: var(--text);
}

.judgment-label .score {
    font-weight: 600;
    margin-left: 8px;
}

/* Judgment button group */
.judgment-buttons {
    display: flex;
    gap: 4px;
}

.jbtn {
    width: 36px;
    height: 32px;
    border: 1px solid var(--border);
    border-radius: 6px;
    background: var(--bg-card);
    cursor: pointer;
    font-size: 14px;
    transition: all 0.15s;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: inherit;
}

.jbtn:hover {
    border-color: var(--text-muted);
}

.jbtn.lower:hover,
.jbtn.lower.active {
    background: var(--gold-light);
    border-color: var(--gold);
    color: var(--gold);
}

.jbtn.agree:hover,
.jbtn.agree.active {
    background: var(--sage-light);
    border-color: var(--sage);
    color: var(--sage);
}

.jbtn.higher:hover,
.jbtn.higher.active {
    background: var(--accent-light);
    border-color: var(--accent);
    color: var(--accent);
}

/* Calibration notes input */
.calibration-notes {
    width: 100%;
    margin-top: 12px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-family: inherit;
    font-size: 13px;
    resize: none;
    min-height: 60px;
}

.calibration-notes:focus {
    outline: none;
    border-color: var(--accent);
}

/* Calibration progress in sidebar */
.calibration-progress-card {
    background: var(--bg-card);
    border-radius: 12px;
    padding: 16px;
}

.calibration-progress-bar {
    height: 6px;
    background: var(--border);
    border-radius: 3px;
    overflow: hidden;
    margin-top: 8px;
}

.calibration-progress-fill {
    height: 100%;
    background: var(--sage);
    border-radius: 3px;
    transition: width 0.3s ease;
}

/* Detail footer with navigation */
.detail-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.calibration-status {
    font-size: 13px;
    color: var(--text-muted);
    font-family: 'DM Mono', monospace;
}

.calibration-status .count {
    color: var(--sage);
    font-weight: 600;
}
