/* Popup de Bienvenida - Estilos CSS */

.popup-bienvenida-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.8);
    z-index: 999999;
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.popup-bienvenida-overlay.mostrar {
    opacity: 1;
    visibility: visible;
}

.popup-bienvenida-container {
    position: relative;
    width: 600px;
    height: 600px;
    max-width: 90vw;
    max-height: 90vh;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.3);
    transform: scale(0.7);
    transition: transform 0.3s ease;
}

.popup-bienvenida-overlay.mostrar .popup-bienvenida-container {
    transform: scale(1);
}

.popup-bienvenida-close {
    position: absolute;
    top: 15px;
    right: 15px;
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.9);
    border: none;
    border-radius: 6px;
    font-size: 24px;
    font-weight: bold;
    color: #333;
    cursor: pointer;
    z-index: 10;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.popup-bienvenida-close:hover {
    background: rgba(255, 255, 255, 1);
    transform: scale(1.1);
}

.popup-bienvenida-content {
    width: 100%;
    height: 100%;
    position: relative;
}

.popup-bienvenida-imagen {
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
    position: relative;
    cursor: default;
}

/* Áreas clickeables para las banderas */
.popup-bandera-chile,
.popup-bandera-peru {
    position: absolute;
    bottom: 20%;
    width: 25%;
    height: 20%;
    cursor: pointer;
    transition: all 0.2s ease;
    border-radius: 10px;
}

.popup-bandera-chile {
    left: 15%;
}

.popup-bandera-peru {
    right: 15%;
}

/* Efectos hover para las banderas */
.popup-bandera-chile:hover,
.popup-bandera-peru:hover {
    background: rgba(255, 255, 255, 0.1);
    transform: scale(1.05);
    box-shadow: 0 0 20px rgba(255, 255, 255, 0.3);
}

/* Indicadores visuales para las áreas clickeables */
.popup-bandera-chile:before,
.popup-bandera-peru:before {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 0;
    height: 0;
    border: 8px solid transparent;
    border-bottom: 12px solid rgba(255, 255, 255, 0.8);
    opacity: 0;
    transition: opacity 0.2s ease;
}

.popup-bandera-chile:hover:before,
.popup-bandera-peru:hover:before {
    opacity: 1;
}

/* Responsive Design Mejorado */

/* Tablets y dispositivos medianos */
@media (max-width: 768px) {
    .popup-bienvenida-container {
        width: 90vw !important;
        height: auto !important;
        min-height: 400px;
        max-height: 70vh !important;
        aspect-ratio: 1/1; /* Mantener proporción cuadrada */
    }
    
    .popup-bienvenida-imagen {
        width: 100%;
        height: 100%;
        min-height: 400px;
    }
    
    .popup-bandera-chile,
    .popup-bandera-peru {
        width: 30% !important;
        height: 25% !important;
        bottom: 15% !important;
    }
    
    .popup-bandera-chile {
        left: 10% !important;
    }
    
    .popup-bandera-peru {
        right: 10% !important;
    }
    
    .popup-bienvenida-close {
        width: 40px;
        height: 40px;
        top: 15px;
        right: 15px;
        font-size: 22px;
    }
}

/* Móviles */
@media (max-width: 480px) {
    .popup-bienvenida-overlay {
        padding: 10px;
        box-sizing: border-box;
    }
    
    .popup-bienvenida-container {
        width: 95vw !important;
        height: auto !important;
        min-height: 350px;
        max-height: 80vh !important;
        max-width: 95vw !important;
        border-radius: 12px;
        aspect-ratio: 1/1; /* Mantener proporción cuadrada */
    }
    
    .popup-bienvenida-imagen {
        width: 100%;
        height: 100%;
        min-height: 350px;
        border-radius: 12px;
    }
    
    .popup-bienvenida-close {
        width: 36px !important;
        height: 36px !important;
        top: 12px !important;
        right: 12px !important;
        font-size: 20px !important;
        border-radius: 50%;
    }
    
    .popup-bandera-chile,
    .popup-bandera-peru {
        width: 35% !important;
        height: 30% !important;
        bottom: 12% !important;
        min-height: 60px;
        border-radius: 8px;
    }
    
    .popup-bandera-chile {
        left: 8% !important;
    }
    
    .popup-bandera-peru {
        right: 8% !important;
    }
    
    /* Mejorar área de toque en móviles */
    .popup-bandera-chile:before,
    .popup-bandera-peru:before {
        border-bottom: 16px solid rgba(255, 255, 255, 0.9);
        border-width: 12px;
    }
    
    /* Efecto de toque más visible */
    .popup-bandera-chile:active,
    .popup-bandera-peru:active {
        background: rgba(255, 255, 255, 0.25) !important;
        transform: scale(0.95) !important;
    }
}

