/* ============================================================
   PORTAL CONTAINER
   ============================================================ */
#portal-container {
    position: relative;
    z-index: 10;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    transition: opacity 0.4s ease, transform 0.4s ease;
}

#portal-container.fade-out {
    opacity: 0;
    transform: scale(0.97);
    pointer-events: none;
}

/* Título principal */
.portal-title {
    font-size: clamp(1.8rem, 5vw, 3rem);
    font-weight: 300;
    letter-spacing: 0.05em;
    color: #ffffff;
    text-align: center;
    margin-bottom: 40px;
    text-shadow: 0 0 40px rgba(94, 129, 172, 0.6);
}

/* ============================================================
   PANEL GLASSMORPHISM
   ============================================================ */
.portal-panel {
    background: var(--portal-panel-bg);
    border: 1px solid var(--portal-border);
    border-radius: 16px;
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    width: 100%;
    max-width: 740px;
    box-shadow:
        0 0 0 1px rgba(255,255,255,0.04) inset,
        0 20px 60px rgba(0, 0, 0, 0.5),
        0 0 80px rgba(94, 129, 172, 0.08);
    overflow: hidden;
    position: relative;
}

/* Puntos de esquina del panel */
.portal-panel::before,
.portal-panel::after {
    content: '';
    position: absolute;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: rgba(94, 129, 172, 0.6);
    box-shadow: 0 0 6px rgba(94, 129, 172, 0.8);
}
.portal-panel::before { top: 12px; left: 12px; }
.portal-panel::after  { top: 12px; right: 12px; }

/* Header del panel */
.panel-header {
    padding: 14px 24px;
    border-bottom: 1px solid rgba(80, 120, 200, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
    position: relative;
}

.panel-label {
    font-size: 0.7rem;
    letter-spacing: 0.2em;
    color: rgba(160, 185, 220, 0.7);
    font-weight: 500;
}

/* ============================================================
   SELECTOR DE IDIOMA — lang-switcher
   Estética dark/tech: pill glassmorphism con banderas emoji
   ============================================================ */
.lang-switcher {
    display: flex;
    align-items: center;
    gap: 2px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(94, 129, 172, 0.25);
    border-radius: 20px;
    padding: 3px;
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
}

.lang-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 28px;
    height: 28px;
    border-radius: 50%;
    border: 1.5px solid transparent;
    background: transparent;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1;
    padding: 0;
    transition:
        background 0.2s ease,
        border-color 0.2s ease,
        transform 0.15s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    /* Sobreescribir estilos globales de button */
    width: 28px !important;
    min-height: unset !important;
    color: inherit !important;
}

.lang-btn:hover {
    background: rgba(94, 129, 172, 0.18);
    transform: scale(1.12);
}

.lang-btn:active {
    transform: scale(0.95);
}

/* Estado activo: borde accent + fondo sutil */
.lang-btn--active {
    background: rgba(94, 129, 172, 0.22) !important;
    border-color: rgba(94, 129, 172, 0.7) !important;
    box-shadow: 0 0 8px rgba(94, 129, 172, 0.3);
}

/* Responsive: en móvil pequeño, el switcher se coloca debajo del label */
@media (max-width: 480px) {
    .panel-header {
        flex-direction: column;
        gap: 8px;
        padding: 12px 16px;
    }

    .lang-switcher {
        position: static;
        transform: none;
    }
}

/* Body del panel */
.panel-body {
    padding: 30px 30px 24px;
}

.panel-subtitle {
    font-size: 1.4rem;
    font-weight: 700;
    letter-spacing: 0.08em;
    color: #ffffff;
    text-align: center;
    margin-bottom: 24px;
}

/* ============================================================
   GRID DE TARJETAS
   ============================================================ */
.cards-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

/* ============================================================
   TARJETA BASE
   ============================================================ */
