/* ========================================
   Estimador de Precios del Oro - Estilos
   ======================================== */

/* --- Variables --- */
:root {
    --gold-300: #fbbf24;
    --gold-400: #f59e0b;
    --gold-500: #d97706;
    --gold-600: #b45309;
    --bg-dark: #0f172a;
    --bg-card: rgba(30, 41, 59, 0.6);
    --bg-card-hover: rgba(30, 41, 59, 0.8);
    --border-subtle: rgba(255, 255, 255, 0.1);
    --border-hover: rgba(255, 255, 255, 0.2);
    --text-primary: #e2e8f0;
    --text-muted: #94a3b8;
    --green: #22c55e;
    --red: #ef4444;
}

/* --- Canvas Background --- */
#canvas-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
}

/* --- Glassmorphism --- */
.glass {
    background: rgba(30, 41, 59, 0.4);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--border-subtle);
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

.glass-card {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-subtle);
    border-radius: 1rem;
    transition: transform 0.3s ease, box-shadow 0.3s ease, background 0.3s;
}

.glass-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.5);
    background: var(--bg-card-hover);
    border-color: var(--border-hover);
}

/* --- Gold Gradient Text --- */
.gold-gradient-text {
    background: linear-gradient(135deg, var(--gold-300) 0%, var(--gold-400) 50%, var(--gold-500) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* --- Gold Glow --- */
.gold-glow {
    box-shadow: 0 0 20px rgba(245, 158, 11, 0.15), 0 0 60px rgba(245, 158, 11, 0.05);
}

.gold-glow-strong {
    box-shadow: 0 0 30px rgba(245, 158, 11, 0.25), 0 0 80px rgba(245, 158, 11, 0.1);
}

/* --- KPI Cards --- */
.kpi-card {
    background: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-subtle);
    border-radius: 1rem;
    padding: 1.25rem 1.5rem;
    transition: transform 0.3s ease, box-shadow 0.3s ease, border-color 0.3s;
}

.kpi-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.4);
    border-color: rgba(245, 158, 11, 0.3);
}

.kpi-card .kpi-label {
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
    margin-bottom: 0.25rem;
}

.kpi-card .kpi-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: #fff;
}

.kpi-card .kpi-sub {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
}

/* --- Formula Styling --- */
.formula {
    font-family: 'Courier New', Courier, monospace;
    background: rgba(0, 0, 0, 0.3);
    border-left: 3px solid var(--gold-400);
    padding: 0.75rem 1rem;
    border-radius: 0 0.5rem 0.5rem 0;
    overflow-x: auto;
    font-size: 0.9rem;
    color: var(--gold-300);
    margin: 0.75rem 0;
    line-height: 1.6;
}

/* --- Model Tabs --- */
.model-tabs {
    display: flex;
    gap: 0.25rem;
    overflow-x: auto;
    padding-bottom: 0.5rem;
    scrollbar-width: thin;
    scrollbar-color: rgba(245, 158, 11, 0.3) transparent;
}

.model-tab {
    padding: 0.6rem 1.2rem;
    border-radius: 0.75rem 0.75rem 0 0;
    background: rgba(30, 41, 59, 0.4);
    border: 1px solid transparent;
    border-bottom: none;
    color: var(--text-muted);
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.25s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.model-tab:hover {
    background: rgba(30, 41, 59, 0.6);
    color: var(--text-primary);
}

.model-tab.active {
    background: var(--bg-card);
    border-color: var(--border-subtle);
    color: var(--gold-400);
    font-weight: 600;
    position: relative;
}

.model-tab.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background: var(--gold-400);
}

.model-panel {
    display: none;
    padding: 1.5rem;
}

.model-panel.active {
    display: block;
}

/* --- Confidence Bar --- */
.confidence-bar {
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    overflow: hidden;
    position: relative;
}

.confidence-bar-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.6s ease;
}

.confidence-bar-fill.high {
    background: linear-gradient(90deg, var(--gold-400), var(--green));
}

.confidence-bar-fill.medium {
    background: linear-gradient(90deg, var(--gold-400), var(--gold-500));
}

.confidence-bar-fill.low {
    background: linear-gradient(90deg, var(--red), var(--gold-500));
}

/* --- Sparkline Container --- */
.sparkline-container {
    position: relative;
    width: 100%;
    height: 80px;
}

