/*
   ONAPB — Isla flotante de navegación mobile
   Se activa solo <768px. No toca el navbar de escritorio/tablet.
*/

/* En <768px reemplazamos el menú hamburguesa clásico por la isla */
@media (max-width: 767.98px) {
    .custom-navbar .navbar-toggler {
        display: none !important;
    }
    .custom-navbar #navbarNav.collapse {
        display: none !important;
    }

    /* Deja lugar para que la isla no tape el contenido */
    body {
        padding-bottom: calc(78px + env(safe-area-inset-bottom, 0px));
    }

}

/* Banner "Instalá la app" (PWA). El display lo maneja el JS del layout. */
.kfx-pwa-banner {
    position: fixed;
    left: 0;
    right: 0;
    bottom: env(safe-area-inset-bottom, 0px);
    z-index: 1055;   /* aviso pasajero: por encima del botón de Genius */
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    padding: 14px 16px;
    background: var(--surface-container);
    color: var(--on-surface);
    border-top: 1px solid var(--outline-variant);
    box-shadow: var(--shadow-lg);
}
/* En mobile se corre arriba de la isla (va después de la regla base). */
@media (max-width: 767.98px) {
    .kfx-pwa-banner { bottom: calc(84px + env(safe-area-inset-bottom, 0px)); }
}
.kfx-pwa-banner .text-muted { color: var(--on-surface-muted) !important; }
.kfx-pwa-dismiss {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: none;
    background: none;
    color: var(--on-surface);
}

/* Aviso de cookies: tarjeta abajo a la izquierda en escritorio, arriba de
   la isla en mobile. Mientras está abierto no se muestra el banner PWA. */
.kfx-cookie-notice {
    position: fixed;
    left: 16px;
    bottom: calc(16px + env(safe-area-inset-bottom, 0px));
    z-index: 1056;
    max-width: 420px;
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
    padding: 16px;
    background: var(--surface-container);
    color: var(--on-surface);
    border: 1px solid var(--outline-variant);
    box-shadow: var(--shadow-lg);
    font-size: .9rem;
    line-height: 1.5;
}
.kfx-cookie-notice[hidden] { display: none; }
.kfx-cookie-notice p { margin: 0; }
.kfx-cookie-notice a { color: var(--primary-text); }
@media (max-width: 767.98px) {
    .kfx-cookie-notice {
        left: 8px;
        right: 8px;
        max-width: none;
        bottom: calc(84px + env(safe-area-inset-bottom, 0px));
    }
}
body.kfx-cookie-open .kfx-pwa-banner { display: none !important; }

.kfx-remember .form-check-label { font-size: .9rem; }
.kfx-remember-hint { font-size: .8rem; color: var(--on-surface-muted); margin-top: 2px; }
.kfx-remember-hint a { color: var(--primary-text); }

/* Barra superior mobile: avisos + "Más", íconos sueltos de 44×44 como
   la barra de Instagram (sin caja alrededor). */
.mobile-top-actions {
    display: none;
    align-items: center;
    gap: 4px;
    margin-left: auto;
}
@media (max-width: 767.98px) {
    .mobile-top-actions { display: flex; }
}
.mobile-top-btn {
    position: relative;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: none;
    background: none;
    color: #f5f3ef;
    font-size: 24px;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}
.mobile-top-btn:hover,
.mobile-top-btn.active { color: #ffffff; }
.mobile-top-badge {
    position: absolute;
    top: 6px;
    right: 4px;
    min-width: 18px;
    height: 18px;
    padding: 0 4px;
    border-radius: 999px;
    background: #f5f3ef;
    color: #050505;
    font: 800 0.65rem/18px var(--font-body);
    text-align: center;
    border: 2px solid #050505;
    box-sizing: content-box;
}

/* ══════════════════════════════
   ISLA FLOTANTE
══════════════════════════════ */
.mobile-island-wrap {
    display: none;
}
@media (max-width: 767.98px) {
    .mobile-island-wrap {
        display: flex;
        justify-content: center;
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        padding-bottom: calc(14px + env(safe-area-inset-bottom, 0px));
        z-index: 1040;
        pointer-events: none;
    }
}

.mobile-island {
    display: flex;
    align-items: center;
    gap: 2px;
    pointer-events: auto;
    background: rgba(17, 17, 17, 0.86);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 24px;
    padding: 4px 4px;
    box-shadow: var(--shadow-lg);
    /* El arrastre estilo Instagram (ver script al final del componente)
       maneja el gesto entero: sin esto, el navegador intenta hacer
       scroll/selección con el dedo en vez de dejarnos leer el arrastre. */
    touch-action: none;
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

/* D2: como Instagram, sin bloque de color (pero con textos). Reposo = ícono outline en
   blanco al 72 %; activo o tocado = ícono relleno en blanco pleno. */
.mi-item {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 3px;
    width: 64px;
    min-height: 48px;
    padding: 0;
    border-radius: 18px;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.72);
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}

.mi-item .mi-ico {
    width: 26px;
    height: 26px;
    vertical-align: 0 !important;
}
.mi-item .mi-ico-on { display: none; }

.mi-item.active,
.mi-item.mi-touching {
    color: #ffffff;
}
.mi-item.active .mi-ico-on,
.mi-item.mi-touching .mi-ico-on { display: block; }
.mi-item.active .mi-ico-off,
.mi-item.mi-touching .mi-ico-off { display: none; }

/* Mientras se arrastra el dedo, solo el ítem tocado se ve activo. */
.mobile-island.mi-dragging .mi-item.active:not(.mi-touching) {
    color: rgba(255, 255, 255, 0.72);
}
.mobile-island.mi-dragging .mi-item.active:not(.mi-touching) .mi-ico-on { display: none; }
.mobile-island.mi-dragging .mi-item.active:not(.mi-touching) .mi-ico-off { display: block; }

/* Textos visibles debajo de cada ícono: el público incluye socios
   mayores y "Mi QR" o "Beneficios" no se entienden solo por el ícono. */
.mi-item { min-height: 54px; }
.mi-item .mi-ico { width: 22px; height: 22px; }
/* Todos los íconos en un hueco de la misma altura, así los textos quedan
   alineados aunque Mi QR y el avatar sean más altos. */
.mi-item > .mi-ico,
.mi-item > .mi-main-box,
.mi-item > .mi-avatar { margin-block: calc((34px - 22px) / 2); }
.mi-item > .mi-main-box { margin-block: 0; }
.mi-item > .mi-avatar { margin-block: 5px; }
.mi-item .mi-label {
    font-family: var(--font-body);
    font-size: 0.6875rem;
    font-weight: 600;
    letter-spacing: 0.02em;
    line-height: 1.2;
}

/* Acción central (Mi QR): el ícono dentro de un cuadrado con borde,
   como el "+" de Instagram. */
.mi-main-box {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border: 1.5px solid currentColor;
    border-radius: 10px;
}
.mi-item-main .mi-main-box { width: 34px; height: 34px; }
.mi-item-main .mi-ico { width: 20px; height: 20px; }

/* Perfil: avatar redondo con iniciales; activo = anillo claro de 2 px. */
.mi-avatar {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #242424;
    color: #f5f3ef;
    font: 700 0.62rem/1 var(--font-body);
    letter-spacing: 0.02em;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.28);
}
.mi-item-avatar.active .mi-avatar,
.mi-item-avatar.mi-touching .mi-avatar {
    box-shadow: 0 0 0 2px #050505, 0 0 0 4px #f5f3ef;
}
.mobile-island.mi-dragging .mi-item-avatar.active:not(.mi-touching) .mi-avatar {
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.28);
}

