/* ================================================= */
/* FONT-FACE ORIGINAL MANTENIDO Y AMPLIADO         */
/* ================================================= */
/* Asegúrate de que los archivos TTF estén en el directorio /fonts/ */
@font-face {
    font-family: 'Euphemia Regular';
    src: url('/fonts/Euphemia-Regular.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
}

@font-face {
    font-family: 'Euphemia Bold';
    src: url('/fonts/Euphemia-Bold.ttf') format('truetype');
    font-weight: 700;
    font-style: normal;
}

@font-face {
    font-family: 'Euphemia Italic';
    src: url('/fonts/Euphemia-Italic.ttf') format('truetype');
    font-weight: 400;
    font-style: italic;
}

@font-face{
    font-family: 'Snell Roundhand Regular';
    src: url('/fonts/snellroundhand_black.otf') format('opentype');
    font-weight: 400;
    font-style: normal;
}

@font-face{
    font-family: 'Snell Roundhand Bold';
    src: url('/fonts/snellroundhand_bold.otf') format('opentype');
    font-weight: 700;
    font-style: normal;
}

/* ================================================= */
/* VARIABLES DEL DISEÑO OSCURO                     */
/* ================================================= */
:root {
    --color-principal-oscuro: #1F2037; /* Fondo azul oscuro/morado */
    --color-acento-rosa: #EC0058; /* Magenta fuerte */
    --color-texto-claro: #D9DBE9; /* Texto principal claro */
    --color-texto-gris: #A0A3BD; /* Texto secundario/placeholders */
    --color-lineas-rejilla: #2D3154; /* Color de las líneas de rejilla */

    --font-script: 'Euphemia Italic', cursive;
}


/* ================================================= */
/* ESTILOS GLOBALES Y DE FONDO                     */
/* ================================================= */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Euphemia Regular', Arial, sans-serif;
    background-color: var(--color-principal-oscuro);
    color: var(--color-texto-claro);
    margin: 0;
    padding: 0;
    min-height: 100vh;
    /* Por defecto, hacemos que el body sea flexible para centrar el contenido (útil para el formulario de registro/login) */
    display: flex; 
    justify-content: center;
    align-items: center;
}

/* Aplica la rejilla a todo el cuerpo o a un contenedor principal */
.grid-background {
    position: relative;
    width: 100%;
    min-height: 100vh;
    padding: 20px 0;
    overflow: hidden;
}

/* Generación de la Rejilla */
.grid-background::before,
.grid-background::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
    background-repeat: repeat;
    opacity: 0.5;
}

/* Líneas Verticales */
.grid-background::before {
    background-image: linear-gradient(to right, transparent 99%, var(--color-lineas-rejilla) 100%);
    background-size: 50px 100%;
}

/* Líneas Horizontales */
.grid-background::after {
    background-image: linear-gradient(to bottom, transparent 99%, var(--color-lineas-rejilla) 100%);
    background-size: 100% 50px;
}

/* Contenedor principal de la sección */
.container {
    text-align: center;
    background: transparent;
    padding: 40px 20px;
    max-width: 1200px;
    margin: auto;
    position: relative;
    z-index: 10;
}

.hidden {
    display: none !important;
}

/* ================================================= */
/* TIPOGRAFÍA Y TEXTO                              */
/* ================================================= */
h1 {
    font-family: var(--font-script);
    font-size: 4.5em;
    margin-bottom: 20px;
    color: var(--color-acento-rosa);
    text-shadow: 0 0 10px rgba(236, 0, 88, 0.4);
}

h2 {
    font-family: 'Euphemia Bold', sans-serif;
    text-transform: uppercase;
    letter-spacing: 5px;
    color: var(--color-texto-claro);
}

p {
    color: var(--color-texto-gris);
    margin-bottom: 30px;
}

/* ================================================= */
/* BOTONES Y ACCIONES                              */
/* ================================================= */
.btn {
    text-decoration: none;
    padding: 12px 25px;
    background: var(--color-acento-rosa);
    color: var(--color-texto-claro);
    border-radius: 5px;
    transition: background 0.2s;
    text-transform: uppercase;
    font-weight: 700;
    letter-spacing: 1px;
    border: none;
    cursor: pointer;
}

.btn:hover:not(:disabled) {
    background: #ff337e;
}

.btn:disabled {
    background-color: var(--color-lineas-rejilla);
    cursor: not-allowed;
    opacity: 0.7;
}

/* ================================================= */
/* ESTILO DE FORMULARIO (PARA REGISTRO/LOGIN)      */
/* ================================================= */
.form-box {
    background-color: rgb(21, 24, 43); 
    padding: 30px;
    border-radius: 8px;
    display: inline-block;
    min-width: 350px;
    max-width: 90%; 
    text-align: left;
    border: 1px solid var(--color-lineas-rejilla);
}