.sparkline-container canvas {
    width: 100% !important;
    height: 100% !important;
}

/* --- Chart Containers --- */
.chart-container {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 9;
    min-height: 300px;
}

.chart-container canvas {
    width: 100% !important;
    height: 100% !important;
}

.chart-container-square {
    position: relative;
    width: 100%;
    aspect-ratio: 1 / 1;
    max-height: 400px;
}

.chart-container-square canvas {
    width: 100% !important;
    height: 100% !important;
}

/* --- Range Selector Buttons --- */
.range-btn {
    padding: 0.4rem 0.9rem;
    border-radius: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid transparent;
    color: var(--text-muted);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.range-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-primary);
}

.range-btn.active {
    background: rgba(245, 158, 11, 0.15);
    border-color: var(--gold-400);
    color: var(--gold-400);
    font-weight: 600;
}

/* --- Toggle Checkbox (Model Toggles) --- */
.model-toggle {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--text-muted);
    transition: color 0.2s;
}

.model-toggle:hover {
    color: var(--text-primary);
}

.model-toggle input[type="checkbox"] {
    appearance: none;
    -webkit-appearance: none;
    width: 16px;
    height: 16px;
    border: 2px solid var(--border-subtle);
    border-radius: 4px;
    cursor: pointer;
    transition: all 0.2s;
    position: relative;
    flex-shrink: 0;
}

.model-toggle input[type="checkbox"]:checked {
    background: var(--gold-400);
    border-color: var(--gold-400);
}

.model-toggle input[type="checkbox"]:checked::after {
    content: '';
    position: absolute;
    left: 3px;
    top: 0px;
    width: 5px;
    height: 9px;
    border: solid #fff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

/* --- Slider Controls --- */
.mc-slider-group {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.mc-slider-group label {
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
}

.mc-slider-group input[type="range"] {
    -webkit-appearance: none;
    appearance: none;
    width: 100%;
    height: 6px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 3px;
    outline: none;
    cursor: pointer;
}

.mc-slider-group input[type="range"]::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--gold-400);
    cursor: pointer;
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.4);
    transition: transform 0.15s;
}

.mc-slider-group input[type="range"]::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

.mc-slider-group input[type="range"]::-moz-range-thumb {
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--gold-400);
    cursor: pointer;
    border: none;
    box-shadow: 0 0 8px rgba(245, 158, 11, 0.4);
}

/* --- Estimation Cards --- */
.est-card {
    position: relative;
    overflow: hidden;
}

.est-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--gold-300), var(--gold-500));
    opacity: 0;
    transition: opacity 0.3s;
}

.est-card:hover::before {
    opacity: 1;
}

/* --- Positive / Negative indicators --- */
.text-positive {
    color: var(--green);
}

.text-negative {
    color: var(--red);
}

/* --- Metrics Table --- */
.metrics-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.metrics-table th {
    text-align: left;
    padding: 0.6rem 0.75rem;
    color: var(--text-muted);
    font-weight: 500;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-subtle);
}

.metrics-table td {
    padding: 0.6rem 0.75rem;
    color: var(--text-primary);
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

.metrics-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

/* --- Loading Overlay --- */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(15, 23, 42, 0.95);
    z-index: 9999;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1.5rem;
    transition: opacity 0.5s ease;
}

#loading-overlay.hidden {
    opacity: 0;
    pointer-events: none;
}

.loading-spinner {
    width: 48px;
    height: 48px;
    border: 3px solid rgba(245, 158, 11, 0.15);
    border-top-color: var(--gold-400);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.loading-text {
    color: var(--text-muted);
    font-size: 0.95rem;
    font-weight: 400;
}

.loading-progress {
    width: 200px;
    height: 4px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 2px;
    overflow: hidden;
}

.loading-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, var(--gold-400), var(--gold-300));
    border-radius: 2px;
    width: 0%;
    transition: width 0.3s ease;
}

/* --- Disclaimer Box --- */
.disclaimer-box {
    border: 1px solid rgba(245, 158, 11, 0.4);
    background: rgba(245, 158, 11, 0.05);
    border-radius: 0.75rem;
    padding: 1.25rem 1.5rem;
}

