/**
 * Styles pour le module WGL Favorite Products
 * 
 * @author Bibou la Tisane
 * @version 1.0.0
 */

/* ==========================================================================
   Variables CSS
   ========================================================================== */
:root {
  --wgl-heart-color-default: #6c757d;
  --wgl-heart-color-hover: #dc3545;
  --wgl-heart-color-favorite: #dc3545;
  --wgl-heart-size-small: 20px;
  --wgl-heart-size-medium: 24px;
  --wgl-heart-size-large: 28px;
  --wgl-transition-fast: 0.2s ease-in-out;
  --wgl-transition-smooth: 0.3s ease-in-out;
  --wgl-shadow-light: 0 2px 4px rgba(0,0,0,0.1);
  --wgl-shadow-medium: 0 4px 8px rgba(0,0,0,0.15);
  --wgl-border-radius: 0.375rem;
  --wgl-bg-vert : #bfd400;
}

/* ==========================================================================
   Animations communes
   ========================================================================== */
@keyframes wgl-heartbeat {
  0% { transform: scale(1); }
  50% { transform: scale(1.2); }
  100% { transform: scale(1); }
}

@keyframes wgl-pulse {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.1); opacity: 0.7; }
  100% { transform: scale(1); opacity: 1; }
}

@keyframes wgl-spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

@keyframes wgl-fadeIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ==========================================================================
   Coeur sur liste de produits
   ========================================================================== */
.wgl-favorite-heart-container {
  position: absolute;
  top: 60px;
  right: 10px;
  z-index: 10;
  opacity: 0;
  transform: translateY(-5px);
  transition: var(--wgl-transition-smooth);
}

#category .wgl-favorite-heart-container,
#module-ambjolisearch-jolisearch .wgl-favorite-heart-container {
  top: 10px;
}

/* Affichage au survol du produit */
.product-miniature:hover .wgl-favorite-heart-container,
.wgl-favorite-heart-container.is-favorite {
  opacity: 1;
  transform: translateY(0);
}

.wgl-favorite-heart-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border: none;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.9);
  backdrop-filter: blur(4px);
  box-shadow: var(--wgl-shadow-light);
  cursor: pointer;
  transition: var(--wgl-transition-fast);
  position: relative;
}

.wgl-favorite-heart-btn:hover {
  background: var(--wgl-bg-vert);
  box-shadow: var(--wgl-shadow-medium);
  transform: scale(1.05);
}

.wgl-favorite-heart-btn.is-loading {
  pointer-events: none;
}

.wgl-heart-icon {
  fill: var(--wgl-heart-color-default);
  transition: var(--wgl-transition-fast);
  width: var(--wgl-heart-size-small);
  height: var(--wgl-heart-size-small);
}

.wgl-favorite-heart-btn:hover .wgl-heart-icon {
  fill: white;
}

.wgl-favorite-heart-btn.is-favorite .wgl-heart-icon {
  fill: var(--wgl-heart-color-favorite);
  animation: wgl-heartbeat 0.6s ease-in-out;
}

/* Tooltip */
.wgl-heart-tooltip {
  position: absolute;
  bottom: -35px;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 4px 8px;
  border-radius: var(--wgl-border-radius);
  font-size: 12px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: var(--wgl-transition-fast);
  z-index: 1000;
}

.wgl-heart-tooltip::before {
  content: '';
  position: absolute;
  top: -4px;
  left: 50%;
  transform: translateX(-50%);
  border-left: 4px solid transparent;
  border-right: 4px solid transparent;
  border-bottom: 4px solid rgba(0, 0, 0, 0.8);
}

.wgl-favorite-heart-container:hover .wgl-heart-tooltip {
  opacity: 1;
  animation: wgl-fadeIn 0.3s ease-out;
}

/* ==========================================================================
   Bouton sur fiche produit
   ========================================================================== */
.wgl-favorite-product-page {
  margin: 15px 0;
}

.wgl-favorite-product-btn {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: var(--wgl-border-radius);
  font-size: 14px;
  font-weight: 500;
  transition: var(--wgl-transition-fast);
  position: relative;
  overflow: hidden;
}

.wgl-favorite-product-btn .wgl-heart-icon {
  fill: currentColor;
  transition: var(--wgl-transition-fast);
  flex-shrink: 0;
}

.wgl-favorite-product-btn.is-favorite {
  background-color: var(--wgl-bg-vert);;
  border-color: var(--wgl-bg-vert);;
  color: white;
}

.wgl-favorite-product-btn.is-favorite .wgl-heart-icon {
  animation: wgl-pulse 2s infinite;
}

.wgl-favorite-product-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--wgl-shadow-medium);
}

.wgl-favorite-product-btn.is-loading {
  pointer-events: none;
  opacity: 0.7;
}

