/* Frontend styles for Algo Image Carousel */

.algo-image-carousel {
  position: relative !important;
  width: 100%;
  height: 400px; /* Default height if not set via admin */
  overflow: hidden;
  background: #000; /* Add background color to prevent transparency */
  z-index: 1;
  /* Ensure carousel is isolated from other page elements */
  isolation: isolate;
  contain: layout style paint;
}

/* Ensure all absolutely positioned elements within carousel are contained */
.algo-image-carousel * {
  position: relative;
}

.algo-image-carousel .carousel-slide,
.algo-image-carousel .carousel-nav,
.algo-image-carousel .carousel-dots {
  position: absolute !important;
}

.carousel-slide {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  visibility: hidden; /* Hide inactive slides completely */
  transition: opacity 0.8s ease-in-out;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1;
  will-change: opacity; /* Optimize for animations */
}

.carousel-slide.active {
  opacity: 1;
  visibility: visible; /* Show active slide */
  z-index: 2;
}

.carousel-slide img {
  width: 100%;
  height: 100% !important; /* Force 100% height */
  object-fit: cover;
  display: block;
  backface-visibility: hidden; /* Prevent flickering */
  -webkit-backface-visibility: hidden;
  transform: translateZ(0); /* Force GPU acceleration */
  -webkit-transform: translateZ(0);
  image-rendering: -webkit-optimize-contrast; /* Improve image quality */
  image-rendering: crisp-edges;
}

.image-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 2;
  background: rgba(
    0,
    0,
    0,
    0.3
  ); /* Add slight overlay to prevent transparency */
}

/* Navigation buttons */
.carousel-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.7);
  color: white;
  border: none;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  cursor: pointer;
  z-index: 10;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.3s ease;
  -webkit-tap-highlight-color: transparent; /* Remove tap highlight on mobile */
}

.carousel-nav.prev {
  left: 20px;
}

.carousel-nav.next {
  right: 20px;
}

.carousel-nav:hover {
  background: rgba(0, 0, 0, 0.9);
}

/* Dots navigation */
.carousel-dots {
  position: absolute !important;
  bottom: 20px !important;
  left: 50% !important;
  transform: translateX(-50%) !important;
  display: flex !important;
  gap: 10px;
  z-index: 10;
  padding: 10px;
  background: rgba(0, 0, 0, 0.3);
  border-radius: 20px;
  backdrop-filter: blur(5px);
  /* Ensure dots stay within carousel bounds */
  max-width: calc(100% - 40px);
  overflow: hidden;
}

.carousel-dots .dot {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.6);
  border: 2px solid rgba(255, 255, 255, 0.4);
  cursor: pointer;
  transition: all 0.3s ease;
  -webkit-tap-highlight-color: transparent; /* Remove tap highlight on mobile */
  display: block;
  min-width: 12px;
  min-height: 12px;
  box-sizing: border-box;
  flex-shrink: 0;
}

.carousel-dots .dot:hover {
  background: rgba(255, 255, 255, 0.9);
  border-color: rgba(255, 255, 255, 0.7);
  transform: scale(1.1);
}

.carousel-dots .dot.active {
  background: #ffffff;
  border-color: #ffffff;
  transform: scale(1.3);
  box-shadow: 0 0 15px rgba(255, 255, 255, 0.8);
}
