/* Wolmart Mega Menu Masonry Layout Styles */

/* Fix mega menu positioning and width issues */
.megamenu[style*="width"] {
  max-width: min(var(--megamenu-width, 1200px), calc(100vw - 40px)) !important;
}

/* Prevent mega menu from being positioned off-screen */
.megamenu[style*="left"][style*="-"] {
  left: 0 !important;
  transform: none !important;
}

/* Force removal of Elementor's equal height behavior - ONLY in mega menu */
.wolmart-block [data-elementor-type="wolmart_template"] .elementor-section,
.wolmart-block [data-elementor-type="wolmart_template"] .e-con,
.wolmart-block .masonry-layout .e-con-inner,
.wolmart-block .masonry-layout .e-con {
  height: auto !important;
  min-height: unset !important;
  flex: 0 0 auto !important;
  align-self: flex-start !important;
}

/* Main container - force masonry with CSS columns - ONLY in mega menu */
.wolmart-block .masonry-layout > .e-con-inner,
.wolmart-block .masonry-layout > .e-con {
  display: block !important;
  column-count: 4;
  column-gap: 20px;
  column-fill: auto !important;
}

/* Each card must break the flex behavior - ONLY in mega menu */
.wolmart-block .masonry-layout .e-con[data-element_type="container"] {
  display: inline-block !important;
  width: 100% !important;
  break-inside: avoid;
  page-break-inside: avoid;
  margin: 0 0 20px 0 !important;
  vertical-align: top;
  transform: translateZ(0);
}

/* Force widgets to natural height - ONLY in mega menu */
.wolmart-block .masonry-layout .elementor-widget-container,
.wolmart-block .masonry-layout .elementor-widget-wrap {
  height: auto !important;
  min-height: 0 !important;
}

/* Override Elementor's stretched container - ONLY in mega menu */
.wolmart-block .masonry-layout .elementor-bc-flex-widget .elementor-section-content-middle {
  align-items: flex-start !important;
}

/* Disable any flex grow/shrink that forces equal heights - ONLY in mega menu */
.wolmart-block .masonry-layout .e-con > .e-con {
  flex-grow: 0 !important;
  flex-shrink: 0 !important;
  flex-basis: auto !important;
}

/* Ensure content takes natural height */
.wolmart-block .custom-megamenu .elementor-widget-wrap,
.wolmart-block .custom-megamenu .elementor-widget {
  height: auto !important;
  min-height: auto !important;
}

/* Tablet: 2 columns */
@media (min-width: 768px) and (max-width: 1024px) {
  .wolmart-block .custom-megamenu > .e-con:first-child,
  .wolmart-block .custom-megamenu > .elementor-section:first-child > .e-con {
    column-count: 2;
  }
}

/* Mobile: 1 column */
@media (max-width: 767px) {
  .wolmart-block .custom-megamenu > .e-con:first-child,
  .wolmart-block .custom-megamenu > .elementor-section:first-child > .e-con {
    column-count: 1;
  }
  
  .wolmart-block .custom-megamenu .e-con[data-element_type="container"] {
    margin-bottom: 15px !important;
  }
}

/* Style for better visual appearance */
.custom-megamenu .wolmart-icon-lists {
  background: rgba(248,248,248,0.5);
  border-radius: 5px;
}

/* Override theme's border styling for icon list items */
.custom-megamenu .wolmart-icon-lists.block-type .wolmart-icon-list-item::after,
.wolmart-block .wolmart-icon-lists.block-type .wolmart-icon-list-item::after {
  display: none !important;
  border: none !important;
}

/* Fix masonry layout with CSS columns - Target ONLY custom-megamenu class */
.wolmart-block .custom-megamenu.masonry-style .e-con-full.e-flex.e-con.e-parent {
  column-count: 4;
  column-gap: 10px;
  display: block !important;
  flex-wrap: unset !important;
}

.wolmart-block .custom-megamenu.masonry-style .e-con-full.e-flex.e-con.e-child {
  break-inside: avoid;
  margin-bottom: 10px;
  display: inline-block !important;
  width: 100% !important;
}

@media (max-width: 768px) {
  .wolmart-block .custom-megamenu.masonry-style .e-con-full.e-flex.e-con.e-parent {
    column-count: 2;
  }
}

/* Ensure cards with gray background maintain their style - ONLY in mega menu */
.wolmart-block .custom-megamenu .e-con[style*="background"] {
  padding: 10px !important;
  border-radius: 8px;
  box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* Main section with masonry style */
.custom-megamenu.masonry-style {
    width: 100%;
}

.custom-megamenu.masonry-style .elementor-section-boxed > .elementor-container {
    max-width: 100%;
}

/* Column styling for masonry effect */
.megamenu-column {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
}

/* Heading styles */
.megamenu-column h4 {
    font-size: 14px !important;
    text-transform: uppercase !important;
    font-weight: 600 !important;
    color: #333 !important;
    margin: 0 0 10px 0 !important;
    padding-bottom: 8px !important;
    border-bottom: 2px solid #e1e1e1 !important;
    width: 100%;
}

/* Additional spacing between category groups in same column */
.megamenu-column .elementor-widget-wolmart_widget_heading:not(:first-child) {
    margin-top: 25px !important;
}

/* Icon list styles */
.megamenu-column .elementor-icon-list-items {
    margin: 0 !important;
    padding: 0 !important;
    width: 100%;
}

.megamenu-column .elementor-icon-list-item {
    padding: 4px 0 !important;
    margin: 0 !important;
}

.megamenu-column .elementor-icon-list-item a {
    color: #666 !important;
    text-decoration: none !important;
    font-size: 13px !important;
    line-height: 1.5 !important;
    transition: color 0.2s ease;
    display: block;
}

.megamenu-column .elementor-icon-list-item a:hover {
    color: #333 !important;
    text-decoration: underline !important;
}

/* View All link styling */
.megamenu-column .elementor-icon-list-item:last-child a {
    font-weight: 600 !important;
    color: #0073aa !important;
    margin-top: 5px;
}

.megamenu-column .elementor-icon-list-item:last-child a:hover {
    color: #005177 !important;
}

/* Responsive adjustments */
@media (max-width: 1024px) {
    .megamenu-column {
        width: 50% !important;
    }
}

@media (max-width: 768px) {
    .megamenu-column {
        width: 100% !important;
        padding: 0 10px;
    }
    
    .megamenu-column h4 {
        font-size: 13px !important;
    }
    
    .megamenu-column .elementor-icon-list-item a {
        font-size: 12px !important;
    }
}

/* Mega menu width adjustments */
.wolmart-mega-menu-width-850 .custom-megamenu.masonry-style {
    max-width: 850px;
    margin: 0 auto;
}

.wolmart-mega-menu-width-1200 .custom-megamenu.masonry-style {
    max-width: 1200px;
    margin: 0 auto;
}

.wolmart-mega-menu-width-1400 .custom-megamenu.masonry-style {
    max-width: 1400px;
    margin: 0 auto;
}

.wolmart-mega-menu-width-100 .custom-megamenu.masonry-style {
    max-width: 100%;
}

/* Ensure proper column heights for masonry effect */
.custom-megamenu.masonry-style .elementor-container {
    align-items: flex-start !important;
}

@media (max-width: 768px) {
    .megamenu-column {
        padding-bottom: 20px;
        margin-bottom: 20px;
    }
}