/**
 * GT - Afficher toutes les images produit
 * Styles pour la modale carousel des déclinaisons
 *
 * @author    GT (Leman SA)
 * @copyright 2024 Leman SA
 * @license   https://opensource.org/licenses/AFL-3.0 Academic Free License 3.0 (AFL-3.0)
 */

/* ==========================================================================
   LIGNES CLIQUABLES DU TABLEAU
   ========================================================================== */

/**
 * Style de base pour les lignes cliquables
 */
.gt-clickable-row {
  cursor: pointer;
  transition:
    background-color 0.2s ease,
    transform 0.15s ease;
  position: relative;
}

/**
 * Effet au survol
 */
.gt-clickable-row:hover {
  background-color: rgba(var(--bs-primary-rgb, 13, 110, 253), 0.08) !important;
}

/**
 * Effet au focus (accessibilité)
 */
.gt-clickable-row:focus {
  outline: 2px solid var(--bs-primary, #0d6efd);
  outline-offset: -2px;
  background-color: rgba(var(--bs-primary-rgb, 13, 110, 253), 0.05) !important;
}

/**
 * Indicateur visuel d'images disponibles
 */
.gt-image-indicator {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  margin-left: 0.5rem;
  color: var(--bs-primary, #0d6efd);
  opacity: 0.7;
  transition:
    opacity 0.2s ease,
    transform 0.2s ease;
}

.gt-image-indicator i {
  font-size: 1rem;
}

.gt-clickable-row:hover .gt-image-indicator {
  opacity: 1;
  transform: scale(1.1);
}

/* ==========================================================================
   MODALE COMBINATION
   ========================================================================== */

/**
 * Style de base de la modale
 */
.gt-combination-modal .modal-content {
  border-radius: 0.5rem;
  overflow: hidden;
  border: none;
  box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

/**
 * En-tête de la modale
 */
.gt-combination-modal .modal-header {
  background-color: var(--bs-light, #f8f9fa);
  border-bottom: 1px solid var(--bs-border-color, #dee2e6);
  padding: 1rem 1.25rem;
}

.gt-combination-modal .modal-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: #009fe3;
}

.gt-modal-reference {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/**
 * Corps de la modale
 */
.gt-combination-modal .modal-body {
  padding: 1.5rem;
  background-color: var(--bs-white, #fff);
}

/**
 * Bouton fermer
 */
.gt-combination-modal .btn-close {
  opacity: 0.7;
  transition: opacity 0.2s ease;
}

.gt-combination-modal .btn-close:hover {
  opacity: 1;
}

/* ==========================================================================
   CAROUSEL
   ========================================================================== */

/**
 * Conteneur du carousel
 */
#gt-combination-carousel {
  position: relative;
  border-radius: 0.375rem;
  overflow: hidden;
}

/**
 * Items du carousel
 */
#gt-combination-carousel .carousel-item {
  background-color: var(--bs-light, #f8f9fa);
}

#gt-combination-carousel .carousel-item img {
  max-height: 70vh;
  object-fit: contain;
  margin: 0 auto;
}

/**
 * Boutons de navigation
 */
#gt-combination-carousel .carousel-control-prev,
#gt-combination-carousel .carousel-control-next {
  width: 3rem;
  height: 3rem;
  top: 50%;
  transform: translateY(-50%);
  background-color: rgba(0, 0, 0, 0.5);
  border-radius: 50%;
  opacity: 0.7;
  transition:
    opacity 0.2s ease,
    background-color 0.2s ease;
}

#gt-combination-carousel .carousel-control-prev {
  left: 0.75rem;
}

#gt-combination-carousel .carousel-control-next {
  right: 0.75rem;
}

#gt-combination-carousel .carousel-control-prev:hover,
#gt-combination-carousel .carousel-control-next:hover {
  opacity: 1;
  background-color: rgba(0, 0, 0, 0.7);
}

#gt-combination-carousel .carousel-control-prev:focus,
#gt-combination-carousel .carousel-control-next:focus {
  opacity: 1;
  outline: 2px solid var(--bs-primary, #0d6efd);
  outline-offset: 2px;
}

#gt-combination-carousel .carousel-control-prev-icon,
#gt-combination-carousel .carousel-control-next-icon {
  width: 1.25rem;
  height: 1.25rem;
}

/* ==========================================================================
   THUMBNAILS
   ========================================================================== */

/**
 * Liste des thumbnails
 */
.gt-thumbnails-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  list-style: none;
  padding: 1rem 0 0 0;
  margin: 0;
  justify-content: center;
  border-top: 1px solid var(--bs-border-color, #dee2e6);
  margin-top: 1rem;
}

