/* ==========================================================
   ESTILOS GENERALES Y CONTENEDOR PRINCIPAL
   ========================================================== */

.ep-encuesta-container {
    max-width: 900px;
    margin: 30px auto;
    padding: 20px;
    background-color: #f7f7f7;
    border-radius: 8px;
}

.ep-encuesta-container h2 {
    color: #333;
    border-bottom: 2px solid #ddd;
    padding-bottom: 10px;
}

.ep-introduccion {
    border-left: 4px solid #3498db;
    padding: 10px 15px;
    margin-bottom: 20px;
    background-color: #ecf0f1;
    border-radius: 4px;
}

/* Alertas de estado (Encuesta cerrada/Ya votó) */
.ep-alerta-cerrada, .ep-alerta-votado {
    padding: 10px;
    margin-bottom: 20px;
    border-radius: 4px;
    text-align: center;
    font-weight: bold;
}
.ep-alerta-cerrada {
    background-color: #f39c12;
    color: #fff;
}
.ep-alerta-votado {
    background-color: #27ae60;
    color: #fff;
}
.ep-mensaje-alerta.ep-error {
    color: #c0392b;
    background-color: #fde8e5;
    border: 1px solid #c0392b;
    padding: 10px;
    margin-top: 15px;
    border-radius: 4px;
}
.ep-mensaje-alerta.ep-success {
    color: #27ae60;
    background-color: #e5fde8;
    border: 1px solid #27ae60;
    padding: 10px;
    margin-top: 15px;
    border-radius: 4px;
}


/* ==========================================================
   ESTRUCTURA DE CANDIDATOS (Flexbox)
   ========================================================== */

