/* ============================================
   Custom Overrides — Home Improve In & Out 2
   Site colors: Primary #2797B9, Button #55555e, Header bg #fff
   ============================================ */

/* === Fix 1: Sticky Header === */
header.elementor-location-header {
  position: sticky !important;
  top: 0 !important;
  z-index: 9999 !important;
  width: 100% !important;
  background: #ffffff !important;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
}

/* Override Elementor sticky inline styles that break our sticky */
header.elementor-location-header .elementor-sticky {
  position: relative !important;
  width: 100% !important;
  top: auto !important;
}

header.elementor-location-header .elementor-sticky--active {
  position: relative !important;
  width: 100% !important;
  top: auto !important;
  margin-top: 0 !important;
}

.elementor-sticky__spacer { display: none !important; }

/* Hide the duplicate non-sticky header section (first child) */
header.elementor-location-header > section.elementor-sticky__spacer {
  display: none !important;
}

/* === Fix 3: Desktop Dropdown Flyout === */
.elementor-nav-menu--main .menu-item-has-children { position: relative; }

.elementor-nav-menu--main .menu-item-has-children > .sub-menu {
  display: none;
  position: absolute;
  top: 100%;
  left: 0;
  background: #fff !important;
  min-width: 220px;
  width: max-content;
  max-width: 320px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, 0.14);
  border-radius: 0 0 4px 4px;
  z-index: 10000;
  padding: 6px 0;
  list-style: none;
}

.elementor-nav-menu--main .menu-item-has-children:hover > .sub-menu {
  display: block;
}

/* Submenu link styling */
.elementor-nav-menu--main .sub-menu li a {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  padding: 11px 22px !important;
  font-size: 14px;
  color: #515151 !important;
  text-decoration: none;
  white-space: normal;
  word-wrap: break-word;
  transition: background 0.2s, color 0.2s;
  background: #fff !important;
}

.elementor-nav-menu--main .sub-menu li a:hover {
  background: #2797B9 !important;
  color: #fff !important;
}

