/**
 * Battery Shop - Mobile Optimization
 * Hamburger menu for filters & sort on mobile
 * @package BatteryShop
 */

/* ========== Mobile Hamburger Menu (≤ 992px) ========== */

/* Hamburger toggle button — hidden on desktop, very prominent on mobile */
.bs-mobile-fab {
    display: none;
    position: fixed;
    bottom: 24px;
    right: 20px;
    width: 64px;
    height: 64px;
    background: linear-gradient(135deg, #f5a623 0%, #ff6b35 100%);
    color: #fff;
    border: 3px solid #fff;
    border-radius: 50%;
    box-shadow:
        0 8px 24px rgba(245,166,35,0.55),
        0 4px 12px rgba(0,0,0,0.25),
        inset 0 -3px 6px rgba(0,0,0,0.15);
    cursor: pointer;
    z-index: 9999;
    align-items: center;
    justify-content: center;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    animation: bs-fab-attention 2s ease-in-out infinite;
}
.bs-mobile-fab:hover {
    background: linear-gradient(135deg, #ffc857 0%, #ff6b35 100%);
    transform: scale(1.12) rotate(-8deg);
    box-shadow:
        0 12px 32px rgba(245,166,35,0.7),
        0 6px 16px rgba(0,0,0,0.3),
        inset 0 -3px 6px rgba(0,0,0,0.15);
}
.bs-mobile-fab:active {
    transform: scale(0.92);
    transition: transform 0.1s;
}
.bs-mobile-fab svg {
    width: 32px;
    height: 32px;
    fill: currentColor;
    filter: drop-shadow(0 1px 2px rgba(0,0,0,0.3));
}
.bs-mobile-fab__badge {
    position: absolute;
    top: -4px;
    left: -4px;
    background: linear-gradient(135deg, #e74c3c 0%, #c0392b 100%);
    color: #fff;
    border-radius: 50%;
    min-width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.78rem;
    font-weight: 700;
    padding: 0 6px;
    border: 2.5px solid #fff;
    box-shadow: 0 3px 8px rgba(0,0,0,0.35);
}

/* Strong attention-grabbing animation */
@keyframes bs-fab-attention {
    0%, 100% {
        box-shadow:
            0 8px 24px rgba(245,166,35,0.55),
            0 4px 12px rgba(0,0,0,0.25),
            inset 0 -3px 6px rgba(0,0,0,0.15),
            0 0 0 0 rgba(245,166,35,0.6);
        transform: scale(1);
    }
    25% {
        transform: scale(1.05);
    }
    50% {
        box-shadow:
            0 8px 24px rgba(245,166,35,0.55),
            0 4px 12px rgba(0,0,0,0.25),
            inset 0 -3px 6px rgba(0,0,0,0.15),
            0 0 0 16px rgba(245,166,35,0);
        transform: scale(1);
    }
    75% {
        transform: scale(1.03);
    }
}

/* Optional label tooltip — visible text next to FAB */
.bs-mobile-fab__label {
    position: absolute;
    right: 70px;
    top: 50%;
    transform: translateY(-50%) translateX(8px);
    background: var(--bs-primary-dark);
    color: #fff;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.82rem;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: all 0.3s ease;
    box-shadow: 0 3px 10px rgba(0,0,0,0.25);
}
.bs-mobile-fab__label::after {
    content: '';
    position: absolute;
    right: -5px;
    top: 50%;
    transform: translateY(-50%);
    border: 5px solid transparent;
    border-right-color: var(--bs-primary-dark);
}
.bs-mobile-fab:hover .bs-mobile-fab__label {
    opacity: 1;
    transform: translateY(-50%) translateX(0);
}

/* Make sure FAB stays on top of everything */
.bs-mobile-fab,
.bs-mobile-overlay,
.bs-mobile-drawer {
    z-index: 99999 !important;
}

/* Overlay backdrop */
.bs-mobile-overlay {
    display: none;
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,0.5);
    z-index: 999;
    opacity: 0;
    transition: opacity 0.3s;
}
.bs-mobile-overlay.is-active {
    display: block;
    opacity: 1;
}

/* Drawer panel */
.bs-mobile-drawer {
    position: fixed;
    top: 0;
    right: -78%;
    width: 78%;
    max-width: 340px;
    height: 100vh;
    background: #fff;
    z-index: 1000;
    box-shadow: -4px 0 20px rgba(0,0,0,0.15);
    transition: right 0.3s ease, transform 0.3s ease;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    display: flex;
    flex-direction: column;
    will-change: transform, right;
}
.bs-mobile-drawer.is-active { right: 0; }
/* During drag — disable transition for smooth follow */
.bs-mobile-drawer.is-dragging {
    transition: none;
}

.bs-mobile-drawer__header {
    background: linear-gradient(135deg, var(--bs-primary) 0%, var(--bs-primary-light) 100%);
    color: #fff;
    padding: 18px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-shrink: 0;
}
.bs-mobile-drawer__title {
    font-size: 1.05rem;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 8px;
}
.bs-mobile-drawer__title svg { fill: currentColor; }
.bs-mobile-drawer__close {
    background: rgba(255,255,255,0.2);
    border: none;
    color: #fff;
    width: 34px;
    height: 34px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--bs-transition);
}
.bs-mobile-drawer__close:hover { background: rgba(255,255,255,0.3); }
.bs-mobile-drawer__close svg { width: 18px; height: 18px; fill: currentColor; }

/* Drawer body — scrollable area (between header and footer) */
.bs-mobile-drawer__body {
    padding: 16px;
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Sticky footer at the bottom of the drawer */
.bs-mobile-drawer__footer {
    flex-shrink: 0;
    background: #fff;
    border-top: 1px solid var(--bs-border);
    padding: 12px 16px;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.05);
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    position: sticky;
    bottom: 0;
    z-index: 5;
}

/* Mobile sort section inside drawer */
.bs-mobile-sort {
    margin-bottom: 18px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--bs-border);
}
.bs-mobile-sort__title {
    font-size: 0.9rem;
    font-weight: 700;
    color: var(--bs-primary-dark);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 6px;
}
.bs-mobile-sort__title svg { fill: var(--bs-secondary); width: 18px; height: 18px; }
.bs-mobile-sort__select {
    width: 100%;
    padding: 10px 35px 10px 12px;
    border: 1px solid var(--bs-border);
    border-radius: var(--bs-radius);
    font-family: var(--bs-font);
    font-size: 0.9rem;
    background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath fill='%237f8c8d' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E") no-repeat left 12px center;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    cursor: pointer;
    direction: rtl;
    color: var(--bs-text);
}

