/**
 * Divi Mega Menu - Mobile Styles
 * Responsive mobile-first design
 */

/* Mobile-first approach */
@media (max-width: 980px) {
    
    /* Hide desktop mega menu on mobile (unless mobile-active) */
    .divi-mega-menu-nav:not(.mobile-active) {
        display: none;
    }
    
    /* Hide all mega menu dropdowns in mobile */
    .mega-menu-dropdown {
        display: none !important;
    }
    
    /* Mobile Announcement Bar - Ultra Compact */
    .divi-mega-menu-announcement-bar {
        padding: 0.15rem 1rem !important;
        min-height: 24px !important;
        max-height: 24px !important;
    }
    
    .divi-mega-menu-announcement-bar .announcement-content {
        gap: 0.1rem !important;
        font-size: 11px !important;
        line-height: 1.2 !important;
        min-height: 24px !important;
    }
    
    .divi-mega-menu-announcement-bar .announcement-item {
        padding: 0 !important;
        margin: 0 !important;
    }
    

    
    /* Mobile menu shows when active */
    .divi-mega-menu-nav.mobile-active {
        display: flex !important;
    }
    
    /* Mobile Logo Bar - Restructured Layout */
    .divi-mega-menu-logo-bar {
        padding: 8px 0 !important;
    }
    
    .logo-bar-content {
        display: grid !important;
        grid-template-columns: auto 1fr auto !important;
        grid-template-rows: auto auto !important;
        grid-template-areas: 
            "logo . actions"
            "search search hamburger" !important;
        gap: 0.5rem !important;
        padding: 0.3rem 1rem !important;
        align-items: center !important;
    }
    
    /* Logo - Left side, top row */
    .logo-section {
        grid-area: logo !important;
        justify-self: start !important;
        padding-right: 1rem !important;
    }
    
    .logo-image {
        max-height: 32px !important;
        height: 32px !important;
    }
    
    /* Actions (account + cart) - Right side, top row */
    .actions-section {
        grid-area: actions !important;
        justify-self: end !important;
        display: flex !important;
        gap: 0.5rem !important;
    }
    
    /* Search - Full width, bottom row */
    .search-section {
        grid-area: search !important;
        justify-self: stretch !important;
        width: 100% !important;
        max-width: none !important;
    }
    
    .search-section input {
        width: 100% !important;
    }
    
    /* Hamburger - Right side, bottom row - Integrated in logo bar */
    .mobile-menu-toggle {
        display: flex !important;
        align-items: center;
        justify-content: center;
        width: 40px;
        height: 40px;
        background: #f8f9fa;
        border: 1px solid #dee2e6;
        cursor: pointer;
        z-index: 1000;
        position: relative;
        padding: 8px;
        border-radius: 6px;
        transition: all 0.3s ease;
        grid-area: hamburger !important;
        justify-self: end !important;
        margin: 0 !important;
        flex-shrink: 0;
    }
    
    .mobile-menu-toggle:hover {
        background-color: #e9ecef;
        border-color: #adb5bd;
    }
    
    .mobile-menu-toggle:focus {
        outline: 2px solid #007cba;
        outline-offset: 2px;
    }
    
    .mobile-menu-toggle .hamburger {
        width: 24px;
        height: 22px;
        position: relative;
        transform: rotate(0deg);
        transition: .5s ease-in-out;
        cursor: pointer;
    }
    
    .mobile-menu-toggle .hamburger span {
        display: block;
        position: absolute;
        height: 3px;
        width: 100%;
        background: #333;
        border-radius: 9px;
        opacity: 1;
        left: 0;
        transform: rotate(0deg);
        transition: .25s ease-in-out;
    }
    
    .mobile-menu-toggle .hamburger span:nth-child(1) {
        top: 0px;
    }
    
    .mobile-menu-toggle .hamburger span:nth-child(2) {
        top: 7px;
    }
    
    .mobile-menu-toggle .hamburger span:nth-child(3) {
        top: 14px;
    }
    
    .mobile-menu-toggle .hamburger span:nth-child(4) {
        top: 21px;
    }
    
    /* Hamburger animation - open state */
    .mobile-menu-toggle.open .hamburger span:nth-child(1) {
        top: 11px;
        width: 0%;
        left: 50%;
    }
    
    .mobile-menu-toggle.open .hamburger span:nth-child(2) {
        top: 11px;
        transform: rotate(45deg);
    }
    
    .mobile-menu-toggle.open .hamburger span:nth-child(3) {
        top: 11px;
        transform: rotate(-45deg);
    }
    
    .mobile-menu-toggle.open .hamburger span:nth-child(4) {
        top: 11px;
        width: 0%;
        left: 50%;
    }
    
    /* Make hamburger visible */
    .mobile-menu-toggle .hamburger span {
        background: #333 !important;
        height: 3px !important;
    }
    

    
    /* Mobile menu container - hidden by default */
    .divi-mega-menu {
        position: relative;
        width: 100%;
    }

    /* Mobile navigation - shown when active */
    .divi-mega-menu-nav.mobile-active {
        display: flex !important;
        flex-direction: column;
        background: var(--mega-menu-bg, #ffffff);
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
        border-radius: 8px;
        margin: 10px;
        overflow: hidden;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        z-index: 9999;
        max-height: 80vh;
        overflow-y: auto;

    }
    
    /* Ensure mega-menu-items shows in mobile */
    .divi-mega-menu-nav.mobile-active .mega-menu-items {
        display: flex !important;
        flex-direction: column;
        width: 100%;
    }

    /* Mobile menu items */
    .divi-mega-menu-nav.mobile-active .divi-mega-menu-item {
        border-bottom: 1px solid var(--mega-menu-border, #e5e7eb);
        background: #fff;
    }

    .divi-mega-menu-nav.mobile-active .divi-mega-menu-item:last-child {
        border-bottom: none;
    }

    .divi-mega-menu-nav.mobile-active .divi-mega-menu-link {
        display: block;
        padding: 1rem;
        color: var(--mega-menu-text, #374151);
        text-decoration: none;
        font-weight: 500;
        background: transparent;
        transition: all 0.2s ease;
        border: none;
        width: 100%;
        text-align: left;
        font-size: 16px;
        position: relative;
    }

    .divi-mega-menu-nav.mobile-active .divi-mega-menu-link:hover {
        background: var(--mega-menu-hover-bg, #f3f4f6);
        color: var(--mega-menu-hover-text, #1f2937);
    }
    
    /* Add arrow for items with mega menus in mobile */
    .divi-mega-menu-nav.mobile-active .divi-mega-menu-item[data-has-mega="true"] .divi-mega-menu-link::after {
        content: "▼";
        position: absolute;
        right: 1rem;
        transition: transform 0.2s ease;
        font-size: 12px;
    }
    
    .divi-mega-menu-nav.mobile-active .divi-mega-menu-item[data-has-mega="true"].mobile-expanded .divi-mega-menu-link::after {
        transform: rotate(180deg);
    }
    
    /* Mobile submenu (expanded state) */
    .divi-mega-menu-nav.mobile-active .mobile-submenu {
        display: none;
        background: #f8f9fa;
        border-top: 1px solid #e5e7eb;
        padding: 0;
    }
    
    .divi-mega-menu-nav.mobile-active .divi-mega-menu-item.mobile-expanded .mobile-submenu {
        display: block;
    }
    
    .divi-mega-menu-nav.mobile-active .mobile-submenu .mega-menu-category {
        border-bottom: 1px solid #e5e7eb;
    }
    
    .divi-mega-menu-nav.mobile-active .mobile-submenu .mega-menu-category:last-child {
        border-bottom: none;
    }
    
    .divi-mega-menu-nav.mobile-active .mobile-submenu .mega-menu-category-title {
        font-size: 14px;
        font-weight: 600;
        color: #6b7280;
        padding: 0.75rem 1rem;
        margin: 0;
        background: #f1f3f4;
        border-bottom: 1px solid #e5e7eb;
    }
    
    .divi-mega-menu-nav.mobile-active .mobile-submenu .mega-menu-category-link {
        display: block;
        padding: 0.5rem 1.5rem;
        color: #4b5563;
        text-decoration: none;
        font-size: 14px;
        border-bottom: 1px solid #f3f4f6;
    }
    
    .divi-mega-menu-nav.mobile-active .mobile-submenu .mega-menu-category-link:hover {
        background: #e5e7eb;
        color: #1f2937;
    }
    
    /* Category title links in mobile */
    .divi-mega-menu-nav.mobile-active .mega-menu-category-title-link {
        color: inherit;
        text-decoration: none;
    }
    
    /* Direct links (for Brands, Learn, etc.) */
    .divi-mega-menu-nav.mobile-active .mobile-direct-link {
        display: block;
        padding: 0.75rem 1rem;
        color: #374151;
        text-decoration: none;
        border-bottom: 1px solid #f3f4f6;
        font-size: 15px;
    }
    
    .divi-mega-menu-nav.mobile-active .mobile-direct-link:hover {
        background: #f9fafb;
        color: #1f2937;
    }
    
    /* Category wrappers (for collapsible categories) */
    .divi-mega-menu-nav.mobile-active .mobile-category-wrapper {
        border-bottom: 1px solid #e5e7eb;
    }
    
    .divi-mega-menu-nav.mobile-active .mobile-category-wrapper:last-child {
        border-bottom: none;
    }
    
    /* Category toggle buttons */
    .divi-mega-menu-nav.mobile-active .mobile-category-toggle {
        width: 100%;
        display: flex;
        justify-content: space-between;
        align-items: center;
        padding: 0.75rem 1rem;
        background: #f8f9fa;
        border: none;
        text-align: left;
        font-size: 14px;
        font-weight: 600;
        color: #4b5563;
        cursor: pointer;
    }
    
    .divi-mega-menu-nav.mobile-active .mobile-category-toggle:hover {
        background: #e5e7eb;
    }
    
    .divi-mega-menu-nav.mobile-active .mobile-category-arrow {
        font-size: 12px;
        transition: transform 0.2s ease;
    }
    
    /* Category links (hidden by default) */
    .divi-mega-menu-nav.mobile-active .mobile-category-links {
        display: none;
        background: #ffffff;
    }
    
    .divi-mega-menu-nav.mobile-active .mobile-sub-link {
        display: block;
        padding: 0.5rem 1.5rem;
        color: #6b7280;
        text-decoration: none;
        font-size: 14px;
        border-bottom: 1px solid #f9fafb;
    }
    
    .divi-mega-menu-nav.mobile-active .mobile-sub-link:hover {
        background: #f3f4f6;
        color: #374151;
    }



    /* Mobile mega menu dropdown */
    .mega-menu-dropdown {
        position: static;
        width: 100%;
        background: var(--mega-menu-dropdown-bg, #f9fafb);
        box-shadow: none;
        border: none;
        border-top: 1px solid var(--mega-menu-border, #e5e7eb);
        opacity: 0;
        visibility: hidden;
        max-height: 0;
        overflow: hidden;
        transform: none;
        transition: all 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .divi-mega-menu-item.active .mega-menu-dropdown {
        opacity: 1;
        visibility: visible;
        max-height: 1000px; /* Large enough to accommodate content */
        transform: none;
    }

    /* Mobile mega menu content */
    .mega-menu-content {
        max-width: none;
        margin: 0;
        padding: 1rem;
        display: block; /* Stack columns vertically */
        grid-template-columns: none;
        gap: 1.5rem;
    }

    /* Mobile menu columns */
    .mega-menu-column {
        min-height: auto;
        margin-bottom: 1.5rem;
    }

    .mega-menu-column:last-child {
        margin-bottom: 0;
    }

    .mega-menu-column.links-column {
        grid-column: auto;
    }

    .mega-menu-column.products-column {
        grid-column: auto;
        border-left: none;
        border-top: 2px solid var(--mega-menu-accent, #10b981);
        padding-left: 0;
        padding-top: 1.5rem;
        margin-top: 1.5rem;
    }

    /* Mobile column titles */
    .mega-menu-column-title {
        font-size: 1rem;
        font-weight: 700;
        color: var(--mega-menu-title, #1f2937);
        margin: 0 0 0.75rem 0;
        padding-bottom: 0.5rem;
        border-bottom: 2px solid var(--mega-menu-accent, #10b981);
        text-align: center;
    }

    /* Mobile links */
    .mega-menu-links {
        display: grid;
        grid-template-columns: 1fr;
        gap: 0;
    }

    .mega-menu-links li {
        margin: 0;
        border-bottom: 1px solid rgba(229, 231, 235, 0.5);
    }

    .mega-menu-links li:last-child {
        border-bottom: none;
    }

    .mega-menu-links a {
        display: flex;
        align-items: center;
        padding: 0.75rem 1rem;
        color: var(--mega-menu-link, #6b7280);
        text-decoration: none;
        transition: all 0.3s ease;
        border-radius: 0;
        font-size: 0.9rem;
        position: relative;
    }

    .mega-menu-links a::before {
        content: '→';
        margin-right: 0.5rem;
        color: var(--mega-menu-accent, #10b981);
        font-weight: bold;
        transition: transform 0.3s ease;
    }

    .mega-menu-links a:hover {
        color: var(--mega-menu-hover, #10b981);
        background: rgba(16, 185, 129, 0.05);
        padding-left: 1.25rem;
    }

    .mega-menu-links a:hover::before {
        transform: translateX(4px);
    }

    /* Mobile product cards */
    .mega-menu-product-card {
        background: #ffffff;
        border-radius: 12px;
        overflow: hidden;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
        transition: all 0.3s ease;
        margin-bottom: 1rem;
        border: 1px solid var(--mega-menu-border, #e5e7eb);
    }

    .mega-menu-product-card:hover {
        transform: translateY(-2px);
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
        border-color: var(--mega-menu-accent, #10b981);
    }

    .mega-menu-product-card .product-image {
        position: relative;
        overflow: hidden;
        height: 120px;
    }

    .mega-menu-product-card .product-image img {
        width: 100%;
        height: 100%;
        object-fit: cover;
        transition: transform 0.3s ease;
    }

    .mega-menu-product-card:hover .product-image img {
        transform: scale(1.05);
    }

    .mega-menu-product-card .sale-badge {
        position: absolute;
        top: 0.5rem;
        right: 0.5rem;
        background: linear-gradient(135deg, #ef4444, #dc2626);
        color: white;
        padding: 0.25rem 0.5rem;
        border-radius: 6px;
        font-size: 0.75rem;
        font-weight: 700;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    .mega-menu-product-card .product-info {
        padding: 1rem;
    }

    .mega-menu-product-card .product-title {
        margin: 0 0 0.5rem 0;
        font-size: 0.95rem;
        font-weight: 600;
        line-height: 1.3;
        color: var(--mega-menu-title, #1f2937);
    }

    .mega-menu-product-card .product-title a {
        color: inherit;
        text-decoration: none;
        transition: color 0.2s ease;
    }

    .mega-menu-product-card .product-title a:hover {
        color: var(--mega-menu-hover, #10b981);
    }

    .mega-menu-product-card .product-price {
        font-size: 1rem;
        font-weight: 700;
        color: var(--mega-menu-hover, #10b981);
        margin-bottom: 0.5rem;
    }

    .mega-menu-product-card .product-description {
        font-size: 0.8rem;
        color: var(--mega-menu-link, #6b7280);
        line-height: 1.4;
        margin-bottom: 0.75rem;
        display: -webkit-box;
        -webkit-line-clamp: 2;
        -webkit-box-orient: vertical;
        overflow: hidden;
    }

    /* Mobile star rating */
    .star-rating {
        display: flex;
        align-items: center;
        gap: 0.125rem;
        margin-bottom: 0.75rem;
        justify-content: center;
    }

    .star-rating .star {
        color: #fbbf24;
        font-size: 0.75rem;
    }

    .star-rating .star.empty {
        color: #d1d5db;
    }

    .star-rating .review-count {
        margin-left: 0.5rem;
        font-size: 0.7rem;
        color: var(--mega-menu-link, #6b7280);
    }

    /* Mobile product actions */
    .product-actions {
        display: flex;
        gap: 0.5rem;
        flex-direction: row;
    }

    .view-product-btn,
    .add-to-cart-btn {
        flex: 1;
        display: inline-block;
        padding: 0.75rem 1rem;
        border-radius: 8px;
        text-decoration: none;
        font-size: 0.8rem;
        font-weight: 600;
        text-align: center;
        transition: all 0.3s ease;
        cursor: pointer;
        border: none;
        text-transform: uppercase;
        letter-spacing: 0.5px;
    }

    .view-product-btn {
        background: linear-gradient(135deg, var(--mega-menu-hover, #10b981), #059669);
        color: white;
        box-shadow: 0 2px 8px rgba(16, 185, 129, 0.3);
    }

    .view-product-btn:hover {
        background: linear-gradient(135deg, #059669, #047857);
        transform: translateY(-1px);
        box-shadow: 0 4px 12px rgba(16, 185, 129, 0.4);
    }

    .add-to-cart-btn {
        background: transparent;
        color: var(--mega-menu-hover, #10b981);
        border: 2px solid var(--mega-menu-hover, #10b981);
    }

    .add-to-cart-btn:hover {
        background: var(--mega-menu-hover, #10b981);
        color: white;
        transform: translateY(-1px);
    }

    /* Mobile accordion animation */
    .mega-menu-dropdown {
        transition: max-height 0.4s cubic-bezier(0.4, 0, 0.2, 1),
                    opacity 0.3s ease,
                    padding 0.3s ease;
    }

    /* Mobile touch improvements */
    .divi-mega-menu-link,
    .mega-menu-links a,
    .view-product-btn,
    .add-to-cart-btn {
        -webkit-tap-highlight-color: rgba(16, 185, 129, 0.2);
        touch-action: manipulation;
    }

    /* Mobile loading state */
    .mega-menu-loading {
        display: flex;
        align-items: center;
        justify-content: center;
        min-height: 100px;
        color: var(--mega-menu-link, #6b7280);
        font-size: 0.9rem;
    }

    /* Mobile scrolling improvements */
    .mega-menu-dropdown {
        -webkit-overflow-scrolling: touch;
    }

    /* Mobile dark mode adjustments */
    @media (prefers-color-scheme: dark) {
        .mega-menu-product-card {
            background: #374151;
            border-color: #4b5563;
        }

        .mega-menu-dropdown {
            background: #1f2937;
        }
    }

    /* Mobile high contrast mode */
    @media (prefers-contrast: high) {
        .divi-mega-menu-link,
        .mega-menu-links a {
            border: 1px solid currentColor;
            margin-bottom: 2px;
        }

        .mega-menu-product-card {
            border: 2px solid currentColor;
        }
    }

    /* Mobile reduced motion */
    @media (prefers-reduced-motion: reduce) {
        .mega-menu-dropdown,
        .divi-mega-menu-link,
        .mega-menu-links a,
        .mega-menu-product-card,
        .view-product-btn,
        .add-to-cart-btn {
            transition: none;
        }

        .divi-mega-menu-link::after {
            transition: none;
        }
    }
}

/* Hide hamburger menu on desktop */
@media (min-width: 981px) {
    .mobile-menu-toggle {
        display: none !important;
    }
}

/* Prevent body scroll when mobile menu is open */
body.mobile-menu-open {
    overflow: hidden;
    position: fixed;
    width: 100%;
}

/* Tablet adjustments */
@media (min-width: 981px) and (max-width: 1024px) {
    .mega-menu-content {
        grid-template-columns: repeat(3, 1fr);
        gap: 1.5rem;
        padding: 1.5rem;
    }

    .mega-menu-column.products-column {
        grid-column: span 1;
        padding-left: 1rem;
    }

    .mega-menu-product-card .product-image img {
        height: 120px;
    }
}

/* Large mobile adjustments */
@media (min-width: 481px) and (max-width: 980px) {
    .mega-menu-content {
        padding: 1.25rem;
    }

    .mega-menu-links {
        grid-template-columns: repeat(2, 1fr);
        gap: 0.5rem;
    }

    .mega-menu-links li {
        border-bottom: none;
        border: 1px solid rgba(229, 231, 235, 0.5);
        border-radius: 6px;
        margin-bottom: 0.5rem;
    }

    .mega-menu-links a {
        padding: 0.75rem;
        border-radius: 6px;
    }
}

/* Extra small mobile */
@media (max-width: 480px) {
    .divi-mega-menu-nav {
        margin: 0 5px;
    }

    .mega-menu-content {
        padding: 0.75rem;
    }

    .mega-menu-column {
        margin-bottom: 1rem;
    }

    .mega-menu-product-card .product-info {
        padding: 0.75rem;
    }

    .product-actions {
        flex-direction: column;
    }

    .view-product-btn,
    .add-to-cart-btn {
        flex: none;
    }
    

}