.mode-card {
    border-radius: 14px;
    padding: 28px 20px 24px;
    cursor: pointer;
    position: relative;
    overflow: hidden;
    transition: transform 0.25s ease, box-shadow 0.25s ease;
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
    gap: 8px;
    user-select: none;
}

.mode-card:hover {
    transform: translateY(-4px) scale(1.02);
}

/* ============================================================
   TARJETA MANUAL (blanca/clara)
   ============================================================ */
.card-manual {
    background: var(--card-manual-bg);
    box-shadow: 0 8px 30px rgba(0,0,0,0.3);
}

.card-manual:hover {
    box-shadow: 0 16px 40px rgba(0,0,0,0.4), 0 0 20px rgba(94, 129, 172, 0.3);
}

.card-manual .card-icon { color: #2c3e50; }
.card-manual .card-mode-label { color: #555; }
.card-manual .card-title { color: #1a1a2e; }
.card-manual .card-desc { color: #555; }

/* ============================================================
   TARJETA IA (morada/gradiente)
   ============================================================ */
.card-ia {
    background: var(--card-ia-bg);
    box-shadow: 0 8px 30px rgba(139, 92, 246, 0.3);
}

.card-ia:hover {
    box-shadow: 0 16px 40px rgba(139, 92, 246, 0.5), 0 0 30px rgba(167, 139, 250, 0.3);
}

.card-ia .card-icon { color: rgba(255,255,255,0.9); }
.card-ia .card-mode-label { color: rgba(255,255,255,0.75); }
.card-ia .card-title { color: #ffffff; }
.card-ia .card-desc { color: rgba(255,255,255,0.8); }

/* Sparkles de la tarjeta IA */
.card-sparkles {
    position: absolute;
    inset: 0;
    pointer-events: none;
}

.sparkle {
    position: absolute;
    font-size: 1rem;
    color: rgba(255,255,255,0.6);
    animation: sparkleAnim 2.5s ease-in-out infinite;
}

.s1 { top: 12px; left: 16px; animation-delay: 0s; font-size: 0.8rem; }
.s2 { top: 10px; right: 20px; animation-delay: 0.8s; font-size: 1.2rem; }
.s3 { bottom: 20px; right: 14px; animation-delay: 1.5s; font-size: 0.7rem; }

@keyframes sparkleAnim {
    0%, 100% { opacity: 0.3; transform: scale(1); }
    50%       { opacity: 1;   transform: scale(1.3); }
}

/* Badge "Próximamente" */
.card-badge {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.35);
    color: rgba(255,255,255,0.85);
    font-size: 0.55rem;
    letter-spacing: 0.15em;
    padding: 3px 10px;
    border-radius: 20px;
    border: 1px solid rgba(255,255,255,0.2);
    white-space: nowrap;
}

/* ============================================================
   ICONOS DE TARJETA
   ============================================================ */
.card-icon svg {
    width: 48px;
    height: 48px;
}

.card-mode-label {
    font-size: 0.65rem;
    letter-spacing: 0.15em;
    font-weight: 600;
    margin-top: 4px;
}

.card-title {
    font-size: 1.6rem;
    font-weight: 800;
    letter-spacing: 0.05em;
    line-height: 1;
}

.card-desc {
    font-size: 0.8rem;
    line-height: 1.4;
    max-width: 160px;
}

/* ============================================================
   FOOTER DEL PANEL
   ============================================================ */
.panel-footer {
    padding: 10px 20px;
    border-top: 1px solid rgba(80, 120, 200, 0.15);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.65rem;
    color: rgba(140, 170, 210, 0.6);
    font-family: 'Courier New', monospace;
    letter-spacing: 0.05em;
}

.footer-value { color: rgba(140, 200, 255, 0.8); }
.footer-sep   { color: rgba(140, 170, 210, 0.4); }



 /* ============================================================
   SEMÁFORO DE CONEXIÓN (online / offline)
   ============================================================ */

/* 1. Estilos base del punto (siempre presentes) */
#status-dot {
    display: inline-block;
    width: 10px;
    height: 10px;
    border-radius: 50%;
    margin-right: 6px;
    vertical-align: middle;
    transition: all 0.3s ease; /* Transición suave para color y sombra */
}

/* 2. Estilos del texto */
#status-text {
    font-size: 0.75rem;
    font-family: 'Courier New', monospace;
    letter-spacing: 0.05em;
    vertical-align: middle;
    transition: color 0.3s ease;
}

/* 3. CLASES DE ESTADO (Lo que el JS pone y quita) */

/* ONLINE: Verde con animación y sombra */
.dot-online { 
    background-color: #2ecc71; 
    box-shadow: 0 0 6px rgba(46, 204, 113, 0.7); 
    animation: pulse 2s infinite; 
}

/* OFFLINE: Rojo sin animación */
.dot-offline { 
    background-color: #e74c3c; 
    box-shadow: 0 0 6px rgba(231, 76, 60, 0.7); 
    animation: none; 
}

.text-online  { color: #2ecc71; }
.text-offline { color: #e74c3c; }

/* Animación */
@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.3; }
}

/* ============================================================
   NOTIFICACIONES TOAST
   ============================================================ */
#notification-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}

#notification-container .toast {
    pointer-events: auto;
}

.footer-icons {
    margin-left: auto;
    display: flex;
    gap: 10px;
    font-size: 0.85rem;
    opacity: 0.5;
}

/* ============================================================
   ESTRELLA DECORATIVA ESQUINA
   ============================================================ */
.corner-star {
    position: fixed;
    bottom: 30px;
    right: 30px;
    font-size: 2rem;
    color: rgba(94, 129, 172, 0.4);
    animation: rotateStar 8s linear infinite;
    pointer-events: none;
    z-index: 5;
}

@keyframes rotateStar {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* ============================================================
   RESPONSIVE — PORTAL
   ============================================================ */
@media (max-width: 767px) {
    .cards-grid { grid-template-columns: 1fr 1fr; gap: 12px; }
    .card-title { font-size: 1.2rem; }
    .card-desc { font-size: 0.72rem; }
    .card-icon svg { width: 36px; height: 36px; }
}

@media (max-width: 420px) {
    .cards-grid { grid-template-columns: 1fr; }
    .portal-title { font-size: 1.5rem; }
}

/* ============================================================
   BOTÓN PWA — Instalar aplicación
   ─────────────────────────────────────────────────────────────
   Diseño: pill glassmorphism con gradiente azul, icono animado
   y badge "PWA". Posición: esquina inferior derecha.
   Llamativo pero sutil — pulso de atención 3 ciclos al entrar.
   Funcional en PC (beforeinstallprompt) y móvil (iOS/Android).
   ============================================================ */

/* ── Botón principal ── */
.pwa-install-btn {
    position: fixed !important;
    bottom: 28px !important;
    right: 28px !important;
    left: auto !important;
    z-index: 9000;

    /* JS lo muestra con flex cuando procede */
    display: none;
    align-items: center;
    gap: 10px;

    /* Sobreescribir estilos globales de button */
    width: auto !important;
    padding: 12px 20px 12px 16px !important;

    /* Gradiente azul marino → accent — llamativo pero elegante */
    background: linear-gradient(135deg,
        rgba(15, 25, 50, 0.95) 0%,
        rgba(30, 55, 100, 0.92) 50%,
        rgba(20, 40, 80, 0.95) 100%
    ) !important;
    border: 1.5px solid rgba(94, 129, 172, 0.6) !important;
    border-radius: 50px !important; /* pill shape */
    cursor: pointer;
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 0.88rem !important;
    font-weight: 600;
    color: rgba(255, 255, 255, 0.92) !important;
    letter-spacing: 0.02em;
    white-space: nowrap;

    /* Glassmorphism */
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow:
        0 4px 20px rgba(0, 0, 0, 0.45),
        0 0 0 1px rgba(94, 129, 172, 0.15),
        0 0 30px rgba(74, 111, 165, 0.12),
        inset 0 1px 0 rgba(255, 255, 255, 0.08) !important;

    /* Estado inicial: invisible y desplazado hacia abajo */
    opacity: 0;
    transform: translateY(20px);
    will-change: transform, opacity;

    /* Transición base (hover/active) */
    transition:
        background 0.25s ease,
        border-color 0.25s ease,
        box-shadow 0.25s ease,
        transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1);

    /* Área táctil mínima WCAG */
    min-height: 48px !important;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

/* ── Estado visible: animación de entrada + pulso de atención ── */
.pwa-install-btn--visible {
    animation:
        pwaEntrada 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards,
        pwaPulso   2.6s ease-in-out 1.4s 3;
}

/* ── Hover ── */
.pwa-install-btn:hover {
    background: linear-gradient(135deg,
        rgba(20, 38, 75, 0.98) 0%,
        rgba(50, 90, 155, 0.95) 50%,
        rgba(30, 60, 120, 0.98) 100%
    );
    border-color: rgba(122, 163, 212, 0.85);
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.55),
        0 0 0 1px rgba(94, 129, 172, 0.3),
        0 0 40px rgba(74, 111, 165, 0.28),
        inset 0 1px 0 rgba(255, 255, 255, 0.12);
    transform: translateY(-3px);
}

/* ── Active ── */
.pwa-install-btn:active {
    transform: translateY(-1px) scale(0.97);
    transition-duration: 0.1s;
}

/* ── Icono SVG de descarga ── */
.pwa-install-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    flex-shrink: 0;
    color: #7aa3d4;
    transition: color 0.2s, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.pwa-install-icon svg {
    width: 18px;
    height: 18px;
}

/* Animación del icono al hacer hover: pequeño rebote hacia abajo */
.pwa-install-btn:hover .pwa-install-icon {
    color: #a8c8f0;
    transform: translateY(2px);
}

/* ── Etiqueta de texto ── */
.pwa-install-label {
    flex: 1;
    color: rgba(255, 255, 255, 0.9);
    font-size: 0.88rem;
    font-weight: 600;
}

/* ── Badge "PWA" ── */
.pwa-install-badge {
    font-size: 0.6rem;
    font-weight: 800;
    letter-spacing: 0.1em;
    color: #7aa3d4;
    background: rgba(74, 111, 165, 0.2);
    border: 1px solid rgba(74, 111, 165, 0.4);
    border-radius: 4px;
    padding: 2px 6px;
    line-height: 1.5;
    text-transform: uppercase;
    flex-shrink: 0;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
}

.pwa-install-btn:hover .pwa-install-badge {
    background: rgba(74, 111, 165, 0.35);
    color: #c0d8f5;
    border-color: rgba(94, 129, 172, 0.6);
}

/* ── Animaciones ── */
@keyframes pwaEntrada {
    from {
        opacity: 0;
        transform: translateY(20px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes pwaPulso {
    0%, 100% {
        box-shadow:
            0 4px 20px rgba(0, 0, 0, 0.45),
            0 0 0 1px rgba(94, 129, 172, 0.15),
            0 0 30px rgba(74, 111, 165, 0.12);
    }
    50% {
        box-shadow:
            0 4px 20px rgba(0, 0, 0, 0.45),
            0 0 0 4px rgba(74, 111, 165, 0.3),
            0 0 50px rgba(74, 111, 165, 0.35);
    }
}

/* ============================================================
   TOOLTIP iOS — instrucciones "Añadir a pantalla de inicio"
   ============================================================ */
.pwa-ios-tooltip {
    position: fixed;
    bottom: 90px;
    right: 20px;
    z-index: 9001;
    max-width: 290px;
    background: rgba(10, 15, 30, 0.97);
    border: 1.5px solid rgba(94, 129, 172, 0.5);
    border-radius: 16px;
    padding: 14px 16px;
    font-family: 'Inter', system-ui, sans-serif;
    font-size: 0.82rem;
    color: rgba(255, 255, 255, 0.85);
    line-height: 1.55;
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    box-shadow:
        0 8px 32px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(94, 129, 172, 0.1);

    opacity: 0;
    transform: translateY(8px);
    transition: opacity 0.3s ease, transform 0.3s ease;
}

.pwa-ios-tooltip--visible {
    opacity: 1;
    transform: translateY(0);
}

.pwa-ios-tooltip p {
    margin: 0;
    padding-right: 28px; /* espacio para el botón cerrar */
}

.pwa-ios-tooltip strong {
    color: #7aa3d4;
}

.pwa-ios-share-icon {
    display: inline-block;
    font-size: 1rem;
    vertical-align: middle;
    color: #7aa3d4;
}

/* Flecha apuntando al botón (abajo a la derecha) */
.pwa-ios-tooltip-arrow {
    position: absolute;
    bottom: -8px;
    right: 28px;
    width: 14px;
    height: 8px;
    background: rgba(10, 15, 30, 0.97);
    clip-path: polygon(0 0, 100% 0, 50% 100%);
    border-left: 1.5px solid rgba(94, 129, 172, 0.5);
    border-right: 1.5px solid rgba(94, 129, 172, 0.5);
}

/* Botón cerrar del tooltip */
.pwa-ios-tooltip-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 26px;
    height: 26px;
    background: rgba(255, 255, 255, 0.08);
    border: none;
    border-radius: 50%;
    color: rgba(255, 255, 255, 0.6);
    font-size: 0.75rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    transition: background 0.15s, color 0.15s;
    font-family: inherit;
    line-height: 1;
    width: 26px !important;
}

.pwa-ios-tooltip-close:hover {
    background: rgba(255, 255, 255, 0.18);
    color: rgba(255, 255, 255, 0.95);
}

/* ── Responsive: en móvil el botón se centra en la parte inferior ── */
@media (max-width: 480px) {
    .pwa-install-btn {
        right: auto;
        left: 50%;
        bottom: 20px;
        /* Estado inicial centrado */
        transform: translateX(-50%) translateY(20px);
    }

    /* Cuando es visible: centrado sin desplazamiento vertical */
    .pwa-install-btn--visible {
        animation:
            pwaEntradaMobil 0.5s cubic-bezier(0.34, 1.56, 0.64, 1) forwards,
            pwaPulsoMobil   2.6s ease-in-out 1.4s 3;
    }

    .pwa-install-btn:hover {
        transform: translateX(-50%) translateY(-3px);
    }

    .pwa-install-btn:active {
        transform: translateX(-50%) scale(0.97);
    }

    @keyframes pwaEntradaMobil {
        from {
            opacity: 0;
            transform: translateX(-50%) translateY(20px) scale(0.95);
        }
        to {
            opacity: 1;
            transform: translateX(-50%) translateY(0) scale(1);
        }
    }

    @keyframes pwaPulsoMobil {
        0%, 100% {
            box-shadow:
                0 4px 20px rgba(0, 0, 0, 0.45),
                0 0 0 1px rgba(94, 129, 172, 0.15),
                0 0 30px rgba(74, 111, 165, 0.12);
        }
        50% {
            box-shadow:
                0 4px 20px rgba(0, 0, 0, 0.45),
                0 0 0 4px rgba(74, 111, 165, 0.3),
                0 0 50px rgba(74, 111, 165, 0.35);
        }
    }

    .pwa-ios-tooltip {
        right: auto;
        left: 50%;
        transform: translateX(-50%) translateY(8px);
        max-width: calc(100vw - 40px);
    }

    .pwa-ios-tooltip--visible {
        transform: translateX(-50%) translateY(0);
    }

    .pwa-ios-tooltip-arrow {
        right: auto;
        left: 50%;
        transform: translateX(-50%);
    }
}