/* --- Run Button --- */
.btn-gold {
    background: linear-gradient(135deg, var(--gold-400) 0%, var(--gold-500) 100%);
    color: #0f172a;
    font-weight: 700;
    padding: 0.7rem 1.5rem;
    border-radius: 0.75rem;
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 0.9rem;
}

.btn-gold:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 20px rgba(245, 158, 11, 0.4);
}

.btn-gold:active {
    transform: translateY(0);
}

.btn-gold:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

/* --- Section Titles --- */
.section-title {
    position: relative;
    display: inline-block;
}

.section-title::after {
    content: '';
    position: absolute;
    bottom: -4px;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, var(--gold-400), transparent);
    border-radius: 1px;
}

/* --- Animations --- */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse-gold {
    0%, 100% {
        box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.3);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(245, 158, 11, 0);
    }
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.animate-fade-in {
    animation: fadeIn 0.6s ease forwards;
}

.animate-slide-up {
    animation: slideUp 0.6s ease forwards;
}

.animate-pulse-gold {
    animation: pulse-gold 2s ease-in-out infinite;
}

/* Staggered animation delays */
.delay-100 { animation-delay: 0.1s; }
.delay-200 { animation-delay: 0.2s; }
.delay-300 { animation-delay: 0.3s; }
.delay-400 { animation-delay: 0.4s; }

/* --- Scrollbar Styling --- */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: rgba(15, 23, 42, 0.5);
}

::-webkit-scrollbar-thumb {
    background: rgba(245, 158, 11, 0.3);
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: rgba(245, 158, 11, 0.5);
}

/* --- Percentile Table --- */
.percentile-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.percentile-table th {
    text-align: center;
    padding: 0.5rem;
    color: var(--gold-400);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    border-bottom: 1px solid var(--border-subtle);
}

.percentile-table td {
    text-align: center;
    padding: 0.5rem;
    color: var(--text-primary);
    font-weight: 500;
    border-bottom: 1px solid rgba(255, 255, 255, 0.03);
}

/* --- Source / Bibliography --- */
.source-item {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 0.5rem 0;
}

.source-item i {
    color: var(--gold-400);
    margin-top: 0.15rem;
    flex-shrink: 0;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .chart-container {
        aspect-ratio: 4 / 3;
        min-height: 250px;
    }

    .kpi-card .kpi-value {
        font-size: 1.25rem;
    }

    .model-tabs {
        gap: 0.125rem;
    }

    .model-tab {
        padding: 0.5rem 0.8rem;
        font-size: 0.75rem;
    }

    .model-panel {
        padding: 1rem;
    }
}

@media (max-width: 480px) {
    .chart-container {
        min-height: 200px;
    }

    .kpi-card {
        padding: 1rem;
    }

    .kpi-card .kpi-value {
        font-size: 1.1rem;
    }
}

/* --- Test Badges (ADF, Ljung-Box, etc.) --- */
.test-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.25rem 0.75rem;
    border-radius: 9999px;
    font-size: 0.75rem;
    font-weight: 600;
}

.test-badge-pass {
    background: rgba(34, 197, 94, 0.15);
    color: #22c55e;
    border: 1px solid rgba(34, 197, 94, 0.3);
}

.test-badge-fail {
    background: rgba(239, 68, 68, 0.15);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.test-badge-pending {
    background: rgba(148, 163, 184, 0.15);
    color: #94a3b8;
    border: 1px solid rgba(148, 163, 184, 0.3);
}

/* --- Regime Badges --- */
.regime-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.3rem 0.8rem;
    border-radius: 0.5rem;
    font-size: 0.8rem;
    font-weight: 600;
}

