/**
 * DFS Mobile Experience (Estilo Mercado Libre)
 * Bottom Navigation Bar + Drawer Propio de Categorías
 */

/* =========================================================
   1. VISIBILIDAD RESPONSIVA (Solo Móvil y Tablet <= 920px)
   ========================================================= */
@media (min-width: 921px) {
    #dfs-bottom-nav,
    #dfs-category-drawer,
    #dfs-category-drawer-overlay {
        display: none !important;
    }
}

@media (max-width: 920px) {
    /* Compensación en el cuerpo de la página para que la barra inferior no tape el contenido */
    body {
        padding-bottom: calc(62px + env(safe-area-inset-bottom, 0px)) !important;
    }

    /* Reposicionamiento inteligente de botones flotantes (WhatsApp, Instagram, Subir) */
    .joinchat,
    .wa__popup_chat_box,
    .wa__btn_popup,
    [class*="whatsapp"],
    .ct-back-to-top,
    .qlwapp-toggle {
        bottom: calc(75px + env(safe-area-inset-bottom, 0px)) !important;
        transition: bottom 0.2s ease !important;
    }

    /* =========================================================
       2. BOTTOM NAVIGATION BAR (Barra Inferior Fija)
       ========================================================= */
    .dfs-bottom-bar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        width: 100%;
        height: calc(58px + env(safe-area-inset-bottom, 0px));
        padding-bottom: env(safe-area-inset-bottom, 0px);
        background: #ffffff;
        display: flex;
        align-items: center;
        justify-content: space-around;
        box-shadow: 0 -2px 12px rgba(0, 0, 0, 0.08);
        border-top: 1px solid #eaeaea;
        z-index: 99990;
        user-select: none;
        -webkit-tap-highlight-color: transparent;
    }

    .dfs-bottom-item {
        flex: 1;
        height: 100%;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        text-decoration: none;
        background: transparent;
        border: none;
        padding: 4px 0;
        color: #555555;
        font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
        font-size: 10px;
        font-weight: 500;
        letter-spacing: 0.2px;
        transition: color 0.15s ease, transform 0.15s ease;
        cursor: pointer;
    }

    .dfs-bottom-item:active {
        transform: scale(0.92);
    }

    .dfs-bottom-item.is-active {
        color: #d62828; /* Rojo insignia de Duty Free */
        font-weight: 700;
    }

    .dfs-bottom-item.is-active svg {
        stroke: #d62828;
    }

    .dfs-bottom-icon {
        position: relative;
        display: flex;
        align-items: center;
        justify-content: center;
        margin-bottom: 2px;
    }

    .dfs-bottom-icon svg {
        width: 22px;
        height: 22px;
        stroke: #4a4a4a;
        transition: stroke 0.15s ease;
    }

    .dfs-bottom-label {
        font-size: 10.5px;
        line-height: 1.1;
    }

    /* Badge dinámico de carrito */
    .dfs-cart-badge {
        position: absolute;
        top: -4px;
        right: -9px;
        background-color: #d62828;
        color: #ffffff;
        font-size: 10px;
        font-weight: 700;
        line-height: 1;
        padding: 2px 5px;
        border-radius: 10px;
        border: 2px solid #ffffff;
        display: none;
        min-width: 16px;
        text-align: center;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.2);
    }

    .dfs-cart-badge.has-items,
    .dfs-cart-badge:not(:empty):not(:contains("0")) {
        display: inline-block;
    }

    /* =========================================================
       3. DRAWER LATERAL PROPIO DE CATEGORÍAS (App Style)
       ========================================================= */
    .dfs-drawer-overlay {
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        backdrop-filter: blur(2px);
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s cubic-bezier(0.16, 1, 0.3, 1);
        z-index: 99998;
    }

    .dfs-drawer-overlay.is-open {
        opacity: 1;
        pointer-events: auto;
    }

    .dfs-drawer {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: min(340px, 86vw);
        height: 100%;
        background: #ffffff;
        z-index: 99999;
        display: flex;
        flex-direction: column;
        transform: translateX(-100%);
        transition: transform 0.32s cubic-bezier(0.16, 1, 0.3, 1);
        box-shadow: 8px 0 25px rgba(0, 0, 0, 0.18);
        overflow: hidden;
    }

    .dfs-drawer.is-open {
        transform: translateX(0);
    }

    /* Cabecera del Drawer */
    .dfs-drawer-header {
        background: linear-gradient(135deg, #d62828 0%, #b71c1c 100%);
        color: #ffffff;
        padding: calc(18px + env(safe-area-inset-top, 0px)) 16px 16px 16px;
        display: flex;
        align-items: center;
        justify-content: space-between;
    }

    .dfs-drawer-greeting {
        display: block;
        font-size: 11px;
        text-transform: uppercase;
        letter-spacing: 0.8px;
        opacity: 0.9;
        font-weight: 500;
    }

    .dfs-drawer-title {
        margin: 2px 0 0 0;
        font-size: 20px;
        font-weight: 800;
        color: #ffffff;
        font-family: inherit;
    }

    .dfs-close-btn {
        background: rgba(255, 255, 255, 0.2);
        border: none;
        color: #ffffff;
        width: 34px;
        height: 34px;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: background 0.2s;
    }

    .dfs-close-btn:active {
        background: rgba(255, 255, 255, 0.4);
    }

    /* Cuerpo con scroll del Drawer */
    .dfs-drawer-body {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 14px 16px 80px 16px;
    }

    /* Buscador integrado en el Drawer */
    .dfs-drawer-search {
        margin-bottom: 16px;
    }

    .dfs-search-wrapper {
        position: relative;
        display: flex;
        align-items: center;
        background: #f4f5f7;
        border-radius: 24px;
        padding: 8px 14px;
        border: 1px solid #e2e4e8;
    }

    .dfs-search-wrapper input {
        border: none;
        background: transparent;
        outline: none;
        font-size: 13.5px;
        width: 100%;
        padding-left: 8px;
        color: #222222;
    }

    .dfs-search-wrapper input::placeholder {
        color: #888888;
    }

    .dfs-search-icon {
        stroke: #777777;
        flex-shrink: 0;
    }

    /* Títulos de sección */
    .dfs-section-title {
        font-size: 11px;
        font-weight: 700;
        color: #8c8c8c;
        letter-spacing: 0.6px;
        margin: 12px 0 8px 6px;
    }

    .dfs-section-divider {
        height: 1px;
        background: #f0f0f0;
        margin: 16px 0;
    }

    /* Elementos de categoría */
    .dfs-category-item {
        display: flex;
        align-items: center;
        padding: 11px 12px;
        margin-bottom: 4px;
        border-radius: 10px;
        text-decoration: none;
        color: #2b2b2b;
        font-size: 14px;
        font-weight: 600;
        transition: background 0.15s ease;
    }

    .dfs-category-item:active {
        background: #f5f6f8;
    }

    .dfs-cat-icon {
        font-size: 18px;
        margin-right: 12px;
        width: 24px;
        display: inline-flex;
        justify-content: center;
    }

    .dfs-cat-text {
        flex: 1;
    }

    .dfs-cat-arrow {
        color: #b5b5b5;
        font-size: 18px;
        font-weight: 300;
    }

    /* Item destacado (Ofertas) */
    .dfs-item-highlight {
        background: #fff5f5;
        color: #d62828;
    }

    .dfs-item-highlight:active {
        background: #ffe3e3;
    }

    .dfs-badge-off {
        background: #d62828;
        color: #ffffff;
        font-size: 9.5px;
        font-weight: 800;
        padding: 2px 7px;
        border-radius: 6px;
        letter-spacing: 0.5px;
    }
}
