/* ============================================================================
   🤖 AI TRANSLATOR — Estilos del botón flotante, barra de progreso y toasts
   ============================================================================ */

/* ========== BOTÓN FLOTANTE "Traducir Oráculo" ========== */
.ai-translator-btn {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 99990;
    display: none;
    align-items: center;
    gap: 10px;
    padding: 14px 22px;
    border: none;
    border-radius: 50px;
    background: linear-gradient(135deg, #6d28d9 0%, #2563eb 50%, #06b6d4 100%);
    color: #ffffff;
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    font-size: 0.95rem;
    font-weight: 700;
    letter-spacing: 0.3px;
    cursor: pointer;
    box-shadow:
        0 10px 30px rgba(109, 40, 217, 0.45),
        0 0 0 1px rgba(255, 255, 255, 0.1) inset,
        0 0 24px rgba(6, 182, 212, 0.3);
    opacity: 0;
    transform: translateY(20px) scale(0.9);
    transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.3s ease;
    -webkit-tap-highlight-color: transparent;
}

.ai-translator-btn--visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.ai-translator-btn:hover {
    transform: translateY(-2px) scale(1.03);
    box-shadow:
        0 14px 40px rgba(109, 40, 217, 0.6),
        0 0 0 1px rgba(255, 255, 255, 0.2) inset,
        0 0 36px rgba(6, 182, 212, 0.5);
}

.ai-translator-btn:active {
    transform: translateY(0) scale(0.98);
}

.ai-translator-btn__icon {
    font-size: 1.3rem;
    display: inline-flex;
    align-items: center;
    line-height: 1;
    filter: drop-shadow(0 0 6px rgba(6, 182, 212, 0.7));
    animation: aiTranslatorIconSpin 6s linear infinite;
}

@keyframes aiTranslatorIconSpin {
    0%   { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.ai-translator-btn__label {
    line-height: 1;
    white-space: nowrap;
}

.ai-translator-btn__pulse {
    position: absolute;
    top: 50%;
    right: 16px;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: #fff;
    transform: translateY(-50%);
    box-shadow: 0 0 8px #fff, 0 0 16px rgba(255, 255, 255, 0.8);
    animation: aiTranslatorPulse 1.6s ease-in-out infinite;
    pointer-events: none;
}

@keyframes aiTranslatorPulse {
    0%, 100% { opacity: 0.4; transform: translateY(-50%) scale(0.8); }
    50%      { opacity: 1;   transform: translateY(-50%) scale(1.3); }
}

/* ========== BARRA DE PROGRESO MODAL ========== */
.ai-translator-progress {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) scale(0.9);
    z-index: 99999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 24px 28px;
    border-radius: 18px;
    background: linear-gradient(135deg, rgba(15, 7, 30, 0.97) 0%, rgba(25, 14, 50, 0.97) 100%);
    border: 1px solid rgba(124, 58, 237, 0.4);
    box-shadow:
        0 20px 60px rgba(0, 0, 0, 0.6),
        0 0 40px rgba(124, 58, 237, 0.3),
        0 0 0 1px rgba(255, 255, 255, 0.05) inset;
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    min-width: 320px;
    max-width: 90vw;
    opacity: 0;
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.ai-translator-progress--visible {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1);
}

.ai-translator-progress__inner {
    display: flex;
    align-items: center;
    gap: 18px;
    width: 100%;
}

.ai-translator-progress__icon {
    font-size: 2.4rem;
    line-height: 1;
    animation: aiRobotBob 1.8s ease-in-out infinite;
    filter: drop-shadow(0 0 10px rgba(124, 58, 237, 0.8));
}

@keyframes aiRobotBob {
    0%, 100% { transform: translateY(0) rotate(-3deg); }
    50%      { transform: translateY(-6px) rotate(3deg); }
}

.ai-translator-progress__content {
    flex: 1;
    min-width: 0;
}

.ai-translator-progress__title {
    font-family: 'Cinzel', 'Inter', serif;
    font-size: 0.92rem;
    font-weight: 600;
    color: #f0b429;
    margin-bottom: 8px;
    line-height: 1.3;
    text-shadow: 0 0 12px rgba(240, 180, 41, 0.4);
}

.ai-translator-progress__bar {
    height: 6px;
    background: rgba(255, 255, 255, 0.06);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 4px;
    border: 1px solid rgba(255, 255, 255, 0.04);
}

.ai-translator-progress__fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, #6d28d9 0%, #2563eb 50%, #06b6d4 100%);
    border-radius: 4px;
    transition: width 0.4s ease;
    box-shadow: 0 0 12px rgba(6, 182, 212, 0.6);
    position: relative;
    overflow: hidden;
}

.ai-translator-progress__fill::after {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.4) 50%, transparent 100%);
    animation: aiProgressShine 1.5s linear infinite;
}

