/* ==========================================
   MOBILE HEADER STYLES (max-width: 1023px)
   ========================================== */

/* Hide ALL mobile elements on desktop (1024px and above) */
@media (min-width: 1024px) {
    .mobile-header-new,
    .mobile-category-strip,
    .mobile-category-popup,
    .mobile-category-popup.show,
    .mobile-category-overlay,
    .mobile-category-overlay.show,
    .mobile-sidebar-overlay,
    .mobile-sidebar,
    .mobile-bottom-nav-new,
    .mobile-search,
    .mobile-search-suggestions,
    .mobile-search-suggestions.show,
    .mobile-search-suggestions.is-open {
        display: none !important;
        visibility: hidden !important;
        pointer-events: none !important;
        opacity: 0 !important;
    }
}

@media (max-width: 1023px) {
    /* Hide desktop header on mobile */
    .il-header {
        display: none !important;
    }
    
    /* Mobile Header Container */
    .mobile-header-new {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 99998;
        background: #fff;
        box-shadow: 0 2px 8px rgba(0,0,0,0.1);
        overflow: visible !important;
    }
    
    /* Row 1: Logo + Search */
    .mobile-header-row1 {
        display: flex;
        align-items: center;
        padding: 10px 12px;
        gap: 10px;
        background: #fff;
    }
    
    .mobile-header-logo {
        flex-shrink: 0;
        width: 110px;
    }
    
    .mobile-header-logo img {
        height: 48px;
        width: auto;
        display: block;
    }
    
    /* Mobile Search Bar */
    .mobile-header-search {
        flex: 1;
        position: relative;
        max-width: calc(100% - 120px);
        overflow: visible !important;
        z-index: 100001 !important;
    }
    
    .mobile-search-form {
        display: flex;
        align-items: stretch;
        width: 100%;
        height: 38px;
        border: 1px solid #e4e4e4;
        border-radius: 20px;
        overflow: hidden;
        background: #f7f7f7;
        position: relative;
        z-index: 100001 !important;
    }
    
    .mobile-search-input {
        flex: 1;
        min-width: 0;
        height: 100%;
        border: 0;
        outline: 0;
        background: transparent;
        padding: 0 14px;
        font-size: 12px;
        pointer-events: auto;
    }
    
    .mobile-search-btn {
        width: 46px;
        min-width: 46px;
        height: 100%;
        border: 0;
        border-radius: 0 20px 20px 0;
        background: #e60023;
        color: #fff;
        display: inline-flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        padding: 0;
        pointer-events: auto;
    }
    
    .mobile-search-btn:hover,
    .mobile-search-btn:active {
        background: #cc001f;
    }
    
    .mobile-search-btn i,
    .mobile-search-btn svg {
        width: 16px;
        height: 16px;
        font-size: 16px;
        line-height: 1;
    }
    
    /* Mobile Search Suggestions */
    .mobile-header-row1 {
        position: relative !important;
        z-index: 100001 !important;
        overflow: visible !important;
    }

    .mobile-search-suggestions {
        display: none !important;
        position: absolute !important;
        top: calc(100% + 6px) !important;
        left: 0 !important;
        right: 0 !important;
        width: 100% !important;
        min-width: 100% !important;
        box-sizing: border-box !important;
        background: #ffffff !important;
        border: 1px solid #e5e7eb !important;
        border-radius: 10px !important;
        box-shadow: 0 12px 30px rgba(0,0,0,0.22) !important;
        z-index: 999999 !important;
        max-height: min(280px, 40vh) !important;
        overflow-y: auto !important;
        overflow-x: hidden !important;
        pointer-events: auto;
    }
    
    .mobile-search-suggestions.show,
    .mobile-search-suggestions.active,
    .mobile-search-suggestions.is-open {
        display: block !important;
    }

    .mobile-suggestion-item {
        display: flex !important;
        flex-direction: column !important;
        align-items: flex-start !important;
        width: 100% !important;
        min-height: 50px !important;
        padding: 10px 12px !important;
        box-sizing: border-box !important;
        background: #fff !important;
        border-bottom: 1px solid #f0f0f0 !important;
        white-space: normal !important;
        overflow: visible !important;
        text-align: left;
        cursor: pointer;
        color: #333;
        font-size: 13px;
        text-decoration: none;
        transition: background 0.15s;
        pointer-events: auto;
    }

    .mobile-suggestion-item:last-child {
        border-bottom: 0 !important;
    }

    .mobile-suggestion-item:hover {
        background: #f7f7f7;
    }

    .mobile-suggestion-item:active {
        background: #f0f0f0;
    }

    .mobile-suggestion-name {
        display: -webkit-box !important;
        width: 100% !important;
        font-size: 13px !important;
        font-weight: 600 !important;
        line-height: 1.35 !important;
        color: #222 !important;
        white-space: normal !important;
        word-break: break-word !important;
        -webkit-line-clamp: 2 !important;
        -webkit-box-orient: vertical !important;
        overflow: hidden !important;
    }

    .mobile-suggestion-source {
        display: block !important;
        margin-top: 3px !important;
        font-size: 11px !important;
        color: #777 !important;
    }
    
    /* Row 2: Category Strip */
    .mobile-category-strip {
        display: flex;
        align-items: center;
        padding: 8px 0;
        background: #fff;
        border-bottom: 1px solid #eee;
        position: relative;
        z-index: 1 !important;
    }
    
    .mobile-category-scroll {
        display: flex;
        align-items: center;
        overflow-x: auto;
        scrollbar-width: none;
        -ms-overflow-style: none;
        gap: 2px;
        padding: 0 8px;
        flex: 1;
    }
    
    .mobile-category-scroll::-webkit-scrollbar {
        display: none;
    }
    
    .mobile-category-item {
        flex-shrink: 0;
        padding: 6px 10px;
        font-size: 12px;
        color: #666;
        text-decoration: none;
        white-space: nowrap;
        border-radius: 16px;
        transition: all 0.2s;
        pointer-events: auto;
    }
    
    .mobile-category-item:hover {
        color: #E60023;
    }
    
    .mobile-category-item.active {
        background: #E60023;
        color: #fff;
        font-weight: 600;
    }
    
    .mobile-category-dropdown-btn {
        flex-shrink: 0;
        padding: 8px 12px;
        background: transparent;
        border: none;
        color: #666;
        font-size: 14px;
        cursor: pointer;
        display: flex;
        align-items: center;
        gap: 4px;
        pointer-events: auto;
    }
    
    .mobile-category-dropdown-btn:hover {
        color: #E60023;
    }
    
    /* Mobile Category Popup */
    .mobile-category-popup {
        display: none;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        max-height: 70vh;
        background: #fff;
        border-radius: 16px 16px 0 0;
        box-shadow: 0 -4px 20px rgba(0,0,0,0.15);
        z-index: 100001;
        transform: translateY(100%);
        transition: transform 0.3s ease;
        pointer-events: none;
    }
    
    .mobile-category-popup.show {
        display: block;
        transform: translateY(0);
        pointer-events: auto;
    }
    
    .mobile-category-popup-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 16px;
        border-bottom: 1px solid #eee;
    }
    
    .mobile-category-popup-title {
        font-size: 16px;
        font-weight: 600;
        color: #333;
    }
    
    .mobile-category-popup-close {
        width: 32px;
        height: 32px;
        background: #f5f5f5;
        border: none;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        color: #666;
        font-size: 14px;
        pointer-events: auto;
    }
    
    .mobile-category-popup-close:hover {
        background: #eee;
        color: #333;
    }
    
    .mobile-category-popup-drag {
        display: flex;
        justify-content: center;
        padding: 8px 0;
    }
    
    .mobile-category-popup-drag-bar {
        width: 40px;
        height: 4px;
        background: #ddd;
        border-radius: 2px;
    }
    
    .mobile-category-popup-list {
        max-height: calc(70vh - 100px);
        overflow-y: auto;
        padding: 8px 0;
    }
    
    .mobile-category-popup-item {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 14px 16px;
        color: #333;
        font-size: 14px;
        text-decoration: none;
        border-bottom: 1px solid #f5f5f5;
        transition: background 0.15s;
        pointer-events: auto;
    }
    
    .mobile-category-popup-item:hover {
        background: #f9f9f9;
    }
    
    .mobile-category-popup-item.active {
        color: #E60023;
        font-weight: 600;
        background: #fff5f5;
    }
    
    .mobile-category-popup-item-check {
        width: 20px;
        height: 20px;
        border: 2px solid #ddd;
        border-radius: 50%;
        display: flex;
        align-items: center;
        justify-content: center;
        color: transparent;
        font-size: 10px;
    }
    
    .mobile-category-popup-item.active .mobile-category-popup-item-check {
        background: #E60023;
        border-color: #E60023;
        color: #fff;
    }
    
    /* Popup Overlay */
    .mobile-category-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        bottom: 0;
        background: rgba(0,0,0,0.4);
        z-index: 100000;
        pointer-events: none;
    }
    
    .mobile-category-overlay.show {
        display: block;
        pointer-events: auto;
    }
    
    /* Mobile Bottom Navigation - Fixed at bottom */
    .mobile-bottom-nav-new {
        display: flex !important;
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        background: #fff;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
        z-index: 99996;
        padding: 6px 0;
        padding-bottom: calc(6px + env(safe-area-inset-bottom, 0));
        border-top: 1px solid #eee;
        pointer-events: auto;
        justify-content: space-around;
        align-items: center;
    }
    
    .mobile-bottom-nav-new-item {
        flex: 1;
        display: flex;
        flex-direction: column;
        align-items: center;
        justify-content: center;
        padding: 4px 2px;
        text-decoration: none;
        color: #999;
        font-size: 10px;
        transition: color 0.2s;
        pointer-events: auto;
        position: relative;
    }
    
    .mobile-bottom-nav-new-item i {
        font-size: 20px;
        margin-bottom: 2px;
        display: block;
    }
    
    .mobile-bottom-nav-new-item span {
        display: block;
        line-height: 1.2;
    }
    
    .mobile-bottom-nav-new-item.active {
        color: #E60023;
    }
    
    .mobile-bottom-nav-new-item .cart-badge {
        position: absolute;
        top: -2px;
        right: calc(50% - 18px);
        background: #E60023;
        color: #fff;
        font-size: 9px;
        min-width: 14px;
        height: 14px;
        border-radius: 7px;
        display: flex;
        align-items: center;
        justify-content: center;
        padding: 0 3px;
    }
    
    /* Body padding for mobile */
    body {
        padding-top: 100px !important;
        padding-bottom: 60px !important;
        position: relative;
    }
    
    /* Main content wrapper */
    main {
        padding-bottom: 60px !important;
    }
    
    /* Ensure first content element has proper spacing below mobile header - 10px target */
    body > main:first-of-type,
    .page-content,
    .container,
    .home-content,
    main > *:first-child {
        margin-top: 10px;
    }
    
    /* Special handling for homepage content */
    body.home main > *:first-child,
    body:not(.inner-page) main > *:first-child {
        margin-top: 10px;
    }
    
    /* Inner page content spacing */
    body.inner-page .supplier-hero:first-child,
    body.inner-page .breadcrumb:first-child,
    body.inner-page .info-content,
    body.inner-page .support-content,
    body.inner-page .learn-more-content,
    body.inner-page main > *:first-child {
        margin-top: 10px !important;
    }
    
    /* Hide old mobile elements that might conflict */
    .mobile-header:not(.mobile-header-new),
    .mobile-search:not(.mobile-header-new .mobile-search),
    .mobile-sidebar-overlay,
    .mobile-sidebar,
    .mobile-quick-actions,
    .mobile-trust-cards,
    .mobile-bottom-nav:not(.mobile-bottom-nav-new) {
        display: none !important;
        pointer-events: none !important;
    }
}

/* ==========================================
   TABLET OVERRIDE (769px – 1024px)
   Re-show mobile header elements that
   mobile.css hides at min-width:769px
   ========================================== */
@media (min-width: 769px) and (max-width: 1024px) {
    .mobile-header-new {
        display: block !important;
    }
    .mobile-category-strip {
        display: flex !important;
    }
    .mobile-category-scroll {
        display: flex !important;
    }
    .mobile-bottom-nav-new {
        display: flex !important;
    }
    body {
        padding-top: 100px !important;
        padding-bottom: 60px !important;
    }
    main {
        padding-bottom: 60px !important;
    }
}

@media (max-width: 480px) {
    .mobile-header-logo {
        width: 85px;
    }
    
    .mobile-header-logo img {
        height: 34px;
    }
    
    .mobile-search-form {
        height: 36px;
    }
    
    .mobile-search-btn {
        width: 42px;
        min-width: 42px;
    }
    
    .mobile-category-item {
        padding: 5px 8px;
        font-size: 11px;
    }
    
    .mobile-bottom-nav-new-item {
        font-size: 9px;
    }
    
    .mobile-bottom-nav-new-item i {
        font-size: 18px;
    }
}
