/* ==========================================================================
   CubaOpina Polls v2 - Frontend Styles (Diseño Limpio y Simple)
   ========================================================================== */

/* Contenedor principal */
.cubaopina-poll-simple {
    max-width: 800px;
    margin: 30px auto;
    padding: 40px 30px;
    background: rgba(255, 255, 255, 0.95);
    background-size: cover;
    background-position: center;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.1);
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
}

.cubaopina-simple-content {
    position: relative;
    z-index: 1;
}

/* Título */
.cubaopina-simple-title {
    font-size: 28px;
    font-weight: 700;
    color: #1a1a1a;
    margin: 0 0 20px 0;
    line-height: 1.3;
    text-align: center;
}

/* Descripción */
.cubaopina-simple-description {
    font-size: 16px;
    color: #444;
    line-height: 1.6;
    margin: 0 0 30px 0;
    text-align: center;
}

.cubaopina-simple-description p {
    margin: 0 0 10px 0;
}

.cubaopina-simple-description p:last-child {
    margin-bottom: 0;
}

/* ==========================================================================
   MODO ICONOS (Pulgares)
   ========================================================================== */

.cubaopina-vote-icons {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 40px;
    margin: 30px 0;
}

.cubaopina-vote-icon {
    position: relative;
    background: transparent;
    border: none;
    padding: 20px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.cubaopina-vote-icon:not(.voted):hover {
    transform: scale(1.1);
}

.cubaopina-vote-icon.voted {
    cursor: default;
    opacity: 0.7;
}

.cubaopina-vote-icon.user-vote {
    opacity: 1;
}

.cubaopina-vote-icon.user-vote::after {
    content: '';
    position: absolute;
    bottom: -10px;
    left: 50%;
    transform: translateX(-50%);
    width: 40px;
    height: 3px;
    background: currentColor;
    border-radius: 3px;
}

.vote-icon-svg {
    width: 80px;
    height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.vote-icon-svg svg {
    width: 100%;
    height: 100%;
    display: block;
    filter: drop-shadow(0 2px 8px rgba(0,0,0,0.15));
}

.vote-icon-stats {
    text-align: center;
}

.vote-icon-count {
    font-size: 32px;
    font-weight: 700;
    line-height: 1;
    margin-bottom: 5px;
    /* El color se hereda del padre (vote-icon-svg) */
}

.vote-icon-percent {
    font-size: 18px;
    font-weight: 600;
    /* El color se hereda del padre (vote-icon-svg) */
}

.vote-icon-badge {
    position: absolute;
    top: 0;
    right: 0;
    background: #ffd700;
    color: #1a1a1a;
    font-size: 11px;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}

/* ==========================================================================
   MODO BOTONES
   ========================================================================== */

.cubaopina-vote-buttons {
    display: flex;
    flex-direction: row;
    justify-content: center;
    gap: 20px;
    margin: 30px auto; /* auto para centrar */
    max-width: 700px; /* Limitar ancho máximo para que no se estiren tanto */
    flex-wrap: nowrap; /* No permite wrap, siempre en línea */
}

.cubaopina-vote-button {
    position: relative;
    padding: 20px 25px;
    border: 2px solid;
    border-radius: 12px; /* Ahora se aplicará correctamente */
    cursor: pointer;
    transition: all 0.3s ease;
    background: transparent;
    width: auto; /* Cambiado de 100% */
    max-width: calc(100% - 40px); /* Deja espacio a los lados */
    margin: 0 auto; /* Centrado */
}

.cubaopina-vote-button:not(.voted):hover {
    transform: translateX(5px);
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
}

.cubaopina-vote-button.voted {
    cursor: default;
    opacity: 0.7;
}

.cubaopina-vote-button.user-vote {
    opacity: 1;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
}

.vote-button-content {
    display: flex;
    align-items: center;
    gap: 15px;
}

.vote-button-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.vote-button-icon svg {
    width: 100%;
    height: 100%;
    display: block;
}

.vote-button-text {
    flex: 1;
    font-size: 18px;
    font-weight: 600;
    color: #1a1a1a;
    text-align: left;
}

.vote-button-stats {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-left: auto;
}

.vote-button-count {
    font-size: 24px;
    font-weight: 700;
    color: #1a1a1a;
}

.vote-button-percent {
    font-size: 18px;
    font-weight: 600;
    color: #666;
}

.vote-button-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #ffd700;
    color: #1a1a1a;
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 12px;
}

/* ==========================================================================
   MENSAJES
   ========================================================================== */

.cubaopina-voted-message {
    text-align: center;
    font-size: 16px;
    font-weight: 600;
    color: #28a745;
    margin: 20px 0 0 0;
}

.cubaopina-login-message {
    text-align: center;
    font-size: 15px;
    color: #666;
    margin: 20px 0 0 0;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.login-icon {
    font-size: 18px;
}

.cubaopina-login-message a {
    color: #2271b1;
    text-decoration: underline;
    font-weight: 600;
}

.cubaopina-login-message a:hover {
    color: #135e96;
}

.cubaopina-total-votes {
    text-align: center;
    font-size: 14px;
    color: #666;
    margin: 25px 0 0 0;
    padding: 15px;
    background: rgba(0,0,0,0.03);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

.total-votes-icon {
    font-size: 16px;
}

.cubaopina-total-votes strong {
    color: #1a1a1a;
    font-weight: 700;
}

/* ==========================================================================
   MODAL DE LOGIN
   ========================================================================== */

.cubaopina-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.cubaopina-modal-content {
    background: #fff;
    padding: 35px;
    border-radius: 12px;
    max-width: 400px;
    width: 90%;
    position: relative;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { 
        opacity: 0;
        transform: translateY(30px);
    }
    to { 
        opacity: 1;
        transform: translateY(0);
    }
}

.cubaopina-modal-close {
    position: absolute;
    top: 15px;
    right: 15px;
    background: none;
    border: none;
    font-size: 28px;
    cursor: pointer;
    color: #999;
    padding: 5px 10px;
    line-height: 1;
    transition: color 0.2s;
}

.cubaopina-modal-close:hover {
    color: #333;
}

.cubaopina-modal-content h3 {
    margin: 0 0 15px 0;
    font-size: 22px;
    color: #1a1a1a;
}

.cubaopina-modal-content p {
    margin: 0 0 25px 0;
    color: #666;
    line-height: 1.6;
}

.cubaopina-modal-button {
    display: block;
    width: 100%;
    padding: 14px;
    background: #2271b1;
    color: #fff;
    text-align: center;
    border-radius: 8px;
    font-weight: 600;
    text-decoration: none;
    transition: background 0.3s ease;
    font-size: 16px;
}

.cubaopina-modal-button:hover {
    background: #135e96;
    color: #fff;
}

/* ==========================================================================
   ESTADOS DE ERROR
   ========================================================================== */

.cubaopina-error,
.cubaopina-inactive {
    padding: 20px;
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 8px;
    color: #721c24;
    text-align: center;
    margin: 20px auto;
    max-width: 600px;
}

/* ==========================================================================
   LOADING STATE
   ========================================================================== */

.cubaopina-vote-icon.loading,
.cubaopina-vote-button.loading {
    pointer-events: none;
    opacity: 0.6;
    position: relative;
}

.cubaopina-vote-icon.loading::before,
.cubaopina-vote-button.loading::before {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid rgba(0,0,0,0.2);
    border-top-color: #1a1a1a;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

@media (max-width: 768px) {
    .cubaopina-poll-simple {
        margin: 20px 10px;
        padding: 30px 20px;
    }

    .cubaopina-simple-title {
        font-size: 22px;
    }

    .cubaopina-simple-description {
        font-size: 15px;
    }

    /* Modo iconos en móvil */
    .cubaopina-vote-icons {
        gap: 30px;
    }

    .vote-icon-svg {
        width: 60px;
        height: 60px;
    }

    .vote-icon-count {
        font-size: 24px;
    }

    .vote-icon-percent {
        font-size: 16px;
    }

    /* Modo botones en móvil */
    .vote-button-content {
        flex-wrap: wrap;
    }

    .vote-button-stats {
        width: 100%;
        justify-content: center;
        margin: 10px 0 0 0;
    }

    .vote-button-text {
        font-size: 16px;
        text-align: center;
        width: 100%;
    }
}

@media (max-width: 480px) {
    .cubaopina-vote-icons {
        gap: 20px;
    }

    .vote-icon-svg {
        width: 50px;
        height: 50px;
    }
}

/* ==========================================================================
   ACCESIBILIDAD
   ========================================================================== */

.cubaopina-vote-icon:focus,
.cubaopina-vote-button:focus,
.cubaopina-modal-close:focus,
.cubaopina-modal-button:focus {
    outline: 2px solid #2271b1;
    outline-offset: 2px;
}

.cubaopina-vote-icon:focus:not(:focus-visible),
.cubaopina-vote-button:focus:not(:focus-visible) {
    outline: none;
}

/* ==========================================================================
   MODO OSCURO
   ========================================================================== */

@media (prefers-color-scheme: dark) {
    .cubaopina-poll-simple {
        background: rgba(30, 30, 30, 0.95);
    }

    .cubaopina-simple-title,
    .vote-button-text,
    .vote-button-count {
        color: #f0f0f0;
    }

    .cubaopina-simple-description,
    .vote-button-percent,
    .cubaopina-login-message,
    .cubaopina-total-votes {
        color: #b0b0b0;
    }
    
    /* Los colores de los pulgares se mantienen según su configuración */
    .vote-icon-count,
    .vote-icon-percent {
        /* Heredan el color del icono - no cambiar */
    }

    .cubaopina-modal-content {
        background: #2c2c2c;
    }

    .cubaopina-modal-content h3 {
        color: #f0f0f0;
    }

    .cubaopina-modal-content p {
        color: #b0b0b0;
    }
}

/* ==========================================================================
   ANIMACIONES ADICIONALES
   ========================================================================== */

.cubaopina-vote-icon,
.cubaopina-vote-button {
    animation: fadeInUp 0.4s ease;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Adiciones CSS para v3.0 - Agregar al archivo CSS existente */

/* API Result Display */
.cubaopina-api-result {
    background: #f0f7ff;
    border: 2px solid #4a90e2;
    border-radius: 8px;
    padding: 12px 16px;
    margin: 15px 0;
    text-align: center;
    font-size: 16px;
}

.cubaopina-api-result .api-icon {
    font-size: 20px;
    margin-right: 8px;
}

.cubaopina-api-result strong {
    color: #2c5aa0;
    font-weight: 600;
}

/* Notificaciones */
.cubaopina-notification {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 15px;
    font-size: 15px;
    font-weight: 500;
    display: none; /* Oculto por defecto, se muestra con fadeIn */
    animation: slideDown 0.3s ease;
}

.cubaopina-notification-success {
    background: #d4edda;
    border: 1px solid #c3e6cb;
    color: #155724;
}

.cubaopina-notification-error {
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

.cubaopina-notification-info {
    background: #d1ecf1;
    border: 1px solid #bee5eb;
    color: #0c5460;
}

@keyframes slideDown {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Botones activos después de votar (para cambio de voto) */
.cubaopina-vote-button.voted:not(:disabled),
.cubaopina-vote-icon.voted:not(:disabled) {
    cursor: pointer;
    opacity: 1;
}

.cubaopina-vote-button.voted:not(:disabled):hover,
.cubaopina-vote-icon.voted:not(:disabled):hover {
    transform: scale(1.05);
}

/* Badge "Tu voto" con animación */
.vote-icon-badge,
.vote-button-badge {
    animation: fadeInBadge 0.3s ease;
}

@keyframes fadeInBadge {
    from {
        opacity: 0;
        transform: scale(0.8);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Loading state para botones */
.cubaopina-vote-button.loading,
.cubaopina-vote-icon.loading {
    opacity: 0.6;
    cursor: wait;
    position: relative;
}

.cubaopina-vote-button.loading::after,
.cubaopina-vote-icon.loading::after {
    content: "";
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Mensajes mejorados */
.cubaopina-voted-message {
    background: #e8f5e9;
    border-left: 4px solid #4caf50;
    padding: 10px 15px;
    margin: 15px 0;
    border-radius: 4px;
    font-size: 14px;
    color: #2e7d32;
}

/* Responsive mejoras */
@media (max-width: 768px) {
    .cubaopina-api-result {
        font-size: 14px;
        padding: 10px 12px;
    }
    
    .cubaopina-notification {
        font-size: 14px;
        padding: 10px 12px;
    }
}


/* ==========================================================================
   NUEVOS ESTILOS - Imagen, Título y Descripción en opciones
   ========================================================================== */

/* Contenedor de opción (para modo botones) */
.cubaopina-vote-option {
    flex: 1;
    max-width: 320px; /* Reducido de 350px para que no se estiren tanto */
    display: flex;
    flex-direction: column;
    gap: 0;
    /* overflow: hidden; REMOVIDO para que se vea el badge completo */
    border-radius: 12px;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    padding-bottom: 15px;
}

/* Contenedor de opción (para modo iconos) */
.cubaopina-vote-option-icon {
    display: flex;
    flex-direction: column;
    gap: 0;
    align-items: center;
}

/* Imagen de la opción */
.vote-option-image {
    width: 100%;
    overflow: hidden;
    border-radius: 12px 12px 0 0;
}

.vote-option-image img {
    width: 100%;
    height: auto;
    display: block;
}

/* Título de la opción */
.vote-option-title {
    width: 100%;
    padding: 12px 20px;
    font-size: 16px;
    font-weight: 700;
    text-align: center;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #fff;
}

/* Descripción de la opción */
.vote-option-description {
    width: 100%;
    padding: 15px 20px;
    font-size: 14px;
    line-height: 1.6;
    color: #444;
    background: #fff;
    text-align: center;
}

/* Ajustar botones cuando tienen imagen/título/descripción */
.cubaopina-vote-option .cubaopina-vote-button {
    border-radius: 12px;
    margin: 0 auto; /* Mantener centrado */
    padding: 14px 25px;
    min-width: calc(100% - 50px);
}

/* Si el botón está solo (sin imagen, título ni descripción), tiene border-radius completo */
.cubaopina-vote-option:not(:has(.vote-option-image)):not(:has(.vote-option-title)):not(:has(.vote-option-description)) .cubaopina-vote-button {
    border-radius: 12px;
    margin: 0 auto; /* Mantener centrado */
}

.cubaopina-vote-option:not(:has(.vote-option-image)):not(:has(.vote-option-title)):not(:has(.vote-option-description)){
    padding-top: 15px;
}

/* Si tiene imagen pero NO tiene título, el botón necesita border-radius superior también */
.cubaopina-vote-option:has(.vote-option-image):not(:has(.vote-option-title)):not(:has(.vote-option-description)) .cubaopina-vote-button {
    border-radius: 0 0 12px 12px;
    margin: 0 auto; /* Mantener centrado */
}

/* Si tiene título pero NO imagen arriba, el título necesita border-radius superior */
.cubaopina-vote-option:not(:has(.vote-option-image)) .vote-option-title {
    border-radius: 12px 12px 0 0;
}

.cubaopina-vote-option .vote-option-image + .cubaopina-vote-button {
    border-radius: 0 0 12px 12px;
    margin: 0 auto; /* Mantener centrado */
}

.cubaopina-vote-option .vote-option-title + .cubaopina-vote-button {
    border-radius: 0 0 12px 12px;
    margin: 0 auto; /* Mantener centrado */
}

.cubaopina-vote-option .vote-option-description + .cubaopina-vote-button {
    /*border-radius: 0 0 12px 12px;*/
    border-radius: 12px;
    margin: 0 auto; /* Mantener centrado */
}

/* Si hay imagen, el título no tiene border-radius superior */
.cubaopina-vote-option .vote-option-image + .vote-option-title {
    border-radius: 0;
}

/* Si hay título, la descripción no tiene border-radius */
.cubaopina-vote-option .vote-option-title + .vote-option-description {
    border-top: 1px solid rgba(0,0,0,0.05);
}

/* Si solo hay imagen (sin título), el botón queda pegado */
.cubaopina-vote-option .vote-option-image:not(:has(+ .vote-option-title)) {
    border-radius: 12px 12px 0 0;
}

/* Para modo iconos */
.cubaopina-vote-option-icon .vote-option-image {
    border-radius: 12px;
    margin-bottom: 12px;
    max-width: 200px;
}

.cubaopina-vote-option-icon .vote-option-title {
    border-radius: 8px;
    margin-bottom: 8px;
    max-width: 200px;
}

.cubaopina-vote-option-icon .vote-option-description {
    border-radius: 8px;
    margin-bottom: 12px;
    max-width: 250px;
    border: 1px solid #e0e0e0;
}

/* Responsive */
@media (max-width: 768px) {
    .cubaopina-vote-buttons {
        gap: 15px; /* Menos espacio en tablets */
        flex-wrap: nowrap !important; /* Forzar que NO se apilen */
    }
    
    .vote-option-title {
        font-size: 14px;
        padding: 10px 15px;
    }
    
    .vote-option-description {
        font-size: 13px;
        padding: 12px 15px;
    }
    
    .cubaopina-vote-option {
        /* min-width REMOVIDO */
        max-width: 350px !important; /* Forzar ancho máximo */
        flex: 1 !important; /* Forzar flex */
    }
}

@media (max-width: 480px) {
    .cubaopina-vote-buttons {
        gap: 10px; /* Menos espacio en móviles */
        flex-wrap: nowrap !important; /* Forzar que NO se apilen */
    }
    
    .vote-option-title {
        font-size: 13px;
        padding: 8px 12px;
    }
    
    .vote-option-description {
        font-size: 12px;
        padding: 10px 12px;
    }
    
    .cubaopina-vote-option {
        /* min-width REMOVIDO */
        max-width: 280px !important;
        flex: 1 !important;
    }
}

/* ==========================================================================
   Imagen Principal de la Encuesta
   ========================================================================== */

.cubaopina-main-image {
    width: 100%;
    margin: 0 0 25px 0;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.cubaopina-main-image img {
    width: 100%;
    height: auto;
    display: block;
}

/* Responsive */
@media (max-width: 768px) {
    .cubaopina-main-image {
        margin-bottom: 20px;
        border-radius: 8px;
    }
}

@media (max-width: 480px) {
    .cubaopina-main-image {
        margin-bottom: 15px;
        border-radius: 6px;
    }
}