/* Inline caret fix */
.elementor-nav-menu--main .sub-menu .menu-item-has-children > a {
  display: flex !important;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.elementor-nav-menu--main .sub-menu .menu-item-has-children > a .sub-arrow {
  display: inline-flex !important;
  align-items: center;
  flex-shrink: 0;
}

.elementor-nav-menu--main .sub-menu .menu-item-has-children > a .sub-arrow i {
  transform: rotate(-90deg) !important;
  font-size: 11px;
}

/* Nested flyout (Areas Served → cities) */
.elementor-nav-menu--main .sub-menu .menu-item-has-children > .sub-menu {
  position: absolute !important;
  top: 0 !important;
  left: 100% !important;
  margin: 0 !important;
  background: #fff !important;
  border-radius: 0 4px 4px 0 !important;
  box-shadow: 4px 4px 16px rgba(0, 0, 0, 0.12) !important;
  z-index: 10001 !important;
  min-width: 180px;
  width: max-content;
  max-width: 320px;
  padding: 6px 0;
}

/* === Fix 4: Dropdown Width === */
.elementor-nav-menu--main .sub-menu li a {
  min-width: 200px;
  padding-right: 30px !important;
}

/* === Fix 5: Mobile/Tablet Nav Menu === */
@media (max-width: 1024px) {
  /* Full-width mobile menu — break out of parent column */
  .elementor-widget-nav-menu {
    position: static !important;
  }

  .elementor-nav-menu--dropdown.elementor-nav-menu__container {
    position: fixed !important;
    top: auto !important;
    left: 0 !important;
    right: 0 !important;
    width: 100vw !important;
    max-width: 100vw !important;
    min-width: 100vw !important;
    background: #fff !important;
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.12) !important;
    z-index: 10000 !important;
    max-height: 80vh;
    overflow-y: auto;
    margin: 0 !important;
    padding: 0 !important;
    transform: none !important;
  }

  /* Menu list reset */
  .elementor-nav-menu--dropdown .elementor-nav-menu {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    padding: 0 !important;
    margin: 0 !important;
    list-style: none !important;
  }

  .elementor-nav-menu--dropdown li {
    width: 100% !important;
    list-style: none;
    display: block !important;
  }

  .elementor-nav-menu--dropdown li > a {
    display: flex !important;
    align-items: center;
    justify-content: center;
    padding: 14px 20px !important;
    font-size: 16px;
    color: #333 !important;
    text-decoration: none;
    border-bottom: 1px solid #f0f0f0;
    width: 100% !important;
    text-align: center;
    box-sizing: border-box;
  }

  /* Parent items with sub-menus: center text+caret */
  .elementor-nav-menu--dropdown .menu-item-has-children > a {
    display: flex !important;
    align-items: center;
    justify-content: center;
    gap: 8px;
  }

  /* Caret inline */
  .elementor-nav-menu--dropdown .menu-item-has-children > a .sub-arrow {
    display: inline-flex !important;
    align-items: center;
    flex-shrink: 0;
    font-size: 12px;
    transition: transform 0.3s;
  }

  .elementor-nav-menu--dropdown .sub-menu-open > a .sub-arrow {
    transform: rotate(180deg);
  }

  /* Sub-menus collapsed by default — full width, indented bg */
  .elementor-nav-menu--dropdown .sub-menu {
    display: none !important;
    position: static !important;
    background: #f8f8f8 !important;
    padding: 0 !important;
    margin: 0 !important;
    width: 100% !important;
    box-shadow: none !important;
    list-style: none !important;
  }

  .elementor-nav-menu--dropdown .sub-menu-open > .sub-menu {
    display: block !important;
  }

  .elementor-nav-menu--dropdown .sub-menu li {
    width: 100% !important;
  }

  .elementor-nav-menu--dropdown .sub-menu a {
    padding: 12px 20px 12px 40px !important;
    font-size: 14px;
    justify-content: center;
    background: #f8f8f8 !important;
    width: 100% !important;
  }

  /* Nested sub-menus (e.g. Areas Served → cities) */
  .elementor-nav-menu--dropdown .sub-menu .sub-menu {
    background: #f2f2f2 !important;
  }

  .elementor-nav-menu--dropdown .sub-menu .sub-menu a {
    padding-left: 60px !important;
    background: #f2f2f2 !important;
  }
}

/* === Elementor responsive visibility === */
@media (max-width: 1024px) {
  .elementor-hidden-tablet {
    display: none !important;
  }
}

@media (max-width: 767px) {
  .elementor-hidden-mobile {
    display: none !important;
  }
}

/* === Mobile header: logo + hamburger side by side === */
@media (max-width: 1024px) {
  /* Force the header section container into a row */
  header.elementor-location-header .elementor-section > .elementor-container {
    display: flex !important;
    flex-direction: row !important;
    flex-wrap: nowrap !important;
    align-items: center !important;
    justify-content: space-between !important;
    padding: 8px 15px !important;
  }

  /* Logo column — shrink to content */
  header.elementor-location-header .elementor-col-33:first-child {
    flex: 0 0 auto !important;
    width: auto !important;
    min-width: 0 !important;
  }

  /* Nav column — shrink to hamburger only, push right */
  header.elementor-location-header .elementor-col-33:nth-child(2) {
    flex: 0 0 auto !important;
    width: auto !important;
    min-width: 0 !important;
    margin-left: auto !important;
  }

  /* Nav widget wrap — just show the hamburger */
  header.elementor-location-header .elementor-col-33:nth-child(2) .elementor-widget-wrap {
    display: flex !important;
    align-items: center !important;
    justify-content: flex-end !important;
  }

  /* Hide the desktop nav on mobile, show only hamburger */
  header.elementor-location-header .elementor-nav-menu--main {
    display: none !important;
  }

  header.elementor-location-header .elementor-menu-toggle {
    display: flex !important;
    align-items: center;
    justify-content: center;
  }

  /* Shrink logo on mobile */
  header.elementor-location-header #site-logo img {
    max-width: 150px !important;
    height: auto !important;
  }

  /* Logo widget — don't stretch */
  header.elementor-location-header .elementor-col-33:first-child .elementor-widget-wrap {
    justify-content: flex-start !important;
    align-items: center !important;
  }
}

