/**
 * NegocioGo — Sistema mobile app-like (≤768px)
 * Bottom nav, bottom sheets, safe-area, tap targets, tipografía compacta.
 */

:root {
    /* Altura de la fila de íconos (sin safe-area). Safe-area va solo como padding inferior. */
    --ng-bottom-nav-height: 56px;
    --ng-bottom-nav-clearance: calc(var(--ng-bottom-nav-height) + env(safe-area-inset-bottom, 0px));
    --ng-sheet-radius: 20px;
    --ng-mobile-pad: 16px;
    --ng-accent: #068C61;
    --ng-accent-soft: #F3FFFA;
    --ng-tap-min: 44px;
}

/* —— Shell con bottom nav —— */
@media (max-width: 768px) {
    body.ng-has-bottom-nav:not(.has-mobile-bottom-nav) {
        padding-bottom: var(--ng-bottom-nav-clearance);
    }

    body.ng-has-bottom-nav.has-mobile-bottom-nav > main.flex-1:not(.map-app-shell) {
        padding-bottom: var(--ng-bottom-nav-clearance);
    }

    body.ng-has-bottom-nav .site-footer {
        margin-bottom: 0;
    }

    body.is-map-app-shell.ng-has-bottom-nav .map-app-shell {
        padding-bottom: 0;
    }

    /* Evitar scroll horizontal global */
    html,
    body {
        overflow-x: clip;
        max-width: 100%;
    }

    /* Tipografía mobile */
    h1,
    .text-4xl,
    .text-5xl {
        font-size: clamp(1.75rem, 7vw, 2.375rem) !important;
        line-height: 1.15 !important;
    }

    h2,
    .text-3xl {
        font-size: clamp(1.375rem, 5vw, 1.625rem) !important;
        line-height: 1.2 !important;
    }

    h3,
    .text-2xl {
        font-size: 1.0625rem !important;
        line-height: 1.3 !important;
    }

    /* Main padding lateral (páginas estándar; full-bleed en mobile-safe.css) */
    body.ng-has-bottom-nav > main.flex-1:not(.map-app-shell):not([class*="px-0"]) {
        padding-left: var(--ng-mobile-pad);
        padding-right: var(--ng-mobile-pad);
        padding-top: 1rem;
    }

    body.ng-has-bottom-nav.has-mobile-bottom-nav > main.flex-1:not(.map-app-shell):not([class*="px-0"]) {
        padding-bottom: var(--ng-bottom-nav-clearance);
    }

    /* Botones táctiles */
    .btn,
    .map-btn,
    .vendly-btn,
    button[type="submit"]:not(.ng-bottom-nav__item),
    a.btn,
    a.map-btn {
        min-height: var(--ng-tap-min);
    }

    .btn-primary,
    .map-btn--primary,
    .vendly-btn--primary {
        border-radius: 14px;
        font-size: 0.9375rem;
        font-weight: 700;
    }

    /* Cards marketplace / explore */
    .vendly-business-card,
    .explore-store-card,
    .map-list-card {
        border-radius: 18px;
        padding: 14px;
    }

    /* Footer móvil: todas las secciones en columna (sin ocultar columnas) */
    .site-footer-inner {
        padding: 2rem 1rem calc(1.5rem + var(--ng-bottom-nav-clearance, 0px));
    }

    body:not(.ng-has-bottom-nav) .site-footer-inner {
        padding-bottom: 1.5rem;
    }

    .site-footer-grid {
        display: flex;
        flex-direction: column;
        gap: 1.5rem;
    }

    .site-footer-brand,
    .site-footer-col {
        width: 100%;
        min-width: 0;
    }

    .footer-heading {
        font-size: 0.6875rem;
        margin-bottom: 0.65rem;
    }

    .footer-links {
        display: block;
    }

    .footer-links li + li {
        margin-top: 0.45rem;
    }

    .footer-links a {
        font-size: 0.8125rem;
        min-height: 2.75rem;
        display: inline-flex;
        align-items: center;
    }

    .footer-bottom {
        margin-top: 1.35rem;
        padding-top: 0.85rem;
    }

    .footer-bottom-copy {
        font-size: 0.75rem;
        line-height: 1.45;
    }


}

