/* ==========================================================================
   Widget · La Genèse de la Courbe ROC (Du Seuil à l'Espace ROC)
   Anti-jitter : tabular-nums, min-heights, minmax(0, 1fr)
   ========================================================================== */

.roc-widget {
  --roc-purple: #7c3aed;
  --roc-purple-light: #f5f3ff;
  --roc-purple-border: #ddd6fe;
  --roc-vp: #10b981;
  --roc-vp-light: #ecfdf5;
  --roc-fp: #f59e0b;
  --roc-fp-light: #fffbeb;
  --roc-fn: #ef4444;
  --roc-fn-light: #fef2f2;
  --roc-vn: #0284c7;
  --roc-vn-light: #f0f9ff;
  --roc-slate: #64748b;
  --roc-slate-light: #f1f5f9;
  --roc-text: #0f172a;
  --roc-border: #e2e8f0;
  --roc-card-bg: #ffffff;

  font-variant-numeric: tabular-nums;
  margin: 1.5rem 0 2rem;
}

/* Presets Bar */
.roc-presets {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin: 0.85rem 0 1.25rem;
}

.roc-preset-btn {
  appearance: none;
  border: 1px solid var(--roc-border);
  background: #ffffff;
  color: #334155;
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
  font-weight: 600;
  border-radius: 9999px;
  cursor: pointer;
  transition: all 0.15s ease;
  line-height: 1.25;
}

.roc-preset-btn:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
  color: var(--roc-text);
}

.roc-preset-btn.active {
  background: #ede9fe;
  color: var(--roc-purple);
  border-color: #c4b5fd;
  font-weight: 700;
  box-shadow: 0 1px 2px rgba(124, 58, 237, 0.1);
}

/* ==========================================================================
   4-Quadrant Architecture (1 -> 2 -> 3 -> 4)
   ========================================================================== */
.roc-quadrants-container {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  margin-top: 1rem;
}

.roc-quadrant-row {
  display: grid;
  grid-template-columns: minmax(0, 1.2fr) minmax(0, 1fr);
  gap: 1.25rem;
  align-items: stretch;
}

@media (max-width: 820px) {
  .roc-quadrant-row {
    grid-template-columns: 1fr;
    gap: 1.25rem;
  }
}

/* Quadrant Cards */
.roc-card {
  background: var(--roc-card-bg);
  border: 1px solid var(--roc-border);
  border-radius: 12px;
  padding: 1.1rem 1.2rem;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.04);
  display: flex;
  flex-direction: column;
  justify-content: flex-start;
  gap: 0.85rem;
}

.roc-card-header {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  padding-bottom: 0.45rem;
  border-bottom: 1px solid var(--roc-border);
  min-height: 28px;
}

.roc-card-title {
  font-size: 0.88rem;
  font-weight: 800;
  color: var(--roc-text);
}

.roc-card-badge {
  font-size: 0.72rem;
  font-weight: 600;
  color: var(--roc-slate);
  background: #f8fafc;
  padding: 0.15rem 0.55rem;
  border-radius: 9999px;
  border: 1px solid var(--roc-border);
  white-space: nowrap;
}

/* SVG Containers */
.roc-svg-wrap {
  width: 100%;
  position: relative;
  background: #f8fafc;
  border: 1px solid var(--roc-border);
  border-radius: 8px;
  padding: 4px;
  overflow: hidden;
}

.roc-svg-wrap svg {
  width: 100%;
  height: auto;
  display: block;
}

.roc-svg-wrap--roc {
  max-width: 270px;
  margin: auto auto;
}

/* Slider Controls below distributions (Q1) */
.roc-slider-container {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
  padding: 0.75rem 0.85rem;
  background: #f8fafc;
  border: 1px solid var(--roc-border);
  border-radius: 8px;
}

.roc-slider-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.roc-slider-label {
  font-size: 0.82rem;
  font-weight: 700;
  color: #334155;
}

.roc-slider-val {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--roc-text);
  min-width: 4rem;
  text-align: right;
}

.roc-slider-container input[type="range"] {
  width: 100%;
  cursor: pointer;
  accent-color: var(--roc-text);
}

.roc-slider-bounds {
  display: flex;
  justify-content: space-between;
  font-size: 0.68rem;
  font-weight: 600;
  color: #94a3b8;
}

/* 2x2 Contingency Table */
.roc-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 5px;
  margin: 0;
}

.roc-th-corner {
  background: transparent;
  color: #94a3b8;
  font-size: 0.72rem;
  font-weight: 600;
  text-align: left;
  padding: 0.3rem 0.5rem;
}

