/*--------------------------------------------------------------
# CUSTOM CAROUSEL SYSTEM (SWIPER REPLACEMENT)
--------------------------------------------------------------*/

/* Carousel Container */
.custom-carousel {
  position: relative;
  width: 100%;
  overflow: hidden;
  touch-action: pan-y;
}

.custom-carousel.loading {
  min-height: 200px;
}

/* Carousel Wrapper */
.carousel-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  will-change: transform;
}

/* Carousel Slides */
.carousel-slide {
  flex-shrink: 0;
  width: 100%;
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Auto sizing for brand logos */
.brands-carousel .carousel-slide {
  width: auto;
  margin-right: 2rem;
}

.brands-carousel .carousel-slide:last-child {
  margin-right: 0;
}

/* Slide content */
.carousel-slide img {
  display: block;
  width: 100%;
  height: auto;
  object-fit: cover;
}

.brands-carousel .carousel-slide img {
  width: auto;
  max-width: 120px;
  height: 60px;
  object-fit: contain;
  opacity: 0.7;
  transition: opacity 0.3s ease, transform 0.3s ease;
}

.brands-carousel .carousel-slide img:hover {
  opacity: 1;
  transform: scale(1.1);
}

/* Navigation Arrows */
.carousel-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.9);
  border: none;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.carousel-nav:hover {
  background: var(--accent-color);
  color: white;
  transform: translateY(-50%) scale(1.1);
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.carousel-nav.prev {
  left: 15px;
}

.carousel-nav.next {
  right: 15px;
}

.carousel-nav svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
}

/* Hide navigation on brands carousel by default */
.brands-carousel .carousel-nav {
  display: none;
}

/* Pagination Dots */
.carousel-pagination {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  margin-top: 20px;
}

.carousel-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: rgba(0, 0, 0, 0.3);
  border: none;
  cursor: pointer;
  transition: all 0.3s ease;
  padding: 0;
}

.carousel-dot.active {
  background: var(--accent-color);
  transform: scale(1.2);
}

.carousel-dot:hover {
  background: var(--accent-color);
  opacity: 0.8;
}

/* Hide pagination on brands carousel */
.brands-carousel .carousel-pagination {
  display: none;
}

/* Progress Bar */
.carousel-progress {
  position: absolute;
  bottom: 0;
  left: 0;
  height: 3px;
  background: var(--accent-color);
  transition: width 0.3s ease;
  z-index: 5;
}

/* Autoplay pause indicator */
.carousel-pause {
  position: absolute;
  top: 15px;
  right: 15px;
  background: rgba(0, 0, 0, 0.5);
  color: white;
  border: none;
  padding: 8px;
  border-radius: 4px;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.3s ease;
  z-index: 10;
}

.custom-carousel:hover .carousel-pause {
  opacity: 1;
}

/* Loading state */
.carousel-loading {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 40px;
  height: 40px;
  border: 3px solid rgba(0, 0, 0, 0.1);
  border-left: 3px solid var(--accent-color);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* Responsive Breakpoints */
@media (max-width: 768px) {
  .carousel-nav {
    width: 36px;
    height: 36px;
  }
  
  .carousel-nav.prev {
    left: 10px;
  }
  
  .carousel-nav.next {
    right: 10px;
  }
  
  .brands-carousel .carousel-slide {
    margin-right: 1.5rem;
  }
  
  .brands-carousel .carousel-slide img {
    max-width: 100px;
    height: 50px;
  }
}

@media (max-width: 576px) {
  .carousel-nav {
    display: none;
  }
  
  .brands-carousel .carousel-slide {
    margin-right: 1rem;
  }
  
  .brands-carousel .carousel-slide img {
    max-width: 80px;
    height: 40px;
  }
}

/* Smooth scrolling for touch devices */
.custom-carousel {
  -webkit-overflow-scrolling: touch;
}

/* Disable text selection during dragging */
.custom-carousel.dragging {
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
}

/* Animation variations */
.carousel-wrapper.fade {
  transition: opacity 0.5s ease;
}

.carousel-wrapper.slide {
  transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
}

.carousel-wrapper.ease-out {
  transition-timing-function: ease-out;
}

.carousel-wrapper.ease-in-out {
  transition-timing-function: ease-in-out;
}

/* Infinite loop animation for brands */
@keyframes infiniteScroll {
  from { transform: translateX(0); }
  to { transform: translateX(-100%); }
}

.brands-carousel.infinite-scroll .carousel-wrapper {
  animation: infiniteScroll linear infinite;
  animation-duration: var(--scroll-duration, 30s);
}

.brands-carousel.infinite-scroll:hover .carousel-wrapper {
  animation-play-state: paused;
}

/* Performance optimizations */
.carousel-wrapper {
  transform: translate3d(0, 0, 0);
  backface-visibility: hidden;
  perspective: 1000px;
}

.carousel-slide {
  transform: translate3d(0, 0, 0);
  backface-visibility: hidden;
}

/* Focus styles for accessibility */
.carousel-nav:focus,
.carousel-dot:focus {
  outline: 2px solid var(--accent-color);
  outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
  .carousel-nav {
    background: white;
    border: 2px solid black;
  }
  
  .carousel-dot {
    border: 1px solid black;
  }
  
  .carousel-dot.active {
    background: black;
  }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
  .carousel-wrapper {
    transition: none;
  }
  
  .brands-carousel.infinite-scroll .carousel-wrapper {
    animation: none;
  }
  
  .carousel-nav,
  .carousel-dot {
    transition: none;
  }
}