/* ============================================
   COMMON.CSS - Estilos compartidos
   Proyecto: Cálculo Integral
   ============================================ */

/* ============================================
   VARIABLES CSS
   ============================================ */
:root {
    /* Colores primarios */
    --primary: #667eea;
    --primary-dark: #5a67d8;
    --primary-light: #a3bffa;
    --secondary: #4facfe;
    
    /* Colores de acento */
    --accent-orange: #f6993f;
    --accent-green: #38c172;
    --accent-red: #e74c3c;
    
    /* Fondos temáticos */
    --bg-real: #fef6e4;
    --bg-real-dark: #f6993f;
    --bg-mate: #eef2ff;
    --bg-mate-dark: #667eea;
    
    /* Fondos generales */
    --bg-dark: #1a1a2e;
    --bg-dark-light: #16213e;
    --bg-light: #f8fafc;
    --bg-white: #ffffff;
    
    /* Texto */
    --text-dark: #1e293b;
    --text-muted: #64748b;
    --text-light: #94a3b8;
    
    /* Sombras */
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 25px rgba(0,0,0,0.15);
    --shadow-xl: 0 20px 40px rgba(0,0,0,0.2);
    
    /* Bordes */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-full: 50px;
    
    /* Transiciones */
    --transition-fast: 0.2s ease;
    --transition-normal: 0.3s ease;
    --transition-slow: 0.5s ease;
}

/* ============================================
   RESET Y BASE
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    scroll-padding-top: 80px;
}

body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    color: var(--text-dark);
    line-height: 1.6;
    overflow-x: hidden;
    background: var(--bg-white);
}

/* ============================================
   NAVEGACIÓN
   ============================================ */
.navbar {
    background: rgba(26, 26, 46, 0.95);
    backdrop-filter: blur(10px);
    padding: 1rem 0;
    transition: var(--transition-normal);
}

.navbar.scrolled {
    padding: 0.5rem 0;
    box-shadow: var(--shadow-lg);
}

.navbar-brand {
    font-size: 1.5rem;
    color: white !important;
}

.brand-integral {
    color: var(--primary);
    font-size: 2rem;
    font-weight: 700;
}

.nav-link {
    color: rgba(255,255,255,0.85) !important;
    font-weight: 500;
    padding: 0.5rem 1rem !important;
    transition: var(--transition-fast);
}

.nav-link:hover {
    color: var(--primary-light) !important;
}

.nav-link.active {
    color: var(--primary-light) !important;
    font-weight: 600;
}

/* ============================================
   SECCIÓN UNIDAD (PÁGINAS INDIVIDUALES)
   ============================================ */
.section-unit {
    padding-top: 120px;
    padding-bottom: 4rem;
}

.unit-header {
    text-align: center;
    margin-bottom: 3rem;
}

.unit-badge {
    display: inline-block;
    background: var(--primary);
    color: white;
    padding: 0.5rem 1.5rem;
    border-radius: var(--radius-full);
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 1rem;
}

.unit-header h2 {
    font-size: 2.5rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-bottom: 0.5rem;
}

.unit-header p {
    color: var(--text-muted);
    font-size: 1.1rem;
}

/* ============================================
   TARJETA DE TEMA
   ============================================ */
.tema-card {
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-md);
    margin-bottom: 2rem;
    overflow: hidden;
}