/* Mobile filters inside drawer — clean, modern styling */
.bs-mobile-drawer .bs-filters {
    width: 100%;
    background: transparent;
    box-shadow: none;
    padding: 0;
    border: none;
    border-radius: 0;
}

/* Each filter section as a clean card */
.bs-mobile-drawer .bs-filters__section {
    border: 1px solid var(--bs-border);
    border-radius: var(--bs-radius);
    margin-bottom: 12px;
    overflow: hidden;
    background: #fff;
    transition: var(--bs-transition);
}
.bs-mobile-drawer .bs-filters__section.bs-filters__section--open {
    border-color: var(--bs-secondary-light);
}

/* Hide the original filter header (we have our own in drawer) */
.bs-mobile-drawer .bs-filters__header { display: none; }

/* Filter title — bigger touch target */
.bs-mobile-drawer .bs-filters__title {
    padding: 14px 16px;
    background: var(--bs-bg);
    margin: 0;
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--bs-primary-dark);
    cursor: pointer;
    user-select: none;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: var(--bs-transition);
}
.bs-mobile-drawer .bs-filters__title:active {
    background: #f0f0f0;
}
.bs-mobile-drawer .bs-filters__title svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}
.bs-mobile-drawer .bs-filters__toggle-arrow {
    margin-right: auto;
    transition: transform 0.3s;
}
.bs-mobile-drawer .bs-filters__section:not(.bs-filters__section--open) .bs-filters__toggle-arrow {
    transform: rotate(180deg);
}

