/* ══════════════════════════════════════════════════════════════════════
   PWA & Touch UX Global — Cootransfusa
   Mejoras táctiles para uso en celular como app instalada.
   Cargado en todas las páginas vía scriptsHeader1.php
   ══════════════════════════════════════════════════════════════════════ */

/* ── 1. Eliminar el highlight azul/gris al tocar (sistema) ─────────── */
*, *::before, *::after {
    -webkit-tap-highlight-color: transparent;
}

/* ── 2. Eliminar delay 300ms al tocar (doble-tap zoom) ─────────────── */
a,
button,
[role="button"],
input[type="submit"],
input[type="button"],
input[type="reset"],
label[for],
select,
.mobile-dock__item,
.drawer-shortcut,
.msv-card,
.module-card__surface,
.card-tile,
.subaction-link,
.btn,
.btn-login,
.gs-pill-link,
.enter-btn,
.chat-open-btn {
    touch-action: manipulation;
}

/* ── 3. Mínimo 48px de altura en controles táctiles ─────────────────
   (Apple HIG: 44pt mínimo / Material Design: 48dp) ──────────────── */
button:not(.msv-back):not(.gs-icon-button):not(.eye-toggle-btn):not(.pwa-install-btn),
input[type="submit"],
input[type="button"],
.btn:not(.badge):not(.btn-sm),
.btn-login,
.gs-pill-link,
.subaction-link,
.enter-btn,
.chat-open-btn {
    min-height: 48px;
}

/* ── 4. Feedback táctil: leve compresión al presionar ────────────────
   Simula la resistencia física de un botón real (tactile click) ─── */
.btn:active,
.btn-login:active,
.gs-pill-link:active,
.subaction-link:active,
.enter-btn:active,
.chat-open-btn:active,
.drawer-shortcut:active,
.mobile-dock__item:active,
.bottom-nav-item:active {
    transform: scale(0.96) !important;
    transition: transform 0.08s ease !important;
    filter: brightness(0.94) !important;
}

/* Cards completas como botón táctil */
.msv-card:active {
    transform: scale(0.98) !important;
    transition: transform 0.08s ease !important;
}

.module-card__surface:active {
    transform: scale(0.99) !important;
    transition: transform 0.08s ease !important;
}

/* ── 5. Prevenir selección de texto accidental en controles ─────────── */
button,
[role="button"],
.mobile-dock__item,
.drawer-shortcut,
.module-card__surface,
.msv-card,
.card-tile,
.bottom-nav-item,
.gs-pill-link,
.enter-btn {
    user-select: none;
    -webkit-user-select: none;
}

/* ── 6. CRÍTICO: Prevenir zoom en iOS al hacer foco en inputs ────────
   iOS hace auto-zoom si el input tiene font-size < 16px.
   Aplica solo en móvil para no afectar layouts de escritorio. ───── */
@media screen and (max-width: 768px) {
    input[type="text"],
    input[type="number"],
    input[type="password"],
    input[type="email"],
    input[type="tel"],
    input[type="date"],
    input[type="month"],
    input[type="week"],
    input[type="time"],
    input[type="datetime-local"],
    input[type="search"],
    input[type="url"],
    select,
    textarea {
        font-size: 16px !important;
    }
}

/* ── 7. Scroll con momentum y overscroll contenido ──────────────────── */
.mod-subview,
.home-drawer,
.msv-wrap {
    -webkit-overflow-scrolling: touch;
    overscroll-behavior: contain;
}

/* ── 8. Botón de ojo en login: mínimo 44×44px ───────────────────────── */
.eye-toggle-btn {
    width: 44px !important;
    height: 44px !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    touch-action: manipulation;
}

/* ── 9. Mejora de legibilidad en tablas en móvil ──────────────────── */
@media screen and (max-width: 576px) {
    .table {
        font-size: 13px;
    }
}

/* ══════════════════════════════════════════════════════════════════════
   BANNER DE INSTALACIÓN PWA
   Aparece automáticamente cuando el dispositivo soporta PWA y la app
   no está instalada. Se muestra con el evento beforeinstallprompt.
   ══════════════════════════════════════════════════════════════════════ */