/* === Fix 6: Dropdown position below header === */
@media (max-width: 1024px) {
  header.elementor-location-header {
    position: sticky !important;
    top: 0 !important;
  }

  header.elementor-location-header .elementor-section {
    position: relative;
  }
}

/* === Fix 7: Gallery Page — Grid Layout === */
.e-gallery-container.e-gallery-masonry {
  display: grid !important;
  grid-template-columns: repeat(4, 1fr) !important;
  gap: 10px !important;
  position: relative !important;
  padding-bottom: 0 !important;
  height: auto !important;
  margin-bottom: 0 !important;
}

/* Override Elementor masonry height:0 */
.e-gallery-masonry {
  height: auto !important;
  margin-bottom: 0 !important;
}

/* Override Elementor lazyload hiding — show all gallery images immediately */
.e-gallery--lazyload .e-gallery-image:not(.e-gallery-image-loaded) {
  filter: none !important;
  opacity: 1 !important;
  transform: none !important;
}

@media (max-width: 1024px) {
  .e-gallery-container.e-gallery-masonry {
    grid-template-columns: repeat(3, 1fr) !important;
  }
}

@media (max-width: 768px) {
  .e-gallery-container.e-gallery-masonry {
    grid-template-columns: repeat(2, 1fr) !important;
  }
}

.e-gallery-item {
  position: relative !important;
  top: auto !important;
  left: auto !important;
  width: 100% !important;
  height: auto !important;
  transform: none !important;
  aspect-ratio: 4/3;
  overflow: hidden;
  border-radius: 4px;
  cursor: pointer;
}

.e-gallery-item .e-gallery-image {
  width: 100% !important;
  height: 100% !important;
  padding-bottom: 0 !important;
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  background-size: cover !important;
  background-position: center !important;
  transition: transform 0.3s ease;
}

.e-gallery-item:hover .e-gallery-image {
  transform: scale(1.02);
}

/* Hide gallery overlay text/info */
.e-gallery-item .elementor-gallery-item__overlay,
.e-gallery-item .e-gallery-item__overlay {
  display: none !important;
}

/* === Fix 7D: Lightbox CSS === */
#lightbox-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 99999;
  align-items: center;
  justify-content: center;
}

#lightbox-overlay.active {
  display: flex;
}

.lb-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.95);
}

.lb-img-wrap {
  position: relative;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 90vw;
  max-height: 88vh;
}

.lb-img {
  max-width: 90vw;
  max-height: 88vh;
  object-fit: contain;
  transition: opacity 0.3s;
}

.lb-close {
  position: absolute;
  top: 16px;
  right: 20px;
  z-index: 2;
  background: none;
  border: none;
  color: #fff;
  font-size: 36px;
  cursor: pointer;
  line-height: 1;
}

.lb-prev, .lb-next {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  z-index: 2;
  background: rgba(255, 255, 255, 0.15);
  border: none;
  color: #fff;
  font-size: 28px;
  padding: 12px 16px;
  cursor: pointer;
  border-radius: 4px;
  transition: background 0.2s;
}

.lb-prev:hover, .lb-next:hover {
  background: rgba(255, 255, 255, 0.3);
}

.lb-prev { left: 16px; }
.lb-next { right: 16px; }

.lb-spinner {
  display: none;
  position: absolute;
  z-index: 1;
  width: 40px;
  height: 40px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top-color: #fff;
  border-radius: 50%;
  animation: lb-spin 0.8s linear infinite;
}

@keyframes lb-spin {
  to { transform: rotate(360deg); }
}

/* === Fix 8: Unfreeze Carousels === */
/* Override the frozen carousel styles injected in each page's <style> block */
.elementor-swiper-button {
  display: flex !important;
}

.swiper-slide:not(:first-child) {
  display: block !important;
}

.swiper-wrapper {
  display: flex !important;
  overflow: visible !important;
}