@keyframes aiProgressShine {
    0%   { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

.ai-translator-progress__pct {
    font-family: 'Inter', sans-serif;
    font-size: 0.78rem;
    font-weight: 700;
    color: rgba(232, 228, 245, 0.7);
    text-align: right;
    letter-spacing: 0.5px;
}

/* ========== CONTENEDOR DE TOASTS ========== */
.ai-translator-toasts {
    position: fixed;
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 99998;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
    max-width: 92vw;
}

.ai-translator-toast {
    padding: 12px 18px;
    border-radius: 12px;
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 0.88rem;
    font-weight: 600;
    color: #ffffff;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
    opacity: 0;
    transform: translateY(-20px) scale(0.95);
    transition: opacity 0.4s ease, transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
    pointer-events: auto;
    max-width: 480px;
    line-height: 1.4;
    word-wrap: break-word;
    border: 1px solid rgba(255, 255, 255, 0.1);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
}

.ai-translator-toast--in {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.ai-translator-toast--ok {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.95) 0%, rgba(6, 182, 212, 0.95) 100%);
    box-shadow: 0 10px 30px rgba(16, 185, 129, 0.4), 0 0 20px rgba(6, 182, 212, 0.3);
}

.ai-translator-toast--warn {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.95) 0%, rgba(240, 180, 41, 0.95) 100%);
    color: #1a0f00;
    box-shadow: 0 10px 30px rgba(245, 158, 11, 0.4);
}

.ai-translator-toast--err {
    background: linear-gradient(135deg, rgba(239, 68, 68, 0.95) 0%, rgba(220, 38, 38, 0.95) 100%);
    box-shadow: 0 10px 30px rgba(239, 68, 68, 0.4);
}

/* ========== RESPONSIVE (móvil) ========== */
@media (max-width: 640px) {
    .ai-translator-btn {
        bottom: 16px;
        right: 16px;
        padding: 12px 18px;
        font-size: 0.88rem;
    }
    .ai-translator-btn__icon {
        font-size: 1.15rem;
    }
    .ai-translator-progress {
        min-width: unset;
        width: calc(100vw - 32px);
        padding: 18px 20px;
    }
    .ai-translator-progress__icon {
        font-size: 2rem;
    }
    .ai-translator-progress__title {
        font-size: 0.85rem;
    }
    .ai-translator-toasts {
        top: 12px;
        max-width: calc(100vw - 24px);
    }
    .ai-translator-toast {
        font-size: 0.82rem;
        padding: 10px 14px;
    }
}

/* ========== RTL (árabe) ========== */
html[dir="rtl"] .ai-translator-btn {
    right: auto;
    left: 24px;
}

html[dir="rtl"] .ai-translator-btn__pulse {
    right: auto;
    left: 16px;
}

@media (max-width: 640px) {
    html[dir="rtl"] .ai-translator-btn {
        left: 16px;
    }
}

/* ========== EVITAR INTERFERENCIA CON OTROS BOTONES FLOTANTES ========== */
/* Si hay un nav floating o panel premium, subir un poco el botón */
body.has-nav-floating .ai-translator-btn {
    bottom: 84px;
}