.form-box input[type="text"],
.form-box input[type="email"],
.form-box input[type="password"],
.form-box select {
    display: block; 
    width: 100%;
    padding: 12px;
    margin-bottom: 20px;
    background-color: var(--color-principal-oscuro);
    border: 1px solid var(--color-lineas-rejilla);
    border-radius: 4px;
    color: var(--color-texto-claro);
    font-size: 1em;
}

.form-box label {
    color: var(--color-texto-gris);
    margin-bottom: 5px;
    display: block;
}

/* ================================================= */
/* ESTILOS DE VOTACIÓN (ESCRITORIO)                */
/* ================================================= */

#vote-container {
    max-width: 1000px;
    margin: 40px auto;
}

#vote-container h1 {
    font-size: 2.5em; 
    font-family: 'Euphemia Bold', sans-serif;
    color: var(--color-texto-claro);
    margin-bottom: 20px;
}

#category-name {
    font-family: 'Euphemia Regular', sans-serif;
    font-size: 3.8em;
    color: var(--color-texto-claro); /* Texto en magenta sólido */
    margin-bottom: 40px;
    letter-spacing: 2px;
    display: inline-block;
    padding: 10px 50px; /* Más espacio lateral para lucir el degradado */
    border: 1px solid var(--color-lineas-rejilla);
    border-radius: 60px;

    /* FONDO MAGENTA QUE SE DESVANECE AL CENTRO */
    /* Usamos RGBA basado en #EC0058 (236, 0, 88) */
    background: linear-gradient(to right, 
        rgba(236, 0, 88, 0.5) 0%,      /* Magenta al 50% de opacidad */
        rgba(236, 0, 88, 0.1) 25%,     /* Se desvanece rápido */
        transparent 50%,               /* Centro totalmente vacío */
        rgba(236, 0, 88, 0.1) 75%,     /* Vuelve a aparecer */
        rgba(236, 0, 88, 0.5) 100%     /* Magenta al 50% de opacidad */
    );
}

/* Contenedor de la lista de candidatos (Cuadrícula Flexible) */
#candidates-list {
    display: flex;
    justify-content: center;
    flex-wrap: wrap; 
    gap: 30px; 
    margin-bottom: 40px;
}

/* Tarjeta Individual de Candidato */
.candidate-card {
    padding: 15px;
    border-radius: 8px;
    text-align: center;
    background-color: var(--color-lineas-rejilla);
    width: 200px; 
    cursor: pointer;
    transition: all 0.3s ease;
    border: 3px solid transparent; 
}

/* Efectos */
.candidate-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.4);
    border-color: var(--color-lineas-rejilla); 
}

.candidate-card.selected {
    border-color: var(--color-acento-rosa); 
    background-color:rgb(47, 27, 57); 
    transform: scale(1.03); 
}

/* Imagen del Candidato */
.candidate-card img {
    width: 120px;
    height: 120px;
    object-fit: cover;
    border-radius: 50%; 
    border: 3px solid var(--color-acento-rosa); 
    margin-bottom: 10px;
    transition: all 0.3s ease;
}

