/* Rare Event Calibration Lab - Custom Styles */
/* Extends shared/css/main.css */

/* ===== Settings Section ===== */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    margin-bottom: 1.5rem;
}

.settings-select,
.settings-input {
    width: 100%;
    padding: 0.5rem 0.75rem;
    border: 1px solid var(--app-border, #e2e8f0);
    border-radius: 6px;
    font-size: 0.95rem;
    background: var(--app-card-bg, #fff);
    color: var(--app-text, #1e293b);
    font-family: inherit;
}

.settings-actions {
    display: flex;
    gap: 0.75rem;
    align-items: center;
    flex-wrap: wrap;
}

.run-btn {
    padding: 0.65rem 2rem;
    font-size: 1rem;
    font-weight: 600;
}

/* ===== Simulation Status ===== */
.sim-status {
    margin-top: 1rem;
    padding: 0.6rem 1rem;
    border-radius: 6px;
    font-size: 0.9rem;
}
.sim-status--running { background: #eff6ff; color: #2563eb; border: 1px solid #bfdbfe; }
.sim-status--done    { background: #f0fdf4; color: #166534; border: 1px solid #bbf7d0; }
.sim-status--error   { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }

/* ===== Section Description ===== */
.section-description {
    color: var(--app-text-muted, #64748b);
    margin-top: -0.5rem;
    margin-bottom: 1.25rem;
    font-size: 0.95rem;
}

/* ===== Correction Toggle Row ===== */
.correction-toggle-row {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1.25rem;
    padding: 0.75rem 1rem;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid var(--app-border, #e2e8f0);
}

/* ===== Conditions Grid ===== */
.conditions-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(380px, 1fr));
    gap: 1.25rem;
}

/* ===== Condition Card ===== */
.condition-card {
    background: var(--app-card-bg, #fff);
    border: 1px solid var(--app-border, #e2e8f0);
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
}

.condition-card__header {
    padding: 1rem 1.25rem 0.75rem;
    background: #f8fafc;
}

.condition-card__header h3 {
    margin: 0 0 0.75rem 0;
    font-size: 1rem;
    font-weight: 700;
}

.condition-stats-row {
    display: flex;
    gap: 0.45rem;
    flex-wrap: wrap;
}

/* ===== Stat Chips ===== */
.stat-chip {
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0.3rem 0.55rem;
    background: var(--app-card-bg, #fff);
    border: 1px solid var(--app-border, #e2e8f0);
    border-radius: 6px;
    min-width: 60px;
}

.stat-chip--highlight { background: #eff6ff; border-color: #bfdbfe; }
.stat-chip--warn      { background: #fffbeb; border-color: #fde68a; }
.stat-chip--danger    { background: #fef2f2; border-color: #fecaca; }

.stat-label {
    font-size: 0.67rem;
    color: var(--app-text-muted, #64748b);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    white-space: nowrap;
}

.stat-value {
    font-size: 0.88rem;
    font-weight: 700;
    color: var(--app-text, #1e293b);
    font-family: 'SF Mono', Monaco, Inconsolata, 'Roboto Mono', monospace;
}

.true-rate-note {
    margin-top: 0.5rem;
    font-size: 0.78rem;
    color: var(--app-text-muted, #64748b);
}

.condition-chart {
    padding: 0.5rem 0.25rem 0.25rem;
}

/* ===== Overlay Toggle Buttons ===== */
.overlay-toggle-row {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
}

.overlay-btn {
    padding: 0.4rem 1.25rem;
    border: 1px solid var(--app-border, #e2e8f0);
    background: var(--app-card-bg, #fff);
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--app-text-muted, #64748b);
    transition: all 0.15s;
    font-family: inherit;
}

.overlay-btn.active {
    background: var(--app-accent, #2563eb);
    color: #fff;
    border-color: var(--app-accent, #2563eb);
}

.overlay-btn:not(.active):hover {
    background: #f1f5f9;
    color: var(--app-text, #1e293b);
}

/* ===== Taller Plot Container ===== */
.plot-container--tall .js-plotly-plot {
    min-height: 390px;
}

/* ===== Plot container default ===== */
.plot-container {
    width: 100%;
    display: block;
}

/* ===== Comparison Charts Grid ===== */
.comparison-charts-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
    margin-top: 0.75rem;
}

.comparison-charts-grid > div {
    min-width: 0;
    width: 100%;
    overflow: hidden;
    position: relative;
}

/* Hard-clip Plotly SVGs inside the side-by-side grid so
   outside-text labels never bleed into the adjacent chart */
.comparison-charts-grid .js-plotly-plot,
.comparison-charts-grid .js-plotly-plot .main-svg {
    max-width: 100% !important;
    overflow: hidden !important;
}

.comparison-charts-grid h4 {
    margin: 0 0 0.5rem 0;
    font-size: 0.85rem;
    color: var(--app-text-muted, #64748b);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

/* ===== Metrics Table ===== */
.table-scroll {
    overflow-x: auto;
}

.metrics-table th,
.metrics-table td {
    white-space: nowrap;
}

.table-note {
    margin-top: 0.75rem;
    font-size: 0.85rem;
    color: var(--app-text-muted, #64748b);
}

/* ===== Tags ===== */
.tag {
    display: inline-block;
    padding: 0.1rem 0.4rem;
    border-radius: 4px;
    font-size: 0.72rem;
    font-weight: 600;
    margin-left: 0.3rem;
    vertical-align: middle;
}

.tag--success { background: #dcfce7; color: #166534; }
.tag--danger  { background: #fef2f2; color: #b91c1c; }
.tag--neutral { background: #f1f5f9; color: #475569; }
.tag--warn    { background: #fef9c3; color: #854d0e; }

/* ===== Two-Act Grid (Math section) ===== */
.two-act-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 1rem;
}

.act-block {
    padding: 0.875rem 1rem;
    border-radius: 8px;
}

.act-good { background: #f0fdf4; border-left: 3px solid #22c55e; }
.act-bad  { background: #fef2f2; border-left: 3px solid #ef4444; }

.act-block h5 {
    margin: 0 0 0.5rem 0;
    font-size: 0.9rem;
    font-weight: 700;
}

.act-block p {
    margin: 0.35rem 0 0;
    font-size: 0.87rem;
    line-height: 1.5;
}

/* ===== Guide Sections (Insights) ===== */
.guide-section {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--app-border, #e2e8f0);
}

.guide-section:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.guide-section h5 {
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
    font-weight: 700;
}

/* ===== Walkthrough Steps ===== */
.walkthrough-steps {
    display: flex;
    flex-direction: column;
    gap: 0.875rem;
}

.walkthrough-step {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.step-num {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    background: var(--app-accent, #2563eb);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.87rem;
    margin-top: 2px;
}

.step-body {
    flex: 1;
}

.step-body strong {
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.94rem;
    color: var(--app-text, #1e293b);
}

.step-body p {
    margin: 0;
    font-size: 0.88rem;
    color: var(--app-text-muted, #64748b);
    line-height: 1.55;
}

/* ===== AUC Plain-English line on condition cards ===== */
.auc-plain-english {
    margin-top: 0.5rem;
    font-size: 0.78rem;
    color: var(--app-text-muted, #64748b);
    line-height: 1.4;
}

/* ===== Chart section labels ===== */
.chart-section-label {
    margin: 0 0 0.5rem 0;
    font-size: 0.85rem;
    font-weight: 700;
    color: var(--app-text, #1e293b);
    line-height: 1.35;
}

.chart-section-sublabel {
    font-size: 0.78rem;
    font-weight: 400;
    color: var(--app-text-muted, #64748b);
}

/* ===== Metric Legend Row (above table) ===== */
.metric-legend-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
    padding: 0.75rem 1rem;
    background: #f8fafc;
    border-radius: 8px;
    border: 1px solid var(--app-border, #e2e8f0);
}

.metric-legend-item {
    display: flex;
    align-items: flex-start;
    gap: 0.5rem;
    flex: 1;
    min-width: 200px;
    font-size: 0.83rem;
    color: var(--app-text-muted, #64748b);
    line-height: 1.4;
}

.metric-legend-badge {
    flex-shrink: 0;
    padding: 0.15rem 0.45rem;
    border-radius: 4px;
    font-size: 0.75rem;
    font-weight: 700;
    white-space: nowrap;
    margin-top: 1px;
}

.metric-legend-badge--disc  { background: #eff6ff; color: #2563eb; border: 1px solid #bfdbfe; }
.metric-legend-badge--calib { background: #fff7ed; color: #c2410c; border: 1px solid #fed7aa; }

/* ===== Narrative Summary Panel ===== */
.narrative-panel {
    background: linear-gradient(135deg, #f0f9ff 0%, #f8fafc 100%);
    border: 1px solid #bae6fd;
    border-radius: 10px;
    padding: 1.25rem 1.5rem;
    margin-bottom: 0.5rem;
}

.narrative-title {
    margin: 0 0 1rem 0;
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--app-text, #1e293b);
}

.narrative-steps {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.narrative-step {
    display: flex;
    gap: 1rem;
    align-items: flex-start;
    padding: 0.75rem 1rem;
    border-radius: 8px;
}

.narrative-step--problem { background: #fff7ed; border-left: 3px solid #f97316; }
.narrative-step--good    { background: #f0fdf4; border-left: 3px solid #22c55e; }
.narrative-step--bad     { background: #fef2f2; border-left: 3px solid #ef4444; }
.narrative-step--fix     { background: #eff6ff; border-left: 3px solid #3b82f6; }

.narrative-step-icon {
    flex-shrink: 0;
    width: 26px;
    height: 26px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.82rem;
    color: #fff;
    margin-top: 2px;
}

.narrative-step--problem .narrative-step-icon { background: #f97316; }
.narrative-step--good    .narrative-step-icon { background: #22c55e; }
.narrative-step--bad     .narrative-step-icon { background: #ef4444; }
.narrative-step--fix     .narrative-step-icon { background: #3b82f6; }

.narrative-step strong {
    display: block;
    margin-bottom: 0.25rem;
    font-size: 0.92rem;
    color: var(--app-text, #1e293b);
}

.narrative-step p {
    margin: 0;
    font-size: 0.88rem;
    line-height: 1.55;
    color: #374151;
}

.narrative-step p strong {
    display: inline;
    color: inherit;
}

/* ===== Overview Details / Notes ===== */
.intro-notes {
    margin-top: 1rem;
    border: 1px solid var(--app-border, #e2e8f0);
    border-radius: 8px;
    overflow: hidden;
}

.intro-notes summary {
    padding: 0.7rem 1rem;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    background: #f8fafc;
    list-style: none;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.intro-notes summary::-webkit-details-marker { display: none; }

.intro-notes[open] summary {
    border-bottom: 1px solid var(--app-border, #e2e8f0);
}

.notes-content {
    padding: 1rem 1.25rem;
}

.notes-content ul {
    margin: 0.5rem 0;
    padding-left: 1.5rem;
}

.notes-content li {
    margin-bottom: 0.4rem;
    line-height: 1.5;
}

/* ===== Equation Blocks ===== */
.equation-block {
    background: #f8fafc;
    border-left: 3px solid var(--app-accent, #2563eb);
    border-radius: 0 6px 6px 0;
    padding: 0.875rem 1.125rem;
    margin-bottom: 1rem;
    font-size: 0.92rem;
}

.equation-block p {
    margin: 0 0 0.5rem 0;
}

.equation-block p:last-child {
    margin-bottom: 0;
}

/* ===== Correction Toggle (CSS toggle switch) ===== */
.insight-toggle-label {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-weight: 500;
    font-size: 0.92rem;
    user-select: none;
}

.insight-toggle-label input[type="checkbox"] {
    position: absolute;
    opacity: 0;
    width: 0;
    height: 0;
}

.insight-toggle-knob {
    display: inline-block;
    width: 38px;
    height: 22px;
    background: #cbd5e1;
    border-radius: 11px;
    position: relative;
    flex-shrink: 0;
    transition: background 0.2s;
}

.insight-toggle-knob::after {
    content: '';
    position: absolute;
    top: 3px;
    left: 3px;
    width: 16px;
    height: 16px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
}

.insight-toggle-label input:checked ~ .insight-toggle-knob {
    background: var(--app-accent, #2563eb);
}

.insight-toggle-label input:checked ~ .insight-toggle-knob::after {
    transform: translateX(16px);
}

.insight-toggle-text {
    color: var(--app-text, #1e293b);
}

.insight-toggle-hint {
    font-size: 0.8rem;
    color: var(--app-text-muted, #64748b);
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .two-act-grid          { grid-template-columns: 1fr; }
    .comparison-charts-grid { grid-template-columns: 1fr; }
    .conditions-grid       { grid-template-columns: 1fr; }
    .correction-toggle-row { flex-direction: column; align-items: flex-start; }
}





















