/* ============================================
   ESTILOS GENERALES ANFECA
   ============================================ */

/* Variables de diseño */
:root {
    /* Colores principales */
    --color-primary: #cd0000;
    --color-primary-dark: #B22222;
    --color-secondary: #1a365d;
    --color-accent: #e53e3e;
    --color-light: #f7fafc;
    --color-gray: #787878;
    --color-gray-light: #BDBDBD;
    --color-gray-ultralight: #EDEDED;
    --color-gray-dark: #4F4F4F;
    --color-red-wine: #570808;
    
    /* Tipografía */
    --font-heading: 'Segoe UI', system-ui, -apple-system, sans-serif;
    --font-body: 'Inter', 'Segoe UI', system-ui, sans-serif;
    
    /* Espaciado */
    --spacing-xs: 0.5rem;
    --spacing-sm: 1rem;
    --spacing-md: 1.5rem;
    --spacing-lg: 2rem;
    --spacing-xl: 3rem;
    
    /* Sombras */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.12);
    --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);
}

/* ============================================
   RESET Y ESTILOS BASE - PREVENIR SCROLL HORIZONTAL
   ============================================ */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    max-width: 100%;
    overflow-x: hidden; /* ¡IMPORTANTE! Elimina scroll horizontal */
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    color: var(--color-gray-dark);
    line-height: 1.6;
    background-color: #ffffff;
    overflow-x: hidden;
    position: relative;
    width: 100%;
}

/* ============================================
   WRAPPER PRINCIPAL - CONTENEDOR DE TODO
   ============================================ */
#page-wrapper {
    width: 100%;
    overflow-x: hidden;
    position: relative;
}

/* ============================================
   TIPOGRAFÍA - AJUSTADA COMO EN MISIÓN Y VISIÓN
   ============================================ */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-heading);
    font-weight: 700;
    line-height: 1.2;
    color: var(--color-secondary);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

h1 {
    font-size: 2.2rem;
    margin-bottom: var(--spacing-md);
}

h2 {
    font-size: 1.8rem;
    margin-bottom: var(--spacing-sm);
}

h3 {
    font-size: 1.4rem;
    margin-bottom: var(--spacing-sm);
}

p {
    margin-bottom: var(--spacing-sm);
    word-wrap: break-word;
    overflow-wrap: break-word;
}

a {
    color: var(--color-primary);
    text-decoration: none;
    transition: color 0.3s ease;
}

a:hover {
    color: var(--color-primary-dark);
}

/* ============================================
   LAYOUT - CONTENEDORES Y SECCIONES
   ============================================ */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--spacing-xs);
}

/* Contenedor centrado más estricto para imágenes y elementos */
.container-fluid {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
}

.section {
    padding: var(--spacing-xl) 0;
    width: 100%;
    position: relative;
}

/* Asegurar que todas las secciones sean de ancho completo */
.section > * {
    max-width: 100%;
}

/* ============================================
   TÍTULOS DE SECCIÓN - CON LÍNEA ROJA Y SUBTÍTULO
   ============================================ */
.section-title {
    text-align: center;
    margin-bottom: var(--spacing-xl);
    margin-top: var(--spacing-xl);
    position: relative;
    padding: 0 var(--spacing-sm);
}

/* El h2 dentro de section-title tendrá margen reducido */
.section-title h2 {
    margin-bottom: calc(var(--spacing-sm) / 2); /* Espacio reducido antes de la línea */
    color: var(--color-secondary);
    font-size: 1.8rem;
}

/* Línea roja - SIEMPRE debajo del h2 */
.section-title::after {
    content: '';
    display: block;
    width: 80px;
    height: 4px;
    background: var(--color-primary);
    margin: calc(var(--spacing-sm) / 2) auto var(--spacing-sm); /* Superior reducido, inferior normal */
    border-radius: 2px;
}

/* Subtítulo - con espaciado adecuado después de la línea */
.section-subtitle {
    text-align: center;
    margin-top: var(--spacing-xs); /* Espacio después de la línea */
    margin-bottom: 0; /* El contenedor padre controla el margen inferior */
    padding: 0 var(--spacing-sm);
    color: var(--color-gray);
    font-size: 1.1rem;
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
}

/* Si el subtítulo está fuera del section-title, mantener consistencia */
.section-title + .section-subtitle {
    margin-top: 0; /* Ya viene con su propio margen del section-title */
    margin-bottom: var(--spacing-lg);
}

/* ============================================
   UTILIDADES - CLASES HELPER
   ============================================ */
.text-center {
    text-align: center;
}

.text-primary {
    color: var(--color-primary);
}

.bg-light {
    background-color: var(--color-gray-ultralight);
}

/* ============================================
   ELEMENTOS ESPECÍFICOS - ASEGURAR RESPONSIVIDAD
   ============================================ */

