/* ==========================================================================
   PAN MANITOS · Capa para celulares y tabletas (≤ 1023 px)
   El diseño de escritorio no cambia: todo está dentro de media queries.
   - Logo animado en la barra superior y buscador que se expande al tocarlo.
   - Barra de navegación inferior tipo aplicación (ver navegacion-movil.blade.php).
   - Bloques que aparecen con animación al desplazarse.
   - Respuesta al toque (en celulares no existe el "pasar el mouse").
   - Distribuciones más compactas: indicadores 2 × 2, accesos rápidos en mosaico.
   ========================================================================== */

/* Todo lo de este bloque aplica solo en tablet y celular (hasta 1023 px de ancho). */
@media (max-width: 1023px) {

    /* ── Barra superior: el logo animado también en el celular ─────────── */
    .fi-topbar-start { display: flex !important; align-items: center; min-width: 0; margin-inline-end: auto; }
    .fi-topbar-start .fi-logo { width: auto !important; }
    .fi-topbar { gap: 6px; }

    /* Buscador compacto: un ícono que se despliega al tocarlo. */
    .fi-topbar .fi-global-search-field .fi-input-wrp {
        width: 42px; transition: width .35s cubic-bezier(.2, .8, .2, 1), box-shadow .2s;
    }
    .fi-topbar .fi-global-search-field input::placeholder { color: transparent; }
    .fi-topbar .fi-global-search-field:focus-within .fi-input-wrp {
        width: min(62vw, 260px); box-shadow: 0 0 0 3px rgba(245, 158, 11, .25);
    }
    .fi-topbar .fi-global-search-field:focus-within input::placeholder { color: #9ca3af; }

    /* ── Espacio para la barra de navegación inferior ──────────────────── */
    body.pm-con-nav-movil .fi-main-ctn { padding-bottom: calc(84px + env(safe-area-inset-bottom)); }
    body.pm-con-nav-movil .fi-no { bottom: calc(76px + env(safe-area-inset-bottom)) !important; }

    /* ── Encabezado de página: decoración animada ──────────────────────── */
    .fi-header { position: relative; overflow: hidden; }
    .fi-header::after {
        content: ""; position: absolute; right: -40px; top: -40px; width: 140px; height: 140px;
        border-radius: 999px; background: radial-gradient(circle, rgba(251, 191, 36, .35), transparent 70%);
        animation: pm-m-flotar 6s ease-in-out infinite; pointer-events: none;
    }
    .fi-header-heading { background: linear-gradient(90deg, #111827, #b45309 60%, #111827); -webkit-background-clip: text; background-clip: text; color: transparent; background-size: 200% 100%; animation: pm-m-brillo 6s ease-in-out infinite; }
    .dark .fi-header-heading { background-image: linear-gradient(90deg, #f9fafb, #fbbf24 60%, #f9fafb); }

    /* ── Indicadores (tarjetas de estadísticas) en 2 × 2 ───────────────── */
    .fi-wi-stats-overview .fi-section-content.fi-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 10px !important; }
    .fi-wi-stats-overview .fi-section-content.fi-grid > * { grid-column: auto !important; }
    .fi-wi-stats-overview-stat { padding: 14px !important; }
    .fi-wi-stats-overview-stat-value { font-size: 1.6rem !important; }
    .fi-wi-stats-overview-stat-label, .fi-wi-stats-overview-stat-description { font-size: 12px !important; }

    /* ── Accesos rápidos en mosaico con ícono grande ───────────────────── */
    .ar-grid { grid-template-columns: repeat(2, minmax(0, 1fr)) !important; gap: 10px !important; }
    .ar-card { flex-direction: column; align-items: flex-start !important; gap: 10px !important; padding: 14px !important; }
    .ar-card .ar-flecha { position: absolute; top: 12px; right: 12px; }
    .ar-card .ar-icono { width: 44px; height: 44px; }
    .ar-card .ar-texto small { display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
}

/* Celulares: títulos más pequeños y menos relleno. */
@media (max-width: 640px) {
    .pm-marca-texto strong { font-size: 15px !important; }
    .fi-topbar-start .pm-marca { gap: 8px; }
}

/* Celulares muy angostos: ajustes mínimos. */
@media (max-width: 340px) {
    .pm-marca-texto { display: none; }    /* en pantallas muy angostas queda solo el logo animado */
}

/* ── Aparición al desplazarse (solo si el script la activa) ──────────────── */
@media (max-width: 1023px) {
    .pm-revelar { opacity: 0; transform: translateY(18px) scale(.985); }
    .pm-revelar.pm-visible {
        opacity: 1; transform: none;
        transition: opacity .55s ease-out, transform .55s cubic-bezier(.2, .8, .2, 1);
        transition-delay: var(--pm-retraso, 0ms);
    }
}

/* ── Respuesta al toque ──────────────────────────────────────────────────── */
@media (hover: none) {
    .ar-card, .fi-ta-record, .fi-wi-stats-overview-stat, .fi-btn, .fi-section, .pm-nav-movil a, .pm-nav-movil button {
        -webkit-tap-highlight-color: transparent;
        transition: transform .15s ease, box-shadow .15s ease;
    }
    .ar-card:active, .fi-ta-record:active, .fi-wi-stats-overview-stat:active { transform: scale(.97); box-shadow: 0 2px 10px rgba(0, 0, 0, .12); }
    .fi-btn:active { transform: scale(.95); }
}

/* ── Barra de navegación inferior ────────────────────────────────────────── */
.pm-nav-movil { display: none; }

@media (max-width: 1023px) {
    .pm-nav-movil {
        position: fixed; z-index: 30; left: 10px; right: 10px; bottom: calc(10px + env(safe-area-inset-bottom));
        display: grid; grid-auto-columns: 1fr; grid-auto-flow: column; align-items: stretch;
        padding: 6px; border-radius: 22px;
        background: rgba(255, 255, 255, .86); -webkit-backdrop-filter: blur(14px); backdrop-filter: blur(14px);
        border: 1px solid rgba(245, 158, 11, .25);
        box-shadow: 0 10px 30px rgba(17, 24, 39, .18);
        animation: pm-m-subir .5s cubic-bezier(.2, .8, .2, 1) backwards;
    }
    .dark .pm-nav-movil { background: rgba(17, 24, 39, .88); border-color: rgba(255, 255, 255, .1); }

    .pm-nav-movil a, .pm-nav-movil button {
        position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
        min-width: 0; padding: 7px 2px; border: 0; border-radius: 16px; background: transparent;
        font-size: 10px; font-weight: 700; letter-spacing: -.1px; line-height: 1.1; color: #6b7280; text-decoration: none; cursor: pointer;
    }
    .dark .pm-nav-movil a, .dark .pm-nav-movil button { color: #9ca3af; }
    .pm-nav-movil svg { width: 22px; height: 22px; transition: transform .25s cubic-bezier(.2, .8, .2, 1); }
    .pm-nav-movil span { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
    .pm-nav-movil a:active svg, .pm-nav-movil button:active svg { transform: scale(.85); }

    /* Se esconde mientras el menú lateral está abierto. */
    .pm-nav-movil { transition: transform .35s cubic-bezier(.2, .8, .2, 1), opacity .25s; }
    .pm-nav-movil.pm-oculta { transform: translateY(140%); opacity: 0; pointer-events: none; }

    /* Menú lateral: las opciones entran en cascada al abrirlo. */
    .fi-sidebar.fi-sidebar-open .fi-sidebar-item,
    .fi-sidebar.fi-sidebar-open .fi-sidebar-group-label { animation: pm-m-entrar .45s cubic-bezier(.2, .8, .2, 1) both; }
    .fi-sidebar.fi-sidebar-open .fi-sidebar-group:nth-child(2) .fi-sidebar-item { animation-delay: .35s; }
    .fi-sidebar.fi-sidebar-open .fi-sidebar-item:nth-child(1) { animation-delay: .04s; }
    .fi-sidebar.fi-sidebar-open .fi-sidebar-item:nth-child(2) { animation-delay: .08s; }
    .fi-sidebar.fi-sidebar-open .fi-sidebar-item:nth-child(3) { animation-delay: .12s; }
    .fi-sidebar.fi-sidebar-open .fi-sidebar-item:nth-child(4) { animation-delay: .16s; }
    .fi-sidebar.fi-sidebar-open .fi-sidebar-item:nth-child(5) { animation-delay: .20s; }
    .fi-sidebar.fi-sidebar-open .fi-sidebar-item:nth-child(6) { animation-delay: .24s; }
    .fi-sidebar.fi-sidebar-open .fi-sidebar-item:nth-child(7) { animation-delay: .28s; }
    .fi-sidebar.fi-sidebar-open .fi-sidebar-item:nth-child(8) { animation-delay: .32s; }
    .fi-sidebar.fi-sidebar-open .fi-sidebar-item:nth-child(n+9) { animation-delay: .36s; }
    .fi-sidebar-close-overlay { -webkit-backdrop-filter: blur(3px); backdrop-filter: blur(3px); }

    .pm-nav-movil .pm-activo { color: #b45309; background: linear-gradient(180deg, #fef3c7, #fde68a); }
    .dark .pm-nav-movil .pm-activo { color: #fbbf24; background: rgba(251, 191, 36, .14); }
    .pm-nav-movil .pm-activo svg { transform: translateY(-2px) scale(1.1); animation: pm-m-rebote .45s ease-out; }
    .pm-nav-movil .pm-activo::after {
        content: ""; position: absolute; bottom: 3px; width: 5px; height: 5px; border-radius: 999px; background: #f59e0b;
        animation: pm-m-pulso 1.8s ease-in-out infinite;
    }
}

/* Animaciones usadas por la capa móvil. */
@keyframes pm-m-entrar { from { opacity: 0; transform: translateX(-16px); } to { opacity: 1; transform: none; } }
@keyframes pm-m-subir { from { transform: translateY(120%); opacity: 0; } to { transform: none; opacity: 1; } }
@keyframes pm-m-rebote { 0% { transform: scale(.8); } 60% { transform: translateY(-3px) scale(1.18); } 100% { transform: translateY(-2px) scale(1.1); } }
@keyframes pm-m-pulso { 0%, 100% { opacity: .5; transform: scale(.8); } 50% { opacity: 1; transform: scale(1.25); } }
@keyframes pm-m-flotar { 0%, 100% { transform: translate(0, 0); } 50% { transform: translate(-14px, 10px); } }
@keyframes pm-m-brillo { 0%, 100% { background-position: 100% 0; } 50% { background-position: 0 0; } }

/* Si el usuario pidió reducir animaciones, se desactivan. */
@media (prefers-reduced-motion: reduce) {
    .pm-revelar { opacity: 1 !important; transform: none !important; }
    .pm-nav-movil, .pm-nav-movil svg, .pm-nav-movil .pm-activo::after, .fi-header::after, .fi-header-heading, .fi-sidebar .fi-sidebar-item, .fi-sidebar .fi-sidebar-group-label { animation: none !important; }
}