/* Pantalla de agradecimiento */
#thanks-screen h1 {
    font-family: var(--font-script); 
    font-size: 5em;
    color: var(--color-acento-rosa);
    text-shadow: 0 0 10px rgba(236, 0, 88, 0.5);
    padding-top: 50px;
}

    .gallery-btn {
        background-color: transparent;
        border: 2px solid var(--color-acento-rosa);
        color: var(--color-acento-rosa);
        padding: 8px 16px;
        border-radius: 20px;
        font-size: 0.85em;
        cursor: pointer;
        margin-top: 10px;
        transition: all 0.3s ease;
        text-transform: uppercase;
        letter-spacing: 1px;
        font-weight: 600;
    }

    .gallery-btn:hover {
        background-color: var(--color-acento-rosa);
        color: white;
        transform: scale(1.05);
    }

    /* ESTILOS MEJORADOS PARA EL MODAL DE GALERÍA */
    .modal-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background-color: rgba(0, 0, 0, 0.95);
        z-index: 1000;
        display: flex;
        justify-content: center;
        align-items: center;
        opacity: 0;
        transition: opacity 0.3s ease;
        overflow-y: auto;
        /* Permite scroll si el contenido es muy alto */
        padding: 20px;
    }

    .modal-overlay.show {
        opacity: 1;
    }

    /* Contenedor principal del modal - controlado y centrado */
    .modal-content {
        position: relative;
        width: 100%;
        max-width: 800px;
        /* Ancho máximo razonable */
        max-height: 90vh;
        /* No excede el 90% de la altura de la pantalla */
        background-color: var(--color-principal-oscuro);
        border-radius: 12px;
        padding: 20px;
        border: 2px solid var(--color-acento-rosa);
        transform: scale(0.8);
        transition: transform 0.3s ease;
        display: flex;
        flex-direction: column;
        overflow: hidden;
        /* Evita desbordamiento */
    }

    .modal-overlay.show .modal-content {
        transform: scale(1);
    }

    /* Header del modal - fijo en la parte superior */
    .modal-header {
        display: flex;
        justify-content: space-between;
        align-items: center;
        margin-bottom: 20px;
        padding-bottom: 15px;
        border-bottom: 1px solid var(--color-lineas-rejilla);
        flex-shrink: 0;
        /* No se encoge */
    }

    .modal-header h3 {
        color: var(--color-acento-rosa);
        font-size: 1.3em;
        text-transform: uppercase;
        letter-spacing: 2px;
        margin: 0;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .close-btn {
        background: none;
        border: none;
        color: var(--color-texto-claro);
        font-size: 2em;
        cursor: pointer;
        padding: 0;
        width: 40px;
        height: 40px;
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.3s ease;
        border-radius: 50%;
        flex-shrink: 0;
    }

    .close-btn:hover {
        background-color: var(--color-acento-rosa);
        transform: rotate(90deg);
    }

    /* Contenedor de galería - controla el overflow y garantiza espacio para botones */
    .gallery-container {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 15px;
        width: 100%;
        max-height: calc(90vh - 120px);
        /* Resta espacio del header */
        overflow-y: auto;
        overflow-x: hidden;
        padding-bottom: 20px;
        /* Espacio extra al final */
    }

    /* Área principal de visualización - tamaño controlado */
    .gallery-main {
        width: 100%;
        max-width: 100%;
        height: 400px;
        /* Altura fija razonable */
        display: flex;
        align-items: center;
        justify-content: center;
        background-color: #000;
        border-radius: 8px;
        overflow: hidden;
        flex-shrink: 0;
    }

    /* Imágenes y videos - NUNCA exceden el contenedor */
    .gallery-main img,
    .gallery-main video {
        max-width: 100%;
        max-height: 100%;
        width: auto;
        height: auto;
        object-fit: contain;
        /* Se ajusta sin distorsión */
        display: block;
    }

    /* Contenedor de miniaturas - scroll horizontal para muchas miniaturas */
    .gallery-thumbnails {
        display: flex;
        gap: 10px;
        flex-wrap: nowrap;
        /* NO wrap - mantiene todo en una línea */
        justify-content: flex-start;
        width: 100%;
        max-width: 100%;
        overflow-x: auto;
        /* Scroll HORIZONTAL */
        overflow-y: hidden;
        padding: 10px 0;
        flex-shrink: 0;
        -webkit-overflow-scrolling: touch;
        /* Scroll suave en iOS */
    }

    /* Esconde la barra de scroll pero mantiene la funcionalidad */
    .gallery-thumbnails::-webkit-scrollbar {
        height: 6px;
    }

    .gallery-thumbnails::-webkit-scrollbar-track {
        background: rgba(255, 255, 255, 0.1);
        border-radius: 10px;
    }

    .gallery-thumbnails::-webkit-scrollbar-thumb {
        background: var(--color-acento-rosa);
        border-radius: 10px;
    }

    /* Miniaturas - tamaño fijo y controlado */
    .thumbnail {
        width: 70px;
        height: 70px;
        object-fit: cover;
        border-radius: 8px;
        cursor: pointer;
        border: 3px solid transparent;
        transition: all 0.3s ease;
        opacity: 0.6;
        flex-shrink: 0;
        /* No se encogen */
    }

    .thumbnail:hover {
        opacity: 1;
        transform: scale(1.1);
    }

    .thumbnail.active {
        border-color: var(--color-acento-rosa);
        opacity: 1;
    }

    /* Icono de video en miniaturas */
    .thumbnail-video {
        position: relative;
        width: 70px;
        height: 70px;
        border-radius: 8px;
    }

    /* Botones de navegación */
    .gallery-nav {
        display: flex;
        gap: 15px;
        margin-top: 15px;
        flex-shrink: 0;
        flex-wrap: wrap;
        justify-content: center;
    }

    .nav-btn {
        background-color: var(--color-acento-rosa);
        color: white;
        border: none;
        padding: 10px 20px;
        border-radius: 25px;
        cursor: pointer;
        font-size: 0.9em;
        font-weight: 600;
        text-transform: uppercase;
        transition: all 0.3s ease;
        white-space: nowrap;
    }

    .nav-btn:hover:not(:disabled) {
        background-color: #ff337e;
        transform: scale(1.05);
    }

    .nav-btn:disabled {
        opacity: 0.4;
        cursor: not-allowed;
        background-color: #666;
    }


/* ================================================= */
/* 📱 MEDIA QUERIES (RESPONSIVE MEJORADO)          */
/* ================================================= */

/* Para dispositivos pequeños (móviles, ancho máximo 768px - Incluimos tablets pequeñas) */
@media (max-width: 768px) {
    
    /* 1. Resetear el centrado forzado del body en las páginas de scroll (ej. Votación) */
    body {
        display: block;
        min-height: auto;
    }

    /* Ajustes para el modal de galería */
    .modal-overlay {
        padding: 10px;
        align-items: flex-start;
        padding-top: 20px;
    }

    .modal-content {
        max-width: 95%;
        max-height: 92vh;
        padding: 15px;
        margin: auto;
    }

    .modal-header h3 {
        font-size: 1em;
        letter-spacing: 1px;
    }

    .close-btn {
        width: 35px;
        height: 35px;
        font-size: 1.5em;
    }

    .gallery-main {
        max-width: 90vw;
        height: 250px;
    }

    .gallery-container {
        gap: 12px;
        max-height: calc(92vh - 100px);
        padding-bottom: 10px;
    }

    .thumbnail,
    .thumbnail-video {
        width: 60px;
        height: 60px;
        min-width: 60px;
    }

    .gallery-thumbnails {
        gap: 8px;
        padding: 8px 0;
    }

    .nav-btn {
        padding: 10px 20px;
        font-size: 0.85em;
    }

    .gallery-nav {
        gap: 10px;
        width: 100%;
        justify-content: center;
    }
    
    .container {
        padding: 20px 10px;
    }

    /* Títulos y Tipografía MÁS GRANDES Y LEGIBLES */
    #vote-container h1 {
        font-size: 2em; 
    }
    
    #category-name {
        font-size: 1.5em;
        letter-spacing: 1px;
        padding: 10px 15px;
        margin-bottom: 30px;
    }
    
    #thanks-screen h1 {
        font-size: 3.5em;
    }
    
    /* 2. Formulario de Registro/Login (para asegurar que sea full-width) */
    .form-box {
        min-width: 100%;
        max-width: 100%;
        padding: 20px;
    }
    
    /* 3. Tarjetas de Candidato: Dos por fila como máximo */
    #candidates-list {
        gap: 15px; 
    }

    .candidate-card {
        width: 45%;
        padding: 10px;
        transform: none;
    }

    .candidate-card.selected {
        transform: none; 
    }

    /* 4. Imágenes en Tarjeta */
    .candidate-card img {
        width: 90px;
        height: 90px;
        border-width: 2px;
    }

    /* 5. Botones */
    #next-btn {
        width: 90%; 
        margin: 0 auto;
        padding: 15px 30px;
        font-size: 1em;
    }
}

