/* ==========================================================================
   Variables, Reset Completo y Arquitectura UI/UX
   ========================================================================== */
:root {
    --color-bg: #121212;
    --color-card: #1E1E1E;
    --color-primary: #0B1B3D;      /* Azul Marino Oscuro */
    --color-secondary: #7A1C31;    /* Guinda/Vino Institucional */
    --color-text-main: #FFFFFF;
    --color-text-muted: #B3B3B3;
    --color-border: #2D2D2D;
    --color-accent-blue: #3B82F6;
    --font-stack: 'Inter', system-ui, -apple-system, sans-serif;
}

*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    background-color: var(--color-bg);
    color: var(--color-text-main);
    font-family: var(--font-stack);
    font-size: 16px;
    overflow-x: hidden;
    scroll-behavior: auto; /* Desactivado para dar control completo a Lenis */
}

body {
    overflow-x: hidden;
    background-color: var(--color-bg);
    line-height: 1.6;
}

/* ==========================================================================
   Componentes Globales HUD & Layout Estilizado
   ========================================================================== */
.card-hud {
    background: var(--color-card);
    border: 1px solid var(--color-border);
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    transition: border-color 0.3s ease;
}
.card-hud:hover {
    border-color: rgba(122, 28, 49, 0.4);
}

.text-center { text-align: center; }
.primary-gradient-text {
    background: linear-gradient(135deg, #FFF, #5C88DA);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}
.secondary-gradient-text {
    background: linear-gradient(135deg, #FFF, #C94A65);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

/* Grillas puras basadas en Bloques Flex o Tablas CSS para soportar weasyprint/renders */
.grid-2 {
    display: table;
    width: 100%;
    table-layout: fixed;
}
.text-block, .kpi-block {
    display: table-cell;
    vertical-align: top;
    padding: 15px;
}

/* ==========================================================================
   Header Fijo Superior Premium
   ========================================================================== */
.main-header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 70px;
    background: rgba(18, 18, 18, 0.85);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--color-border);
    z-index: 1000;
}
.header-container {
    max-width: 1400px;
    margin: 0 auto;
    height: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
}
.logo-area {
    display: flex;
    align-items: center;
    text-decoration: none;
    gap: 12px;
}
.header-logo {
    height: 45px;
    width: auto;
    border-radius: 50%;
}
.logo-text {
    color: var(--color-text-main);
    font-weight: 700;
    font-size: 1.3rem;
    letter-spacing: 1px;
}
.nav-links {
    display: flex;
    gap: 8px;
    background: rgba(11, 27, 61, 0.3);
    padding: 6px;
    border-radius: 30px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}
.nav-item {
    color: var(--color-text-muted);
    text-decoration: none;
    font-size: 0.85rem;
    font-weight: 600;
    padding: 8px 18px;
    border-radius: 20px;
    transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
}
.nav-item:hover, .nav-item.active {
    color: var(--color-text-main);
    background: var(--color-primary);
    box-shadow: 0 4px 12px rgba(11, 27, 61, 0.5);
}
.flag-icon {
    height: 20px;
    width: auto;
    border-radius: 2px;
}

/* ==========================================================================
   Sección: INICIO (Hero Portada A.E.S Exacta)
   ========================================================================== */
.hero-section {
    position: relative;
    width: 100%;
    min-height: 100vh;
    display: flex;
    align-items: center;
    padding: 100px 24px 60px 24px;
    overflow: hidden;
}
.hero-bg {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background-size: cover;
    background-position: center;
    z-index: 1;
    filter: brightness(0.7) contrast(1.05);
}
.hero-content {
    position: relative;
    z-index: 2;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 40px;
}
.cintillo-institucional {
    border-left: 5px solid var(--color-secondary);
    padding-left: 24px;
    max-width: 800px;
}
.cintillo-tag {
    font-size: 0.9rem;
    font-weight: 700;
    letter-spacing: 3px;
    color: var(--color-secondary);
    display: block;
    margin-bottom: 8px;
}
.cintillo-sub {
    font-size: 1.8rem;
    font-weight: 400;
    letter-spacing: 1px;
    color: var(--color-text-muted);
    margin-bottom: 12px;
}
.cintillo-title {
    font-size: 5rem;
    font-weight: 800;
    line-height: 1;
    letter-spacing: -2px;
    color: var(--color-text-main);
}

/* Resumen Ejecutivo Flotante */
.executive-summary-box {
    max-width: 480px;
    align-self: flex-start;
    background: rgba(30, 30, 30, 0.85);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
}
.summary-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
}
.pulse-indicator {
    width: 8px; height: 8px;
    background-color: var(--color-secondary);
    border-radius: 50%;
    box-shadow: 0 0 0 0 rgba(122, 28, 49, 0.7);
    animation: pulse 1.6s infinite;
}
@keyframes pulse {
    0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(122, 28, 49, 0.7); }
    70% { transform: scale(1); box-shadow: 0 0 0 6px rgba(122, 28, 49, 0); }
    100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(122, 28, 49, 0); }
}
.summary-header h3 {
    font-size: 0.95rem; font-weight: 700; letter-spacing: 1px; color: var(--color-text-main);
}
.summary-text {
    font-size: 0.9rem; color: var(--color-text-muted); margin-bottom: 20px;
}
.summary-mini-charts {
    display: flex; gap: 20px;
}
.mini-chart-item {
    flex: 1; background: rgba(0,0,0,0.2); padding: 10px; border-radius: 6px;
}
.mini-label { display: block; font-size: 0.75rem; color: var(--color-text-muted); margin-bottom: 4px; }
.sparkline { width: 100%; height: 30px; display: block; }

