/* admin-quality.css — styles specific to /admin/quality-eval.
 *
 * Builds on the existing admin.css tokens (.admin-card, .admin-table, .btn)
 * so this file only defines bits the base admin stylesheet doesn't cover:
 * summary cards, SVG time-series chart, score pills, drill-down modal.
 */

/* ── Range filter row ────────────────────────────────────────────────── */
.qe-range-row {
    display: flex;
    gap: 8px;
    margin-top: 12px;
    flex-wrap: wrap;
}
.qe-range {
    background: var(--bg-tertiary);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}
.qe-range:hover {
    background: var(--bg-elevated);
    color: var(--text-primary);
}
.qe-range.qe-range--on {
    background: var(--accent);
    color: var(--text-inverse, #030304);
    border-color: var(--accent);
}

/* ── Summary cards ───────────────────────────────────────────────────── */
.qe-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 16px;
    margin-top: 16px;
}
.qe-card {
    padding: 20px;
    border: 1px solid var(--border);
    background: var(--bg-tertiary);
    border-radius: 4px;
}
.qe-card__label {
    font-size: 11px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 8px;
}
.qe-card__value {
    font-size: 32px;
    font-weight: 700;
    font-family: "JetBrains Mono", ui-monospace, monospace;
    color: var(--text-primary);
    line-height: 1.1;
}
.qe-card__value--green { color: #16a34a; }
.qe-card__value--amber { color: #d97706; }
.qe-card__value--red   { color: var(--danger); }
.qe-card__value--gray  { color: var(--text-dim); }
.qe-card__foot {
    font-size: 11px;
    color: var(--text-dim);
    margin-top: 8px;
}

/* ── Score pills (used in cards, table, modal) ───────────────────────── */
.qe-pill {
    display: inline-block;
    font-family: "JetBrains Mono", ui-monospace, monospace;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 999px;
    line-height: 1.2;
    min-width: 52px;
    text-align: center;
}
.qe-pill--green { background: rgba(22, 163, 74, 0.14);  color: #16a34a;  border: 1px solid rgba(22, 163, 74, 0.35); }
.qe-pill--amber { background: rgba(217, 119, 6, 0.14);  color: #d97706;  border: 1px solid rgba(217, 119, 6, 0.35); }
.qe-pill--red   { background: rgba(255, 114, 118, 0.14); color: var(--danger); border: 1px solid rgba(255, 114, 118, 0.35); }
.qe-pill--gray  { background: var(--bg-elevated);        color: var(--text-dim); border: 1px solid var(--border); }

/* ── Legend chips (in the header blurb) ──────────────────────────────── */
.qe-legend {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 600;
    margin: 0 2px;
    font-family: "JetBrains Mono", ui-monospace, monospace;
}
.qe-legend--green { background: rgba(22, 163, 74, 0.14);  color: #16a34a; }
.qe-legend--amber { background: rgba(217, 119, 6, 0.14);  color: #d97706; }
.qe-legend--red   { background: rgba(255, 114, 118, 0.14); color: var(--danger); }
.qe-legend--line-faith { color: #16a34a; font-weight: 600; }
.qe-legend--line-rel   { color: var(--brand-violet, #AD96DC); font-weight: 600; }
.qe-legend--line-cp    { color: #2563eb; font-weight: 600; }
.qe-legend--line-faith::before,
.qe-legend--line-rel::before,
.qe-legend--line-cp::before {
    content: "";
    display: inline-block;
    width: 20px; height: 3px;
    margin-right: 8px;
    vertical-align: middle;
    border-radius: 2px;
}
.qe-legend--line-faith::before { background: #16a34a; }
.qe-legend--line-rel::before   { background: var(--brand-violet, #AD96DC); }
.qe-legend--line-cp::before    { background: #2563eb; }

/* ── Time-series chart ───────────────────────────────────────────────── */
/*
 * The outer `.admin-card` already provides the white/elevated surface,
 * border, and shadow; a second grey panel inside it (the previous version
 * of this rule) created a double-background look. Keep the wrap as a
 * transparent layout hook only.
 */
.qe-chart-wrap {
    margin-top: 12px;
    padding: 8px 4px 4px;
    background: transparent;
    border: none;
}
.qe-chart {
    width: 100%;
    height: auto;
    display: block;
    font-family: "JetBrains Mono", ui-monospace, monospace;
}
/* Major gridlines (0.00, 0.50, 1.00). Minor lines (0.25 / 0.75) get a
 * dashed, lighter variant so the grid reads as guides, not cage bars. */
.qe-chart__grid          { stroke: var(--border); stroke-width: 1; opacity: 0.30; }
.qe-chart__grid--minor   { stroke-dasharray: 2 3; opacity: 0.20; }
.qe-chart__threshold              { stroke-width: 1; stroke-dasharray: 4 4; opacity: 0.55; }
.qe-chart__threshold--amber       { stroke: #d97706; }
.qe-chart__threshold--green       { stroke: #16a34a; }
.qe-chart__threshold-label        { font-size: 10px; font-weight: 600; font-family: "JetBrains Mono", ui-monospace, monospace; opacity: 0.85; }
.qe-chart__threshold-label--amber { fill: #d97706; }
.qe-chart__threshold-label--green { fill: #16a34a; }
.qe-chart__line                   { stroke-width: 2.5; stroke-linecap: round; stroke-linejoin: round; }
.qe-chart__line--faith            { stroke: #16a34a; }
.qe-chart__line--rel              { stroke: var(--brand-violet, #AD96DC); }
.qe-chart__line--cp               { stroke: #2563eb; }
/* Soft translucent band below each line — gives the chart depth without
 * hiding the gridlines. Stroke is off so the polygon itself is invisible
 * apart from its gradient fill (set inline via `fill: url(#qe-grad-*)`). */
.qe-chart__area                   { stroke: none; pointer-events: none; }
.qe-chart__dot                    { fill: currentColor; }
.qe-chart__dot.qe-chart__line--faith { fill: #16a34a; }
.qe-chart__dot.qe-chart__line--rel   { fill: var(--brand-violet, #AD96DC); }
.qe-chart__dot.qe-chart__line--cp    { fill: #2563eb; }
.qe-chart__ylabel,
.qe-chart__xlabel {
    font-size: 11px;
    fill: var(--text-dim);
    font-variant-numeric: tabular-nums;
}
.qe-chart__empty                  { font-size: 14px; fill: var(--text-dim); font-weight: 500; }
.qe-chart-legend {
    display: flex;
    gap: 20px;
    margin-top: 10px;
    padding-left: 52px;  /* aligns with drawChart PAD_L so swatches sit under the plot area */
    font-size: 12px;
}

/* ── Table: ellipsis on the question cell ────────────────────────────── */
.qe-td-ellipsis {
    max-width: 480px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* ── Drill-down modal ────────────────────────────────────────────────── */
.qe-modal[hidden] { display: none; }
.qe-modal {
    position: fixed; inset: 0;
    z-index: 9500;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.qe-modal__backdrop {
    position: absolute; inset: 0;
    background: rgba(3, 3, 4, 0.6);
    backdrop-filter: blur(2px);
}
.qe-modal__panel {
    position: relative;
    width: min(820px, 100%);
    max-height: min(88vh, 820px);
    display: flex; flex-direction: column;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: 8px;
    box-shadow: var(--shadow-md);
}
.qe-modal__head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
}
.qe-modal__title { font-size: 16px; font-weight: 700; margin: 0; }
.qe-modal__close {
    background: transparent; border: none;
    color: var(--text-secondary);
    font-size: 24px; line-height: 1;
    width: 36px; height: 36px;
    border-radius: 50%;
    cursor: pointer;
}
.qe-modal__close:hover { background: var(--bg-elevated); color: var(--text-primary); }
.qe-modal__body {
    padding: 18px 20px 22px;
    overflow-y: auto;
}

.qe-detail__row {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 14px;
    margin-bottom: 16px;
}
.qe-detail__metric {
    display: flex; flex-direction: column; gap: 4px;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 4px;
}
.qe-detail__label {
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 4px;
}
.qe-detail__section { margin-top: 16px; }
.qe-detail__text {
    font-size: 13px;
    line-height: 1.55;
    color: var(--text-primary);
    white-space: pre-wrap;
    word-break: break-word;
}
.qe-detail__error {
    font-size: 12px;
    color: var(--danger);
    background: rgba(255, 114, 118, 0.08);
    border: 1px solid rgba(255, 114, 118, 0.3);
    padding: 8px 12px;
    border-radius: 4px;
    margin: 10px 0;
}
.qe-detail__meta {
    margin-top: 18px;
    padding-top: 12px;
    border-top: 1px dashed var(--border);
    font-size: 11px;
    color: var(--text-dim);
}
.qe-detail__meta code {
    font-family: "JetBrains Mono", ui-monospace, monospace;
    padding: 1px 5px;
    background: var(--bg-elevated);
    border-radius: 3px;
}

.qe-ctx {
    margin-bottom: 10px;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: 4px;
}
.qe-ctx__head {
    font-size: 10px;
    letter-spacing: 0.08em;
    text-transform: uppercase;
    color: var(--text-secondary);
    margin-bottom: 6px;
}
.qe-ctx__body {
    font-size: 12px;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--text-primary);
}

/* ── Mobile tweaks ───────────────────────────────────────────────────── */
@media (max-width: 600px) {
    .qe-card__value { font-size: 26px; }
    .qe-td-ellipsis { max-width: 180px; }
    .qe-modal__panel { max-height: 94vh; }
    .qe-chart-legend { padding-left: 8px; flex-wrap: wrap; }
}