/* Para dispositivos muy estrechos (móviles pequeños, ancho máximo 450px) */
@media (max-width: 450px) {
    
    /* Ajustes para el modal de galería en pantallas muy pequeñas */
    .modal-overlay {
        padding: 5px;
        padding-top: 10px;
    }

    .modal-content {
        padding: 12px;
        max-height: 94vh;
    }

    .modal-header {
        margin-bottom: 12px;
        padding-bottom: 10px;
    }

    .modal-header h3 {
        font-size: 0.9em;
    }

    .gallery-main {
        height: 200px;
    }

    .gallery-container {
        gap: 10px;
        max-height: calc(94vh - 90px);
    }

    .thumbnail,
    .thumbnail-video {
        width: 55px;
        height: 55px;
        min-width: 55px;
    }

    .gallery-thumbnails {
        gap: 6px;
        padding: 6px 0;
    }

    .nav-btn {
        padding: 10px 16px;
        font-size: 0.8em;
    }

    .gallery-nav {
        gap: 8px;
    }
    
    /* Títulos aún más ajustados */
    #vote-container h1 {
        font-size: 1.6em; 
    }
    
    #category-name {
        font-size: 1.3em;
    }
    
    /* Tarjetas de Candidato: Una por fila para mejor usabilidad */
    .candidate-card {
        width: 85%;
        margin: 0 auto;
    }
    
    #candidates-list {
        gap: 20px;
    }
    
    /* Imagen del Candidato: Se mantiene de buen tamaño para la tarjeta única */
    .candidate-card img {
        width: 100px;
        height: 100px;
    }
}