/* ============================================================
   PWA.CSS — Experiencia nativa móvil
   ============================================================ */

/* ── 1. Selección de texto deshabilitada en UI ────────────── */
button, a, label, select, h1, h2, h3, nav, header {
    -webkit-user-select: none;
    user-select: none;
}

/* ── 2. Highlight táctil eliminado ───────────────────────── */
* {
    -webkit-tap-highlight-color: transparent;
}

/* ── 3. Altura real en móvil + layout fijo ───────────────── */
html {
    height: 100dvh;
    position: fixed;
    width: 100%;
    overflow: hidden;
}

body {
    height: 100dvh;
    min-height: 100dvh;
    width: 100%;
    overflow: hidden;
    position: fixed;
}

/* ── 4. Scroll nativo suave ───────────────────────────────── */
* {
    -webkit-overflow-scrolling: touch;
}

/* ── 5. Deshabilitar pull-to-refresh ──────────────────────── */
html, body {
    overscroll-behavior-y: contain;
}

/* ── 6. Área táctil mínima 44x44px ───────────────────────── */
button, a, select, input[type="file"] {
    min-height: 44px;
    min-width: 44px;
}

/* ── 7. Scrollbar oculta visualmente ─────────────────────── */
::-webkit-scrollbar {
    display: none;
}

* {
    scrollbar-width: none;
    -ms-overflow-style: none;
}

/* ── 8. Header fijo ──────────────────────────────────────── */
header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: var(--bg, #f6f7fb);
    width: 100%;
}

/* ── 9. Solo el main hace scroll ─────────────────────────── */
main {
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    height: calc(100dvh - env(safe-area-inset-top) - env(safe-area-inset-bottom));
    animation: fadeIn 0.2s ease-out;
}

/* ── 10. Transiciones de navegación entre páginas ────────── */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ── 11. Botón de instalación PWA ────────────────────────── */
#btnInstalarPWA {
    display: none;
    position: fixed;
    bottom: calc(16px + env(safe-area-inset-bottom));
    right: 16px;
    background: #128C5E;
    color: #fff;
    border: none;
    border-radius: 12px;
    padding: 12px 20px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    align-items: center;
    gap: 8px;
    z-index: 9998;
    min-height: 44px;
}

/* ── 12. Indicador de estado de red ──────────────────────── */
#avisoOffline {
    display: none;
    position: fixed;
    top: calc(8px + env(safe-area-inset-top));
    left: 50%;
    transform: translateX(-50%);
    background: #d33;
    color: #fff;
    padding: 8px 18px;
    border-radius: 999px;
    font-size: 13px;
    font-weight: 500;
    z-index: 9999;
    white-space: nowrap;
}

    #avisoOffline.visible {
        display: block;
        animation: fadeIn 0.3s ease-out;
    }

    #avisoOffline.online {
        background: #0a7;
    }

/* ── 13. Login: altura correcta en móvil ─────────────────── */
.login-container {
    margin: env(safe-area-inset-top) auto env(safe-area-inset-bottom);
}

/* ── 14. Teclado virtual ─────────────────────────────────── */
.interactive-bottom {
    position: sticky;
    bottom: 0;
    bottom: env(keyboard-inset-height, 0px);
}

#contenedorEnviar {
    padding-bottom: max(env(safe-area-inset-bottom), var(--keyboard-height, 0px));
}

/* ── 15. Ajustes exclusivos modo PWA instalada ───────────── */
.pwa-standalone header {
    padding-top: env(safe-area-inset-top);
}

.pwa-standalone #avisoOffline {
    top: calc(8px + env(safe-area-inset-top));
}

/* ── 16. Splash screen de arranque ──────────────────────── */
#pwa-splash {
    position: fixed;
    inset: 0;
    background: #25D366;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 99999;
    transition: opacity 0.4s ease-out;
}

    #pwa-splash.oculto {
        opacity: 0;
        pointer-events: none;
    }

    #pwa-splash .splash-icon {
        width: 96px;
        height: 96px;
        background: #fff;
        border-radius: 22px;
        display: flex;
        align-items: center;
        justify-content: center;
        margin-bottom: 24px;
    }

        #pwa-splash .splash-icon span {
            font-size: 42px;
            font-weight: 700;
            color: #25D366;
            letter-spacing: -2px;
        }

    #pwa-splash .splash-nombre {
        color: #fff;
        font-size: 20px;
        font-weight: 500;
        font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
    }

/* ── 17. Fallback navegadores sin soporte dvh ────────────── */
@supports not (height: 100dvh) {
    html, body {
        height: calc(var(--vh, 1vh) * 100);
        position: fixed;
        width: 100%;
    }
}

/* ── 18. Títulos enfocables para gestión de foco ────────── */
h1[tabindex="-1"],
h2[tabindex="-1"] {
    outline: none;
}

/* ── 19. Navegación por teclado ──────────────────────────── */
:focus-visible {
    outline: 2px solid #25D366;
    outline-offset: 3px;
    border-radius: 4px;
}

:focus:not(:focus-visible) {
    outline: none;
}

/* ── 20. Elementos solo para lectores de pantalla ────────── */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

.separador {
    height: 30px;
}

@media (max-width: 759px) {

    .separador {
        height: 0px;
    }
}
