/* 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: var(--nx-radius-md);
}
.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: var(--accent-text); }
.qe-card__value--amber { color: var(--amber-text); }
.qe-card__value--red   { color: var(--coral-text); }
.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: var(--nx-radius-pill);
    line-height: 1.2;
    min-width: 52px;
    text-align: center;
}
.qe-pill--green { background: var(--green-soft);  color: var(--accent-text);  border: 1px solid var(--green-soft-bd); }
.qe-pill--amber { background: var(--amber-soft);  color: var(--amber-text);  border: 1px solid var(--amber-soft-bd); }
.qe-pill--red   { background: var(--coral-soft); color: var(--coral-text); border: 1px solid var(--coral-soft-bd); }
.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: var(--nx-radius-pill);
    font-size: 11px;
    font-weight: 600;
    margin: 0 2px;
    font-family: "JetBrains Mono", ui-monospace, monospace;
}
.qe-legend--green { background: var(--green-soft);  color: var(--accent-text); }
.qe-legend--amber { background: var(--amber-soft);  color: var(--amber-text); }
.qe-legend--red   { background: var(--coral-soft); color: var(--coral-text); }
.qe-legend--line-faith { color: var(--text-secondary); font-weight: 600; }
.qe-legend--line-rel   { color: var(--text-secondary); font-weight: 600; }
.qe-legend--line-cp    { color: var(--text-secondary); 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: var(--chart-green); }
.qe-legend--line-rel::before   { background: var(--chart-violet); }
.qe-legend--line-cp::before    { background: var(--chart-cyan); }

/* ── 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: 6 6; opacity: 0.8; }
.qe-chart__threshold--amber       { stroke: var(--amber); }
.qe-chart__threshold--green       { stroke: var(--accent); }
.qe-chart__threshold-label        { font-size: 10px; font-weight: 600; font-family: "JetBrains Mono", ui-monospace, monospace; opacity: 0.9;
                                    paint-order: stroke; stroke: var(--bg-secondary); stroke-width: 3px; stroke-linejoin: round; }
/* Faint tint over leading/trailing no-data time spans. */
.qe-chart__nodata                 { fill: var(--text-dim); opacity: 0.06; pointer-events: none; }
.qe-chart__threshold-label--amber { fill: var(--amber-text); }
.qe-chart__threshold-label--green { fill: var(--accent-text); }
/* nxzen series — Faithfulness (green, thickest), Relevance (violet), Context Precision (cyan). */
.qe-chart__line                   { stroke-width: 3; stroke-linecap: round; stroke-linejoin: round; fill: none; }
.qe-chart__line--faith            { stroke: var(--chart-green); stroke-width: 3.5; }
.qe-chart__line--rel              { stroke: var(--chart-violet); }
.qe-chart__line--cp               { stroke: var(--chart-cyan); }
/* Neon glow on the lines — dark mode only (brand signature; disabled in light). */
[data-theme="dark"] .qe-chart__line { filter: url(#qe-line-glow); }
/* Soft gradient area below the primary (Faithfulness) line — fill set inline
 * via `fill: url(#qe-grad-*)`; the path itself is strokeless. */
.qe-chart__area                   { stroke: none; pointer-events: none; }
.qe-chart__dot                    { fill: currentColor; }
.qe-chart__dot.qe-chart__line--faith { fill: var(--chart-green); }
.qe-chart__dot.qe-chart__line--rel   { fill: var(--chart-violet); }
.qe-chart__dot.qe-chart__line--cp    { fill: var(--chart-cyan); }
/* Staggered draw-in: lines draw (pathLength=1 + dashoffset), area fades, dots pop. */
.qe-chart--animate .qe-chart__line { stroke-dasharray: 1; animation: qe-line-draw 0.9s cubic-bezier(.2,.8,.2,1) forwards; }
.qe-chart--animate .qe-chart__area { animation: qe-fade 0.6s ease 0.25s both; }
.qe-chart--animate .qe-chart__dot  { animation: qe-fade 0.4s ease 1.05s both; }
@keyframes qe-line-draw { from { stroke-dashoffset: 1; } to { stroke-dashoffset: 0; } }
@keyframes qe-fade { from { opacity: 0; } to { opacity: 1; } }
@media (prefers-reduced-motion: reduce) {
  .qe-chart--animate .qe-chart__line,
  .qe-chart--animate .qe-chart__area,
  .qe-chart--animate .qe-chart__dot { animation: none; stroke-dasharray: none; }
}
.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: var(--nx-radius-lg);
    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: var(--nx-radius-sm);
}
.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: var(--nx-radius-sm);
    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: var(--nx-radius-sm);
}

.qe-ctx {
    margin-bottom: 10px;
    padding: 10px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--border);
    border-radius: var(--nx-radius-md);
}
.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; }
}