@media (min-width: 769px) {
    .mobile-header-tools,
    .ng-bottom-nav,
    .ng-map-fab,
    .ng-bottom-sheet {
        display: none !important;
    }
}

/* —— Bottom navigation —— */
.ng-bottom-nav {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 90;
    display: flex;
    align-items: flex-end;
    justify-content: space-around;
    /* No min-height + safe-area a la vez: evita franja blanca enorme bajo los íconos */
    min-height: 0;
    height: auto;
    padding: 0.25rem 0.15rem 0;
    padding-bottom: env(safe-area-inset-bottom, 0px);
    background: #fff;
    border-top: 1px solid rgba(15, 23, 42, 0.08);
    box-shadow: 0 -4px 24px -12px rgba(15, 23, 42, 0.12);
    box-sizing: border-box;
}

@media (min-width: 769px) {
    .ng-bottom-nav {
        background: rgba(255, 255, 255, 0.97);
        backdrop-filter: blur(14px);
        -webkit-backdrop-filter: blur(14px);
    }
}

.ng-bottom-nav__item {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.12rem;
    height: var(--ng-bottom-nav-height);
    min-height: var(--ng-bottom-nav-height);
    max-height: var(--ng-bottom-nav-height);
    padding: 0.15rem 0.1rem 0.3rem;
    font-size: 0.625rem;
    font-weight: 600;
    line-height: 1.1;
    color: #64748b;
    text-decoration: none;
    border: none;
    background: transparent;
    border-radius: 10px;
    transition:
        color var(--motion-fast, 160ms) var(--motion-ease, cubic-bezier(0.2, 0.8, 0.2, 1)),
        transform var(--motion-fast, 160ms) var(--motion-ease, cubic-bezier(0.2, 0.8, 0.2, 1));
    -webkit-tap-highlight-color: transparent;
}

.ng-bottom-nav__item svg {
    width: 1.35rem;
    height: 1.35rem;
    flex-shrink: 0;
}

.ng-bottom-nav__item.is-active {
    color: var(--ng-accent);
}

.ng-bottom-nav__item.is-active svg {
    transform: scale(1.06);
    transition: transform var(--motion-fast, 160ms) var(--motion-ease-out, cubic-bezier(0.16, 1, 0.3, 1));
}

.ng-bottom-nav__item:active:not(.is-active) {
    transform: scale(0.96);
}

@media (prefers-reduced-motion: reduce) {
    .ng-bottom-nav__item:active {
        transform: none;
    }
}

/* Dashboard seller: padding main */
@media (max-width: 1023px) {
    body.creator-app.ng-has-bottom-nav .creator-main {
        padding-bottom: calc(1rem + var(--ng-bottom-nav-clearance));
    }

    body.creator-app .creator-mobile-nav {
        display: none !important;
    }
}

/* —— Bottom sheet —— */
.ng-bottom-sheet {
    position: fixed;
    inset: 0;
    z-index: 120;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
    pointer-events: none;
    visibility: hidden;
    transition: visibility 0.25s ease;
}

.ng-bottom-sheet.is-open {
    pointer-events: auto;
    visibility: visible;
}

.ng-bottom-sheet__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.45);
    opacity: 0;
    transition: opacity 0.25s ease;
}

.ng-bottom-sheet.is-open .ng-bottom-sheet__backdrop {
    opacity: 1;
}