.roc-th-col {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 0.4rem 0.5rem;
  text-align: center;
}

.roc-th-title {
  display: block;
  font-size: 0.76rem;
  font-weight: 700;
  color: #334155;
  line-height: 1.25;
}

.roc-th-count {
  display: block;
  font-size: 0.68rem;
  font-weight: 600;
  color: #64748b;
}

.roc-th-row {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-radius: 6px;
  padding: 0.45rem 0.6rem;
  text-align: left;
  min-width: 5rem;
}

.roc-row-test {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  color: #1e293b;
  line-height: 1.25;
}

.roc-row-cond {
  display: block;
  font-size: 0.68rem;
  font-weight: 600;
  color: #64748b;
}

.roc-td-cell {
  border-radius: 8px;
  padding: 0.6rem 0.5rem;
  text-align: center;
  vertical-align: middle;
  border: 1px solid transparent;
}

.roc-td--vp {
  background: #ecfdf5;
  border-color: #a7f3d0;
}

.roc-td--fp {
  background: #fffbeb;
  border-color: #fde68a;
}

.roc-td--fn {
  background: #fef2f2;
  border-color: #fecaca;
}

.roc-td--vn {
  background: #f0f9ff;
  border-color: #bae6fd;
}

.roc-cell-stack {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
}

.roc-cell-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  font-size: 0.68rem;
  font-weight: 700;
  padding: 0.12rem 0.45rem;
  border-radius: 9999px;
  line-height: 1.1;
  letter-spacing: 0.02em;
}

.roc-cell-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  display: inline-block;
}

.roc-pill--vp { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.roc-pill--vp .roc-cell-dot { background: #10b981; }

.roc-pill--fp { background: #fef3c7; color: #92400e; border: 1px solid #fde68a; }
.roc-pill--fp .roc-cell-dot { background: #f59e0b; }

.roc-pill--fn { background: #fee2e2; color: #991b1b; border: 1px solid #fecaca; }
.roc-pill--fn .roc-cell-dot { background: #ef4444; }

.roc-pill--vn { background: #e0f2fe; color: #0369a1; border: 1px solid #bae6fd; }
.roc-pill--vn .roc-cell-dot { background: #0284c7; }

.roc-cell-val {
  font-size: 1.35rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  line-height: 1;
  display: block;
  text-align: center;
}

.roc-td--vp .roc-cell-val { color: #065f46; }
.roc-td--fp .roc-cell-val { color: #92400e; }
.roc-td--fn .roc-cell-val { color: #991b1b; }
.roc-td--vn .roc-cell-val { color: #0369a1; }

/* Metrics Column (Q3) */
.roc-metrics-stack {
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
  gap: 0.55rem;
}

.roc-metric-card {
  background: #ffffff;
  border: 1px solid #e2e8f0;
  border-left: 4px solid transparent;
  border-radius: 8px;
  padding: 0.55rem 0.85rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.6rem;
  min-height: 52px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.02);
  transition: border-color 0.15s ease, background-color 0.15s ease;
}

.roc-metric--se { border-left-color: #10b981; }
.roc-metric--sp { border-left-color: #0284c7; }
.roc-metric--rvpos { border-left-color: #7c3aed; }
.roc-metric--rvneg { border-left-color: #64748b; }

.roc-metric--se .roc-metric-val { color: #065f46; }
.roc-metric--sp .roc-metric-val { color: #0369a1; }
.roc-metric--rvpos .roc-metric-val { color: #6d28d9; }
.roc-metric--rvneg .roc-metric-val { color: #334155; }

.roc-metric-lead {
  display: flex;
  flex-direction: column;
  gap: 0.15rem;
  min-width: 0;
  overflow: hidden;
}

.roc-metric-label {
  font-size: 0.84rem;
  font-weight: 700;
  color: #1e293b;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.roc-metric-fraction {
  font-size: 0.72rem;
  font-weight: 600;
  color: #64748b;
  font-variant-numeric: tabular-nums;
  line-height: 1.25;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.roc-metric-val {
  font-size: 1.25rem;
  font-weight: 800;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
  line-height: 1;
  flex-shrink: 0;
}

/* Dynamic Clinical Note */
.roc-dynamic-note {
  background: #ffffff;
  border: 1px solid var(--roc-border);
  border-left: 4px solid var(--roc-purple);
  border-radius: 8px;
  padding: 0.85rem 1.15rem;
  font-size: 0.88rem;
  line-height: 1.5;
  color: #334155;
  min-height: 60px;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.roc-dynamic-note strong {
  color: var(--roc-text);
}
