/**
 * Product Carousel Styles
 * Carousel moderne et responsive pour les images produit
 * 
 * DEPENDENCIES: Ce fichier utilise les CSS custom properties définies dans global.css :
 * --radius-xl, --radius-md, --shadow-lg, --shadow-md, --surface, --transition, --primary
 * Assurez-vous que global.css est chargé avant ce fichier.
 */

/* ========================================
   CAROUSEL PRINCIPAL
   ======================================== */
.product-carousel {
  border-radius: var(--radius-xl);
  overflow: hidden;
  box-shadow: var(--shadow-lg);
  background: var(--surface);
}

.product-carousel .carousel-inner {
  border-radius: var(--radius-xl);
}

.product-carousel .carousel-item {
  transition: transform 0.6s ease-in-out;
}

.carousel-image {
  aspect-ratio: 3 / 4;
  /* Vertical (portrait) format - taller than wide */
  object-fit: cover;
  width: 100%;
  height: auto;
}

/* Single product image - match carousel sizing */
.single-product-image {
  aspect-ratio: 3 / 4;
  /* Same as carousel for consistent sizing */
  object-fit: cover;
  width: 100%;
  height: auto;
}

/* ========================================
   CONTROLS (PREV/NEXT ARROWS)
   ======================================== */
.product-carousel .carousel-control-prev,
.product-carousel .carousel-control-next {
  width: 48px;
  height: 48px;
  top: 50%;
  transform: translateY(-50%);
  opacity: 0;
  transition: opacity var(--transition), background-color var(--transition);
  background-color: rgba(0, 0, 0, 0.5);
  border-radius: 50%;
  backdrop-filter: blur(4px);
}

.product-carousel:hover .carousel-control-prev,
.product-carousel:hover .carousel-control-next {
  opacity: 1;
}

.product-carousel .carousel-control-prev {
  left: 16px;
}

.product-carousel .carousel-control-next {
  right: 16px;
}

.product-carousel .carousel-control-prev:hover,
.product-carousel .carousel-control-next:hover {
  background-color: rgba(0, 169, 157, 0.9);
}

.carousel-control-prev-icon,
.carousel-control-next-icon {
  width: 24px;
  height: 24px;
}

/* ========================================
   INDICATORS (DOTS)
   ======================================== */
.product-carousel .carousel-indicators {
  margin-bottom: 16px;
}

.product-carousel .carousel-indicators [data-bs-target] {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin: 0 4px;
  background-color: rgba(255, 255, 255, 0.5);
  border: 2px solid rgba(255, 255, 255, 0.8);
  transition: all var(--transition);
}

.product-carousel .carousel-indicators .active {
  width: 12px;
  height: 12px;
  background-color: var(--primary);
  border-color: var(--primary);
}

/* ========================================
   THUMBNAILS
   ======================================== */
.carousel-thumbnails {
  display: flex;
  gap: 8px;
  justify-content: center;
  flex-wrap: wrap;
}

.thumbnail-btn {
  width: 80px;
  height: 80px;
  border: 2px solid transparent;
  border-radius: var(--radius-md);
  padding: 0;
  overflow: hidden;
  background: none;
  cursor: pointer;
  transition: all var(--transition);
  opacity: 0.6;
}

.thumbnail-btn img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.thumbnail-btn:hover {
  opacity: 1;
  border-color: var(--primary);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.thumbnail-btn.active {
  opacity: 1;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px var(--primary);
}

/* ========================================
   ANIMATIONS
   ======================================== */
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: scale(0.95);
  }
  to {
    opacity: 1;
    transform: scale(1);
  }
}

.product-carousel .carousel-item-next,
.product-carousel .carousel-item-prev,
.product-carousel .carousel-item.active {
  animation: fadeIn 0.6s ease-in-out;
}

/* ========================================
   RESPONSIVE
   ======================================== */
@media (max-width: 700px) {
  .carousel-image,
  .single-product-image {
    aspect-ratio: 3 / 4;
    /* Keep vertical format on mobile */
  }
  
  .product-carousel .carousel-control-prev,
  .product-carousel .carousel-control-next {
    width: 40px;
    height: 40px;
  }
  
  .product-carousel .carousel-control-prev {
    left: 8px;
  }
  
  .product-carousel .carousel-control-next {
    right: 8px;
  }
  
  .carousel-control-prev-icon,
  .carousel-control-next-icon {
    width: 20px;
    height: 20px;
  }
  
  .thumbnail-btn {
    width: 60px;
    height: 60px;
  }
  
  .carousel-thumbnails {
    gap: 6px;
  }
}

@media (min-width: 701px) and (max-width: 1024px) {
  .carousel-image,
  .single-product-image {
    aspect-ratio: 3 / 4;
    /* Keep vertical format on tablet */
  }
  
  .thumbnail-btn {
    width: 70px;
    height: 70px;
  }
}

/* ========================================
   DARK MODE
   ======================================== */
@media (prefers-color-scheme: dark) {
  .product-carousel {
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.3);
  }
  
  .product-carousel .carousel-control-prev,
  .product-carousel .carousel-control-next {
    background-color: rgba(255, 255, 255, 0.1);
  }
  
  .product-carousel .carousel-control-prev:hover,
  .product-carousel .carousel-control-next:hover {
    background-color: rgba(0, 169, 157, 0.8);
  }
  
  .product-carousel .carousel-indicators [data-bs-target] {
    background-color: rgba(255, 255, 255, 0.3);
    border-color: rgba(255, 255, 255, 0.5);
  }
  
  .thumbnail-btn {
    border-color: rgba(255, 255, 255, 0.1);
  }
  
  .thumbnail-btn:hover,
  .thumbnail-btn.active {
    border-color: var(--primary);
  }
}

/* ========================================
   LOADING STATE
   ======================================== */
.carousel-image:not([src]),
.carousel-image[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;
  }
}

/* ========================================
   ACCESSIBILITY
   ======================================== */
.carousel-control-prev:focus,
.carousel-control-next:focus,
.thumbnail-btn:focus {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}

/* Improve contrast for better visibility */
.visually-hidden {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