.ng-bottom-sheet__panel {
    position: relative;
    display: flex;
    flex-direction: column;
    max-height: 80vh;
    margin: 0;
    background: #fff;
    border-radius: var(--ng-sheet-radius) var(--ng-sheet-radius) 0 0;
    box-shadow: 0 -12px 40px -8px rgba(15, 23, 42, 0.2);
    transform: translateY(100%);
    transition: transform 0.28s cubic-bezier(0.32, 0.72, 0, 1);
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

.ng-bottom-sheet.is-open .ng-bottom-sheet__panel {
    transform: translateY(0);
}

.ng-bottom-sheet__handle {
    flex-shrink: 0;
    width: 2.5rem;
    height: 0.25rem;
    margin: 0.65rem auto 0;
    border-radius: 999px;
    background: #e2e8f0;
}

.ng-bottom-sheet__header {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
    padding: 0.65rem var(--ng-mobile-pad) 0.5rem;
    border-bottom: 1px solid #f1f5f9;
}

.ng-bottom-sheet__title {
    margin: 0;
    font-size: 1.0625rem;
    font-weight: 700;
    color: #0f172a;
}

.ng-bottom-sheet__close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: var(--ng-tap-min);
    height: var(--ng-tap-min);
    border: none;
    border-radius: 12px;
    background: #f8fafc;
    color: #64748b;
    cursor: pointer;
}

.ng-bottom-sheet__body {
    flex: 1;
    overflow-y: auto;
    overscroll-behavior: contain;
    -webkit-overflow-scrolling: touch;
    padding: 0.85rem var(--ng-mobile-pad);
}

.ng-bottom-sheet__footer {
    flex-shrink: 0;
    display: flex;
    gap: 0.5rem;
    padding: 0.75rem var(--ng-mobile-pad) calc(0.75rem + env(safe-area-inset-bottom, 0px));
    border-top: 1px solid #f1f5f9;
    background: #fff;
}

.ng-bottom-sheet__footer .map-btn,
.ng-bottom-sheet__footer .btn {
    flex: 1;
}

body.ng-sheet-open {
    overflow: hidden;
}

@media (prefers-reduced-motion: reduce) {
    .ng-bottom-sheet__panel,
    .ng-bottom-sheet__backdrop {
        transition: none;
    }

    .ng-bottom-sheet.is-open .ng-bottom-sheet__panel {
        transform: translateY(0);
    }
}

/* Filtros mapa: desktop inline */
@media (min-width: 769px) {
    .map-filter-sheet-head,
    .map-filter-sheet-footer {
        display: none;
    }

    .map-filter-sheet-inner {
        display: contents;
    }

    .map-filter-sheet-scroll {
        display: contents;
    }
}

