/* =========================================================
   GPS ESCOLAR — NORMALIZACIÓN GENERAL
   =========================================================
   RESPONSABILIDAD:
   - Altura completa de la aplicación.
   - Scroll nativo del navegador.
   - Pull-to-refresh en dispositivos compatibles.
   - Footer fijo al borde inferior del viewport.
   - Comportamientos normalizados y explícitos.

   REGLA:
   Ninguna página específica se nombra en este archivo.
   ========================================================= */


/* =========================================================
   1 — DOCUMENTO / SCROLL NATIVO / PULL-TO-REFRESH
   ========================================================= */

html:has(body.viewport-page) {
    height: auto !important;
    min-height: 100% !important;

    overflow-x: hidden !important;
    overflow-y: auto !important;

    overscroll-behavior-y: auto !important;
}


/* =========================================================
   2 — BODY GENERAL
   ========================================================= */

body.viewport-page {
    width: 100% !important;

    height: auto !important;
    min-height: 100vh !important;
    min-height: 100dvh !important;

    margin: 0 !important;

    overflow-x: hidden !important;
    overflow-y: visible !important;

    overscroll-behavior-y: auto !important;
}


/* =========================================================
   3 — CARCASA GENERAL
   ========================================================= */

body.viewport-page .app-shell {
    height: auto !important;

    min-height: 100vh !important;
    min-height: 100dvh !important;

    overflow: visible !important;
}


/* =========================================================
   4 — MENÚ INFERIOR / FOOTER
   ========================================================= */

body.viewport-page .bottom {
    position: fixed !important;

    left: 50% !important;
    right: auto !important;
    bottom: 0 !important;

    transform: translateX(-50%) !important;

    width: 100% !important;
    max-width: 430px !important;

    height: 72px !important;
    min-height: 72px !important;

    margin: 0 !important;

    z-index: 100 !important;
}



/* =========================================================
   6 — COMPORTAMIENTO · SCROLL
   ---------------------------------------------------------
   Clase nueva y explícita.
   Su única responsabilidad es el desplazamiento del elemento.
   No define altura, fondo, márgenes, bordes ni presentación.
   ========================================================= */

.comportamiento-scroll {
    flex: 1 1 0 !important;

    width: 100% !important;
    height: 100% !important;
    min-height: 0 !important;

    margin: 0 0 72px 0 !important;
    padding: 0 !important;

    box-sizing: border-box !important;

    overflow-y: auto !important;
    overflow-x: hidden !important;

    -webkit-overflow-scrolling: touch;
}



/* =========================================================
   7 — PWA · ALTO REAL DE LA VENTANA (GPS 14 mejoras 54)
   ---------------------------------------------------------
   Abierta como app instalada desde Chrome (PWA), en algunos
   teléfonos 100dvh mide más que lo visible (incluye las barras
   del teléfono): las secciones 2 y 3 dejaban la carcasa más
   alta y el mapa quedaba bajo el menú inferior.
   Solo en la PWA se usa el alto real de la ventana
   (--gps-alto-ventana, lo calcula header.php).
   En el navegador y en la APK no aplica.
   ========================================================= */

@media (display-mode: standalone), (display-mode: fullscreen) {
    html body.viewport-page,
    html body.viewport-page .app-shell {
        min-height: var(--gps-alto-ventana, 100vh) !important;
    }

    html body.pagina-mapa-conductor .app-body-frame {
        height: calc(var(--gps-alto-ventana, 100vh) - 72px) !important;
    }
}