/* ============================================================================
   🏛️ BOTÓN «LENGUAJE» — REDISEÑO v9.35 · COHERENCIA CON LA IDENTIDAD VISUAL
   ============================================================================
   PETICIÓN DEL PROPIETARIO
   «ocupo que el botón del lado izquierdo que dice Lenguaje tenga mas diseño y
    estética, necesito coherencia, ocupo que el botón sea igual con el diseño
    de esta aplicación»

   EL PROBLEMA: DOS BOTONES HERMANOS QUE NO SE PARECÍAN EN NADA
   En la misma pantalla, a la misma altura, conviven dos botones flotantes:

     · abajo-DERECHA → «✦ VER ORÁCULOS»  (.snm-launcher)
         púrpura profundo translúcido · borde DORADO · texto DORADO
         tipografía Cinzel en versalitas · medallón dorado circular
     · abajo-IZQUIERDA → «🏳️ Lenguaje»  (este botón)
         degradado AZUL→CIAN plano · texto blanco · Inter minúsculas
         bandera blanca (que además significa «rendición»)

   Parecían de dos aplicaciones distintas. El de la izquierda rompía la paleta
   cósmica dorada/violeta que define al Supra Oráculo.

   LA SOLUCIÓN: NO INVENTAR UN ESTILO NUEVO, SINO ADOPTAR EL EXISTENTE
   Se replica el lenguaje visual de .snm-launcher (oracle-navigator.css:50)
   para que ambos se lean como una PAREJA simétrica:
     · mismo fondo púrpura translúcido con desenfoque
     · mismo borde y color dorado #f0b429
     · misma tipografía Cinzel, 900, versalitas, espaciado de letras
     · mismo medallón circular dorado para el icono
     · misma píldora violeta a la derecha (allí «1/20», aquí «ES»)
     · mismo radio, sombras y curva de animación

   DIFERENCIAS DELIBERADAS (no es un clon: es un hermano)
     · Icono 🌐 en vez de 🏳️: un globo dice «idiomas»; una bandera blanca dice
       «me rindo». El significado importa tanto como el color.
     · Sin «wiggle»: el de Oráculos vibra para reclamar atención porque es la
       acción principal. Éste es una utilidad; que también vibrase generaría
       ruido visual y competencia entre ambos.
     · Su pulso de brillo es más lento y sutil, para ceder protagonismo.
   ============================================================================ */
.ai-translator-btn--left {
    /* ── Posición: espejo exacto del botón de Oráculos (bottom:26px) ─────── */
    right: auto !important;
    left: 26px !important;
    bottom: 26px;
    z-index: 9990;

    /* ── Superficie: púrpura profundo translúcido, no azul plano ────────── */
    gap: 9px;
    padding: 11px 14px 11px 12px;
    border-radius: 50px;
    border: 2px solid rgba(240, 180, 41, 0.75);
    background: linear-gradient(135deg, rgba(28, 20, 65, 0.98), rgba(14, 10, 38, 0.98));
    backdrop-filter: blur(20px) saturate(140%);
    -webkit-backdrop-filter: blur(20px) saturate(140%);

    /* ── Tipografía ceremonial, igual que su hermano ─────────────────────── */
    color: #f0b429;
    font-family: 'Cinzel', 'Inter', serif;
    font-size: 0.9rem;
    font-weight: 900;
    letter-spacing: 1px;
    text-transform: uppercase;

    box-shadow:
        0 18px 46px rgba(0, 0, 0, 0.7),
        0 0 40px rgba(240, 180, 41, 0.35);
    /* Latido lento: presente, pero sin disputarle la atención al principal. */
    animation: aiLangGlow 3.4s ease-in-out infinite;
}

/* El estado visible reutiliza la transición elástica del bloque base. */
.ai-translator-btn--left.ai-translator-btn--visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}

.ai-translator-btn--left:hover {
    transform: translateY(-4px) scale(1.04);
    border-color: rgba(240, 180, 41, 0.95);
    box-shadow:
        0 20px 46px rgba(0, 0, 0, 0.7),
        0 0 44px rgba(240, 180, 41, 0.55);
    animation: none;              /* al enfocarlo, se calma */
}

.ai-translator-btn--left:active {
    transform: translateY(-2px) scale(1.01);
}

