/*
 * Mobile Shop Utility Bar Styles
 * Active on mobile/tablet (max-width: 991px)
 * Desktop sidebar visible from 992px
 */

/* ===========================================
   HIDE ON DESKTOP (992px+) - Show only on mobile/tablet
   =========================================== */
.goled-mobile-shop-header,
.goled-mobile-filter-overlay,
.goled-mobile-filter-panel {
    display: none !important;
}

/* ===========================================
   SMALL MOBILE ADJUSTMENTS
   =========================================== */

/* ===========================================
   RESPONSIVE BREAKPOINTS
   =========================================== */

@media (max-width: 992px) {

    /* Override mobile-sticky class on shop pages */
    body.goled-shop-archive-page.mobile-sticky .mobile-header {
        position: fixed;
        top: 0;
        /* Keep it fixed but not sticky-affecting */
    }
}

@media (max-width: 991px) {
    .goled-mobile-shop-header {
        display: block !important;
    }

    /* Filter panel/overlay - default to hidden, activated via JS */
    .goled-mobile-filter-overlay,
    .goled-mobile-filter-panel {
        display: block !important;
    }

    /* =========================================
       HIDE UNNECESSARY DESKTOP ELEMENTS
       ========================================= */

    /* Hide entire desktop site-header on shop pages */
    body.goled-shop-archive-page .site-header {
        display: none !important;
    }

    /* Hide woocommerce products header (contains H1 we replaced) */
    body.goled-shop-archive-page header.woocommerce-products-header {
        display: none !important;
    }

    /* Hide desktop breadcrumbs */
    .goled-shop-archive-page .woocommerce-breadcrumb,
    .goled-shop-archive-page nav.woocommerce-breadcrumb {
        display: none !important;
    }

    /* Hide the desktop sidebar on mobile */
    .goled-shop-archive-page .goled-shop-sidebar {
        display: none !important;
    }

    /* Hide OLD WooCommerce sorting on mobile (but keep result count) */
    .goled-shop-archive-page .woocommerce-ordering {
        display: none !important;
    }

    /* Style result count - display below utility bar */
    .goled-shop-archive-page .woocommerce-result-count {
        display: block !important;
        width: 100%;
        text-align: center;
        padding: 10px 15px;
        margin: 0;
        font-size: 0.85rem;
        color: var(--text-muted);
        background: var(--body-bg);
        border-bottom: 1px solid var(--border-color);
    }

    /* =========================================
       MOBILE HEADER - NOT STICKY ON SHOP PAGES
       ========================================= */

    /* Override mobile sticky header on shop pages - make it static */
    body.goled-shop-archive-page .mobile-header {
        position: relative !important;
        top: auto !important;
    }

    /* Remove body padding since header is not fixed */
    body.goled-shop-archive-page {
        padding-top: 0 !important;
    }

    /* Adjust main content width */
    .goled-shop-archive-page .goled-shop-main {
        width: 100%;
    }

    /* ===========================================
       TITLE ROW (Back + H1)
       =========================================== */
    .goled-mobile-shop-title-row {
        display: flex;
        align-items: center;
        gap: 12px;
        padding: 12px 15px;
        background: var(--card-bg);
        border-bottom: 1px solid var(--border-color);
    }

    .goled-mobile-result-count {
        margin-left: auto;
        font-size: 0.8rem;
        color: var(--text-muted);
        white-space: nowrap;
    }

    .goled-mobile-back-btn {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        background: var(--input-bg);
        border: 1px solid var(--border-color);
        border-radius: 8px;
        color: var(--text-color);
        text-decoration: none;
        transition: all 0.2s ease;
        flex-shrink: 0;
    }

    .goled-mobile-back-btn:hover {
        background: var(--primary-color);
        color: #000;
        border-color: var(--primary-color);
    }

    .goled-mobile-back-btn i {
        font-size: 1rem;
    }

    .goled-mobile-shop-title {
        font-size: 1.1rem;
        font-weight: 600;
        margin: 0;
        color: var(--text-color);
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        flex: 1;
    }

    /* ===========================================
       UTILITY BAR - Default (scrolls with content)
       =========================================== */
    .goled-mobile-utility-bar {
        display: flex;
        position: relative;
        z-index: 100;
        background: var(--card-bg);
        border-bottom: 1px solid var(--border-color);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    }

    /* ===========================================
       UTILITY BAR - Fixed (like mobile header on other pages)
       Applied via JS when scrolled past
       =========================================== */
    body.utility-bar-fixed .goled-mobile-utility-bar {
        position: fixed !important;
        top: 0 !important;
        left: 0 !important;
        right: 0 !important;
        z-index: 100 !important;
    }

    .goled-utility-btn {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        padding: 14px 16px;
        background: transparent;
        border: none;
        color: var(--text-color);
        font-size: 0.95rem;
        font-weight: 600;
        cursor: pointer;
        transition: all 0.2s ease;
    }

    .goled-utility-btn:first-child {
        border-right: 1px solid var(--border-color);
    }

    .goled-utility-btn:hover,
    .goled-utility-btn:focus {
        background: var(--input-bg);
        color: var(--primary-color);
    }

    .goled-utility-btn.active {
        background: var(--primary-color);
        color: #000;
    }

    .goled-utility-btn i {
        font-size: 1rem;
    }

    /* ===========================================
       SORT DROPDOWN
       =========================================== */
    .goled-mobile-sort-dropdown {
        display: none;
        position: fixed;
        /* Fixed to viewport for proper positioning when utility bar is sticky */
        top: auto;
        /* Will be set by JS */
        left: 0;
        right: 0;
        background: var(--card-bg);
        border: 1px solid var(--border-color);
        border-top: none;
        box-shadow: 0 8px 16px rgba(0, 0, 0, 0.15);
        z-index: 99;
        /* Just below filter panel overlay */
        max-height: 60vh;
        overflow-y: auto;
    }

    .goled-mobile-sort-dropdown.active {
        display: block;
    }

    .goled-sort-option {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 14px 16px;
        color: var(--text-color);
        text-decoration: none;
        border-bottom: 1px solid var(--border-color);
        transition: all 0.2s ease;
    }

    .goled-sort-option:last-child {
        border-bottom: none;
    }

    .goled-sort-option:hover {
        background: var(--input-bg);
        color: var(--primary-color);
    }

    .goled-sort-option.active {
        background: rgba(254, 185, 0, 0.1);
        color: var(--primary-color);
        font-weight: 600;
    }

    .goled-sort-option i {
        color: var(--primary-color);
    }

    /* ===========================================
       OFF-CANVAS FILTER PANEL
       =========================================== */
    .goled-mobile-filter-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.6);
        z-index: 199;
        /* Below filter panel, above loader (90) */
        opacity: 0;
        visibility: hidden;
        transition: all 0.3s ease;
    }

    .goled-mobile-filter-overlay.active {
        opacity: 1;
        visibility: visible;
    }

    .goled-mobile-filter-panel {
        position: fixed;
        top: 0;
        left: 0;
        width: 320px;
        max-width: 85vw;
        height: 100vh;
        background: var(--card-bg);
        z-index: 200;
        /* Above filter overlay (199), above loader (90) */
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        display: flex;
        flex-direction: column;
        overflow: hidden;
    }

    .goled-mobile-filter-panel.active {
        transform: translateX(0);
    }

    .goled-filter-panel-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 16px 20px;
        border-bottom: 1px solid var(--border-color);
        flex-shrink: 0;
    }

    .goled-filter-panel-header h2 {
        margin: 0;
        font-size: 1.2rem;
        font-weight: 700;
        color: var(--text-color);
    }

    .goled-filter-panel-close {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 36px;
        height: 36px;
        background: var(--input-bg);
        border: 1px solid var(--border-color);
        border-radius: 8px;
        color: var(--text-color);
        cursor: pointer;
        transition: all 0.2s ease;
    }

    .goled-filter-panel-close:hover {
        background: var(--primary-color);
        color: #000;
        border-color: var(--primary-color);
    }

    .goled-filter-panel-body {
        flex: 1;
        overflow-y: auto;
        overflow-x: hidden;
        padding: 20px;
        -webkit-overflow-scrolling: touch;
        overscroll-behavior: contain;
        max-height: calc(100vh - 70px);
        /* Account for header */
    }

    .goled-filter-panel-section {
        margin-bottom: 24px;
    }

    .goled-filter-section-title {
        display: flex;
        align-items: center;
        gap: 10px;
        font-size: 1rem;
        font-weight: 600;
        color: var(--text-color);
        margin: 0 0 12px 0;
        padding-bottom: 10px;
        border-bottom: 2px solid var(--primary-color);
    }

    .goled-filter-section-title i {
        color: var(--primary-color);
    }

    /* ===========================================
       MOBILE CATEGORIES LIST
       =========================================== */
    .goled-mobile-categories {
        margin-bottom: 16px;
    }

    .goled-mobile-cat-all {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 12px 14px;
        margin-bottom: 8px;
        background: var(--input-bg);
        border: 1px solid var(--border-color);
        border-radius: 8px;
        color: var(--text-color);
        text-decoration: none;
        font-weight: 500;
        transition: all 0.2s ease;
    }

    .goled-mobile-cat-all:hover,
    .goled-mobile-cat-all.current {
        background: var(--primary-color);
        color: #000;
        border-color: var(--primary-color);
    }

    .goled-mobile-cat-all i {
        font-size: 1rem;
    }

    .goled-mobile-cat-list {
        list-style: none;
        margin: 0;
        padding: 0;
    }

    .goled-mobile-cat-list.goled-cat-child {
        padding-left: 16px;
        margin-top: 4px;
        display: none;
        border-left: 2px solid var(--border-color);
    }

    .goled-mobile-cat-list.goled-cat-child.active {
        display: block;
    }

    /* Show children of current/ancestor categories by default */
    .goled-mobile-cat-item.current>.goled-mobile-cat-list.goled-cat-child,
    .goled-mobile-cat-item.ancestor>.goled-mobile-cat-list.goled-cat-child {
        display: block;
    }

    .goled-mobile-cat-item {
        margin-bottom: 2px;
    }

    .goled-mobile-cat-row {
        display: flex;
        align-items: center;
    }

    .goled-mobile-cat-link {
        flex: 1;
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 10px 12px;
        color: var(--text-color);
        text-decoration: none;
        border-radius: 6px;
        transition: all 0.2s ease;
    }

    .goled-mobile-cat-link:hover {
        background: var(--input-bg);
        color: var(--primary-color);
    }

    .goled-mobile-cat-item.current>.goled-mobile-cat-row>.goled-mobile-cat-link {
        background: rgba(254, 185, 0, 0.15);
        color: var(--primary-color);
        font-weight: 600;
    }

    .goled-cat-count {
        font-size: 0.85rem;
        color: var(--text-muted);
        margin-left: 8px;
    }

    .goled-cat-expand {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 32px;
        height: 32px;
        background: transparent;
        border: none;
        color: var(--text-muted);
        cursor: pointer;
        transition: all 0.2s ease;
        flex-shrink: 0;
    }

    .goled-cat-expand:hover {
        color: var(--primary-color);
    }

    .goled-cat-expand i {
        transition: transform 0.2s ease;
    }

    .goled-mobile-cat-item.expanded>.goled-mobile-cat-row>.goled-cat-expand i {
        transform: rotate(180deg);
    }

    /* ===========================================
       HIDE EXISTING FILTER TOGGLE ON MOBILE
       =========================================== */
    .goled-shop-archive-page .goled-mobile-filter-toggle {
        display: none !important;
    }

    /* ===========================================
       FILTER PANEL - FILTERS SECTION OVERRIDE
       =========================================== */
    .goled-filter-panel-filters .goled-filters-wrapper {
        display: block !important;
        background: transparent;
        border: none;
        padding: 0;
        margin: 0;
    }

    .goled-filter-panel-filters .goled-mobile-filter-toggle {
        display: none !important;
    }

    /* Style filter sections in panel */
    .goled-filter-panel-filters .filter-section {
        margin-bottom: 16px;
        padding-bottom: 16px;
        border-bottom: 1px solid var(--border-color);
    }

    .goled-filter-panel-filters .filter-section:last-child {
        border-bottom: none;
        margin-bottom: 0;
        padding-bottom: 0;
    }

    /* Hide the category filter section since we have our own */
    .goled-filter-panel-filters .category-filter {
        display: none !important;
    }

    /* ===========================================
       MOBILE CATEGORY CHECKBOX
       =========================================== */
    .goled-mobile-cat-checkbox {
        display: flex;
        align-items: center;
        justify-content: center;
        width: 32px;
        height: 32px;
        cursor: pointer;
        flex-shrink: 0;
    }

    .goled-mobile-cat-checkbox input[type="checkbox"] {
        display: none;
    }

    .goled-checkbox-mark {
        width: 18px;
        height: 18px;
        border: 2px solid var(--border-color);
        border-radius: 4px;
        background: var(--card-bg);
        display: flex;
        align-items: center;
        justify-content: center;
        transition: all 0.2s ease;
    }

    .goled-mobile-cat-checkbox:hover .goled-checkbox-mark {
        border-color: var(--primary-color);
    }

    .goled-mobile-cat-checkbox input[type="checkbox"]:checked+.goled-checkbox-mark {
        background: var(--primary-color);
        border-color: var(--primary-color);
    }

    .goled-mobile-cat-checkbox input[type="checkbox"]:checked+.goled-checkbox-mark::after {
        content: '\f00c';
        font-family: 'Font Awesome 6 Free';
        font-weight: 900;
        font-size: 10px;
        color: #000;
    }

    /* Adjust cat link padding when checkbox is present */
    .goled-mobile-cat-row .goled-mobile-cat-link {
        padding-left: 4px;
    }

    /* Active filter row highlight */
    .goled-mobile-cat-row.filter-active {
        background: rgba(254, 185, 0, 0.1);
        border-radius: 6px;
    }

    .goled-mobile-cat-row.filter-active .goled-mobile-cat-link {
        color: var(--primary-color);
        font-weight: 500;
    }

    /* ===========================================
       PRICE FILTER - SINGLE LINE LAYOUT
       =========================================== */
    .goled-filter-panel-filters .price-inputs {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        gap: 8px !important;
        flex-wrap: nowrap !important;
    }

    .goled-filter-panel-filters .price-inputs label {
        display: flex !important;
        flex-direction: row !important;
        align-items: center !important;
        gap: 6px !important;
        flex: 1 !important;
        white-space: nowrap !important;
        margin: 0;
    }

    .goled-filter-panel-filters .price-inputs label span {
        font-size: 0.85rem !important;
        flex-shrink: 0 !important;
    }

    .goled-filter-panel-filters .price-inputs input[type="number"] {
        min-width: 40px !important;
        max-width: 50px !important;
        padding: 8px 6px !important;
        font-size: 0.9rem !important;
        text-align: center !important;
    }

    .goled-filter-panel-filters .price-inputs .price-separator {
        flex-shrink: 0 !important;
        font-size: 1rem !important;
    }
}

@media (max-width: 575px) {
    .goled-mobile-filter-panel {
        width: 280px;
    }

    .goled-mobile-shop-title-row {
        padding: 10px 12px;
    }

    .goled-mobile-shop-title {
        font-size: 1rem;
    }

    .goled-utility-btn {
        padding: 12px 14px;
        font-size: 0.9rem;
    }

    .goled-filter-panel-body {
        padding: 15px;
    }
}