.tema-header {
    background: linear-gradient(135deg, var(--bg-dark) 0%, var(--bg-dark-light) 100%);
    color: white;
    padding: 1.5rem 2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.tema-numero {
    background: var(--primary);
    padding: 0.5rem 1rem;
    border-radius: var(--radius-sm);
    font-weight: 700;
    font-size: 1.1rem;
}

.tema-header h3 {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 600;
}

.tema-content {
    padding: 2rem;
}

/* ============================================
   PREGUNTA GANCHO
   ============================================ */
.pregunta-gancho {
    display: flex;
    align-items: flex-start;
    gap: 1rem;
    background: linear-gradient(135deg, #fef3c7 0%, #fef9c3 100%);
    border-left: 4px solid #f59e0b;
    padding: 1.25rem 1.5rem;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    margin-bottom: 2rem;
}

.pregunta-gancho i {
    font-size: 1.5rem;
    color: #f59e0b;
    flex-shrink: 0;
    margin-top: 0.2rem;
}

.pregunta-gancho p {
    margin: 0;
    font-size: 1.1rem;
    color: var(--text-dark);
    line-height: 1.6;
}

/* ============================================
   BLOQUES TEMÁTICOS
   ============================================ */
.bloque-real {
    background: var(--bg-real);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    height: 100%;
    border-left: 4px solid var(--accent-orange);
}

.bloque-real h5 {
    color: #c2410c;
    font-weight: 700;
    margin-bottom: 1rem;
}

.bloque-mate {
    background: var(--bg-mate);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    height: 100%;
    border-left: 4px solid var(--primary);
}

.bloque-mate h5 {
    color: var(--primary-dark);
    font-weight: 700;
    margin-bottom: 1rem;
}

.lista-simple {
    list-style: none;
    padding: 0;
    margin: 1rem 0;
}

.lista-simple li {
    padding: 0.4rem 0;
    padding-left: 1.5rem;
    position: relative;
}

.lista-simple li::before {
    content: "→";
    position: absolute;
    left: 0;
    color: var(--primary);
    font-weight: bold;
}

.pregunta-clave {
    background: white;
    padding: 1rem;
    border-radius: var(--radius-sm);
    margin-top: 1rem;
    font-weight: 500;
}

/* ============================================
   FÓRMULAS
   ============================================ */
.formula-box {
    background: white;
    border-radius: var(--radius-sm);
    padding: 1rem;
    text-align: center;
    overflow: hidden;
}

.formula-label {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
}

.formula {
    font-size: 1.1rem;
}

.formula-traduccion {
    display: block;
    font-size: 0.85rem;
    color: var(--text-muted);
    font-style: italic;
    margin-top: 0.5rem;
}

.formula-grande {
    background: linear-gradient(135deg, var(--bg-mate) 0%, #e0e7ff 100%);
    padding: 1.5rem;
    border-radius: var(--radius-md);
    text-align: center;
    margin: 1.5rem 0;
    font-size: 1.2rem;
}

/* MathJax ajustes */
mjx-container {
    overflow-x: hidden !important;
    max-width: 100%;
}

.bloque-mate mjx-container,
.formula-box mjx-container {
    overflow: hidden !important;
}

/* ============================================
   CAJA INTERACTIVA
   ============================================ */
.interactivo-box {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border: 2px solid #0ea5e9;
    border-radius: var(--radius-lg);
    padding: 2rem;
    margin-top: 2rem;
}

.interactivo-box h5 {
    color: #0369a1;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.interactivo-box > p {
    color: var(--text-muted);
    margin-bottom: 1.5rem;
}

/* Chart container */
.chart-container {
    position: relative;
    height: 300px;
    background: white;
    border-radius: var(--radius-md);
    padding: 1rem;
}

/* ============================================
   RESUMEN TEMA
   ============================================ */
.resumen-tema {
    background: linear-gradient(135deg, #faf5ff 0%, #f3e8ff 100%);
    border-left: 4px solid #a855f7;
    border-radius: 0 var(--radius-md) var(--radius-md) 0;
    padding: 1.25rem 1.5rem;
    margin-top: 2rem;
    font-size: 1rem;
}

.resumen-tema strong {
    color: #7c3aed;
}

/* ============================================
   FOOTER
   ============================================ */
.site-footer {
    background: var(--bg-dark);
    color: white;
    padding: 2rem 0;
}

.site-footer p {
    margin-bottom: 0.25rem;
}

/* ============================================
   FORMULARIOS
   ============================================ */
.form-control, .form-select {
    border-radius: var(--radius-sm);
    border: 2px solid #e2e8f0;
    padding: 0.75rem 1rem;
    transition: var(--transition-fast);
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.2);
}

.form-range {
    height: 8px;
}

.form-range::-webkit-slider-thumb {
    width: 24px;
    height: 24px;
    background: var(--primary);
    border: 3px solid white;
    box-shadow: var(--shadow-md);
}

.form-range::-moz-range-thumb {
    width: 24px;
    height: 24px;
    background: var(--primary);
    border: 3px solid white;
    box-shadow: var(--shadow-md);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
    border: none;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-sm);
    font-weight: 600;
    transition: var(--transition-normal);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
    background: linear-gradient(135deg, var(--primary-dark) 0%, var(--primary) 100%);
}

/* ============================================
   RESPONSIVE COMÚN
   ============================================ */
@media (max-width: 991.98px) {
    .navbar-collapse {
        background: var(--bg-dark);
        padding: 1rem;
        margin-top: 1rem;
        border-radius: var(--radius-md);
    }
    
    .tema-header {
        flex-direction: column;
        text-align: center;
        gap: 0.75rem;
    }
    
    .tema-header h3 {
        font-size: 1.2rem;
    }
}

@media (max-width: 767.98px) {
    .tema-content {
        padding: 1.25rem;
    }
    
    .interactivo-box {
        padding: 1.25rem;
    }
    
    .chart-container {
        height: 250px;
    }
    
    .pregunta-gancho {
        flex-direction: column;
        text-align: center;
    }
    
    .unit-header h2 {
        font-size: 2rem;
    }
}

/* ============================================
   ACCESIBILIDAD
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
    
    html {
        scroll-behavior: auto;
    }
}

:focus-visible {
    outline: 3px solid var(--primary);
    outline-offset: 2px;
}