/**
 * Thumbnail individuel
 */
.gt-thumbnail {
  width: 4rem;
  height: 4rem;
  cursor: pointer;
  border: 2px solid transparent;
  border-radius: 0.25rem;
  overflow: hidden;
  transition:
    border-color 0.2s ease,
    transform 0.15s ease;
  background-color: var(--bs-light, #f8f9fa);
}

.gt-thumbnail:hover {
  border-color: var(--bs-secondary, #6c757d);
  transform: scale(1.05);
}

.gt-thumbnail:focus {
  outline: none;
  border-color: var(--bs-primary, #0d6efd);
  box-shadow: 0 0 0 2px rgba(var(--bs-primary-rgb, 13, 110, 253), 0.25);
}

.gt-thumbnail.active {
  border-color: var(--bs-primary, #0d6efd);
}

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

/* ==========================================================================
   RESPONSIVE
   ========================================================================== */

/**
 * Tablettes
 */
@media (max-width: 991.98px) {
  .gt-combination-modal .modal-body {
    padding: 1rem;
  }

  #gt-combination-carousel .carousel-item img {
    max-height: 60vh;
  }

  .gt-thumbnail {
    width: 3.5rem;
    height: 3.5rem;
  }
}

/**
 * Mobile
 */
@media (max-width: 575.98px) {
  .gt-combination-modal .modal-header {
    padding: 0.75rem 1rem;
  }

  .gt-combination-modal .modal-title {
    font-size: 1rem;
  }

  .gt-combination-modal .modal-body {
    padding: 0.75rem;
  }

  #gt-combination-carousel .carousel-control-prev,
  #gt-combination-carousel .carousel-control-next {
    width: 2.5rem;
    height: 2.5rem;
  }

  #gt-combination-carousel .carousel-control-prev {
    left: 0.5rem;
  }

  #gt-combination-carousel .carousel-control-next {
    right: 0.5rem;
  }

  #gt-combination-carousel .carousel-item img {
    max-height: 50vh;
  }

  .gt-thumbnails-list {
    gap: 0.375rem;
    padding-top: 0.75rem;
    margin-top: 0.75rem;
  }

  .gt-thumbnail {
    width: 3rem;
    height: 3rem;
  }

  .gt-image-indicator i {
    font-size: 0.875rem;
  }
}

/* ==========================================================================
   ANIMATIONS
   ========================================================================== */

/**
 * Animation d'entrée de la modale (amélioration de Bootstrap)
 */
.gt-combination-modal.fade .modal-dialog {
  transform: scale(0.95) translateY(-10px);
  transition: transform 0.2s ease-out;
}

.gt-combination-modal.show .modal-dialog {
  transform: scale(1) translateY(0);
}

/* ==========================================================================
   ACCESSIBILITÉ
   ========================================================================== */

/**
 * Mode contraste élevé
 */
@media (prefers-contrast: high) {
  .gt-clickable-row:hover {
    background-color: rgba(0, 0, 0, 0.1) !important;
  }

  .gt-thumbnail {
    border-width: 3px;
  }

  .gt-thumbnail.active {
    border-color: #000;
  }
}

/**
 * Réduction des animations si demandé par l'utilisateur
 */
@media (prefers-reduced-motion: reduce) {
  .gt-clickable-row,
  .gt-image-indicator,
  .gt-thumbnail,
  #gt-combination-carousel .carousel-control-prev,
  #gt-combination-carousel .carousel-control-next,
  .gt-combination-modal .btn-close,
  .gt-combination-modal.fade .modal-dialog {
    transition: none;
  }

  .gt-clickable-row:hover .gt-image-indicator {
    transform: none;
  }

  .gt-thumbnail:hover {
    transform: none;
  }
}

/* ==========================================================================
   THÈME SOMBRE (si supporté par le thème)
   ========================================================================== */

@media (prefers-color-scheme: dark) {
  .gt-combination-modal .modal-content {
    background-color: var(--bs-dark, #212529);
    color: var(--bs-light, #f8f9fa);
  }

  .gt-combination-modal .modal-header {
    background-color: rgba(255, 255, 255, 0.05);
    border-bottom-color: rgba(255, 255, 255, 0.1);
  }

  #gt-combination-carousel .carousel-item {
    background-color: rgba(255, 255, 255, 0.05);
  }

  .gt-thumbnail {
    background-color: rgba(255, 255, 255, 0.1);
  }

  .gt-thumbnails-list {
    border-top-color: rgba(255, 255, 255, 0.1);
  }
}

/* Masque le 1er thumbnail de la liste pour éviter la duplication avec l'image principale */
.thumbnails__list .thumbnail:first-child {
  display: none;
}
