/* Megamenu Specific Styles */
.mega-menu {
    position: absolute;
    top: 100%;
    left: 0;
    width: 100%;
    background: white;
    box-shadow: 0 4px 20px rgba(0,0,0,0.1);
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: all 0.3s ease;
    z-index: 999;
    max-height: 50vh;
    overflow-y: auto;
    padding: 6px 0;
}

.mega-menu.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}

.dropdown-content {
    display: none;
    padding: 30px 40px;
}

.dropdown-content.active {
    display: block;
}

/* Products Grid in Megamenu */
.mega-menu .products-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 10px 8px;
    max-width: 1600px;
    margin: 0 auto;
    padding: 0 15px;
}

.mega-menu .product-card {
    text-align: center;
    cursor: pointer;
    transition: transform 0.3s;
    margin-bottom: 20px;
}

.mega-menu .product-image {
    position: relative;
    padding-top: 60%;
    overflow: hidden;
    margin-bottom: 4px;
    background: #f8f8f8;
    border-radius: 3px;
    transition: transform 0.2s ease;
}

.mega-menu .product-image img {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.mega-menu .product-card h4 {
    font-size: 10px;
    margin: 2px 0 1px;
    color: #222;
    font-weight: 500;
    line-height: 1.1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding: 0 1px;
}

.mega-menu .product-card .price {
    font-size: 10px;
    font-weight: 600;
    color: #C27BA0;
    margin: 0;
    line-height: 1.1;
}

/* Responsive adjustments */
@media (max-width: 1200px) {
    .mega-menu .products-grid {
        grid-template-columns: repeat(6, 1fr);
    }
}

@media (max-width: 1024px) {
    .mega-menu .products-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

@media (max-width: 768px) {
    .mega-menu .products-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 6px 4px;
        padding: 0 8px;
    }
    
    .mega-menu {
        position: fixed;
        max-height: 40vh;
        overflow-y: auto;
        padding: 2px 0;
    }
    
    .mega-menu .product-image {
        padding-top: 70%;
    }
    
    .mega-menu .product-card h4 {
        font-size: 8px;
    }
    
    .mega-menu .product-card .price {
        font-size: 8px;
    }
}

@media (max-width: 600px) {
    .mega-menu .products-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

@media (max-width: 480px) {
    .mega-menu .products-grid {
        grid-template-columns: repeat(3, 1fr);
        gap: 6px 4px;
    }
    
    .mega-menu .product-card h4,
    .mega-menu .product-card .price {
        font-size: 8px;
    }
    
    .mega-menu .product-image {
        padding-top: 90%;
    }
}

/* Ensure consistent styling across all pages */
#new-products-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    padding: 20px;
    max-width: 1400px;
    margin: 0 auto;
}

/* Fix for specific pages */
body.products-page .mega-menu,
body.category-page .mega-menu {
    z-index: 1001; /* Above other content */
}

/* Fix for mobile menu */
@media (max-width: 768px) {
    .mega-menu {
        position: fixed;
        top: 80px;
        height: calc(100vh - 80px);
        overflow-y: auto;
    }
}