/* Filter options — bigger touch targets */
.bs-mobile-drawer .bs-filters__options {
    padding: 8px 12px;
    max-height: 280px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Each checkbox option — bigger, easier to tap */
.bs-mobile-drawer .bs-filters__option {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 8px;
    border-bottom: 1px solid #f5f5f5;
    cursor: pointer;
    transition: background 0.2s;
}
.bs-mobile-drawer .bs-filters__option:last-child { border-bottom: none; }
.bs-mobile-drawer .bs-filters__option:active {
    background: var(--bs-bg);
}
.bs-mobile-drawer .bs-filters__option input[type="checkbox"] {
    width: 22px;
    height: 22px;
    flex-shrink: 0;
    cursor: pointer;
    accent-color: var(--bs-secondary);
    margin: 0;
}
.bs-mobile-drawer .bs-filters__option label {
    flex: 1;
    font-size: 0.92rem;
    color: var(--bs-text);
    cursor: pointer;
    margin: 0;
    line-height: 1.5;
}
.bs-mobile-drawer .bs-filters__option-count {
    font-size: 0.78rem;
    color: var(--bs-text-light);
    background: var(--bs-bg);
    padding: 2px 8px;
    border-radius: 10px;
    flex-shrink: 0;
}

/* Price range slider — bigger touch targets */
.bs-mobile-drawer .bs-range-slider {
    padding: 20px 0 10px;
}
.bs-mobile-drawer .bs-range-slider__input {
    height: 36px;
}
.bs-mobile-drawer .bs-range-slider__input::-webkit-slider-thumb {
    width: 28px;
    height: 28px;
}
.bs-mobile-drawer .bs-range-slider__input::-moz-range-thumb {
    width: 28px;
    height: 28px;
}
.bs-mobile-drawer .bs-range-slider__labels {
    font-size: 0.88rem;
    margin-top: 8px;
    display: flex;
    flex-direction: column;
    gap: 4px;
    text-align: center;
}
.bs-mobile-drawer .bs-range-slider__label-sep {
    font-size: 0.78rem;
    color: var(--bs-text-light);
}

/* Reset button — make it prominent at bottom of drawer */
.bs-mobile-drawer .bs-filters__reset {
    display: none !important; /* Hide the small one in header */
}

/* Apply & Reset buttons — side by side, in sticky footer */
.bs-mobile-drawer-apply,
.bs-mobile-drawer-reset {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 13px 8px;
    border: none;
    border-radius: var(--bs-radius);
    font-family: var(--bs-font);
    font-size: 0.92rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.25s ease;
    text-align: center;
}
.bs-mobile-drawer-apply {
    background: linear-gradient(135deg, var(--bs-accent-green) 0%, #219a52 100%);
    color: #fff;
    box-shadow: 0 3px 10px rgba(39,174,96,0.3);
}
.bs-mobile-drawer-apply:hover {
    background: linear-gradient(135deg, #219a52 0%, #1e8e48 100%);
    transform: translateY(-1px);
    box-shadow: 0 5px 14px rgba(39,174,96,0.4);
}
.bs-mobile-drawer-apply:active { transform: translateY(0); }

.bs-mobile-drawer-reset {
    background: #fff;
    color: var(--bs-accent-red);
    border: 1.5px solid var(--bs-accent-red);
}
.bs-mobile-drawer-reset:hover {
    background: var(--bs-accent-red);
    color: #fff;
}

/* ========== Mobile behavior (≤ 992px) ========== */
@media (max-width: 992px) {
    /* Show hamburger FAB — CRITICAL: must always be visible */
    .bs-mobile-fab {
        display: flex !important;
        opacity: 1 !important;
        visibility: visible !important;
    }

    /* Hide the homepage sidebar filters (they appear in drawer instead) */
    .bs-home-sidebar .bs-filter-toggle { display: none; }
    .bs-home-sidebar .bs-filters { display: none; }

    /* Show homepage sort toolbar inline on mobile too (in addition to drawer) */
    .bs-home-toolbar { display: flex !important; flex-wrap: wrap; gap: 8px; }

    /* Show the shop sidebar on mobile? No — it goes into drawer */
    .bs-shop-layout .bs-filters:not(.bs-mobile-drawer .bs-filters) { display: none; }
    .bs-shop-layout { flex-direction: column; }

    /* Reorder: products first, sidebar hidden (in drawer) */
    .bs-home-layout { flex-direction: column; }
    .bs-home-main { order: 1; }
    .bs-home-sidebar { order: 2; width: 100%; position: static; max-height: none; }

    /* Shop layout — products first */
    .bs-shop-main { order: 1; }

    /* Make sure the main nav menu toggle works at tablet width too */
    .bs-mobile-toggle { display: flex !important; }

    /* Main menu — slide-down panel when active */
    .bs-main-menu {
        display: none;
        position: absolute;
        top: 100%;
        right: 0;
        left: 0;
        background: var(--bs-header-bg);
        z-index: 999;
        box-shadow: 0 4px 12px rgba(0,0,0,0.15);
        max-height: 70vh;
        overflow-y: auto;
    }
    .bs-main-menu.active {
        display: block;
        animation: bs-menu-slide-down 0.25s ease;
    }
    @keyframes bs-menu-slide-down {
        from { opacity: 0; transform: translateY(-10px); }
        to { opacity: 1; transform: translateY(0); }
    }
    .bs-main-menu ul {
        flex-direction: column !important;
        padding: 8px 0;
    }
    .bs-main-menu > ul > li {
        width: 100%;
    }
    .bs-main-menu a {
        padding: 14px 18px !important;
        border-bottom: 1px solid rgba(255,255,255,0.08);
        font-size: 0.95rem;
    }
    .bs-main-menu .sub-menu {
        position: static !important;
        box-shadow: none !important;
        background: rgba(0,0,0,0.15) !important;
        padding-right: 20px !important;
        display: block !important;
        min-width: 100% !important;
    }
    .bs-main-menu .sub-menu a {
        padding: 10px 18px !important;
        font-size: 0.88rem;
    }

    /* Category menu — make it full width and collapsible */
    .bs-cat-menu { min-width: 100% !important; }
    .bs-cat-menu__dropdown {
        position: static !important;
        max-height: 50vh;
        overflow-y: auto;
    }

    /* Shop sort toolbar — make it sticky at top */
    .bs-shop-main > div:first-child:has([data-bs-sort]) {
        position: sticky;
        top: 0;
        z-index: 50;
        background: var(--bs-white);
        padding: 10px 14px;
        border-radius: var(--bs-radius);
        box-shadow: 0 2px 8px rgba(0,0,0,0.08);
        margin-bottom: 12px;
    }
}

/* ========== Tablet/mobile breakpoint (≤ 768px) ========== */
@media (max-width: 768px) {
    /* Header layout adjustments */
    .bs-header__inner { flex-wrap: wrap; gap: 10px; }
    .bs-search {
        order: 3;
        max-width: 100% !important;
        flex: 0 0 100% !important;
        margin-top: 8px;
    }
    .bs-header__logo img { max-height: 45px; }
    .bs-header__actions { gap: 8px; }
    .bs-header__action { padding: 6px; }
    .bs-header__user-label { display: none; }

    /* Sticky wrapper — allow content below to scroll */
    .bs-sticky-wrapper { position: relative; }
    .bs-nav { position: relative; }

    /* Topbar adjustments */
    .bs-topbar__inner { flex-direction: column; gap: 8px; }
    .bs-topbar__announcement { font-size: 0.78rem; }
}

/* ========== Smaller mobile (≤ 600px) ========== */
@media (max-width: 600px) {
    .bs-mobile-fab {
        width: 52px;
        height: 52px;
        bottom: 15px;
        right: 15px;
    }
    .bs-mobile-fab svg { width: 24px; height: 24px; }

    .bs-mobile-drawer {
        width: 82%;
        right: -82%;
        max-width: 320px;
    }
    .bs-mobile-drawer__header { padding: 14px 16px; }
    .bs-mobile-drawer__body { padding: 12px; }
}

/* ========== Very small mobile (≤ 400px) ========== */
@media (max-width: 400px) {
    .bs-mobile-fab {
        width: 48px;
        height: 48px;
    }
    .bs-mobile-drawer { width: 88%; right: -88%; max-width: 300px; }
}

/* ========== My Account Mobile (≤ 768px) ========== */
@media (max-width: 768px) {
    .bs-myaccount-header {
        padding: 16px 16px;
        gap: 12px;
    }
    .bs-myaccount-header__avatar {
        width: 50px;
        height: 50px;
        font-size: 1.2rem;
    }
    .bs-myaccount-header__title { font-size: 1.1rem; }
    .bs-myaccount-header__email { font-size: 0.82rem; }

    /* Horizontal scrollable tabs */
    .bs-myaccount-nav {
        padding: 6px;
        gap: 2px;
    }
    .bs-myaccount-nav__item {
        padding: 10px 12px;
        font-size: 0.82rem;
    }
    .bs-myaccount-nav__item svg { width: 16px; height: 16px; }

    .bs-myaccount-content { padding: 16px; }

    /* Stack address cards */
    .bs-myaccount-content .woocommerce-Addresses {
        grid-template-columns: 1fr;
    }

    /* Responsive orders table */
    .bs-myaccount-content .woocommerce-orders-table thead { display: none; }
    .bs-myaccount-content .woocommerce-orders-table,
    .bs-myaccount-content .woocommerce-orders-table tbody,
    .bs-myaccount-content .woocommerce-orders-table tr,
    .bs-myaccount-content .woocommerce-orders-table td {
        display: block;
        width: 100%;
    }
    .bs-myaccount-content .woocommerce-orders-table tr {
        border: 1px solid var(--bs-border);
        border-radius: var(--bs-radius);
        margin-bottom: 12px;
        padding: 8px;
    }
    .bs-myaccount-content .woocommerce-orders-table td {
        border: none;
        padding: 6px 4px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        gap: 10px;
    }
    .bs-myaccount-content .woocommerce-orders-table td:before {
        content: attr(data-title);
        font-weight: 600;
        color: var(--bs-text-light);
        font-size: 0.82rem;
    }
}

/* ========== Checkout mobile (≤ 768px) ========== */
@media (max-width: 768px) {
    .bs-checkout-grid,
    .bs-cart-grid,
    .bs-vo-summary-grid,
    .bs-thankyou-grid {
        grid-template-columns: 1fr !important;
    }
    .bs-checkout-fields { grid-template-columns: 1fr !important; }
    .bs-thankyou-customer { grid-template-columns: 1fr !important; }

    /* Show summary FIRST on mobile (so user sees totals) */
    .bs-checkout-summary,
    .bs-cart-summary,
    .bs-vo-card--info {
        order: -1;
        position: static !important;
    }

    .bs-checkout-item,
    .bs-cart-item {
        grid-template-columns: 70px 1fr !important;
        grid-template-areas:
            "thumb info"
            "qty qty"
            "subtotal remove" !important;
        gap: 10px !important;
    }

    /* Center the quantity selector in its own row */
    .bs-cart-item .bs-cart-item__qty,
    .bs-checkout-item .bs-cart-item__qty {
        grid-area: qty;
        justify-self: center !important; /* center horizontally */
        margin: 0 auto;
    }
}

/* ========== Product grid mobile optimization ========== */
@media (max-width: 600px) {
    .bs-products-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 10px !important;
    }
    .bs-product-card__thumb { height: 140px !important; }
    .bs-product-card__info { padding: 8px !important; }
    .bs-product-card__name { font-size: 0.8rem !important; }
    .bs-product-card__price { font-size: 0.88rem !important; }
}

/* ========== Features banner — 2 columns on mobile ========== */
@media (max-width: 768px) {
    .bs-features-grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 12px !important;
    }
    .bs-features-grid > div {
        padding: 18px 12px !important;
    }
    .bs-features-grid h4 {
        font-size: 0.88rem !important;
    }
    .bs-features-grid p {
        font-size: 0.75rem !important;
    }
}

@media (max-width: 400px) {
    .bs-features-grid > div {
        padding: 14px 8px !important;
    }
    .bs-features-grid h4 {
        font-size: 0.82rem !important;
    }
}

/* ========== Header mobile optimization ========== */
/* (Moved to main mobile breakpoint above) ========== */

/* ========== Footer mobile ========== */
@media (max-width: 992px) {
    .bs-footer__grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 22px !important;
    }
    .bs-footer__top { padding: 28px 0 !important; }
    .bs-footer__col { text-align: right !important; }
}

