/* Overfitting Explorer - Custom Styles */
/* Extends shared/css/main.css */

/* ===== Analysis Layout ===== */
.analysis-layout {
    display: grid;
    grid-template-columns: 1fr 280px;
    gap: 2rem;
}

@media (max-width: 900px) {
    .analysis-layout {
        grid-template-columns: 1fr;
    }
}

/* ===== Model Builder Panel ===== */
.model-builder-panel {
    padding: 1.5rem;
    background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%);
    border-radius: 12px;
    border: 1px solid var(--app-border, #e2e8f0);
}

.model-builder-panel h3 {
    margin: 0 0 0.5rem;
    font-size: 1.1rem;
    color: var(--app-text, #1e293b);
}

.builder-hint {
    color: var(--app-muted, #64748b);
    font-size: 0.9rem;
    margin-bottom: 1.25rem;
}

/* ===== Term Grid (Checkboxes) ===== */
.term-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.term-checkbox {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1rem;
    background: white;
    border: 2px solid var(--app-border, #e2e8f0);
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    user-select: none;
}

.term-checkbox:hover:not(.disabled) {
    border-color: var(--app-accent, #2563eb);
    background: #f0f9ff;
}

.term-checkbox:has(input:checked) {
    border-color: var(--app-accent, #2563eb);
    background: #eff6ff;
}

.term-checkbox.disabled {
    opacity: 0.7;
    cursor: default;
    background: #e2e8f0;
}

.term-checkbox.disabled .term-label {
    color: var(--app-muted, #64748b);
}

.term-checkbox.unavailable {
    opacity: 0.4;
    cursor: not-allowed;
    text-decoration: line-through;
}

.term-checkbox input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--app-accent, #2563eb);
    cursor: inherit;
}

.term-label {
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
    font-size: 0.95rem;
    font-weight: 500;
    color: var(--app-text, #1e293b);
}

.term-counter {
    text-align: right;
    font-size: 0.85rem;
    color: var(--app-muted, #64748b);
    margin-bottom: 1rem;
}

.term-counter strong {
    color: var(--app-accent, #2563eb);
}

.term-counter.at-limit strong {
    color: var(--app-danger, #dc2626);
}

/* ===== Equation Display Box ===== */
.equation-display-box {
    padding: 1rem 1.25rem;
    background: white;
    border-radius: 8px;
    border-left: 4px solid var(--app-accent, #2563eb);
    font-size: 0.95rem;
    color: var(--app-text, #1e293b);
    word-break: break-word;
}

.equation-display-box #equation-text {
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
    font-weight: 500;
}

.equation-display-box .coef {
    color: var(--app-accent, #2563eb);
    font-weight: 700;
}

/* ===== Metrics Panel ===== */
.metrics-panel {
    padding: 1.25rem;
    background: white;
    border-radius: 12px;
    border: 1px solid var(--app-border, #e2e8f0);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
}

.metrics-panel h3 {
    margin: 0 0 1rem;
    font-size: 1.1rem;
    color: var(--app-text, #1e293b);
}

.metrics-group {
    margin-bottom: 1.25rem;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--app-border, #e2e8f0);
}

.metrics-group:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}

.metrics-group h4 {
    margin: 0 0 0.75rem;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--app-muted, #64748b);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.training-metrics h4 {
    color: var(--app-accent, #2563eb);
}

.holdout-metrics h4 {
    color: #f59e0b;
}

.metric-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.5rem 0;
}

.metric-label {
    font-size: 0.9rem;
    color: var(--app-text, #1e293b);
    cursor: help;
}

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

.metrics-advanced {
    margin-top: 0.5rem;
}

.metrics-advanced summary {
    font-size: 0.85rem;
    color: var(--app-muted, #64748b);
    cursor: pointer;
}

.metrics-advanced .metrics-group {
    margin-top: 0.75rem;
    border-bottom: none;
    padding-bottom: 0;
}

/* ===== Holdout Toggle ===== */
.holdout-toggle-container {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
    padding: 1rem 1.25rem;
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border-radius: 10px;
    border: 2px solid #f59e0b;
}

.holdout-button {
    padding: 0.75rem 1.5rem;
    background: #f59e0b;
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

.holdout-button:hover {
    background: #d97706;
    transform: translateY(-1px);
}

.holdout-button.active {
    background: #059669;
}

.holdout-button.active:hover {
    background: #047857;
}

.holdout-hint {
    flex: 1;
    min-width: 200px;
    margin: 0;
    font-size: 0.9rem;
    color: #92400e;
}

/* ===== Plot Container ===== */
.plot-container {
    width: 100%;
    height: 450px;
    margin-bottom: 1rem;
    border-radius: 8px;
    overflow: hidden;
    background: #fafafa;
}

/* ===== Plot Legend ===== */
.plot-legend {
    display: flex;
    flex-wrap: wrap;
    gap: 1.5rem;
    justify-content: center;
    padding: 0.75rem;
    background: #f8fafc;
    border-radius: 8px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    color: var(--app-text, #1e293b);
}

.legend-dot {
    width: 12px;
    height: 12px;
    border-radius: 50%;
}

.legend-dot.training {
    background: #2563eb;
}

.legend-dot.holdout {
    background: #f59e0b;
}

.legend-line {
    width: 24px;
    height: 3px;
    border-radius: 2px;
}

.legend-line.fitted {
    background: #dc2626;
}

/* ===== Saved Models Grid ===== */
.comparison-header {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.comparison-header p {
    margin: 0;
    color: var(--app-muted, #64748b);
}

.saved-models-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    margin-bottom: 1.5rem;
}

@media (max-width: 768px) {
    .saved-models-grid {
        grid-template-columns: 1fr;
    }
}

.empty-model-slot {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 2rem;
    background: #f8fafc;
    border: 2px dashed #cbd5e1;
    border-radius: 12px;
    min-height: 180px;
}

.slot-label {
    font-weight: 600;
    color: var(--app-muted, #64748b);
    margin-bottom: 0.5rem;
}

.slot-hint {
    font-size: 0.85rem;
    color: #94a3b8;
}

/* ===== Saved Model Card ===== */
.saved-model-card {
    padding: 1.25rem;
    background: white;
    border: 2px solid var(--app-border, #e2e8f0);
    border-radius: 12px;
    position: relative;
}

.saved-model-card.best-training {
    border-color: #2563eb;
}

.saved-model-card.best-holdout {
    border-color: #059669;
}

.saved-model-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.75rem;
}

.saved-model-name {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--app-text, #1e293b);
}

.saved-model-delete {
    background: none;
    border: none;
    color: #94a3b8;
    cursor: pointer;
    padding: 0.25rem;
    font-size: 1.1rem;
    line-height: 1;
    transition: color 0.2s ease;
}

.saved-model-delete:hover {
    color: #dc2626;
}

.saved-model-equation {
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
    font-size: 0.8rem;
    color: var(--app-muted, #64748b);
    margin-bottom: 1rem;
    word-break: break-all;
    line-height: 1.4;
}

.saved-model-metrics {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.5rem;
}

.saved-metric {
    display: flex;
    flex-direction: column;
    padding: 0.5rem;
    background: #f8fafc;
    border-radius: 6px;
}

.saved-metric-label {
    font-size: 0.7rem;
    color: var(--app-muted, #64748b);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

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

.saved-metric.highlight .saved-metric-value {
    color: #059669;
}

/* ===== Questions Section ===== */
.questions-list {
    padding-left: 1.5rem;
}

.questions-list li {
    margin-bottom: 1rem;
    line-height: 1.6;
}

.questions-list li:last-child {
    margin-bottom: 0;
}

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

.guide-section {
    padding: 1rem;
    background: #f8fafc;
    border-radius: 8px;
}

.guide-section h5 {
    margin: 0 0 0.5rem;
    font-size: 0.95rem;
    color: var(--app-text, #1e293b);
}

.guide-section p {
    margin: 0;
    font-size: 0.9rem;
    color: var(--app-muted, #64748b);
    line-height: 1.5;
}

/* ===== Callout Boxes ===== */
.callout-box {
    padding: 1rem 1.25rem;
    border-radius: 8px;
    margin: 1rem 0;
}

.callout-blue {
    background: #f0f9ff;
    border-left: 4px solid #3b82f6;
}

.callout-amber {
    background: #fef3c7;
    border-left: 4px solid #f59e0b;
}

.callout-box p {
    margin: 0;
}

/* ===== Scenario Styles ===== */
.scenario-controls {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 1rem;
    margin-bottom: 1rem;
}

.scenario-controls__input {
    display: flex;
    gap: 0.75rem;
    flex: 1;
    min-width: 250px;
}

.scenario-controls__input select {
    flex: 1;
    padding: 0.6rem 1rem;
    border: 1px solid var(--app-border, #e2e8f0);
    border-radius: 8px;
    font-size: 0.95rem;
    background: white;
}

.scenario-description-container {
    padding: 1rem;
    background: #f8fafc;
    border-radius: 8px;
}

.scenario-placeholder {
    color: var(--app-muted, #64748b);
    font-style: italic;
    margin: 0;
}

/* Scenario description rich content */
.scenario-description {
    line-height: 1.6;
}

.scenario-header {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.scenario-icon {
    font-size: 1.5rem;
}

.scenario-header h4 {
    margin: 0;
    flex: 1;
    min-width: 200px;
}

.scenario-badge {
    font-size: 0.75rem;
    padding: 0.25rem 0.75rem;
    background: #e0f2fe;
    color: #0369a1;
    border-radius: 999px;
    font-weight: 500;
}

.scenario-intro {
    margin-bottom: 1rem;
}

.scenario-variables {
    margin: 1rem 0;
    padding: 1rem;
    background: white;
    border-radius: 8px;
}

.scenario-variables h5 {
    margin: 0 0 0.75rem;
    font-size: 0.9rem;
}

.scenario-var-table {
    width: 100%;
    font-size: 0.9rem;
}

.scenario-var-table td {
    padding: 0.5rem 0;
    vertical-align: top;
}

.scenario-var-table td:first-child {
    width: 120px;
}

.var-tag {
    display: inline-block;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    font-family: 'SF Mono', 'Monaco', 'Inconsolata', 'Roboto Mono', monospace;
    font-size: 0.8rem;
    font-weight: 500;
}

.var-tag.predictor {
    background: #dbeafe;
    color: #1d4ed8;
}

.var-tag.outcome {
    background: #dcfce7;
    color: #15803d;
}

.context-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 0.75rem;
    margin: 1rem 0;
}

.context-item {
    display: flex;
    flex-direction: column;
    padding: 0.75rem;
    background: white;
    border-radius: 6px;
    text-align: center;
}

.context-item strong {
    font-size: 0.75rem;
    color: var(--app-muted, #64748b);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.25rem;
}

.context-item span {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--app-text, #1e293b);
}

.scenario-insights {
    margin-top: 1rem;
    padding: 1rem;
    background: #f0fdf4;
    border-radius: 8px;
    border-left: 4px solid #22c55e;
}

.scenario-insights h5 {
    margin: 0 0 0.5rem;
    font-size: 0.9rem;
    color: #15803d;
}

.scenario-insights ul {
    margin: 0;
    padding-left: 1.25rem;
}

.scenario-insights li {
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

/* ===== Equation Block (for MathJax) ===== */
.equation-block {
    padding: 1rem;
    background: #f8fafc;
    border-radius: 8px;
    margin: 1rem 0;
    overflow-x: auto;
}

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

/* ===== Data Table ===== */
.data-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9rem;
}

.data-table th,
.data-table td {
    padding: 0.75rem;
    text-align: left;
    border-bottom: 1px solid var(--app-border, #e2e8f0);
}

.data-table th {
    background: #f8fafc;
    font-weight: 600;
    color: var(--app-text, #1e293b);
}

.data-table td strong {
    color: var(--app-accent, #2563eb);
}

/* ===== Button Styles ===== */
button.primary {
    padding: 0.6rem 1.25rem;
    background: var(--app-accent, #2563eb);
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

button.primary:hover {
    background: #1d4ed8;
    transform: translateY(-1px);
}

button.primary:disabled {
    background: #94a3b8;
    cursor: not-allowed;
    transform: none;
}

button.secondary {
    padding: 0.6rem 1.25rem;
    background: white;
    color: var(--app-text, #1e293b);
    border: 1px solid var(--app-border, #e2e8f0);
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.95rem;
    cursor: pointer;
    transition: all 0.2s ease;
}

button.secondary:hover {
    background: #f8fafc;
    border-color: var(--app-accent, #2563eb);
}

button.secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* ===== Interpretation Aid ===== */
.interpretation-aid {
    margin-top: 1rem;
    background: #f8fafc;
    border-radius: 8px;
    padding: 1rem;
}

.interpretation-aid summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--app-text, #1e293b);
}

.interpretation-content {
    margin-top: 1rem;
}

/* ===== Intro Notes ===== */
details.intro-notes {
    background: #f0f9ff;
    padding: 1rem 1.25rem;
    border-radius: 8px;
    margin: 1rem 0;
}

details.intro-notes summary {
    cursor: pointer;
    font-weight: 600;
    color: var(--app-text, #1e293b);
    user-select: none;
}

details.intro-notes[open] summary {
    margin-bottom: 0.75rem;
}

.notes-content {
    line-height: 1.6;
}

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

.notes-content li {
    margin-bottom: 0.5rem;
}

/* ===== Holdout Reveal Section ===== */
.holdout-section {
    margin-top: 1rem;
}

.holdout-reveal-container {
    padding: 1.5rem;
    border-radius: 12px;
    text-align: center;
}

.holdout-locked {
    padding: 2rem;
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    border: 2px dashed #94a3b8;
    border-radius: 12px;
}

.holdout-locked .lock-icon {
    font-size: 2.5rem;
    display: block;
    margin-bottom: 0.75rem;
}

.holdout-locked h3 {
    margin: 0 0 0.5rem;
    color: var(--app-muted, #64748b);
    font-size: 1.1rem;
}

.holdout-locked p {
    color: var(--app-muted, #64748b);
    font-size: 0.9rem;
    max-width: 500px;
    margin: 0 auto 1rem;
    line-height: 1.5;
}

.models-saved-counter {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--app-accent, #2563eb);
}

.models-saved-counter #models-saved-count {
    font-size: 1.5rem;
}

.holdout-unlocked {
    padding: 2rem;
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    border: 2px solid #f59e0b;
    border-radius: 12px;
}

.holdout-unlocked .holdout-button {
    padding: 1rem 2rem;
    font-size: 1.1rem;
    background: #f59e0b;
    color: white;
    border: none;
    border-radius: 10px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-bottom: 0.75rem;
}

.holdout-unlocked .holdout-button:hover {
    background: #d97706;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.4);
}

.holdout-unlocked .holdout-button.revealed {
    background: #059669;
}

.holdout-unlocked .holdout-button.revealed:hover {
    background: #047857;
}

.holdout-unlocked .holdout-hint {
    margin: 0;
    color: #92400e;
    font-size: 0.9rem;
    line-height: 1.5;
}

/* ===== Saved Models Line Style ===== */
.legend-line.saved {
    background: linear-gradient(90deg, #8b5cf6, #a78bfa, #8b5cf6);
    background-size: 12px 3px;
}

/* ===== Holdout Metric Styling ===== */
.saved-metric.holdout-metric {
    background: rgba(245, 158, 11, 0.1);
    border-radius: 4px;
    padding: 0.25rem;
}

.saved-metric-value.degraded {
    color: #dc2626;
    font-weight: 700;
}

.saved-metric-value.good {
    color: #059669;
    font-weight: 600;
}

.saved-metric-value.muted {
    color: var(--app-muted, #64748b);
}

/* Active holdout button state */
.holdout-unlocked .holdout-button.active {
    background: #059669;
}

.holdout-unlocked .holdout-button.active:hover {
    background: #047857;
}