.elementor-widget-image-carousel .swiper-slide:not(:first-child) {
  display: block !important;
}

.elementor-widget-image-carousel .swiper-slide {
  flex-shrink: 0;
}

@media (max-width: 1024px) {
  .swiper-slide {
    flex: initial !important;
    max-width: initial !important;
  }
  .swiper-slide:not(:first-child) {
    display: block !important;
  }
}

/* Carousel nav buttons */
.elementor-swiper-button {
  background: #ffffff !important;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
  color: #000000 !important;
}

.elementor-swiper-button i {
  color: #000000 !important;
}

.elementor-swiper-button:hover {
  background: #ffffff !important;
}

/* Thumbnail strip for slideshow skin — keep visible */
.elementor-thumbnails-swiper {
  display: block !important;
  margin-top: 10px;
}

.elementor-thumbnails-swiper .swiper-slide {
  opacity: 0.6;
  cursor: pointer;
  transition: opacity 0.3s;
}

.elementor-thumbnails-swiper .swiper-slide-active,
.elementor-thumbnails-swiper .swiper-slide:hover {
  opacity: 1;
}

/* Slideshow main image container — only in main swiper, NOT thumbnails */
.elementor-main-swiper:not(.elementor-thumbnails-swiper) .elementor-carousel-image {
  width: 100% !important;
  padding-bottom: 75% !important; /* 4:3 aspect ratio */
  background-size: cover !important;
  background-position: center !important;
  border-radius: 4px;
  position: relative !important;
}

/* Thumbnail images — small, no padding-bottom */
.elementor-thumbnails-swiper .elementor-carousel-image {
  width: 100% !important;
  padding-bottom: 75% !important;
  background-size: cover !important;
  background-position: center !important;
  border-radius: 2px;
}

/* Thumbnail strip — constrain height */
.elementor-thumbnails-swiper {
  max-height: 80px !important;
}

.elementor-thumbnails-swiper .swiper-slide {
  max-height: 70px !important;
}

/* Swiper slide must have dimensions */
.elementor-main-swiper:not(.elementor-thumbnails-swiper) .swiper-slide {
  width: 100% !important;
  height: auto !important;
  flex-shrink: 0 !important;
}

/* Ensure the main swiper container has height */
.elementor-main-swiper:not(.elementor-thumbnails-swiper) {
  width: 100% !important;
  overflow: hidden !important;
}

/* === Mobile-only carousel + reviews stacking === */
@media (max-width: 767px) {
  /* Stack the 2-column carousel + reviews sections */
  .elementor-section > .elementor-container > .elementor-col-50 {
    width: 100% !important;
    flex: 0 0 100% !important;
  }

  /* Carousel container needs full width */
  .e-swiper-container {
    width: 100% !important;
  }

  .elementor-widget-media-carousel,
  .elementor-widget-reviews {
    width: 100% !important;
  }

  /* Thumbnail strip on mobile — smaller but visible */
  .elementor-thumbnails-swiper .swiper-slide {
    max-width: 60px !important;
  }

  /* Reviews carousel on mobile */
  .elementor-widget-reviews .elementor-main-swiper {
    width: 100% !important;
  }
}

/* === Fix 11: Smooth Scroll === */
html {
  scroll-behavior: smooth;
  scroll-padding-top: 100px;
}

/* === Fix 13: Vertical centering in text+image sections === */
.elementor-section > .elementor-container {
  display: flex;
  align-items: center;
}

.elementor-section > .elementor-container > .elementor-column {
  display: flex;
  flex-direction: column;
  justify-content: center;
}

/* Text widget wraps should also center vertically */
.elementor-column > .elementor-widget-wrap {
  display: flex;
  flex-direction: column;
  justify-content: center;
  width: 100%;
}

/* Image sizing */
.elementor-widget-image img {
  width: 100%;
  height: auto;
  object-fit: cover;
}

@media (max-width: 767px) {
  .elementor-section > .elementor-container {
    flex-direction: column;
  }

  .elementor-widget-image img {
    height: auto;
    max-height: 400px;
  }
}
