/* ================================================= */
/* ESTILOS BASE (Móviles Primero) OPTIMIZADO V2 */
/* ================================================= */

body {
    font-family: Arial, sans-serif;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px;
    background-color: #f0f0f0;
    margin: 0;
}

.header {
    text-align: center;
    margin-bottom: 20px;
    padding: 10px;
}

.header h1 {
    color: #007bff;
    font-size: 1.8em;
    margin: 0;
}

.header h2 {
    color: #666;
    font-size: 1em;
    margin: 5px 0 0;
    font-style: italic;
}

.candidato-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding: 10px;
    background-color: white;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
    width: 100%;
    box-sizing: border-box;
    max-width: 500px; 
}

.candidato-item {
    display: flex;
    align-items: center;
    padding: 10px;
    border-radius: 6px;
    /* Estilos de barra de progreso genéricos */
    background: linear-gradient(to right, #d4edda 0%, #d4edda var(--votos-porcentaje), #e9e9e9 var(--votos-porcentaje), #e9e9e9 100%);
    transition: all 0.5s ease-out;
    flex-wrap: nowrap;
    border-left: 5px solid #ccc; 
}

/* ================================================= */
/* CLASES DE COLOR POR PARTIDO POLÍTICO (Sin cambios) */
/* ================================================= */

/* PARTIDO DC - Demócrata Cristiano (Ejemplo de color) */
.partido-adc {
    background-color: #fff8e1 !important; 
    background: linear-gradient(to right, #00771f 0%, #66ff4a var(--votos-porcentaje), #fff8e1 var(--votos-porcentaje), #fff8e1 100%) !important;
    border-left: 5px solid #f9a825 !important;
}

/* PARTIDO LIBRE */
.partido-alibre {
    background-color: #f7d4d4 !important; 
    background: linear-gradient(to right, #cc0000 0%, #cc0000 var(--votos-porcentaje), #f7d4d4 var(--votos-porcentaje), #f7d4d4 100%) !important;
    border-left: 5px solid #990000 !important;
}

/* PARTIDO PINU - Innovación y Unidad (Ejemplo de color) */
.partido-apinu {
    background-color: #e0f2f1 !important; 
    background: linear-gradient(to right, #f39f04 0%, #f5bd3e var(--votos-porcentaje), #e0f2f1 var(--votos-porcentaje), #e0f2f1 100%) !important;
    border-left: 5px solid #00796b !important;
}

/* PARTIDO LIBERAL */
.partido-aliberal {
    background-color: #f7e4d4 !important; 
    background: linear-gradient(to right, #f51313 0%, #e74c4c var(--votos-porcentaje), #f7e4d4 var(--votos-porcentaje), #f7e4d4 100%) !important;
    border-left: 5px solid #cc0000 !important;
}

/* PARTIDO NACIONAL */
.partido-anacional {
    background-color: #d4e3f7 !important; 
    background: linear-gradient(to right, #1200a4 0%, #148eff var(--votos-porcentaje), #d4e3f7 var(--votos-porcentaje), #d4e3f7 100%) !important;
    border-left: 5px solid #003366 !important;
}

.candidato-image {
    width: 50px;
    height: 50px;
    object-fit: cover;
    border-radius: 50%;
    border: 2px solid #007bff;
    flex-shrink: 0;
}

.candidato-info {
    flex-grow: 1;
    text-align: left;
    margin-left: 10px;
    min-width: 0;
    overflow: hidden; 
}

.candidato-nombre {
    font-size: 1em;
    font-weight: bold;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.candidato-partido {
    font-size: 0.8em;
    color: #555;
    font-style: italic;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.candidato-votos {
    min-width: 90px;
    text-align: right;
    font-weight: bold;
    font-size: 0.9em;
    color: #007bff;
    flex-shrink: 0;
}

.ultima-actualizacion {
    margin-top: 15px;
    padding: 8px;
    border-top: 1px solid #ccc;
    text-align: center;
    font-size: 0.75em;
    color: #666;
    width: 100%;
}


/* ================================================= */
/* ESTILOS DE BOTONES (SOLUCIÓN GARANTIZADA MÓVIL) 🚀 */
/* ================================================= */

.button-container {
    display: flex;
    /* 💥 CLAVE 1: Forzar apilamiento vertical en móvil */
    flex-direction: column; 
    gap: 10px; /* Espacio vertical entre los botones */
    margin: 20px 0;
    padding: 10px;
    width: 100%;
    box-sizing: border-box;
    /* Centrar el grupo de botones */
    align-items: center; 
    justify-content: center;
}

.modern-button {
    text-decoration: none;
    padding: 12px 15px;
    border-radius: 8px;
    font-weight: bold;
    color: #ffffff;
    transition: all 0.3s ease;
    text-align: center;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    display: inline-block;
    
    /* 💥 CLAVE 2: Ancho predecible en móvil */
    width: 90%; 
    max-width: 300px; /* Límite para que no sean ridículamente anchos */
    
    /* Nota: margin-bottom se elimina si se usa gap en el contenedor */
}

/* Estilos específicos de color */
.left-button {
    background-image: linear-gradient(45deg, #007bff, #0056b3); /* Azul */
}

.center-button {
    background-image: linear-gradient(45deg, #28a745, #1e7e34); /* Verde */
}

.right-button {
    background-image: linear-gradient(45deg, #ffc107, #d39e00); /* Amarillo/Naranja */
}

/* Efecto hover */
.modern-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 10px rgba(0, 0, 0, 0.2);
    opacity: 0.9;
}

/* ================================================= */
/* MEDIA QUERIES (Ajustes para Tabletas y Escritorio) */
/* ================================================= */

/* Pantallas Medianas (Tabletas, ancho > 600px) */
@media (min-width: 600px) {
    /* --- Botones: Volver a una fila --- */
    .button-container {
        /* 💥 CLAVE 3: Volver a disposición horizontal */
        flex-direction: row; 
        gap: 20px;
        flex-wrap: nowrap;
    }
    .modern-button {
        width: auto; /* Dejamos que el contenido y padding definan el ancho */
        min-width: 180px; 
        max-width: none; /* Eliminar el límite de ancho de móvil */
        padding: 12px 25px; 
    }

    /* --- Contenido --- */
    .candidato-container {
        width: 90%;
        max-width: 700px;
    }
    .header h1 {
        font-size: 2.2em;
    }
    .header h2 {
        font-size: 1.1em;
    }
    .candidato-item {
        padding: 15px;
    }
    .candidato-image {
        width: 60px;
        height: 60px;
    }
    .candidato-nombre {
        font-size: 1.1em;
    }
    .candidato-partido {
        font-size: 0.9em;
    }
    .candidato-votos {
        min-width: 120px;
        font-size: 1.1em;
    }
}

/* Pantallas Grandes (Escritorio, ancho > 900px) */
@media (min-width: 900px) {
    .header h1 {
        font-size: 2.5em;
    }
    .candidato-container {
        max-width: 900px;
        gap: 25px;
        padding: 20px;
    }
    .candidato-image {
        width: 70px;
        height: 70px;
    }
    .candidato-votos {
        min-width: 150px;
        font-size: 1.2em;
    }
}