.regime-bullish { background: rgba(34, 197, 94, 0.15); color: #22c55e; border: 1px solid rgba(34, 197, 94, 0.3); }
.regime-bearish { background: rgba(239, 68, 68, 0.15); color: #ef4444; border: 1px solid rgba(239, 68, 68, 0.3); }
.regime-sideways { background: rgba(148, 163, 184, 0.15); color: #94a3b8; border: 1px solid rgba(148, 163, 184, 0.3); }
.regime-vol-low { background: rgba(34, 197, 94, 0.1); color: #86efac; }
.regime-vol-normal { background: rgba(245, 158, 11, 0.1); color: #fbbf24; }
.regime-vol-high { background: rgba(239, 68, 68, 0.1); color: #fca5a5; }
.regime-vol-extreme { background: rgba(239, 68, 68, 0.2); color: #ef4444; border: 1px solid rgba(239, 68, 68, 0.4); }

/* --- VaR Cards --- */
.var-card {
    border-top: 3px solid rgba(239, 68, 68, 0.5);
}

.var-card:hover {
    border-top-color: #ef4444;
}

/* --- Ratio Rows --- */
.ratio-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.5rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.ratio-row:last-child {
    border-bottom: none;
}

/* --- DM Matrix Table --- */
.dm-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.7rem;
}

.dm-table th, .dm-table td {
    padding: 0.3rem 0.4rem;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.dm-table th {
    color: var(--gold-400);
    font-weight: 600;
    background: rgba(245, 158, 11, 0.05);
}

.dm-cell-better {
    background: rgba(34, 197, 94, 0.1);
    color: #22c55e;
}

.dm-cell-worse {
    background: rgba(239, 68, 68, 0.1);
    color: #ef4444;
}

.dm-cell-neutral {
    color: var(--text-muted);
}

/* --- KaTeX Dark Theme --- */
.katex { color: var(--gold-300); font-size: 1.1em; }
.katex .mord, .katex .mbin, .katex .mrel, .katex .mop, .katex .mpunct { color: var(--gold-300); }

.formula-katex {
    background: rgba(0, 0, 0, 0.3);
    border-left: 3px solid var(--gold-400);
    padding: 0.75rem 1rem;
    border-radius: 0 0.5rem 0.5rem 0;
    overflow-x: auto;
    margin: 0.5rem 0;
}

.formula-name {
    font-size: 0.8rem;
    color: var(--gold-300);
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.formula-explanation {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 0.25rem;
    line-height: 1.5;
}

/* --- Education Panel Components --- */
.purpose-box {
    background: rgba(245, 158, 11, 0.05);
    border: 1px solid rgba(245, 158, 11, 0.2);
    border-radius: 0.75rem;
    padding: 1rem 1.25rem;
    margin: 0.75rem 0;
}

.purpose-box-title {
    color: var(--gold-400);
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.intuition-box {
    background: rgba(59, 130, 246, 0.05);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 0.75rem;
    padding: 1rem 1.25rem;
    margin: 0.75rem 0;
}

.intuition-box-title {
    color: #60a5fa;
    font-weight: 600;
    font-size: 0.85rem;
    margin-bottom: 0.5rem;
}

.strengths-box {
    background: rgba(34, 197, 94, 0.05);
    border: 1px solid rgba(34, 197, 94, 0.2);
    border-radius: 0.75rem;
    padding: 1rem 1.25rem;
}

.weaknesses-box {
    background: rgba(239, 68, 68, 0.05);
    border: 1px solid rgba(239, 68, 68, 0.2);
    border-radius: 0.75rem;
    padding: 1rem 1.25rem;
}

.procedure-step {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.procedure-step-number {
    flex-shrink: 0;
    width: 1.5rem;
    height: 1.5rem;
    border-radius: 50%;
    background: rgba(245, 158, 11, 0.15);
    color: var(--gold-400);
    font-size: 0.7rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
}

.procedure-step-text {
    font-size: 0.85rem;
    color: var(--text-primary);
    line-height: 1.5;
}

.glossary-term {
    text-decoration: underline dotted rgba(245, 158, 11, 0.5);
    text-underline-offset: 2px;
    cursor: help;
    position: relative;
}

.glossary-term:hover::after {
    content: attr(data-definition);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(15, 23, 42, 0.95);
    border: 1px solid var(--gold-400);
    color: var(--text-primary);
    padding: 0.5rem 0.75rem;
    border-radius: 0.5rem;
    font-size: 0.75rem;
    white-space: normal;
    width: max-content;
    max-width: 250px;
    z-index: 100;
    pointer-events: none;
    line-height: 1.4;
}

.metrics-interpretation {
    background: rgba(59, 130, 246, 0.05);
    border: 1px solid rgba(59, 130, 246, 0.15);
    border-radius: 0.5rem;
    padding: 0.75rem 1rem;
    margin-top: 0.75rem;
    font-size: 0.8rem;
    color: var(--text-muted);
    line-height: 1.5;
}

.edu-section-title {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--gold-400);
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