.wgl-favorite-product-btn.is-loading .wgl-btn-text {
  opacity: 0.5;
}

/* Message de feedback sur fiche produit */
.wgl-favorite-message {
  margin-top: 10px;
  animation: wgl-fadeIn 0.5s ease-out;
}

.wgl-favorite-message .alert {
  margin-bottom: 0;
  padding: 8px 12px;
  font-size: 13px;
}

/* ==========================================================================
   Badge dans le header
   ========================================================================== */
.wgl-favorite-header-badge {
  position: relative;
  display: inline-flex;
  align-items: center;
  float: right;
  padding: 34px 0;
}

@media (max-width: 1199px) {
    .wgl-favorite-header-badge {
        padding: 25px 0;
    }
}

.wgl-favorites-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: transparent;
  transition: var(--wgl-transition-fast);
  position: relative;
  text-decoration: none;
}

.wgl-favorite-header-badge:hover .wgl-favorites-link{
  color: var(--wgl-bg-vert);
}

.wgl-favorite-header-badge:hover .wgl-favorites-link > .wgl-header-heart-icon {
  -webkit-transform: rotateY(180deg);
  -moz-transform: rotateY(180deg);
  -ms-transform: rotateY(180deg);
  -o-transform: rotateY(180deg);
  transform: rotateY(180deg);
  color: var(--wgl-bg-vert);
}

.wgl-header-heart-icon {
  transition: var(--wgl-transition-fast);
  font-size: 22px;
  color: var(--header-top-text-color);
}

.wgl-favorite-count {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  border-radius: 50%;
  animation: wgl-fadeIn 0.3s ease-out;
}

.wgl-favorite-count[data-count="0"] {
  display: none;
}

/* Dropdown rapide des favoris (fonctionnalité future) */
.wgl-favorites-dropdown {
  position: absolute;
  top: 100%;
  right: 0;
  width: 300px;
  background: white;
  border: 1px solid #dee2e6;
  border-radius: var(--wgl-border-radius);
  box-shadow: var(--wgl-shadow-medium);
  z-index: 1000;
  animation: wgl-fadeIn 0.3s ease-out;
}

.wgl-dropdown-header {
  padding: 12px 16px;
  border-bottom: 1px solid #dee2e6;
  background: #f8f9fa;
}

.wgl-dropdown-header h6 {
  margin: 0;
  font-weight: 600;
  color: #495057;
}

.wgl-dropdown-content {
  max-height: 300px;
  overflow-y: auto;
  padding: 8px 0;
}

.wgl-dropdown-footer {
  padding: 12px 16px;
  border-top: 1px solid #dee2e6;
  background: #f8f9fa;
  text-align: center;
}

/* ==========================================================================
   Lien dans le compte client
   ========================================================================== */
.wgl-account-heart-icon {
  fill: currentColor;
  margin-right: 12px;
  transition: var(--wgl-transition-fast);
}

a:hover .wgl-account-heart-icon {
  fill: var(--wgl-heart-color-hover);
  transform: scale(1.1);
}

/* ==========================================================================
   Page des favoris
   ========================================================================== */
.wgl-favorites-page {
  padding: 20px 0;
}

.wgl-favorites-header {
  border-bottom: 2px solid #e9ecef;
  padding-bottom: 20px;
}

.wgl-page-heart-icon {
  fill: var(--wgl-heart-color-favorite);
  vertical-align: middle;
}

/* Carte produit favoris */
.wgl-favorite-product-card {
  transition: var(--wgl-transition-fast);
  border: 1px solid #dee2e6;
  overflow: hidden;
}

.wgl-favorite-product-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--wgl-shadow-medium);
}

.wgl-product-image-container {
  position: relative;
  overflow: hidden;
}

.wgl-favorites-products .img-fluid{
  margin: auto;
}

.wgl-favorites-products h3.product-title a {
  font-size: 14px;
  text-align: center;
  color: #1d202d;
}

.wgl-favorites-products .product-miniature .ttproduct-image-container{
  text-align: center;
}

.wgl-product-image {
  width: 100%;
  height: 200px;
  object-fit: cover;
  transition: var(--wgl-transition-smooth);
}

.wgl-favorite-product-card:hover .wgl-product-image {
  transform: scale(1.05);
}

/* Bouton de suppression rapide */
.wgl-quick-remove {
  position: absolute;
  top: 8px;
  right: 8px;
  opacity: 1;
  transition: var(--wgl-transition-fast);
}

.wgl-remove-btn {
  width: 28px;
  height: 28px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: rgba(220, 53, 69, 0.9);
  border: none;
  color: white;
  transition: var(--wgl-transition-fast);
}

.wgl-remove-btn:hover {
  background: rgba(220, 53, 69, 1);
  transform: scale(1.1);
}

