/* Gallery Frontend Styles */

.sgm-gallery-wrapper {
    margin: 0;
    width: 100%;
    position: relative; /* Create stacking context */
    z-index: 1; /* Establish a baseline z-index */
}

.sgm-gallery-container {
    position: relative;
    z-index: 2; /* Higher than wrapper */
}

/* Base swiper styling */
.sgm-gallery-container .swiper {
    width: 100%;
    height: 70vh !important; 
    max-height: 800px !important;
    margin-left: auto;
    margin-right: auto;
    z-index: 3; /* Higher than container */
}

.sgm-gallery-container .swiper-slide {
    text-align: center;
    background: #fff;
    display: flex !important;
    justify-content: center;
    align-items: center;
    height: 70vh !important; 
    max-height: 800px !important;
    opacity: 1 !important;
    position: relative; /* Create stacking context */
    z-index: 4; /* Higher than swiper */
}

.sgm-gallery-container .swiper-slide::before {background-color: #fff !important;}

.sgm-image-wrapper {
    width: 100%;
    position: relative; /* Create stacking context */
    z-index: 5; /* Higher than slide */
    height: 100%;
    display: flex;
    flex-direction: column;
    justify-content: center;
}


.sgm-image-wrapper img {
    max-width: 100%;
    height: 100%;
    display: block !important;
    margin: 0 auto;
    opacity: 1 !important;
    position: relative; /* As you discovered, this is crucial */
    z-index: 99999; /* Very high to ensure visibility */
}

.sgm-caption {
  color: #002E5D;
  padding: 10px 15px;
  text-align: left;
  width: 90vw;
  box-sizing: border-box;
  margin: 0;
  position: absolute;
  z-index: 99999;
  bottom: -45px;
  height: 45px;
  max-width: 1200px;
  left: 50%;
  transform: translateX(-50%);
  font-size: 16px;
  font-weight: 600;
}




/* Navigation buttons */
.sgm-gallery-container .swiper-button-next,
.sgm-gallery-container .swiper-button-prev {
    color: #fff;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 50%;
    width: 40px;
    height: 40px;
    z-index: 10000; /* Very high to ensure visibility */
}

.sgm-gallery-container .swiper-button-next:after,
.sgm-gallery-container .swiper-button-prev:after {
    font-size: 18px;
}

/* Pagination */
.sgm-gallery-container .swiper-pagination {
    position: absolute;
  bottom: -45px;
  z-index: 10000;
  background: transparent;
  height: 45px;
  display: flex;
  justify-content: flex-end;
  align-items: center;
  max-width: 1200px;
  width: 90vw;
  transform: translateX(-50%);
  left: 50%;
}

.sgm-gallery-container .swiper-horizontal .swiper-pagination-bullets .swiper-pagination-bullet{border: 1px solid #002E5D;}


/* Fix for opacity issues */
.swiper-wrapper {
    opacity: 1 !important;
}

.swiper-slide-active {
    opacity: 1 !important;
    z-index: 5 !important;
}

/* Override any hidden styles that might be applied */
.swiper-slide-active, 
.swiper-slide-duplicate-active {
    visibility: visible !important;
}

/* Ensure images in active slides are visible */
.swiper-slide-active img,
.swiper-slide-duplicate-active img {
    visibility: visible !important;
    opacity: 1 !important;
}

/* Force visibility on Swiper container */
.swiper {
    overflow: visible !important;
}

/* Responsive styles */
@media (max-width: 768px) {
    .sgm-gallery-container .swiper-button-next,
    .sgm-gallery-container .swiper-button-prev {
        width: 30px;
        height: 30px;
    }
    
    .sgm-caption {font-size: 14px;}
    .sgm-gallery-container .swiper, .sgm-gallery-container .swiper-slide  {max-height: 460px !important;}
}
