/* Product Image Carousel Styles */

:root {
  --carousel-transition-duration: 0.5s;
  --carousel-arrow-opacity: 0.1;
  --carousel-arrow-hover-opacity: 0.8;
  --carousel-dot-size: 8px;
  --carousel-arrow-size: 24px;
}

/* Carousel Wrapper */
.product-carousel-wrapper {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: var(--product-card-radius, 8px);
  background-color: #f9f9f9;
}

/* Image Slider */
.product-image-slider {
  position: relative;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Individual Carousel Images */
.carousel-image {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  transition: opacity var(--carousel-transition-duration) ease-in-out;
  display: flex;
  align-items: center;
  justify-content: center;
}

.carousel-image.active {
  opacity: 1;
}

.carousel-image img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.5s ease;
}

/* Navigation Arrows */
.carousel-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  width: var(--carousel-arrow-size);
  height: var(--carousel-arrow-size);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: var(--carousel-arrow-opacity);
  transition: opacity 0.3s ease, color 0.3s ease;
  z-index: 10;
  font-size: 12px;
  color: #007bff;
  text-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
}

.carousel-prev {
  left: 8px;
}

.carousel-next {
  right: 8px;
}

/* Show arrows on hover for desktop */
.product-card:hover .carousel-nav {
  opacity: var(--carousel-arrow-hover-opacity);
}

.carousel-nav:hover {
  color: #0056b3;
  opacity: 1;
}

.carousel-nav:focus {
  outline: 2px solid var(--color-accent, #001738);
  outline-offset: 2px;
}

/* Dot Indicators */
.carousel-indicators {
  position: absolute;
  bottom: 12px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  gap: 6px;
  z-index: 10;
}

.carousel-dot {
  width: var(--carousel-dot-size);
  height: var(--carousel-dot-size);
  border-radius: 50%;
  border: none;
  background: rgba(255, 255, 255, 0.5);
  cursor: pointer;
  transition: background-color 0.3s ease, transform 0.2s ease;
}

.carousel-dot.active {
  background: rgba(255, 255, 255, 0.9);
  transform: scale(1.2);
}

.carousel-dot:hover {
  background: rgba(255, 255, 255, 0.8);
}

.carousel-dot:focus {
  outline: 1px solid var(--color-accent, #001738);
  outline-offset: 2px;
}

/* Mobile Specific Styles */
@media (max-width: 768px) {
  .carousel-nav {
    opacity: 0.4; /* More visible on mobile */
    width: 28px;
    height: 28px;
    font-size: 14px;
    color: #007bff;
  }
  
  .carousel-prev {
    left: 6px;
  }
  
  .carousel-next {
    right: 6px;
  }
  
  .carousel-indicators {
    bottom: 8px;
  }
  
  .carousel-dot {
    width: 6px;
    height: 6px;
  }
}

/* High DPI/Retina Display Support */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
  .carousel-nav {
    text-shadow: 0 1px 4px rgba(0, 0, 0, 0.6);
  }
}

/* Hover Effects for Product Card */
.product-card:hover .carousel-image img {
  transform: scale(1.02); /* Subtle zoom on hover */
}

/* Accessibility Improvements */
@media (prefers-reduced-motion: reduce) {
  .carousel-image,
  .carousel-nav,
  .carousel-dot,
  .carousel-image img {
    transition: none;
  }
}

/* Focus Visible for Better Accessibility */
.carousel-nav:focus-visible,
.carousel-dot:focus-visible {
  outline: 2px solid var(--color-accent, #001738);
  outline-offset: 2px;
}

/* Loading State */
.carousel-image img[src=""] {
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading 1.5s infinite;
}

@keyframes loading {
  0% {
    background-position: 200% 0;
  }
  100% {
    background-position: -200% 0;
  }
}

/* Ensure carousel works with existing product card layout */
.product-image-container .product-carousel-wrapper {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Override any existing hover effects that might interfere */
.product-carousel-wrapper:hover .carousel-image img {
  transform: scale(1.02);
}

/* Ensure proper z-index layering */
.product-carousel-wrapper {
  z-index: 1;
}

.product-carousel-wrapper .carousel-nav {
  z-index: 10;
}

.product-carousel-wrapper .carousel-indicators {
  z-index: 10;
}

/* Smooth image loading */
.carousel-image img {
  opacity: 1;
  transition: opacity 0.3s ease, transform 0.5s ease;
}

.carousel-image img[src=""] {
  opacity: 0;
}

/* Enhanced mobile touch area */
@media (max-width: 768px) {
  .carousel-nav {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }
  
  .carousel-dot {
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
  }
}

/* Improve carousel appearance in product grid */
.product-card .product-image-container {
  border-radius: var(--product-card-radius, 8px);
  overflow: hidden;
}

/* Ensure carousel doesn't interfere with existing product card styles */
.product-card:hover .product-carousel-wrapper .carousel-image img {
  transform: scale(1.02);
}

/* Better fallback styling */
.carousel-image img[alt*="View"] {
  background-color: #f9f9f9;
}

/* Improved spacing for carousel elements */
.carousel-indicators {
  padding: 0 4px;
  background: rgba(0, 0, 0, 0.1);
  border-radius: 12px;
  backdrop-filter: blur(2px);
}

/* Enhanced arrow styling */
.carousel-nav i {
  font-size: inherit;
  line-height: 1;
}

/* Prevent text selection on carousel controls */
.carousel-nav,
.carousel-dot {
  user-select: none;
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
}