/* Contenedor principal de la lista de candidatos */
.ep-candidatos-lista {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Cada fila de candidato */
.ep-candidato-item {
    display: flex;
    align-items: flex-start;
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 6px;
    background-color: #fff;
}


/* ==========================================================
   COLUMNA 1: INFO CANDIDATO
   ========================================================== */

.ep-info-candidato {
    flex: 0 0 20%; /* Ocupa el 20% de la fila */
    min-width: 120px;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    padding-right: 15px;
}

.ep-candidato-foto {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    object-fit: cover;
    margin-bottom: 5px;
    border: 3px solid #3498db;
}

.ep-info-texto h3 {
    margin: 5px 0 5px 0;
    font-size: 1.1em;
    color: #333;
}

.ep-candidato-logo {
    max-width: 50px;
    max-height: 50px;
}


/* ==========================================================
   COLUMNA 2: CALIFICACIÓN (VOTOS)
   ========================================================== */

.ep-calificacion-wrapper {
    flex: 0 0 30%; /* Ocupa el 30% de la fila */
    padding: 0 20px;
    border-left: 1px solid #eee;
    box-sizing: border-box;
}

.ep-calificacion-botones label {
    display: block;
    margin-bottom: 10px;
    font-weight: normal;
    cursor: pointer;
}

.ep-calificacion-botones input[type="radio"] {
    margin-right: 8px;
    transform: scale(1.1);
}

.ep-calificacion-finalizada {
    color: #7f8c8d;
    font-style: italic;
    padding-top: 10px;
}


/* ==========================================================
   COLUMNA 3: RESULTADOS (GRÁFICA + TOTALES/PORCENTAJES)
   *** REGLAS CLAVE AGREGADAS PARA ALINEAR EL TEXTO JUNTO AL GRÁFICO ***
   ========================================================== */

.ep-resultados-grafica {
    flex: 1; /* Ocupa el espacio restante */
    min-width: 350px; 
    height: 100%;
    border-left: 1px solid #ddd;
    padding-left: 20px;
    box-sizing: border-box;
    
    /* PROPIEDADES CLAVE AGREGADAS: Esto es lo que faltaba */
    display: flex; 
    flex-direction: row; 
    align-items: center; 
    justify-content: space-around;
}

/* Contenedor de Votos y Porcentajes */
.ep-resultados-totales-info {
    flex: 0 0 45%; 
    padding-right: 15px;
    font-size: 0.9em;
}

.ep-total-votos-display strong {
    color: #2c3e50;
    font-size: 1.1em;
    display: block;
    margin-bottom: 5px;
}

.ep-porcentajes-detalle p {
    margin: 3px 0;
    line-height: 1.3;
}
.ep-porcentajes-detalle strong {
    color: #34495e; 
    font-weight: bold;
}

/* El Canvas de Chart.js */
.ep-resultados-grafica canvas {
    max-width: 150px; 
    max-height: 150px;
    flex: 0 0 50%; 
}


/* ==========================================================
   CONTROLES FINALES (OPINIÓN Y CAPTCHA)
   ========================================================== */

.ep-opinion-captcha-wrapper {
    display: flex;
    justify-content: space-between;
    gap: 30px;
    margin-top: 25px;
    padding-top: 15px;
    border-top: 1px solid #eee;
}

.ep-opinion-usuario, .ep-captcha-wrapper {
    flex: 1;
}

.ep-opinion-usuario h3, .ep-captcha-wrapper h3 {
    font-size: 1em;
    color: #3498db;
    margin-top: 0;
    border-bottom: 1px dashed #ccc;
    padding-bottom: 5px;
}

.ep-opinion-usuario textarea {
    width: 100%;
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    box-sizing: border-box;
}

.ep-captcha-wrapper input[type="number"] {
    padding: 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    width: 100px;
    text-align: center;
    margin-top: 5px;
}

.ep-submit-wrapper {
    text-align: center;
    margin-top: 20px;
}

.ep-submit-wrapper button {
    padding: 10px 30px;
    font-size: 1.1em;
    background-color: #2ecc71;
    border-color: #27ae60;
    cursor: pointer;
    transition: background-color 0.3s;
}

.ep-submit-wrapper button:hover:not(:disabled) {
    background-color: #27ae60;
}

.ep-submit-wrapper button:disabled {
    background-color: #bdc3c7;
    border-color: #95a5a6;
    cursor: not-allowed;
}


/* ==========================================================
   RESPONSIVE (Móviles)
   ========================================================== */

@media (max-width: 768px) {
    
    /* La columna de candidatos ahora será una pila vertical */
    .ep-candidato-item {
        flex-direction: column; 
        align-items: center;
    }

    /* Info Candidato: Ocupa todo el ancho en la parte superior */
    .ep-info-candidato {
        width: 100%;
        margin-bottom: 15px;
        padding: 0 0 10px 0;
        border-bottom: 1px solid #f0f0f0;
    }

    /* Votos: Ocupa el ancho completo */
    .ep-calificacion-wrapper {
        width: 100%;
        padding: 10px 0;
        text-align: center;
        border-left: none; /* Eliminar borde lateral en móvil */
    }
    
    /* Intenta poner los radios en fila si caben */
    .ep-calificacion-botones {
        display: flex; 
        flex-wrap: wrap; 
        justify-content: center;
    }
    .ep-calificacion-botones label {
        flex: 1 1 40%; 
        margin: 5px;
        text-align: left;
    }

    /* Gráfica y Totales: Ahora en dos filas verticales */
    .ep-resultados-grafica {
        width: 100%; 
        min-width: 100%; 
        max-width: 300px; /* Limitar el ancho de la gráfica en móvil */
        height: auto; 
        margin: 15px auto 0 auto; /* Centrar en móvil */
        border-left: none;
        padding-left: 0;
        border-top: 1px solid #eee; /* Agregar borde superior */

        /* Volver a apilar verticalmente */
        flex-direction: column; 
        justify-content: center;
    }
    
    /* Ajustar el orden y el espaciado en móvil */
    .ep-resultados-totales-info {
        flex: none;
        width: 100%;
        padding-right: 0;
        margin-bottom: 15px;
        text-align: center;
    }

    .ep-resultados-grafica canvas {
        flex: none;
        margin-top: 10px;
    }

    /* Controles finales también en pila vertical */
    .ep-opinion-captcha-wrapper {
        flex-direction: column;
        gap: 20px;
    }

    .ep-captcha-wrapper input[type="number"] {
        width: 100%; 
    }
}