.mi-item.disabled {
    color: rgba(255, 255, 255, 0.3);
    cursor: default;
}

/* ══════════════════════════════
   SHEETS (Más / Cuenta)
══════════════════════════════ */
/* Cerrada: visibility:hidden (+ inert en el markup) para que sus links no
   entren en el orden de tabulación ni los lea el lector de pantalla. */
.mobile-sheet {
    position: fixed;
    inset: 0;
    z-index: 1060;   /* por encima del botón de Genius (1050) */
    background: rgba(0, 0, 0, 0.55);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity var(--dur-quick, 220ms) var(--ease-out-soft, ease), visibility 0s linear var(--dur-quick, 220ms);
}
.mobile-sheet.open {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
    transition: opacity var(--dur-quick, 220ms) var(--ease-out-soft, ease), visibility 0s;
}

.mobile-sheet-panel {
    position: absolute;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--surface-container-lowest);
    border-radius: 20px 20px 0 0;
    padding: 10px 18px calc(20px + env(safe-area-inset-bottom, 0px));
    max-height: 75vh;
    overflow-y: auto;
    transform: translateY(100%);
    transition: transform 0.28s cubic-bezier(0.2, 0.8, 0.2, 1);
    box-shadow: var(--shadow-lg);
}
.mobile-sheet-panel:focus { outline: none; }
.mobile-sheet.open .mobile-sheet-panel {
    transform: translateY(0);
}

.mobile-sheet-handle {
    width: 36px;
    height: 5px;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.3);
    margin: 8px auto 14px;
}

.mobile-sheet-title {
    font-family: var(--font-display);
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: var(--on-surface-muted);
    font-size: 0.85rem;
    margin-bottom: 6px;
}

.mobile-sheet-panel a.sheet-link,
.mobile-sheet-panel form.sheet-link button {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 13px 2px;
    border-bottom: 1px solid var(--outline-variant);
    color: var(--on-surface);
    text-decoration: none;
    font-size: 0.95rem;
    background: none;
    border-left: none;
    border-right: none;
    border-top: none;
    text-align: left;
}
.mobile-sheet-panel a.sheet-link:last-child,
.mobile-sheet-panel form.sheet-link:last-child button {
    border-bottom: none;
}
.mobile-sheet-panel a.sheet-link svg,
.mobile-sheet-panel form.sheet-link button svg {
    color: var(--primary-text);
    font-size: 1.05rem;
    width: 20px;
    text-align: center;
}
.mobile-sheet-panel a.sheet-link.text-danger svg,
.mobile-sheet-panel form.sheet-link button.text-danger svg {
    color: #b00000;
}

.sheet-context {
    display: flex;
    align-items: center;
    gap: 7px;
    margin: 0 0 10px;
    padding-bottom: 10px;
    border-bottom: 1px dashed var(--outline-variant);
    color: var(--on-surface-muted);
    font-size: 0.82rem;
    font-weight: 600;
}
.sheet-context svg { color: var(--primary-text); }

.sheet-count {
    margin-left: auto;
    min-width: 22px;
    height: 22px;
    padding: 0 6px;
    border-radius: 999px;
    background: var(--primary);
    color: #fff;
    font-size: 0.72rem;
    font-weight: 800;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

/* Reduced motion: el panel aparece sin deslizarse; el fondo mantiene un
   fade corto (bloque global en kinetic-arena-v3.css). */
@media (prefers-reduced-motion: reduce) {
    .mobile-sheet-panel {
        transition: none !important;
    }
}

/* Teléfonos de 320-359 px (iPhone SE 1.ª gen., Android chicos): 5 × 64 px
   no entra; se achica el ítem y el texto sin bajar del target de 44 px. */
@media (max-width: 359.98px) {
    .mi-item { width: 58px; }
    .mi-item .mi-label { font-size: 0.625rem; letter-spacing: 0; }
}
