/* Todo el Día — barra inferior (móvil) + tira horizontal (escritorio, ≥900px) */

body {
    padding-bottom: calc(84px + env(safe-area-inset-bottom, 0px)) !important;
}

/* --- Barra inferior --- */
.pwa-bottom-nav {
    --nav-ink: #0f172a;
    --nav-muted: #64748b;
    --nav-active: #0369a1;
    --nav-active-icon: #0ea5e9;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    box-sizing: border-box;
    z-index: 99999;
    margin: 0;
    min-height: 68px;
    padding: 12px 4px calc(10px + env(safe-area-inset-bottom, 0px));
    display: flex;
    flex-direction: row;
    align-items: center;
    justify-content: space-around;
    gap: 2px;
    background: #ffffff;
    box-shadow: 0 -5px 20px rgba(0, 0, 0, 0.1);
    border-top: 1px solid #e2e8f0;
}

.pwa-bottom-nav::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 4px;
    background: linear-gradient(
        90deg,
        #dc2626 0%,
        #ea580c 28%,
        #f59e0b 55%,
        #38bdf8 100%
    );
    pointer-events: none;
}

.pwa-bottom-nav.pwa-nav-strip--fe-day::before,
.pwa-desktop-nav.pwa-nav-strip--fe-day::before {
    background: linear-gradient(
        90deg,
        #be123c 0%,
        #c026d3 22%,
        #ea580c 48%,
        #f59e0b 72%,
        #38bdf8 100%
    );
    opacity: 0.95;
}

.pwa-nav-item {
    flex: 1;
    min-width: 0;
    max-width: 22%;
    text-decoration: none !important;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    padding: 4px 2px;
    color: var(--nav-muted);
    font-size: 0.625rem;
    font-weight: 700;
    letter-spacing: 0.02em;
    border-radius: 14px;
    position: relative;
    z-index: 1;
    transition:
        color 0.18s ease,
        transform 0.15s ease,
        background 0.18s ease;
    -webkit-tap-highlight-color: transparent;
}

.pwa-nav-item:focus-visible {
    outline: 3px solid var(--nav-active-icon);
    outline-offset: 3px;
    box-shadow: 0 0 0 1px rgba(255, 255, 255, 0.9);
}

.pwa-nav-item:active {
    transform: scale(0.96);
}

.pwa-nav-item__icon {
    width: 44px;
    height: 32px;
    display: grid;
    place-items: center;
    border-radius: 12px;
    transition:
        background 0.2s ease,
        box-shadow 0.2s ease,
        color 0.2s ease;
}

.pwa-nav-item__icon .bi {
    font-size: 1.35rem;
    line-height: 1;
}

