/**
 * Sikkim Supreme - Custom Mobile Bottom Navigation Bar, Explore Popup, and Full-Screen Live Search
 * Displayed exclusively on mobile devices (max-width: 768px)
 */

/* Hidden on desktop/tablets by default */
.bsec-mobile-nav-bar,
.bsec-mobile-explore-modal {
    display: none !important;
}

@media (max-width: 768px) {
    /* Safe offset for page body so fixed navigation never covers footer/content */
    body,
    body.has-bsec-mobile-nav {
        padding-bottom: calc(72px + env(safe-area-inset-bottom, 0px)) !important;
    }

    /* ====================================================
     * 1. BULLETPROOF FIXED BOTTOM NAVIGATION BAR
     * ==================================================== */
    .bsec-mobile-nav-bar {
        display: flex !important;
        position: fixed !important;
        position: -webkit-sticky;
        bottom: 0 !important;
        left: 0 !important;
        right: 0 !important;
        top: auto !important;
        width: 100% !important;
        max-width: 100vw !important;
        z-index: 999999 !important;
        background: #ffffff !important;
        border-top: 1px solid #eef2f6 !important;
        box-shadow: 0 -3px 18px rgba(15, 23, 42, 0.08) !important;
        height: auto !important;
        min-height: calc(58px + env(safe-area-inset-bottom, 0px)) !important;
        padding-top: 6px !important;
        padding-bottom: max(6px, env(safe-area-inset-bottom, 0px)) !important;
        padding-left: max(0px, env(safe-area-inset-left, 0px)) !important;
        padding-right: max(0px, env(safe-area-inset-right, 0px)) !important;
        align-items: center !important;
        justify-content: space-around !important;
        box-sizing: border-box !important;
        user-select: none !important;
        -webkit-user-select: none !important;
        -webkit-tap-highlight-color: transparent !important;
        /* Hardware Acceleration / Compositor Lock - Prevents scroll jitter and detachment */
        -webkit-transform: translate3d(0, 0, 0) !important;
        transform: translate3d(0, 0, 0) !important;
        -webkit-backface-visibility: hidden !important;
        backface-visibility: hidden !important;
        -webkit-perspective: 1000 !important;
        perspective: 1000 !important;
        will-change: transform !important;
        contain: layout style paint;
        touch-action: manipulation;
        pointer-events: auto !important;
        margin: 0 !important;
    }

    .bsec-mobile-nav-item {
        flex: 1 1 0 !important;
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        text-decoration: none !important;
        color: #64748b;
        position: relative !important;
        padding: 2px 0 2px !important;
        margin: 0 !important;
        background: transparent !important;
        border: none !important;
        outline: none !important;
        cursor: pointer;
        font-family: inherit;
        transition: color 0.15s ease;
        box-sizing: border-box !important;
        min-width: 0 !important;
    }

    .bsec-mobile-nav-item:focus {
        outline: none !important;
    }

    .bsec-mobile-nav-item:active {
        opacity: 0.75;
    }

    .bsec-mobile-nav-icon-wrap {
        position: relative;
        display: flex;
        align-items: center;
        justify-content: center;
        height: 24px;
        width: 24px;
        margin: 0 auto;
        flex-shrink: 0;
    }

    .bsec-mobile-nav-icon-wrap svg {
        width: 22px;
        height: 22px;
        stroke: currentColor;
        stroke-width: 1.85;
        stroke-linecap: round;
        stroke-linejoin: round;
        fill: none;
        transition: stroke 0.18s ease, transform 0.18s ease;
        display: block;
    }

    /* Active Indicator Dot under the icon */
    .bsec-mobile-nav-dot {
        width: 4px;
        height: 4px;
        border-radius: 50%;
        background-color: var(--bsec-mobile-nav-active, #1B4D3E);
        margin: 1px 0;
        opacity: 0;
        transform: scale(0);
        transition: transform 0.22s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.18s ease;
        flex-shrink: 0;
    }

    .bsec-mobile-nav-label {
        font-size: 11px !important;
        line-height: 1.15 !important;
        font-weight: 500 !important;
        letter-spacing: 0.01em !important;
        color: #64748b;
        transition: color 0.18s ease, font-weight 0.18s ease;
        white-space: nowrap !important;
        overflow: hidden !important;
        text-overflow: ellipsis !important;
        text-align: center !important;
        display: block !important;
    }

    /* Active State (Deep Forest Green #1B4D3E) */
    .bsec-mobile-nav-item.is-active {
        color: var(--bsec-mobile-nav-active, #1B4D3E);
    }

    .bsec-mobile-nav-item.is-active .bsec-mobile-nav-icon-wrap svg {
        stroke: var(--bsec-mobile-nav-active, #1B4D3E);
        transform: scale(1.05);
    }

    .bsec-mobile-nav-item.is-active .bsec-mobile-nav-label {
        color: var(--bsec-mobile-nav-active, #1B4D3E);
        font-weight: 600;
    }

    .bsec-mobile-nav-item.is-active .bsec-mobile-nav-dot {
        opacity: 1;
        transform: scale(1);
    }

    /* Cart Badge Count */
    .bsec-mobile-nav-badge {
        position: absolute;
        top: -4px;
        right: -9px;
        background: var(--bsec-mobile-nav-badge, #1B4D3E);
        color: #ffffff;
        font-size: 10px;
        font-weight: 700;
        line-height: 1;
        min-width: 17px;
        height: 17px;
        border-radius: 9999px;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0 4px;
        box-shadow: 0 1px 4px rgba(0, 0, 0, 0.25);
        transition: transform 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.2s ease;
        pointer-events: none;
    }

    .bsec-mobile-nav-badge.is-hidden,
    .bsec-mobile-nav-badge[data-count="0"] {
        display: none !important;
    }

    .bsec-mobile-nav-bar .bsec-mobile-nav-cart-btn {
        display: flex !important;
        visibility: visible !important;
    }

    /* Completely hide FluentCart default floating body cart icon on mobile */
    .fct-cart-drawer-open-btn,
    .fluent-cart-cart-floating-button,
    button[data-fluent-cart-cart-expand-button].fct-cart-drawer-open-btn {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }

    /* ====================================================
     * 2. EXPLORE POPUP MODAL (Matching Image 1)
     * ==================================================== */
    .bsec-mobile-explore-modal {
        position: fixed;
        inset: 0;
        z-index: 1000000 !important;
        display: none;
        align-items: flex-end;
        justify-content: center;
        padding: 0 16px calc(68px + env(safe-area-inset-bottom, 0px));
        box-sizing: border-box;
    }

    .bsec-mobile-explore-modal.is-open {
        display: flex !important;
    }

    .bsec-mobile-explore-backdrop {
        position: absolute;
        inset: 0;
        background: rgba(0, 0, 0, 0.65);
        backdrop-filter: blur(4px);
        -webkit-backdrop-filter: blur(4px);
        animation: bsecFadeIn 0.22s ease-out;
    }

    .bsec-mobile-explore-wrapper {
        position: relative;
        z-index: 2;
        width: 100%;
        max-width: 360px;
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 14px;
        animation: bsecSlideUpPop 0.28s cubic-bezier(0.16, 1, 0.3, 1);
    }

    .bsec-mobile-explore-card {
        width: 100%;
        background: #ffffff;
        border-radius: 22px;
        box-shadow: 0 16px 40px rgba(0, 0, 0, 0.25);
        padding: 20px 22px 18px;
        box-sizing: border-box;
    }

    .bsec-mobile-explore-list {
        display: flex;
        flex-direction: column;
    }

    .bsec-mobile-explore-row {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 12px 0;
        border-bottom: 1px solid #f1f5f9;
        text-decoration: none;
        transition: opacity 0.15s ease;
    }

    .bsec-mobile-explore-row:last-child {
        border-bottom: none;
    }

    .bsec-mobile-explore-row:active {
        opacity: 0.7;
    }

    .bsec-cat-name {
        font-size: 15px;
        font-weight: 500;
        color: #1e293b;
        letter-spacing: -0.01em;
    }

    .bsec-cat-count-badge {
        font-size: 12px;
        font-weight: 600;
        padding: 3px 9px;
        border-radius: 6px;
        min-width: 22px;
        text-align: center;
        line-height: 1.3;
    }

    .bsec-cat-count-badge.badge-gray {
        background: #8A8A8A;
        color: #ffffff;
    }

    .bsec-cat-count-badge.badge-terracotta {
        background: #C04A2F;
        color: #ffffff;
    }

    .bsec-mobile-explore-footer {
        padding-top: 14px;
        border-top: 1px solid #f1f5f9;
        text-align: center;
        margin-top: 4px;
    }

    .bsec-view-all-cats-link {
        display: inline-flex;
        align-items: center;
        justify-content: center;
        gap: 6px;
        font-size: 15px;
        font-weight: 600;
        color: var(--bsec-mobile-nav-active, #1B4D3E);
        text-decoration: none;
        transition: opacity 0.15s ease;
    }

    .bsec-view-all-cats-link:active {
        opacity: 0.75;
    }

    .bsec-view-all-cats-link svg {
        transition: transform 0.15s ease;
    }

    .bsec-view-all-cats-link:active svg {
        transform: translateX(3px);
    }

    /* Floating Circular Close Button (✕) */
    .bsec-mobile-explore-close-circle {
        width: 44px;
        height: 44px;
        border-radius: 50%;
        background: #262626;
        color: #ffffff;
        border: none;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        box-shadow: 0 4px 14px rgba(0, 0, 0, 0.35);
        outline: none;
        transition: transform 0.15s ease, background 0.15s ease;
    }

    .bsec-mobile-explore-close-circle:active {
        transform: scale(0.92);
        background: #0f172a;
    }
}

/* ====================================================
 * 3. BSEC SEARCH WIDGET ELEMENT (Header / Content Trigger)
 * ==================================================== */
.bsec-search-widget-root {
    width: 100%;
    max-width: var(--bsec-search-max-width, 360px);
}

.bsec-search-widget-trigger {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--bsec-search-bg, #f8fafc);
    border: 1px solid var(--bsec-search-border, #e2e8f0);
    border-radius: var(--bsec-search-radius, 9999px);
    padding: 8px 16px;
    height: 42px;
    cursor: pointer;
    font-family: inherit;
    text-align: left;
    color: #64748b;
    transition: all 0.18s ease;
    box-sizing: border-box;
    outline: none;
}

.bsec-search-widget-trigger:focus-visible {
    border-color: #1B4D3E;
    box-shadow: 0 0 0 3px rgba(27, 77, 62, 0.15);
}

.bsec-search-widget-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    color: #94a3b8;
    flex-shrink: 0;
}

.bsec-search-widget-text {
    flex: 1;
    font-size: 13.5px;
    color: #64748b;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-weight: 400;
}

.bsec-search-widget-shortcut {
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
}

.bsec-kbd-shortcut {
    display: inline-block;
    padding: 2px 6px;
    font-size: 11px;
    font-family: inherit;
    font-weight: 600;
    line-height: 1;
    color: #64748b;
    background: #e2e8f0;
    border-radius: 5px;
    box-shadow: 0 1px 0 rgba(0, 0, 0, 0.08);
}

/* ====================================================
 * 4. LIVE SEARCH MODAL & DIALOG (Shared Base)
 * ==================================================== */
.bsec-mobile-search-modal {
    position: fixed;
    inset: 0;
    z-index: 1000000 !important;
    display: none;
    box-sizing: border-box;
}

.bsec-search-modal-dialog {
    display: flex;
    flex-direction: column;
    background: #ffffff;
    box-sizing: border-box;
}

    /* Top Search Header Bar */
    .bsec-search-header-bar {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 12px 16px;
        background: #ffffff;
        border-bottom: 1px solid #f1f5f9;
        box-sizing: border-box;
    }

    .bsec-search-input-wrap {
        flex: 1;
        position: relative;
        display: flex;
        align-items: center;
        background: #f1f5f9;
        border-radius: 12px;
        height: 44px;
    }

    .bsec-search-icon-left {
        position: absolute;
        left: 12px;
        color: #94a3b8;
        display: flex;
        align-items: center;
        justify-content: center;
        pointer-events: none;
    }

    .bsec-mobile-search-input {
        width: 100%;
        height: 100%;
        border: none;
        background: transparent;
        padding: 0 36px 0 38px;
        font-size: 15px;
        color: #0f172a;
        outline: none;
        box-sizing: border-box;
        font-family: inherit;
    }

    .bsec-mobile-search-input::placeholder {
        color: #94a3b8;
        font-size: 14px;
    }

    .bsec-search-clear-btn {
        position: absolute;
        right: 10px;
        width: 20px;
        height: 20px;
        border-radius: 50%;
        background: #cbd5e1;
        color: #475569;
        border: none;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        padding: 0;
        outline: none;
        transition: background 0.15s ease;
    }

    .bsec-search-clear-btn:active {
        background: #94a3b8;
    }

    .bsec-search-cancel-btn {
        background: transparent;
        border: none;
        font-size: 15px;
        font-weight: 500;
        color: #334155;
        padding: 0 4px;
        cursor: pointer;
        outline: none;
        white-space: nowrap;
        font-family: inherit;
    }

    .bsec-search-cancel-btn:active {
        opacity: 0.6;
    }

    /* Scrollable Search Content */
    .bsec-search-scroll-body {
        flex: 1;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        padding: 18px 16px calc(30px + env(safe-area-inset-bottom, 0px));
        box-sizing: border-box;
    }

    /* State A: Initial Screen */
    .bsec-search-block {
        margin-bottom: 26px;
    }

    .bsec-search-block-header {
        display: flex;
        align-items: center;
        gap: 7px;
        font-size: 12px;
        font-weight: 700;
        letter-spacing: 0.05em;
        color: #334155;
        margin-bottom: 12px;
    }

    .bsec-trending-pills-wrap {
        display: flex;
        flex-wrap: wrap;
        gap: 8px;
    }

    .bsec-trending-pill {
        background: #f8fafc;
        border: 1px solid #e2e8f0;
        border-radius: 20px;
        padding: 8px 14px;
        font-size: 13px;
        font-weight: 500;
        color: #334155;
        cursor: pointer;
        outline: none;
        font-family: inherit;
        transition: all 0.15s ease;
    }

    .bsec-trending-pill:active {
        background: var(--bsec-mobile-nav-active, #1B4D3E);
        color: #ffffff;
        border-color: var(--bsec-mobile-nav-active, #1B4D3E);
        transform: scale(0.96);
    }

    /* Explore Collections 2-Column Grid */
    .bsec-collections-grid {
        display: grid;
        grid-template-columns: 1fr 1fr;
        gap: 10px;
    }

    .bsec-collection-card {
        background: #ffffff;
        border: 1px solid #e2e8f0;
        border-radius: 14px;
        padding: 14px;
        text-decoration: none;
        display: flex;
        flex-direction: column;
        gap: 4px;
        box-sizing: border-box;
        transition: border-color 0.15s ease, box-shadow 0.15s ease;
    }

    .bsec-collection-card:active {
        border-color: var(--bsec-mobile-nav-active, #1B4D3E);
        box-shadow: 0 2px 8px rgba(27, 77, 62, 0.1);
    }

    .bsec-col-name {
        font-size: 14px;
        font-weight: 600;
        color: #0f172a;
        line-height: 1.25;
    }

    .bsec-col-count {
        font-size: 12px;
        color: #64748b;
    }

    /* State B: Live Search Results (Matching Image 3) */
    .bsec-results-header-row {
        display: flex;
        align-items: center;
        justify-content: space-between;
        margin-bottom: 12px;
    }

    .bsec-results-title {
        font-size: 13px;
        font-weight: 700;
        color: #334155;
        letter-spacing: 0.03em;
    }

    .bsec-see-all-shop-link {
        display: flex;
        align-items: center;
        gap: 4px;
        font-size: 13px;
        font-weight: 600;
        color: var(--bsec-mobile-nav-active, #1B4D3E);
        text-decoration: none;
    }

    .bsec-see-all-shop-link:active {
        opacity: 0.7;
    }

    .bsec-live-results-card {
        background: #ffffff;
        border: 1px solid #e2e8f0;
        border-radius: 16px;
        overflow: hidden;
        box-sizing: border-box;
    }

    .bsec-live-products-list {
        display: flex;
        flex-direction: column;
    }

    /* Product Item in Search Results */
    .bsec-search-item {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 13px 14px;
        border-bottom: 1px solid #f1f5f9;
        box-sizing: border-box;
    }

    .bsec-search-item:last-child {
        border-bottom: none;
    }

    .bsec-search-thumb {
        width: 54px;
        height: 54px;
        border-radius: 10px;
        object-fit: cover;
        background: #f8fafc;
        border: 1px solid #f1f5f9;
        flex-shrink: 0;
    }

    .bsec-search-info {
        flex: 1;
        min-width: 0;
    }

    .bsec-search-title {
        font-size: 14px;
        font-weight: 600;
        color: #0f172a;
        line-height: 1.3;
        margin: 0 0 3px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        text-decoration: none;
        display: block;
    }

    .bsec-search-title:active {
        color: var(--bsec-mobile-nav-active, #1B4D3E);
    }

    .bsec-search-subtitle {
        font-size: 12px;
        color: #64748b;
        margin: 0 0 4px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .bsec-search-price-row {
        display: flex;
        align-items: baseline;
        gap: 6px;
    }

    .bsec-search-price {
        font-size: 14px;
        font-weight: 700;
        color: #0f172a;
    }

    .bsec-search-compare-price {
        font-size: 12px;
        text-decoration: line-through;
        color: #94a3b8;
    }

    /* + Add to Cart Button */
    .bsec-search-add-btn {
        background: var(--bsec-mobile-nav-active, #1B4D3E);
        color: #ffffff;
        border: none;
        border-radius: 8px;
        padding: 7px 13px;
        font-size: 12px;
        font-weight: 600;
        display: inline-flex;
        align-items: center;
        gap: 5px;
        cursor: pointer;
        flex-shrink: 0;
        outline: none;
        font-family: inherit;
        transition: background 0.15s ease, transform 0.1s ease;
    }

    .bsec-search-add-btn:active {
        transform: scale(0.95);
        opacity: 0.9;
    }

    .bsec-search-add-btn.is-loading {
        pointer-events: none;
        opacity: 0.8;
    }

    .bsec-search-add-btn.is-added {
        background: #15803d;
        color: #ffffff;
    }

    /* Search Spinner */
    .bsec-live-loading {
        padding: 30px;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        gap: 10px;
        color: #64748b;
        font-size: 13px;
    }

    .bsec-spinner {
        width: 24px;
        height: 24px;
        border: 2.5px solid #e2e8f0;
        border-top-color: var(--bsec-mobile-nav-active, #1B4D3E);
        border-radius: 50%;
        animation: bsecSpin 0.7s linear infinite;
    }

    /* Search Empty State */
    .bsec-live-empty {
        padding: 30px 20px;
        text-align: center;
    }

    .bsec-live-empty p {
        font-size: 14px;
        font-weight: 600;
        color: #0f172a;
        margin: 0 0 4px;
    }

    .bsec-live-empty small {
        font-size: 12px;
        color: #64748b;
    }

/* ====================================================
 * 5. SEARCH MODAL RESPONSIVE DISPLAY (Mobile vs Desktop)
 * ==================================================== */

/* Mobile: Full-Screen App Takeover */
@media (max-width: 768px) {
    .bsec-mobile-search-modal {
        flex-direction: column;
        background: #ffffff;
    }

    .bsec-mobile-search-modal.is-open {
        display: flex !important;
        animation: bsecFadeIn 0.2s ease-out;
    }

    .bsec-search-modal-dialog {
        width: 100%;
        height: 100%;
    }

    .bsec-cancel-text {
        display: inline;
    }

    .bsec-cancel-esc {
        display: none !important;
    }
}

/* Desktop: Sleek Spotlight Dialog with Backdrop Blur */
@media (min-width: 769px) {
    .bsec-mobile-search-modal {
        align-items: flex-start;
        justify-content: center;
        background: rgba(15, 23, 42, 0.55);
        backdrop-filter: blur(8px);
        -webkit-backdrop-filter: blur(8px);
        padding: 75px 20px 40px;
    }

    .bsec-mobile-search-modal.is-open {
        display: flex !important;
        animation: bsecSpotlightBackdrop 0.2s ease-out;
    }

    .bsec-search-modal-dialog {
        width: 100%;
        max-width: 680px;
        max-height: calc(85vh - 75px);
        border-radius: 20px;
        box-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.35), 0 0 0 1px rgba(0, 0, 0, 0.08);
        overflow: hidden;
        animation: bsecSpotlightSlideDown 0.22s cubic-bezier(0.16, 1, 0.3, 1);
    }

    .bsec-search-header-bar {
        padding: 16px 20px;
        gap: 14px;
    }

    .bsec-search-input-wrap {
        height: 48px;
        border-radius: 14px;
    }

    .bsec-mobile-search-input {
        font-size: 16px;
    }

    .bsec-cancel-text {
        display: none !important;
    }

    .bsec-cancel-esc {
        display: inline-flex !important;
        align-items: center;
        justify-content: center;
        padding: 4px 8px;
        font-size: 11px;
        font-weight: 700;
        color: #64748b;
        background: #f1f5f9;
        border: 1px solid #e2e8f0;
        border-radius: 6px;
        box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
        cursor: pointer;
        transition: background 0.15s ease, color 0.15s ease;
    }

    .bsec-search-cancel-btn:hover .bsec-cancel-esc {
        background: #e2e8f0;
        color: #0f172a;
    }

    .bsec-search-scroll-body {
        padding: 20px 22px 28px;
        max-height: 520px;
        overflow-y: auto;
    }

    .bsec-search-scroll-body::-webkit-scrollbar {
        width: 6px;
    }

    .bsec-search-scroll-body::-webkit-scrollbar-track {
        background: transparent;
    }

    .bsec-search-scroll-body::-webkit-scrollbar-thumb {
        background: #cbd5e1;
        border-radius: 4px;
    }

    .bsec-search-scroll-body::-webkit-scrollbar-thumb:hover {
        background: #94a3b8;
    }
}

/* Keyframes */
@keyframes bsecFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes bsecSpotlightBackdrop {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes bsecSpotlightSlideDown {
    from {
        opacity: 0;
        transform: translateY(-16px) scale(0.98);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes bsecSlideUpPop {
    from {
        opacity: 0;
        transform: translateY(24px) scale(0.96);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

@keyframes bsecSpin {
    to { transform: rotate(360deg); }
}