/* Imágenes responsivas */
img, video, iframe {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Tablas responsivas */
table {
    width: 100%;
    max-width: 100%;
    overflow-x: auto;
    display: block;
}

/* Elementos embebidos */
embed, object, iframe {
    max-width: 100%;
    display: block;
}

/* Listas */
ul, ol {
    padding-left: 1.5rem;
    word-wrap: break-word;
}

/* Formularios */
input, textarea, select, button {
    max-width: 100%;
    font-family: inherit;
}

/* ============================================
   BOTONES
   ============================================ */
.btn {
    display: inline-block;
    padding: 0.75rem 1.5rem;
    background-color: var(--color-primary);
    color: white;
    border: none;
    border-radius: 4px;
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    max-width: 100%;
    white-space: nowrap;
}

.btn:hover {
    background-color: var(--color-primary-dark);
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background-color: var(--color-secondary);
}

.btn-secondary:hover {
    background-color: #2d4a7d;
}

/* ============================================
   REGLAS ESPECIALES PARA EVITAR DESBORDAMIENTO
   ============================================ */
.prevent-overflow {
    overflow-wrap: break-word;
    word-wrap: break-word;
    hyphens: auto;
}

.full-width {
    width: 100vw;
    position: relative;
    left: 50%;
    right: 50%;
    margin-left: -50vw;
    margin-right: -50vw;
}

/* Clase para forzar que los elementos no excedan el ancho */
.max-width-100 {
    max-width: 100% !important;
    width: auto !important;
}

/* ============================================
   MEDIA QUERIES - RESPONSIVIDAD
   ============================================ */

/* Tablet y dispositivos medianos */
@media (max-width: 1024px) {
    .container {
        padding: 0 var(--spacing-sm);
    }
    
    .section {
        padding: var(--spacing-lg) 0;
    }
    
    h1 {
        font-size: 2.1rem;
    }
    
    h2 {
        font-size: 1.7rem;
    }
    
    .section-title h2 {
        font-size: 1.7rem;
    }
}

/* Dispositivos móviles (768px) */
@media (max-width: 768px) {
    h1 {
        font-size: 2rem;
        line-height: 1.3;
        padding: 0 1rem;
    }
    
    h2 {
        font-size: 1.6rem;
        line-height: 1.3;
        padding: 0 1rem;
    }
    
    h3 {
        font-size: 1.3rem;
        padding: 0 1rem;
    }
    
    .section {
        padding: var(--spacing-lg) 1rem;
    }
    
    .section-title {
        padding: 0 1rem;
        margin-top: var(--spacing-lg);
        margin-bottom: var(--spacing-lg);
    }
    
    .section-title h2 {
        font-size: 1.6rem;
        padding: 0;
    }
    
    .section-subtitle {
        padding: 0 1rem;
        font-size: 1rem;
    }
    
    .container {
        padding: 0 1rem;
    }
    
    /* Asegurar que todo el contenido esté dentro de la pantalla */
    body, html {
        position: relative;
        width: 100%;
        overflow-x: hidden;
    }
    
    /* Forzar que todos los elementos hijos respeten el ancho */
    body > * {
        max-width: 100vw !important;
        width: 100% !important;
        overflow-x: hidden !important;
    }
    
    /* Botones responsivos */
    .btn {
        width: 100%;
        max-width: 300px;
        margin: 0 auto;
        display: block;
    }
}

/* Teléfonos pequeños (480px) */
@media (max-width: 480px) {
    h1 {
        font-size: 1.8rem;
        padding: 0 0.5rem;
    }
    
    h2 {
        font-size: 1.5rem;
        padding: 0 0.5rem;
    }
    
    h3 {
        font-size: 1.2rem;
        padding: 0 0.5rem;
    }
    
    .section {
        padding: var(--spacing-md) 0.5rem;
    }
    
    .container {
        padding: 0 0.5rem;
    }
    
    .section-title {
        padding: 0 0.5rem;
        margin-top: var(--spacing-md);
        margin-bottom: var(--spacing-md);
    }
    
    .section-title h2 {
        font-size: 1.5rem;
    }
    
    .section-subtitle {
        padding: 0 0.5rem;
        font-size: 0.95rem;
    }
    
    /* Ajustes adicionales para pantallas muy pequeñas */
    body {
        font-size: 15px;
    }
    
    /* Asegurar que las tablas sean scrollables horizontalmente si es necesario */
    .table-responsive {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* Teléfonos muy pequeños (320px) */
@media (max-width: 320px) {
    h1 {
        font-size: 1.6rem;
    }
    
    h2 {
        font-size: 1.4rem;
    }
    
    h3 {
        font-size: 1.1rem;
    }
    
    .section-title h2 {
        font-size: 1.4rem;
    }
}

/* ============================================
   CLASES ESPECIALES PARA CONTENIDO EXTERNO
   ============================================ */
/* Si usas contenido de terceros (videos embebidos, iframes, etc.) */
.responsive-embed {
    position: relative;
    padding-bottom: 56.25%; /* 16:9 */
    height: 0;
    overflow: hidden;
    max-width: 100%;
}

.responsive-embed iframe,
.responsive-embed object,
.responsive-embed embed {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

/* ============================================
   FIX PARA PROBLEMAS COMUNES DE SCROLL HORIZONTAL
   ============================================ */
/* Eliminar márgenes/padding que puedan causar overflow */
body.fix-overflow,
.fix-overflow {
    overflow-x: hidden !important;
}

/* Forzar viewport en dispositivos móviles */
@viewport {
    width: device-width;
    zoom: 1.0;
}

/* Safari fix */
@supports (-webkit-touch-callout: none) {
    body, html {
        max-width: 100% !important;
        overflow-x: hidden !important;
        position: relative !important;
    }
}