/* Mobile Header Complete Fix */

/* Prevent any horizontal overflow */
html {
    overflow-x: hidden !important;
    width: 100% !important;
    max-width: 100vw !important;
}

body {
    overflow-x: hidden !important;
    width: 100% !important;
    max-width: 100vw !important;
    position: relative;
}

/* Fix overlapping elements on mobile */
@media (max-width: 768px) {
    /* Ensure no fixed/absolute elements overlap header */
    .site-header {
        position: relative !important;
        z-index: 1000 !important;
    }
    
    .header-main {
        position: sticky !important;
        top: 0 !important;
        z-index: 1000 !important;
    }
    
    /* Fix any floating badges/banners */
    .product-badge,
    .discount-tag,
    [style*="position: absolute"] {
        z-index: 1 !important;
    }
}

/* Mobile Header Specific Fixes */
@media (max-width: 768px) {
    /* Header top bar */
    .header-top {
        padding: 5px 0;
        font-size: 11px;
    }
    
    .header-top .container {
        padding: 0 10px !important;
    }
    
    .header-contact span,
    .header-links a {
        font-size: 11px;
    }
    
    /* Main header */
    .header-main {
        padding: 8px 0 !important;
        position: sticky;
        top: 0;
        background: white;
        z-index: 1000;
    }
    
    .header-main .container {
        padding: 0 8px !important;
        max-width: 100% !important;
        overflow: visible;
    }
    
    /* Header content layout */
    .header-content {
        display: grid !important;
        grid-template-columns: 40px 1fr auto !important;
        grid-template-rows: auto auto !important;
        gap: 8px !important;
        align-items: center !important;
        width: 100% !important;
        max-width: 100% !important;
    }
    
    /* Mobile menu button */
    .mobile-menu-btn {
        grid-column: 1 !important;
        grid-row: 1 !important;
        width: 40px;
        height: 40px;
        display: flex !important;
        align-items: center;
        justify-content: center;
        padding: 0;
        font-size: 20px;
    }
    
    /* Logo */
    .logo {
        grid-column: 2 !important;
        grid-row: 1 !important;
        text-align: center !important;
        min-width: 0;
        overflow: hidden;
    }
    
    .logo a {
        display: inline-flex !important;
        align-items: center;
        gap: 8px;
        white-space: nowrap;
    }
    
    .logo-text {
        font-size: 20px !important;
        display: inline-block;
    }
    
    /* Header actions (Cart + Login/User) */
    .header-actions {
        grid-column: 3 !important;
        grid-row: 1 !important;
        display: flex !important;
        gap: 5px !important;
        align-items: center !important;
        flex-shrink: 0 !important;
    }
    
    .header-actions a,
    .header-actions button {
        flex-shrink: 0;
    }
    
    .header-actions a:not(.cart-btn) {
        font-size: 16px !important;
        padding: 8px !important;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Cart button mobile */
    .cart-btn {
        padding: 8px 12px !important;
        font-size: 14px !important;
        border-radius: 20px !important;
        gap: 4px !important;
    }
    
    .cart-count {
        font-size: 11px !important;
        padding: 2px 6px !important;
        min-width: 18px;
        height: 18px;
        display: flex;
        align-items: center;
        justify-content: center;
    }
    
    /* Search bar - second row */
    .search-bar {
        grid-column: 1 / -1 !important;
        grid-row: 2 !important;
        width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }
    
    .search-form {
        width: 100% !important;
        max-width: 100% !important;
        display: flex !important;
    }
    
    .search-input {
        flex: 1 !important;
        min-width: 0 !important;
        padding: 10px 12px !important;
        font-size: 14px !important;
        border-radius: 20px 0 0 20px !important;
    }
    
    .search-btn,
    #voiceSearchBtn {
        padding: 10px 12px !important;
        font-size: 14px !important;
        flex-shrink: 0 !important;
    }
    
    .search-btn {
        border-radius: 0 20px 20px 0 !important;
    }
    
    #voiceSearchBtn {
        border-radius: 0 !important;
    }
    
    /* Navigation */
    .header-nav {
        position: fixed;
        top: 0;
        left: -100%;
        width: 80%;
        max-width: 300px;
        height: 100vh;
        background: white;
        box-shadow: 4px 0 15px rgba(0,0,0,0.2);
        transition: left 0.3s ease;
        z-index: 2000;
        overflow-y: auto;
    }
    
    .header-nav.active {
        left: 0;
    }
    
    .nav-menu {
        flex-direction: column;
        padding: 60px 0 20px;
    }
    
    .nav-menu > li {
        width: 100%;
    }
    
    .nav-menu > li > a {
        color: var(--dark);
        padding: 15px 20px;
        border-bottom: 1px solid var(--border);
        display: flex;
        justify-content: space-between;
    }
    
    .nav-menu > li > a:hover {
        background: var(--light);
        color: var(--primary);
    }
}

@media (max-width: 480px) {
    .logo-text {
        font-size: 18px !important;
    }
    
    .cart-btn {
        padding: 6px 10px !important;
        font-size: 13px !important;
    }
    
    .header-actions a:not(.cart-btn) {
        font-size: 14px !important;
        padding: 6px !important;
    }
}