/* Actions produit */
.wgl-product-actions {
  display: flex;
  gap: 8px;
  align-items: center;
}

.wgl-product-price {
  color: var(--wgl-heart-color-favorite);
  font-size: 1.1em;
}

/* État vide */
.wgl-favorites-empty {
  padding: 60px 20px;
}

.wgl-empty-icon {
  opacity: 0.5;
}

.wgl-empty-actions {
  margin-top: 30px;
}

/* Pagination */
.wgl-favorites-pagination .pagination {
  margin-bottom: 0;
}

.wgl-favorites-pagination .page-link {
  color: var(--wgl-heart-color-favorite);
  border-color: #dee2e6;
}

.wgl-favorites-pagination .page-item.active .page-link {
  background-color: var(--wgl-heart-color-favorite);
  border-color: var(--wgl-heart-color-favorite);
}

.wgl-favorites-pagination .page-link:hover {
  color: var(--wgl-heart-color-hover);
  background-color: #f8f9fa;
}

/* ==========================================================================
   Spinner de chargement
   ========================================================================== */
.wgl-heart-loader,
.wgl-btn-loader {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

.wgl-spinner {
  width: 16px;
  height: 16px;
  border: 2px solid #f3f3f3;
  border-top: 2px solid var(--wgl-heart-color-favorite);
  border-radius: 50%;
  animation: wgl-spin 1s linear infinite;
}

.wgl-loading-favorites {
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 20px;
  color: #6c757d;
}

.wgl-loading-favorites .wgl-spinner {
  width: 20px;
  height: 20px;
  margin-bottom: 8px;
}

/* ==========================================================================
   Messages et notifications
   ========================================================================== */
.wgl-favorite-notification {
  position: fixed;
  top: 20px;
  right: 20px;
  z-index: 9999;
  max-width: 300px;
  padding: 12px 16px;
  background: white;
  border: 1px solid #dee2e6;
  border-radius: var(--wgl-border-radius);
  box-shadow: var(--wgl-shadow-medium);
  animation: wgl-fadeIn 0.5s ease-out;
}

.wgl-favorite-notification.success {
  border-left: 4px solid #28a745;
}

.wgl-favorite-notification.error {
  border-left: 4px solid #dc3545;
}

.wgl-favorite-notification.info {
  border-left: 4px solid #17a2b8;
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */
@media (max-width: 768px) {
  .wgl-favorite-heart-container {
    top: 8px;
    right: 8px;
  }
  
  .wgl-favorite-heart-btn {
    width: 36px;
    height: 36px;
  }
  
  .wgl-heart-icon {
    width: 18px;
    height: 18px;
  }
  
  .wgl-favorites-dropdown {
    width: 280px;
    right: -20px;
  }
  
  .wgl-favorites-page {
    padding: 15px 0;
  }
  
  .wgl-favorites-header .col-md-4 {
    margin-top: 15px;
    text-align: center !important;
  }
  
  .wgl-product-image {
    height: 180px;
  }
  
  .wgl-product-actions {
    flex-direction: column;
  }
  
  .wgl-product-actions .btn {
    width: 100%;
  }
}

@media (max-width: 576px) {
  .wgl-favorite-product-btn {
    padding: 10px 16px;
    font-size: 13px;
  }
  
  .wgl-favorites-empty {
    padding: 40px 15px;
  }
  
  .wgl-empty-icon svg {
    width: 60px;
    height: 60px;
  }
  
  .wgl-empty-actions .btn {
    display: block;
    width: 100%;
    margin: 5px 0;
  }
}

/* ==========================================================================
   Mode sombre (si le thème le supporte)
   ========================================================================== */
@media (prefers-color-scheme: dark) {
  :root {
    --wgl-heart-color-default: #adb5bd;
    --wgl-heart-color-hover: #f8d7da;
  }
  
  .wgl-favorite-heart-btn {
    background: white;
    color: #f8f9fa;
    border: 1px solid var(--wgl-bg-vert);;
  }
  
  .wgl-favorite-heart-btn:hover {
    background: var(--wgl-bg-vert);;
  }
  
  .wgl-heart-tooltip {
    background: rgba(255, 255, 255, 0.9);
    color: #212529;
  }
  
  .wgl-favorites-dropdown {
    background: #212529;
    border-color: #495057;
    color: #f8f9fa;
  }
  
  .wgl-dropdown-header,
  .wgl-dropdown-footer {
    background: #343a40;
    border-color: #495057;
  }
}

/* Animation pour le badge mis à jour */
.wgl-badge-updated {
    animation: wgl-pulse 0.5s ease-in-out;
    transform: scale(1.1);
}

/* Animation pour le coeur */
.wgl-heart-animate {
    animation: wgl-heartbeat 0.6s ease-in-out;
}