.pwa-install-banner {
    position: fixed;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    left: 50%;
    transform: translateX(-50%) translateY(140%);
    width: min(calc(100% - 24px), 440px);
    padding: 16px 16px 16px 18px;
    border-radius: 22px;
    background: rgba(5, 16, 42, 0.97);
    border: 1px solid rgba(100, 160, 255, 0.24);
    box-shadow:
        0 24px 50px rgba(0, 0, 0, 0.5),
        0 0 0 1px rgba(70, 130, 255, 0.08);
    backdrop-filter: blur(18px);
    -webkit-backdrop-filter: blur(18px);
    z-index: 8500;
    display: flex;
    align-items: center;
    gap: 14px;
    transition: transform 0.42s cubic-bezier(0.34, 1.38, 0.64, 1);
    color: #e8f1ff;
}

.pwa-install-banner.is-visible {
    transform: translateX(-50%) translateY(0);
}

.pwa-install-banner__icon {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    border-radius: 14px;
    overflow: hidden;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    display: flex;
    align-items: center;
    justify-content: center;
}

.pwa-install-banner__icon img {
    width: 36px;
    height: 36px;
    object-fit: contain;
}

.pwa-install-banner__text {
    flex: 1;
    min-width: 0;
}

.pwa-install-banner__text strong {
    display: block;
    font-size: 0.92rem;
    font-weight: 700;
    margin-bottom: 2px;
    color: #ffffff;
    line-height: 1.2;
}

.pwa-install-banner__text span {
    font-size: 0.76rem;
    color: #6b8ab8;
    line-height: 1.3;
}

.pwa-install-banner__actions {
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex-shrink: 0;
}

.pwa-install-btn {
    padding: 9px 15px;
    border-radius: 11px;
    border: none;
    font-size: 0.8rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    touch-action: manipulation;
    min-height: 36px;
    line-height: 1;
    font-family: inherit;
    transition: filter 0.15s ease, transform 0.1s ease;
}

.pwa-install-btn:active {
    transform: scale(0.94) !important;
    transition: transform 0.08s ease !important;
}

.pwa-install-btn--primary {
    background: linear-gradient(135deg, #1d69ff, #0f4ccc);
    color: #fff;
    box-shadow: 0 8px 18px rgba(29, 105, 255, 0.30);
}

.pwa-install-btn--primary:hover {
    filter: brightness(1.08);
}

.pwa-install-btn--dismiss {
    background: rgba(255, 255, 255, 0.05);
    color: #6b8ab8;
    border: 1px solid rgba(255, 255, 255, 0.08);
}

.pwa-install-btn--dismiss:hover {
    color: #a0bcd8;
}

/* En pantallas muy pequeñas: simplificar layout del banner */
@media (max-width: 359px) {
    .pwa-install-banner {
        flex-wrap: wrap;
        gap: 10px;
    }

    .pwa-install-banner__actions {
        flex-direction: row;
        width: 100%;
    }

    .pwa-install-btn {
        flex: 1;
    }
}

/* ── Banner especial iOS: aparece desde abajo con flecha ── */
.pwa-install-banner--ios {
    bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    padding-right: 12px;
    gap: 12px;
}

.pwa-install-banner--ios::after {
    content: '';
    position: absolute;
    bottom: -9px;
    left: 50%;
    transform: translateX(-50%);
    border-left: 9px solid transparent;
    border-right: 9px solid transparent;
    border-top: 9px solid rgba(5, 16, 42, 0.97);
}

.pwa-install-banner--ios .pwa-install-banner__text span {
    color: #8eaacc;
    line-height: 1.45;
}

.pwa-install-banner--ios .pwa-install-banner__text em {
    font-style: normal;
    color: #ffffff;
    font-weight: 600;
}

.pwa-install-banner--ios .pwa-install-btn--dismiss {
    width: 32px;
    height: 32px;
    min-height: 32px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    border-radius: 50%;
    flex-shrink: 0;
}