/* Accesibilidad: foco por teclado claramente visible sobre fondo oscuro. */
.ai-translator-btn--left:focus-visible {
    outline: 3px solid rgba(240, 180, 41, 0.9);
    outline-offset: 3px;
}

/* ── Medallón dorado del icono (idéntico al de «Ver Oráculos») ──────────── */
.ai-translator-btn--left .ai-translator-btn__icon {
    width: 32px;
    height: 32px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: linear-gradient(135deg, #f0b429, #e5a820);
    color: #0a0820;
    font-size: 1rem;
    font-weight: 900;
    box-shadow: 0 0 16px rgba(240, 180, 41, 0.8);
    filter: none;                 /* anula el resplandor cian heredado */
    animation: aiLangOrbit 14s linear infinite;
}

.ai-translator-btn--left .ai-translator-btn__label {
    text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
}

/* ── Píldora del idioma activo: gemela del contador «1/20» ──────────────── */
.ai-translator-btn--left .ai-translator-btn__code {
    padding: 4px 10px;
    border-radius: 12px;
    background: rgba(124, 106, 239, 0.32);
    border: 1.5px solid rgba(124, 106, 239, 0.6);
    color: #cfc6ff;
    font-family: 'Cinzel', serif;
    font-size: 0.78rem;
    font-weight: 700;
    letter-spacing: 1px;
    line-height: 1;
    text-transform: uppercase;
}

/* El punto blanco parpadeante del diseño antiguo sobra: la píldora del idioma
   ya comunica el estado, y dos elementos pulsando a la vez era ruido. */
.ai-translator-btn--left .ai-translator-btn__pulse {
    display: none;
}

@keyframes aiLangGlow {
    0%, 100% {
        box-shadow:
            0 18px 46px rgba(0, 0, 0, 0.7),
            0 0 30px rgba(240, 180, 41, 0.3);
    }
    50% {
        box-shadow:
            0 18px 46px rgba(0, 0, 0, 0.7),
            0 0 46px rgba(240, 180, 41, 0.55),
            0 0 76px rgba(124, 106, 239, 0.28);
    }
}

@keyframes aiLangOrbit {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* ── Móvil: mismas medidas que su hermano para que sigan emparejados ────── */
@media (max-width: 768px) {
    .ai-translator-btn--left {
        left: 12px !important;
        bottom: 16px;
        padding: 9px 11px 9px 10px;
        font-size: 0.82rem;
        letter-spacing: 0.8px;
        gap: 8px;
    }
    .ai-translator-btn--left .ai-translator-btn__icon {
        width: 28px;
        height: 28px;
        font-size: 0.9rem;
    }
    .ai-translator-btn--left .ai-translator-btn__label {
        font-size: 0.82rem;
    }
    .ai-translator-btn--left .ai-translator-btn__code {
        padding: 3px 8px;
        font-size: 0.72rem;
    }
}

/* ── Pantallas estrechas: evitar el choque con «VER ORÁCULOS» ────────────
   VERIFICADO CON CAPTURA, NO SUPUESTO. A 390 px (iPhone) los dos botones se
   solapaban: «VER ORÁCULOS» tapaba la mitad derecha del de idioma y su texto
   quedaba cortado en «LENG».

   El punto de corte estaba mal calibrado: se fijó en 380 px, pero el móvil de
   referencia mide 390, así que la regla nunca llegaba a aplicarse.

   Medidas reales a lo ancho:
     «VER ORÁCULOS» ≈ 220 px  ·  «LENGUAJE» completo ≈ 190 px  →  410 px > 390 ✗
     «VER ORÁCULOS» ≈ 220 px  ·  medallón + idioma  ≈  94 px  →  314 px < 390 ✓

   Por debajo de 480 px se retira SÓLO la palabra. Se conservan el medallón
   dorado y la píldora del idioma, que es justo lo que identifica al botón y
   lo que informa de un vistazo. El nombre completo sigue disponible para los
   lectores de pantalla mediante aria-label. */
@media (max-width: 480px) {
    .ai-translator-btn--left .ai-translator-btn__label {
        display: none;
    }
    .ai-translator-btn--left {
        padding: 9px 10px;
        gap: 7px;
        /* Tope duro de anchura: por mucho que crezca la etiqueta del idioma
           (中文, 한국, हिं…), el botón no puede invadir el carril del otro. */
        max-width: 40vw;
    }
}

/* A partir de aquí ya no basta con encoger: hay que SEPARAR en vertical.
   Tras aplicar el modo compacto, la captura a 390 px mostró que el botón de
   idioma seguía rozando el halo dorado de «VER ORÁCULOS». Los dos elementos
   compartían la misma línea de base (bottom:16px) y sus resplandores se tocan
   aunque las cajas no lleguen a cruzarse.

   Se eleva el botón de idioma a su propio renglón. Es la solución honesta:
   dos elementos flotantes en una pantalla de 390 px no caben cómodamente en
   la misma fila, y apretarlos más sacrificaría la superficie táctil mínima. */
@media (max-width: 480px) {
    .ai-translator-btn--left {
        bottom: 78px;
    }
}

/* ── RTL (árabe): el par se refleja completo, sin solaparse ─────────────── */
html[dir="rtl"] .ai-translator-btn--left {
    left: auto !important;
    right: 26px !important;
}
@media (max-width: 768px) {
    html[dir="rtl"] .ai-translator-btn--left {
        right: 12px !important;
    }
}

/* ── Respeto por quien pide menos movimiento ────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
    .ai-translator-btn--left,
    .ai-translator-btn--left .ai-translator-btn__icon {
        animation: none !important;
    }
}

/* ========== SELECTOR DE IDIOMAS (DROPDOWN DE BANDERAS) ========== */
.ai-translator-langpicker {
    position: fixed;
    z-index: 99995;
    display: none;
    width: 220px;
    max-height: 60vh;
    overflow-y: auto;
    padding: 8px;
    border-radius: 16px;
    background: linear-gradient(160deg, rgba(20, 16, 48, 0.98) 0%, rgba(12, 10, 32, 0.98) 100%);
    border: 1px solid rgba(124, 106, 239, 0.35);
    box-shadow: 0 16px 50px rgba(0, 0, 0, 0.6), 0 0 30px rgba(109, 40, 217, 0.3);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    opacity: 0;
    transform: translateY(12px) scale(0.96);
    transform-origin: bottom left;
    transition: opacity 0.22s ease, transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.ai-translator-langpicker--visible {
    opacity: 1;
    transform: translateY(0) scale(1);
}
.ai-translator-langopt {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 11px 14px;
    margin: 2px 0;
    border: none;
    border-radius: 10px;
    background: transparent;
    color: #e9e6ff;
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 0.95rem;
    font-weight: 600;
    text-align: left;
    cursor: pointer;
    transition: background 0.18s ease, transform 0.12s ease;
}
.ai-translator-langopt:hover {
    background: rgba(124, 106, 239, 0.22);
    transform: translateX(3px);
}
.ai-translator-langopt.active {
    background: linear-gradient(135deg, rgba(109, 40, 217, 0.45), rgba(37, 99, 235, 0.35));
    box-shadow: inset 0 0 0 1px rgba(240, 180, 41, 0.4);
}
.ai-translator-langopt__flag {
    font-size: 1.3rem;
    line-height: 1;
}
.ai-translator-langopt__name {
    line-height: 1;
}
/* Scrollbar fino */
.ai-translator-langpicker::-webkit-scrollbar { width: 6px; }
.ai-translator-langpicker::-webkit-scrollbar-thumb {
    background: rgba(124, 106, 239, 0.5);
    border-radius: 3px;
}
html[dir="rtl"] .ai-translator-langpicker { transform-origin: bottom right; }
html[dir="rtl"] .ai-translator-langopt { text-align: right; }
html[dir="rtl"] .ai-translator-langopt:hover { transform: translateX(-3px); }

@media (max-width: 640px) {
    body.has-nav-floating .ai-translator-btn {
        bottom: 76px;
    }
}