.pwa-nav-item__label {
    line-height: 1.1;
    text-align: center;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.pwa-nav-item:not(.active) .pwa-nav-item__icon {
    background: rgba(248, 250, 252, 0.95);
    color: #475569;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
}

.pwa-nav-item.active {
    color: var(--nav-active) !important;
}

.pwa-nav-item.active .pwa-nav-item__icon {
    background: linear-gradient(155deg, #e0f2fe 0%, #bae6fd 50%, #7dd3fc 100%);
    color: var(--nav-active);
    box-shadow:
        0 2px 10px rgba(14, 165, 233, 0.25),
        0 0 0 1px rgba(255, 255, 255, 0.6) inset;
}

.pwa-nav-item.active .pwa-nav-item__icon .bi {
    color: #0369a1;
}

/* --- Tira desktop (oculta en móvil; se muestra desde 900px con header) --- */
.pwa-desktop-nav {
    --nav-ink: #0f172a;
    --nav-muted: #64748b;
    --nav-active: #0369a1;
    --nav-active-icon: #0ea5e9;
    display: none;
    position: relative;
    z-index: 2;
    box-sizing: border-box;
    width: 100%;
    max-width: min(960px, calc(100% - 32px));
    margin: 0 auto;
    padding: 0 16px 10px;
    flex-direction: row;
    align-items: stretch;
    justify-content: center;
    flex-wrap: wrap;
    gap: 4px 8px;
    background: var(--h-surface, #ffffff);
    border-top: 1px solid var(--h-line, #e2e8f0);
}

.pwa-desktop-nav::before {
    content: "";
    position: absolute;
    left: 0;
    right: 0;
    top: 0;
    height: 4px;
    background: linear-gradient(
        90deg,
        #dc2626 0%,
        #ea580c 28%,
        #f59e0b 55%,
        #38bdf8 100%
    );
    pointer-events: none;
}

.pwa-desktop-nav__item {
    flex: 1 1 auto;
    min-width: 0;
    max-width: 11rem;
    text-decoration: none !important;
    display: inline-flex;
    flex-direction: row;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 12px;
    border-radius: 12px;
    color: var(--nav-muted);
    font-size: 0.8125rem;
    font-weight: 700;
    letter-spacing: 0.01em;
    transition:
        color 0.18s ease,
        background 0.18s ease,
        transform 0.15s ease;
    -webkit-tap-highlight-color: transparent;
}

.pwa-desktop-nav__item:focus-visible {
    outline: 3px solid var(--nav-active-icon);
    outline-offset: 2px;
    box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.22);
}

.pwa-desktop-nav__item:hover {
    color: var(--nav-ink);
    background: rgba(241, 245, 249, 0.95);
}

.pwa-desktop-nav__item:active {
    transform: scale(0.98);
}

.pwa-desktop-nav__icon {
    width: 36px;
    height: 32px;
    flex-shrink: 0;
    display: grid;
    place-items: center;
    border-radius: 10px;
    background: rgba(248, 250, 252, 0.95);
    color: #475569;
    box-shadow: 0 1px 2px rgba(15, 23, 42, 0.06);
    transition:
        background 0.2s ease,
        box-shadow 0.2s ease,
        color 0.2s ease;
}

.pwa-desktop-nav__icon .bi {
    font-size: 1.15rem;
    line-height: 1;
}

.pwa-desktop-nav__label {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.pwa-desktop-nav__item.active {
    color: var(--nav-active) !important;
}

.pwa-desktop-nav__item.active .pwa-desktop-nav__icon {
    background: linear-gradient(155deg, #e0f2fe 0%, #bae6fd 50%, #7dd3fc 100%);
    color: var(--nav-active);
    box-shadow:
        0 2px 10px rgba(14, 165, 233, 0.22),
        0 0 0 1px rgba(255, 255, 255, 0.6) inset;
}

.pwa-desktop-nav__item.active .pwa-desktop-nav__icon .bi {
    color: #0369a1;
}

/* Modo oscuro — inferior */
html[data-theme="dark"] .pwa-bottom-nav {
    --nav-ink: #f1f5f9;
    --nav-muted: #94a3b8;
    --nav-active: #38bdf8;
    --nav-active-icon: #7dd3fc;
    background: #1e293b;
    border-top-color: #334155;
    box-shadow: 0 -5px 24px rgba(0, 0, 0, 0.35);
}

html[data-theme="dark"] .pwa-nav-item:not(.active) .pwa-nav-item__icon {
    background: rgba(15, 23, 42, 0.85);
    color: #94a3b8;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

html[data-theme="dark"] .pwa-nav-item.active .pwa-nav-item__icon {
    background: linear-gradient(155deg, #0c4a6e 0%, #075985 50%, #0369a1 100%);
    color: #e0f2fe;
    box-shadow:
        0 2px 10px rgba(14, 165, 233, 0.35),
        0 0 0 1px rgba(255, 255, 255, 0.08) inset;
}

html[data-theme="dark"] .pwa-nav-item.active .pwa-nav-item__icon .bi {
    color: #bae6fd;
}

/* Modo oscuro — tira desktop */
html[data-theme="dark"] .pwa-desktop-nav {
    --nav-ink: #f1f5f9;
    --nav-muted: #94a3b8;
    --nav-active: #38bdf8;
    --nav-active-icon: #7dd3fc;
    background: var(--h-surface, #1e293b);
    border-top-color: var(--h-line, #334155);
}

html[data-theme="dark"] .pwa-desktop-nav__item:hover {
    background: rgba(51, 65, 85, 0.45);
    color: var(--nav-ink);
}

html[data-theme="dark"] .pwa-desktop-nav__item:not(.active) .pwa-desktop-nav__icon {
    background: rgba(15, 23, 42, 0.85);
    color: #94a3b8;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.25);
}

html[data-theme="dark"] .pwa-desktop-nav__item.active .pwa-desktop-nav__icon {
    background: linear-gradient(155deg, #0c4a6e 0%, #075985 50%, #0369a1 100%);
    color: #e0f2fe;
    box-shadow:
        0 2px 10px rgba(14, 165, 233, 0.35),
        0 0 0 1px rgba(255, 255, 255, 0.08) inset;
}

html[data-theme="dark"] .pwa-desktop-nav__item.active .pwa-desktop-nav__icon .bi {
    color: #bae6fd;
}

/* Tablet: barra inferior tipo dock (solo <900px) */
@media (min-width: 768px) and (max-width: 899.98px) {
    body {
        padding-bottom: calc(92px + env(safe-area-inset-bottom, 0px)) !important;
    }

    .pwa-bottom-nav {
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        width: min(560px, calc(100vw - 40px));
        max-width: 94vw;
        border-radius: 18px 18px 0 0;
        padding: 10px 10px calc(12px + env(safe-area-inset-bottom, 0px));
        min-height: 70px;
        border-left: 1px solid #e2e8f0;
        border-right: 1px solid #e2e8f0;
    }

    .pwa-nav-item {
        max-width: none;
        flex: 1 1 0;
        padding: 6px 4px;
    }

    .pwa-nav-item__label {
        font-size: 0.6875rem;
    }

    .pwa-nav-item__icon {
        width: 46px;
        height: 34px;
    }

    html[data-theme="dark"] .pwa-bottom-nav {
        border-left-color: #334155;
        border-right-color: #334155;
    }
}

/* Escritorio: menú arriba con el header; sin barra fija abajo */
@media (min-width: 900px) {
    body {
        padding-bottom: calc(20px + env(safe-area-inset-bottom, 0px)) !important;
    }

    .pwa-bottom-nav {
        display: none !important;
    }

    .pwa-desktop-nav {
        display: flex;
    }
}

/* Volver arriba (por encima del contenido, debajo de la barra inferior en móvil) */
.td-scroll-top {
    position: fixed;
    z-index: 99990;
    right: 14px;
    bottom: calc(88px + env(safe-area-inset-bottom, 0px));
    width: 48px;
    height: 48px;
    border: none;
    border-radius: 999px;
    display: grid;
    place-items: center;
    cursor: pointer;
    color: #f8fafc;
    background: linear-gradient(155deg, #0369a1 0%, #2563eb 55%, #4f46e5 100%);
    box-shadow:
        0 4px 18px rgba(37, 99, 235, 0.45),
        0 0 0 1px rgba(255, 255, 255, 0.18) inset;
    transition: transform 0.15s ease, box-shadow 0.2s ease, opacity 0.2s ease;
    -webkit-tap-highlight-color: transparent;
}

.td-scroll-top .bi {
    font-size: 1.75rem;
    line-height: 1;
    margin-top: -2px;
}

.td-scroll-top:hover {
    box-shadow:
        0 6px 22px rgba(37, 99, 235, 0.5),
        0 0 0 1px rgba(255, 255, 255, 0.22) inset;
}

.td-scroll-top:active {
    transform: scale(0.94);
}

.td-scroll-top:focus-visible {
    outline: 3px solid #38bdf8;
    outline-offset: 3px;
}

.td-scroll-top[hidden] {
    display: none !important;
}

html[data-theme="dark"] .td-scroll-top {
    background: linear-gradient(155deg, #0c4a6e 0%, #1d4ed8 50%, #5b21b6 100%);
    box-shadow:
        0 4px 20px rgba(0, 0, 0, 0.45),
        0 0 0 1px rgba(255, 255, 255, 0.1) inset;
}

@media (min-width: 900px) {
    .td-scroll-top {
        bottom: calc(22px + env(safe-area-inset-bottom, 0px));
        right: 22px;
    }
}

@media (min-width: 768px) and (max-width: 899.98px) {
    .td-scroll-top {
        bottom: calc(96px + env(safe-area-inset-bottom, 0px));
    }
}
