/* Estilos para selector de idiomas */
#language-selector {
    position: relative;
    display: flex;
    align-items: center;
    z-index: 2000; /* Asegurar que esté por encima de todo */
}

.lang-dropdown {
    position: relative;
}

.lang-current {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.1);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    padding: 8px 12px;
    color: white;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 14px;
    font-weight: 500;
    height: 36px;
    min-width: 80px;
    -webkit-tap-highlight-color: transparent; /* Eliminar highlight en iOS */
    touch-action: manipulation; /* Mejor soporte touch */
}

.lang-current:hover,
.lang-current:active {
    background: rgba(255, 255, 255, 0.2);
    border-color: rgba(255, 255, 255, 0.3);
}

/* Banderas con CSS como fallback y soporte para imágenes reales */
.flag-icon {
    width: 20px;
    height: 15px;
    border-radius: 2px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    overflow: hidden;
    position: relative;
    flex-shrink: 0;
}

/* Banderas CSS */
.flag-es {
    background: linear-gradient(to bottom, #c60b1e 33%, #ffc400 33%, #ffc400 66%, #c60b1e 66%);
}

.flag-gb {
    background: 
        linear-gradient(45deg, transparent 40%, #c8102e 40%, #c8102e 60%, transparent 60%),
        linear-gradient(-45deg, transparent 40%, #c8102e 40%, #c8102e 60%, transparent 60%),
        linear-gradient(to bottom, #012169 33%, #ffffff 33%, #ffffff 66%, #012169 66%);
}

.flag-de {
    background: linear-gradient(to bottom, #000000 33%, #dd0000 33%, #dd0000 66%, #ffce00 66%);
}

.flag-fr {
    background: linear-gradient(to right, #0055a4 33%, #ffffff 33%, #ffffff 66%, #ef4135 66%);
}

.flag-nl {
    background: linear-gradient(to bottom, #c8102e 33%, #ffffff 33%, #ffffff 66%, #003da5 66%);
}

/* Imágenes de banderas reales tendrán prioridad */
.flag-icon img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.lang-current svg {
    transition: transform 0.3s ease;
    flex-shrink: 0;
}

.lang-dropdown.open .lang-current svg {
    transform: rotate(180deg);
}

.lang-options {
    position: absolute;
    top: 100%;
    right: 0;
    background: white;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    min-width: 140px;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 2001; /* Más alto para móviles */
    overflow: hidden;
    margin-top: 8px;
}

.lang-options.open {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.lang-option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: #333;
    cursor: pointer;
    transition: background-color 0.2s ease;
    font-size: 14px;
    font-weight: 500;
    position: relative;
    -webkit-tap-highlight-color: transparent; /* Eliminar highlight en iOS */
    touch-action: manipulation; /* Mejor soporte touch */
}

.lang-option:hover,
.lang-option:active {
    background-color: #f5f5f5;
}

.lang-option.active {
    background-color: #e3f2fd;
    color: #1976d2;
    font-weight: 600;
}

.lang-option.active::after {
    content: '✓';
    position: absolute;
    right: 12px;
    color: #1976d2;
    font-weight: bold;
}

.lang-option:first-child {
    border-radius: 8px 8px 0 0;
}

.lang-option:last-child {
    border-radius: 0 0 8px 8px;
}

.lang-option .flag-icon {
    width: 22px;
    height: 16px;
}

/* Ajustes para navbar específicos */
.navbar .nav-links #language-selector {
    margin-left: 10px;
}

/* Responsive */
@media (max-width: 992px) {
    .navbar .nav-links #language-selector {
        margin: 10px 0;
        justify-content: center;
    }
    
    .lang-current {
        padding: 10px 14px;
        font-size: 15px;
        height: 40px;
        min-width: 100px;
    }
    
    .lang-options {
        min-width: 120px;
        position: fixed;
        right: 20px;
        left: auto;
        z-index: 9999; /* Más alto en tablets */
    }
    
    .lang-option {
        padding: 14px 18px;
        font-size: 15px;
    }
}

@media (max-width: 768px) {
    #language-selector {
        z-index: 10000; /* Máximo z-index en móviles */
    }
    
    .lang-current {
        padding: 8px 12px;
        font-size: 13px;
        height: 36px;
        min-width: 90px;
        /* Mejorar área de toque */
        min-height: 44px; /* Tamaño mínimo recomendado para touch */
    }
    
    .flag-icon {
        width: 18px;
        height: 13px;
    }
    
    .lang-option .flag-icon {
        width: 20px;
        height: 14px;
    }
    
    .lang-options {
        min-width: 110px;
        position: fixed; /* Usar fixed en móviles */
        right: 10px;
        top: auto;
        z-index: 10001; /* Asegurar que esté encima de todo */
        box-shadow: 0 8px 30px rgba(0,0,0,0.2); /* Sombra más prominente */
    }
    
    .lang-option {
        padding: 12px 16px;
        font-size: 13px;
        min-height: 44px; /* Área de toque más grande */
        display: flex;
        align-items: center;
    }
    
    /* Asegurar que no interfiera con el menú móvil */
    .nav-links.active #language-selector {
        position: relative;
        z-index: 10002;
    }
}

/* Animación de carga de idioma */
.language-loading {
    opacity: 0.7;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.language-loaded {
    opacity: 1;
    pointer-events: auto;
}