/* ==========================================================================
   Secciones Contenedoras Comunes
   ========================================================================== */
.content-section {
    position: relative;
    padding: 100px 24px;
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}
.section-pre {
    display: block; font-size: 0.85rem; font-weight: 700; color: var(--color-secondary);
    letter-spacing: 2px; margin-bottom: 6px; text-transform: uppercase;
}
.section-title {
    font-size: 2.2rem; font-weight: 700; color: var(--color-text-main); margin-bottom: 24px;
}
.section-desc {
    font-size: 1.05rem; color: var(--color-text-muted); max-width: 900px; margin-bottom: 40px;
}
.literary-text {
    font-size: 1.1rem; line-height: 1.8; color: var(--color-text-muted); text-align: justify;
}

/* Tarjetas KPI */
.kpi-block {
    display: flex; flex-direction: column; gap: 20px; padding-left: 40px;
}
.kpi-card {
    background: linear-gradient(145deg, #232323, #1a1a1a);
}
.kpi-value { font-size: 3.5rem; font-weight: 800; line-height: 1; margin-bottom: 10px; }
.kpi-title { font-size: 1.05rem; font-weight: 600; color: var(--color-text-main); margin-bottom: 4px; }
.kpi-desc { font-size: 0.85rem; color: var(--color-text-muted); }

/* ==========================================================================
   Sección: DATOS OFICIALES (Terminal e Indicadores)
   ========================================================================== */
.terminal-ide {
    background: #000000 !important;
    font-family: 'Courier New', Courier, monospace;
    border: 1px solid #333;
    padding: 0; margin-bottom: 50px; overflow: hidden;
}
.terminal-header {
    background: #111; padding: 12px 16px; border-bottom: 1px solid #222;
    display: flex; align-items: center; position: relative;
}
.terminal-buttons { display: flex; gap: 8px; }
.terminal-buttons span {
    width: 12px; height: 12px; border-radius: 50%; display: inline-block;
}
.terminal-buttons span:nth-child(1) { background: #FF5F56; }
.terminal-buttons span:nth-child(2) { background: #FFBD2E; }
.terminal-buttons span:nth-child(3) { background: #27C93F; }
.terminal-title {
    position: absolute; left: 50%; transform: translateX(-50%);
    font-size: 0.8rem; color: #666; font-weight: bold;
}
.terminal-body { padding: 20px; overflow-x: auto; font-size: 0.9rem; }
.token-keyword { color: #F92672; }
.token-function { color: #66D9EF; }
.token-string { color: #E6DB74; }
.token-comment { color: #75715E; }

/* Arquitectura de Gráficos HUD */
.subsection-title { font-size: 1.4rem; font-weight: 600; margin-bottom: 24px; padding-left: 8px; border-left: 3px solid var(--color-primary); }
.charts-row {
    display: flex; gap: 24px; width: 100%; margin-bottom: 40px;
}
.chart-wrapper {
    flex: 1; min-width: 0; background: var(--color-card);
}
.chart-wrapper h4 { font-size: 0.95rem; font-weight: 600; margin-bottom: 16px; color: var(--color-text-muted); }
.canvas-container { position: relative; width: 100%; height: 260px; }

/* ==========================================================================
   Sección: ANÁLISIS (Pipeline y ETL)
   ========================================================================== */
.data-pipeline-grid {
    display: flex; gap: 20px; margin-bottom: 50px; width: 100%;
}
.db-node {
    flex: 1; text-align: center; padding: 30px 20px;
}
.node-icon { font-size: 2.5rem; margin-bottom: 12px; }
.db-node h5 { font-size: 1rem; font-weight: 600; margin-bottom: 6px; color: var(--color-text-main); }
.node-tag { display: inline-block; font-size: 0.75rem; background: var(--color-primary); padding: 4px 12px; border-radius: 12px; color: #93C5FD; font-weight: 500; }

/* ==========================================================================
   Sección: MODELO (Algoritmo & Formulario Completo)
   ========================================================================== */
.grid-form {
    display: flex; gap: 40px; align-items: flex-start;
}
.model-info, .interactive-form-box { flex: 1; min-width: 0; }

/* Math Engine */
.math-container { background: rgba(11, 27, 61, 0.15); border-left: 4px solid var(--color-accent-blue); margin-bottom: 30px; }
.math-label { display: block; font-size: 0.8rem; color: var(--color-text-muted); margin-bottom: 8px; font-weight: 600; }
.math-formula {
    font-family: 'Times New Roman', Times, serif; font-style: italic; font-size: 1.4rem; color: #93C5FD; display: flex; align-items: center; justify-content: center; gap: 8px;
}
.math-fraction { display: inline-flex; flex-direction: column; align-items: center; font-size: 0.95rem; vertical-align: middle; padding: 0 4px; }
.math-numerator { border-bottom: 1px solid #93C5FD; padding-bottom: 2px; text-align: center; }
.math-denominator { padding-top: 2px; text-align: center; }

/* HUD de Resultados Dinámicos */
.hud-box { background: rgba(11, 27, 61, 0.35); border-color: var(--color-primary); }
.hud-title { font-size: 1rem; font-weight: 600; margin-bottom: 16px; color: var(--color-text-muted); text-transform: uppercase; }
.hud-verdict-badge {
    padding: 16px; border-radius: 8px; font-size: 1.2rem; font-weight: 700; transition: all 0.4s ease; margin-bottom: 20px;
}
.hud-verdict-badge.no-risk { background: rgba(255,255,255,0.05); color: var(--color-text-muted); }
.hud-verdict-badge.low-risk { background: rgba(39, 201, 63, 0.15); color: #27C93F; border: 1px solid rgba(39, 201, 63, 0.3); }
.hud-verdict-badge.high-risk { background: rgba(122, 28, 49, 0.4); color: #FFA3B1; border: 1px solid var(--color-secondary); box-shadow: 0 0 20px rgba(122, 28, 49, 0.3); }

.apoyos-card { background: rgba(0,0,0,0.2); border-radius: 8px; padding: 20px; text-align: left; border: 1px dashed var(--color-border); }
.apoyos-card h5 { font-size: 0.95rem; color: var(--color-text-main); margin-bottom: 12px; font-weight: 600; }
.apoyos-card ul { padding-left: 20px; color: var(--color-text-muted); font-size: 0.9rem; display: flex; flex-direction: column; gap: 8px; }

/* Estilizado del Formulario HUD */
.interactive-form-box { background: #171717; }
.form-box-title { font-size: 1.3rem; font-weight: 700; margin-bottom: 24px; padding-bottom: 12px; border-bottom: 1px solid var(--color-border); }
.form-group-section { margin-bottom: 30px; }
.form-group-section h4 { font-size: 0.9rem; font-weight: 700; color: var(--color-secondary); text-transform: uppercase; letter-spacing: 1px; margin-bottom: 16px; }
.form-field { margin-bottom: 20px; }
.form-field > label { display: block; font-size: 0.9rem; font-weight: 500; color: var(--color-text-main); margin-bottom: 8px; }

/* Controles robustos basados exactamente en capturas */
.form-control {
    width: 100%; background: #222; border: 1px solid var(--color-border); border-radius: 8px; padding: 12px 16px; color: #FFF; font-family: inherit; font-size: 0.95rem; outline: none; transition: border-color 0.3s;
}
.form-control:focus { border-color: var(--color-primary); }

.segmented-control {
    display: flex; background: #222; border: 1px solid var(--color-border); border-radius: 8px; padding: 4px; overflow: hidden;
}
.segmented-control input[type="radio"] { display: none; }
.segmented-control label {
    flex: 1; text-align: center; padding: 10px; font-size: 0.9rem; font-weight: 600; color: var(--color-text-muted); cursor: pointer; border-radius: 6px; transition: all 0.2s ease;
}
.segmented-control input[type="radio"]:checked + label {
    background: var(--color-primary); color: #FFF; box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}

/* Slider Customizado */
.slider-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 8px; }
.slider-badge { background: #222; border: 1px solid var(--color-border); padding: 4px 12px; border-radius: 6px; font-size: 0.85rem; font-weight: 700; color: #FFF; }
.form-slider {
    width: 100%; -webkit-appearance: none; appearance: none; height: 6px; background: #222; border-radius: 3px; outline: none;
}
.form-slider::-webkit-slider-thumb {
    -webkit-appearance: none; width: 18px; height: 18px; border-radius: 50%; background: #FFF; cursor: pointer; transition: transform 0.1s;
}
.form-slider::-webkit-slider-thumb:hover { transform: scale(1.2); }

.btn-primary {
    width: 100%; background: #262626; border: 1px solid #333; color: #FFF; padding: 16px; border-radius: 30px; font-size: 1rem; font-weight: 600; cursor: pointer; transition: all 0.3s; margin-top: 10px;
}
.btn-primary:hover { background: var(--color-secondary); border-color: var(--color-secondary); box-shadow: 0 6px 20px rgba(122, 28, 49, 0.4); }

/* ==========================================================================
   Footer & Elementos Responsivos Básicos
   ========================================================================== */
.main-footer { padding: 40px 24px; border-top: 1px solid var(--color-border); text-align: center; font-size: 0.85rem; color: var(--color-text-muted); }

@media (max-width: 1024px) {
    .grid-2, .grid-form, .charts-row, .data-pipeline-grid { display: flex; flex-direction: column; gap: 30px; }
    .text-block, .kpi-block { display: block; width: 100%; padding: 0; }
    .kpi-block { padding-left: 0; }
    .cintillo-title { font-size: 3.5rem; }
    .nav-links { display: none; } /* En móvil se simplifica para priorizar visualización HUD */
}

/* Contenedor en fila horizontal estricta */
.hero-cards-grid {
    display: flex !important;
    flex-direction: row !important;
    justify-content: space-between;
    align-items: stretch;
    gap: 16px;
    width: 100%;
    margin-top: 30px;
    overflow-x: auto; /* Permite scroll horizontal si la pantalla es muy estrecha */
    padding-bottom: 10px;
}

/* Tarjetas individuales cuadradas en fila */
.hero-card {
    flex: 1 1 0px; /* Obliga a los 5 cuadros a compartir exactamente el mismo ancho */
    min-width: 180px;
    aspect-ratio: 1 / 1; /* Mantiene la forma cuadrada perfecta */
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    
    background: rgba(18, 18, 20, 0.85);
    backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 16px; /* Bordes suaves redondeados */
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    
    transition: transform 0.3s ease, border-color 0.3s ease, box-shadow 0.3s ease;
}

.hero-card:hover {
    transform: translateY(-6px);
    border-color: #ef4444;
    box-shadow: 0 12px 28px rgba(239, 68, 68, 0.2);
}

.hero-card-title {
    color: #ef4444;
    font-size: 0.85rem;
    font-weight: 700;
    margin-bottom: 12px;
    letter-spacing: 0.6px;
    text-transform: uppercase;
}

.hero-card-text {
    color: #cbd5e1;
    font-size: 0.82rem;
    line-height: 1.4;
    margin: 0;
}

/* =========================================================
   FLIP CARD 3D - LAYOUT PERFECTO
   ========================================================= */
.charts-row {
    display: flex;
    gap: 20px;
    width: 100%;
}

.flip-card {
    background-color: transparent;
    perspective: 1000px;
    cursor: pointer;
    flex: 1;
    height: 480px; /* Mas alto para dar espacio de sobra a la gráfica */
    position: relative;
    user-select: none;
}

.flip-card-inner {
    position: relative;
    width: 100%;
    height: 100%;
    transition: transform 0.6s cubic-bezier(0.4, 0, 0.2, 1);
    transform-style: preserve-3d;
}

/* Estado cuando se da clic */
.flip-card.is-flipped .flip-card-inner {
    transform: rotateY(180deg) !important;
}

.flip-card-front, 
.flip-card-back {
    position: absolute !important;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    -webkit-backface-visibility: hidden !important;
    backface-visibility: hidden !important;
    border-radius: 16px;
    box-sizing: border-box;
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    align-items: center;
}

/* Lado Frontal (Gráfica) */
.flip-card-front {
    z-index: 2;
    transform: rotateY(0deg);
}

/* Título en la parte superior */
.flip-card-front h4,
.flip-card-back h4 {
    text-align: center !important;
    font-size: 1.15rem;
    font-weight: 700;
    margin: 0 0 10px 0;
    color: #ffffff;
    width: 100%;
}

/* Contenedor central de la gráfica (Ocupa la mayor parte) */
.flip-card-front .canvas-container {
    position: relative;
    width: 100%;
    flex: 1; /* Maximiza la gráfica */
    display: flex;
    align-items: center;
    justify-content: center;
}

.flip-card-front canvas {
    pointer-events: none !important; /* Permite hacer clic en cualquier parte */
}

/* Lado Trasero (Explicación) */
.flip-card-back {
    transform: rotateY(180deg);
    background: rgba(18, 18, 22, 0.98) !important;
    border: 1px solid rgba(239, 68, 68, 0.5) !important;
    z-index: 1;
}

.flip-card-back h4 {
    color: #ef4444;
}

.flip-card-back p {
    color: #cbd5e1;
    font-size: 0.92rem;
    line-height: 1.6;
    text-align: justify;
    margin: auto 0;
}

/* Texto chico "Clic para ver..." HASTA ABAJO */
.flip-hint {
    font-size: 0.75rem;
    color: #94a3b8;
    text-align: center;
    display: block;
    width: 100%;
    margin-top: 8px;
    opacity: 0.8;
}