/* —— Map mobile app mode —— */
@media (max-width: 768px) {
    .map-filter-actions-desktop {
        display: none !important;
    }

    .map-page.ng-map-app-mode .map-filter-sheet-head {
        display: flex;
    }
    .map-page.ng-map-app-mode {
        --map-nav-offset: 3.5rem;
        min-height: 100dvh;
        padding: 0;
    }

    .map-page.ng-map-app-mode .map-page__toolbar {
        padding: 0.5rem var(--ng-mobile-pad);
        top: 3.5rem;
    }

    .map-page.ng-map-app-mode .map-layout.is-map-view {
        flex: 1;
        min-height: 0;
    }

    .map-page.ng-map-app-mode .map-layout.is-map-view .map-canvas-wrap {
        min-height: calc(100dvh - var(--map-nav-offset, 3.5rem) - var(--map-toolbar-height, 3.75rem) - var(--ng-bottom-nav-clearance, 0px));
        border-radius: 0;
    }

    .map-page.ng-map-app-mode .map-layout.is-map-view .map-canvas {
        min-height: inherit;
    }

    .map-page.ng-map-app-mode .map-popup-card {
        display: none !important;
    }

    /* Filtros como bottom sheet */
    .map-page.ng-map-app-mode .map-filters {
        display: none;
        position: fixed;
        inset: 0;
        z-index: 110;
        margin: 0;
        padding: 0;
        border: none;
        border-radius: 0;
        background: transparent;
        flex-direction: column;
        justify-content: flex-end;
        pointer-events: none;
        visibility: hidden;
    }

    .map-page.ng-map-app-mode .map-filters.is-open {
        display: flex;
        pointer-events: auto;
        visibility: visible;
    }

    .map-page.ng-map-app-mode .map-filters.is-open::before {
        content: "";
        position: absolute;
        inset: 0;
        background: rgba(15, 23, 42, 0.45);
    }

    .map-page.ng-map-app-mode .map-filters > * {
        position: relative;
        z-index: 1;
    }

    .map-page.ng-map-app-mode .map-filters.is-open .map-filter-sheet-inner {
        position: relative;
        display: flex;
        flex-direction: column;
        max-height: 80vh;
        width: 100%;
        background: #fff;
        border-radius: var(--ng-sheet-radius) var(--ng-sheet-radius) 0 0;
        overflow: hidden;
        animation: ng-sheet-up 0.28s cubic-bezier(0.32, 0.72, 0, 1);
    }

    .map-page.ng-map-app-mode .map-filter-sheet-scroll {
        overflow-y: auto;
        padding: 0.85rem var(--ng-mobile-pad);
        flex: 1;
    }

    .map-page.ng-map-app-mode .map-filter-sheet-footer {
        display: flex;
        gap: 0.5rem;
        padding: 0.75rem var(--ng-mobile-pad) calc(0.75rem + env(safe-area-inset-bottom, 0px));
        border-top: 1px solid #f1f5f9;
        background: #fff;
    }

    .map-page.ng-map-app-mode .map-filter-sheet-footer .map-btn {
        flex: 1;
    }

    /* FAB lista / mapa */
    .ng-map-fab {
        position: fixed;
        left: 50%;
        transform: translateX(-50%);
        bottom: calc(var(--ng-bottom-nav-clearance) + 0.75rem);
        z-index: 85;
        display: inline-flex;
        align-items: center;
        gap: 0.4rem;
        min-height: var(--ng-tap-min);
        padding: 0 1.1rem;
        font-size: 0.875rem;
        font-weight: 700;
        color: #0f172a;
        background: #fff;
        border: 1px solid #e2e8f0;
        border-radius: 999px;
        box-shadow: 0 8px 28px -8px rgba(15, 23, 42, 0.25);
        cursor: pointer;
        -webkit-tap-highlight-color: transparent;
    }

    .ng-map-fab svg {
        width: 1.1rem;
        height: 1.1rem;
    }

    .ng-map-fab:active {
        transform: translateX(-50%) scale(0.97);
    }

    /* Store sheet content */
    .ng-map-store-sheet .map-popup-premium {
        border: none;
        box-shadow: none;
        padding: 0;
    }
}

@keyframes ng-sheet-up {
    from {
        transform: translateY(100%);
    }
    to {
        transform: translateY(0);
    }
}

@media (prefers-reduced-motion: reduce) {
    .map-page.ng-map-app-mode .map-filters.is-open .map-filter-sheet-inner {
        animation: none;
    }
}

/* Storefront: carrito sobre bottom nav */
@media (max-width: 768px) {
    .sfv-store.ng-has-bottom-nav {
        --sf-bottom-nav-clearance: var(--ng-bottom-nav-clearance);
    }

    .sfv-store.ng-has-bottom-nav.has-cart-bar {
        --sf-cart-bar-clearance: calc(4.75rem + var(--ng-bottom-nav-clearance));
    }

    .sfv-store.ng-has-bottom-nav .sf-cart-bar {
        bottom: var(--ng-bottom-nav-clearance);
    }

    .sfv-store.ng-has-bottom-nav.has-cart-bar .sfv-mobile-bar {
        bottom: calc(var(--ng-bottom-nav-clearance) + 3.35rem);
    }
}

/* Teléfonos pequeños */
@media (max-width: 430px) {
    :root {
        --ng-mobile-pad: 14px;
    }

    .ng-bottom-nav__item {
        font-size: 0.5625rem;
    }
}