/* Móviles muy pequeños */
@media (max-width: 360px) {
    .popup-bienvenida-container {
        width: 98vw !important;
        height: auto !important;
        min-height: 320px;
        max-height: 75vh !important;
        margin: 5px;
    }
    
    .popup-bienvenida-imagen {
        min-height: 320px;
    }
    
    .popup-bandera-chile,
    .popup-bandera-peru {
        width: 38% !important;
        height: 32% !important;
        bottom: 10% !important;
        min-height: 55px;
    }
    
    .popup-bandera-chile {
        left: 6% !important;
    }
    
    .popup-bandera-peru {
        right: 6% !important;
    }
    
    .popup-bienvenida-close {
        width: 32px !important;
        height: 32px !important;
        top: 8px !important;
        right: 8px !important;
        font-size: 18px !important;
    }
}

/* Modo landscape en móviles - Mejorado */
@media (max-height: 500px) and (orientation: landscape) and (max-width: 768px) {
    .popup-bienvenida-container {
        width: 80vw !important;
        height: 85vh !important;
        max-height: 85vh !important;
        aspect-ratio: auto;
    }
    
    .popup-bienvenida-imagen {
        height: 100%;
        min-height: auto;
    }
    
    .popup-bandera-chile,
    .popup-bandera-peru {
        width: 25% !important;
        height: 30% !important;
        bottom: 20% !important;
    }
    
    .popup-bandera-chile {
        left: 15% !important;
    }
    
    .popup-bandera-peru {
        right: 15% !important;
    }
}

/* Mejorar feedback táctil para móviles */
.popup-bandera-chile.touching,
.popup-bandera-peru.touching {
    background: rgba(255, 255, 255, 0.2) !important;
    transform: scale(0.95) !important;
    transition: all 0.1s ease !important;
}

.popup-bandera-chile.clicked,
.popup-bandera-peru.clicked {
    background: rgba(255, 255, 255, 0.3) !important;
    transform: scale(1.05) !important;
    transition: all 0.2s ease !important;
}

/* Prevenir selección de texto en móviles */
.popup-bienvenida-container * {
    -webkit-user-select: none;
    -moz-user-select: none;
    -ms-user-select: none;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
}

/* Mejoras para dispositivos con notch */
@supports (padding: max(0px)) {
    .popup-bienvenida-overlay {
        padding-top: max(env(safe-area-inset-top), 20px);
        padding-bottom: max(env(safe-area-inset-bottom), 20px);
        padding-left: max(env(safe-area-inset-left), 10px);
        padding-right: max(env(safe-area-inset-right), 10px);
    }
}

/* Animaciones adicionales */
@keyframes pulseFlag {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.05);
    }
}

.popup-bandera-chile:active,
.popup-bandera-peru:active {
    animation: pulseFlag 0.3s ease;
}

/* Prevenir overflow en móviles */
body.popup-abierto {
    overflow: hidden !important;
    position: fixed !important;
    width: 100% !important;
    height: 100vh !important;
}

/* Ocultar en dispositivos muy pequeños si está configurado */
.popup-bienvenida-overlay[data-mostrar-movil="0"] {
    display: none;
}

@media (max-width: 480px) {
    .popup-bienvenida-overlay[data-mostrar-movil="0"] {
        display: none !important;
    }
}

/* Clase específica para móviles aplicada por JavaScript */
.popup-bienvenida-container.mobile-popup {
    width: 95vw !important;
    height: auto !important;
    min-height: 350px;
    max-height: 80vh !important;
    aspect-ratio: 1/1;
    border-radius: 12px;
}

.popup-bienvenida-container.mobile-popup .popup-bienvenida-imagen {
    min-height: 350px;
    border-radius: 12px;
}

/* Asegurar que las media queries tengan prioridad sobre estilos inline */
@media (max-width: 480px) {
    .popup-bienvenida-container {
        width: 95vw !important;
        height: auto !important;
        min-height: 350px !important;
        max-height: 80vh !important;
    }
}

@media (max-width: 360px) {
    .popup-bienvenida-container {
        width: 98vw !important;
        min-height: 320px !important;
        max-height: 75vh !important;
    }
}