@media (max-width: 576px) {
    .bs-footer__grid {
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 18px !important;
    }
    .bs-footer__badges { justify-content: center; }
    .bs-footer__col { text-align: center !important; }
    .bs-footer__contact-item { justify-content: center; }
}

@media (max-width: 400px) {
    .bs-footer__grid {
        grid-template-columns: 1fr !important;
    }
}

/* Prevent body scroll when drawer is open */
body.bs-drawer-open {
    overflow: hidden;
}

/* =====================================================================
   نیروکده — اصلاحات ظاهری سبد خرید، صفحه محصول و تسویه‌حساب (2026-11)
   ===================================================================== */

/* وسط‌چین عمودی عدد تعداد (سبد خرید، صفحه محصول و تسویه‌حساب) */
.bs-cart-item__qty-input,
.bs-single-product__qty-input,
.bs-checkout-item .bs-cart-item__qty-input {
    padding: 0 !important;
    line-height: 38px !important;
    height: 38px !important;
    -moz-appearance: textfield;
    appearance: textfield;
}

/* ترتیب سکشن‌های سبد خرید در موبایل: محصولات (۱) → کد تخفیف (۲) → خلاصه سفارش (آخر) */
@media (max-width: 992px) {
    .bs-cart-main { display: flex; flex-direction: column; }
    .bs-cart-main > .bs-cart-section:not(.bs-cart-section--coupon) { order: 1; }
    .bs-cart-main > .bs-cart-section--coupon { order: 2; }
    html body .bs-cart-summary { order: 0 !important; }

    .bs-cart-main > .bs-cart-section:not(.bs-cart-section--coupon) .bs-cart-section__num { font-size: 0; }
    .bs-cart-main > .bs-cart-section:not(.bs-cart-section--coupon) .bs-cart-section__num::before {
        content: '۱'; font-size: .85rem; font-weight: 700;
    }
    .bs-cart-main > .bs-cart-section--coupon .bs-cart-section__num { font-size: 0; }
    .bs-cart-main > .bs-cart-section--coupon .bs-cart-section__num::before {
        content: '۲'; font-size: .85rem; font-weight: 700;
    }

    /* تسویه‌حساب: خلاصه حساب بعد از اطلاعات گیرنده و اقلام سفارش */
    html body .bs-checkout-summary { order: 0 !important; }
}
