/**
 * Frontend styles for WooCommerce Cart Progress Rewards
 * 
 * @package WooCommerce_Cart_Progress_Rewards
 * @version 1.0.0
 */

/* Progress Container - Design plus discret */
.wcpr-progress-container {
  background: #fafafa;
  border: 1px solid #f0f0f0;
  border-radius: 6px;
  padding: 16px;
  margin: 16px 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  position: relative;
}

.wcpr-progress-header {
  margin-bottom: 16px;
  text-align: center;
}

.wcpr-progress-header h3 {
  margin: 0 0 8px 0;
  color: #333;
  font-size: 18px;
  font-weight: 600;
}

.wcpr-current-total {
  margin: 0;
  font-size: 14px;
  color: #666;
  font-weight: 500;
}

/* Progress Bar Wrapper - Design frise chronologique */
.wcpr-progress-bar-wrapper {
  position: relative;
  margin: 20px 0;
  min-height: 150px;
  width: 100%;
}

.wcpr-progress-bar {
  height: 12px;
  background: #e8e8e8;
  border-radius: 6px;
  position: relative;
  margin: 50px 0 40px 0;
  box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.1);
  z-index: 1;
  width: 100%;
  overflow: visible;
}

.wcpr-progress-fill {
  height: 100%;
  background: linear-gradient(45deg, #84b876, #458d42);
  border-radius: 6px;
  transition: width 1.5s cubic-bezier(0.25, 0.46, 0.45, 0.94);
  position: relative;
  overflow: hidden;
  box-shadow: 0 2px 8px rgba(132, 184, 118, 0.4);
  transform: translateZ(0);
  max-width: 100%;
}

/* Style spécial quand la barre atteint 100% */
.wcpr-progress-fill[style*="100%"] {
  background: linear-gradient(45deg, #84b876, #458d42, #fce452) !important;
  box-shadow: 0 2px 12px rgba(132, 184, 118, 0.6),
    0 0 20px rgba(252, 228, 82, 0.3) !important;
  animation: wcpr-progress-complete-pulse 2s ease-in-out infinite;
}

.wcpr-progress-fill[style*="100%"]::after {
  content: "🎉";
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 16px;
  animation: wcpr-celebration 2s ease-in-out infinite;
  z-index: 2;
}

@keyframes wcpr-progress-complete-pulse {
  0%,
  100% {
    box-shadow: 0 2px 12px rgba(132, 184, 118, 0.6),
      0 0 20px rgba(252, 228, 82, 0.3);
  }
  50% {
    box-shadow: 0 2px 16px rgba(132, 184, 118, 0.8),
      0 0 30px rgba(252, 228, 82, 0.5);
  }
}

@keyframes wcpr-tier-glow {
  0% {
    box-shadow: 0 0 0 3px #84b876, 0 0 15px rgba(132, 184, 118, 0.6),
      0 2px 8px rgba(0, 0, 0, 0.15);
  }
  100% {
    box-shadow: 0 0 0 3px #84b876, 0 0 25px rgba(132, 184, 118, 0.8),
      0 2px 12px rgba(0, 0, 0, 0.2);
  }
}

@keyframes wcpr-celebration {
  0%,
  100% {
    transform: translateY(-50%) scale(1);
  }
  50% {
    transform: translateY(-50%) scale(1.2);
  }
}

.wcpr-progress-fill.wcpr-progress-animated {
  animation: wcpr-progress-glow 3s ease-in-out infinite alternate;
}

@keyframes wcpr-progress-glow {
  0% {
    box-shadow: 0 2px 8px rgba(132, 184, 118, 0.4);
  }
  100% {
    box-shadow: 0 2px 12px rgba(132, 184, 118, 0.7),
      0 0 20px rgba(132, 184, 118, 0.3);
  }
}

.wcpr-progress-fill::before {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(
    90deg,
    rgba(255, 255, 255, 0) 0%,
    rgba(255, 255, 255, 0.2) 20%,
    rgba(255, 255, 255, 0.5) 50%,
    rgba(255, 255, 255, 0.2) 80%,
    rgba(255, 255, 255, 0) 100%
  );
  animation: wcpr-shimmer 1.8s ease-in-out infinite;
}

.wcpr-progress-fill::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  right: 0;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.6),
    transparent
  );
  animation: wcpr-pulse 2s ease-in-out infinite alternate;
}

@keyframes wcpr-shimmer {
  0% {
    transform: translateX(-100%);
  }
  100% {
    transform: translateX(100%);
  }
}

@keyframes wcpr-pulse {
  0% {
    opacity: 0.4;
    transform: scale(1);
  }
  100% {
    opacity: 1;
    transform: scale(1.02);
  }
}

/* Tier Milestones - Design moderne */
.wcpr-tier-milestone {
  position: absolute;
  top: -45px;
  transform: translateX(-50%);
  text-align: center;
  transition: all 0.3s ease;
  min-width: 100px;
  max-width: 140px;
  z-index: 100;
  overflow: visible;
}

.wcpr-tier-milestone:hover {
  transform: translateX(-50%) translateY(-4px) scale(1.02);
}

.wcpr-tier-milestone.pending {
  opacity: 0.6;
}

.wcpr-tier-milestone.achieved {
  opacity: 1;
  animation: wcpr-tier-achieved 0.6s ease-out;
}

.wcpr-tier-milestone.achieved::before {
  content: "";
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  animation: wcpr-achievement-sweep 2s ease-in-out infinite;
}

@keyframes wcpr-tier-achieved {
  0% {
    transform: scale(0.95);
    opacity: 0.8;
  }
  50% {
    transform: scale(1.05);
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

@keyframes wcpr-achievement-sweep {
  0% {
    left: -100%;
  }
  100% {
    left: 100%;
  }
}

/* Marqueurs de paliers */
.wcpr-tier-marker {
  position: relative;
  margin-bottom: 12px;
}

.wcpr-tier-marker::before {
  content: "";
  position: absolute;
  bottom: -5px;
  left: 50%;
  transform: translateX(-50%);
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: #999;
  border: 3px solid #fff;
  box-shadow: 0 0 0 2px #e8e8e8, 0 2px 6px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
  z-index: 10;
}

.wcpr-tier-milestone.achieved .wcpr-tier-marker::before {
  background: #84b876;
  box-shadow: 0 0 0 3px #84b876, 0 0 15px rgba(132, 184, 118, 0.6),
    0 2px 8px rgba(0, 0, 0, 0.15);
  width: 5px;
  height: 5px;
  animation: wcpr-tier-glow 2s ease-in-out infinite alternate;
}

.wcpr-tier-amount {
  background: linear-gradient(135deg, #84b876, #6fa566);
  color: white;
  padding: 6px 12px;
  border-radius: 16px;
  font-size: 13px;
  font-weight: 700;
  display: inline-block;
  box-shadow: 0 3px 8px rgba(132, 184, 118, 0.4);
  border: 2px solid rgba(255, 255, 255, 0.2);
}

.wcpr-tier-milestone.pending .wcpr-tier-amount {
  background: linear-gradient(135deg, #999, #777);
  box-shadow: 0 3px 8px rgba(153, 153, 153, 0.3);
}

.wcpr-tier-info {
  display: block;
  margin-top: 4px;
}

.wcpr-tier-description {
  color: #555;
  font-size: 12px;
  line-height: 1.4;
  margin-bottom: 8px;
  word-wrap: break-word;
  padding: 4px 8px;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 6px;
  border: 1px solid rgba(0, 0, 0, 0.1);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.wcpr-tier-milestone.achieved .wcpr-tier-description {
  color: #333;
  font-weight: 600;
  background: rgba(132, 184, 118, 0.1);
  border-color: rgba(132, 184, 118, 0.3);
}

/* Icônes des paliers */
.wcpr-tier-icon {
  font-size: 20px;
  margin-bottom: 6px;
  display: block;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
  filter: drop-shadow(0 1px 2px rgba(0, 0, 0, 0.1));
}

/* Supprimer les icônes automatiques puisque nous utilisons les icônes personnalisées */

/* Reward Buttons - Design moderne */
.wcpr-select-reward-btn,
.wcpr-claim-reward-btn {
  background: linear-gradient(135deg, #84b876, #6fa566);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 700;
  transition: all 0.3s ease;
  text-decoration: none;
  display: inline-block;
  margin-top: 6px;
  position: relative;
  z-index: 1000;
  pointer-events: auto;
  user-select: none;
  box-shadow: 0 3px 8px rgba(132, 184, 118, 0.4);
  border: 2px solid rgba(255, 255, 255, 0.2);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.wcpr-select-reward-btn:hover,
.wcpr-claim-reward-btn:hover {
  background: linear-gradient(135deg, #6fa566, #458d42);
  transform: translateY(-3px) scale(1.02);
  color: white;
  box-shadow: 0 6px 15px rgba(69, 141, 66, 0.5);
}

.wcpr-select-reward-btn:active,
.wcpr-claim-reward-btn:active {
  transform: translateY(0);
}

.wcpr-claim-reward-btn {
  background: #458d42;
}

.wcpr-claim-reward-btn:hover {
  background: #1f4071;
}

.wcpr-reward-claimed {
  background: linear-gradient(135deg, #d4edda, #c3e6cb);
  color: #155724;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  border: 2px solid #4caf50;
  margin-top: 4px;
  display: inline-block;
  box-shadow: 0 2px 6px rgba(76, 175, 80, 0.3);
  text-transform: uppercase;
  letter-spacing: 0.3px;
}

/* Free Product Badge */
.wcpr-free-badge {
  background: #458d42;
  color: white;
  font-size: 11px;
  font-weight: 600;
  padding: 2px 6px;
  border-radius: 10px;
  margin-left: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  box-shadow: 0 1px 3px rgba(69, 141, 66, 0.3);
}

/* Free Product Cart Item Styling */
.wcpr-free-product-item {
  background: rgba(132, 184, 118, 0.05);
  border-left: 3px solid #84b876;
  padding-left: 8px;
}

.wcpr-free-product-item .product-name {
  position: relative;
}

.wcpr-remove-free-product {
  color: #84b876 !important;
  text-decoration: none;
  transition: color 0.3s ease;
}

.wcpr-remove-free-product:hover {
  color: #458d42 !important;
}

/* Locked Product */
.wcpr-locked-product {
  color: #6c757d;
  font-size: 16px;
  cursor: help;
}

/* Next Tier Info - Plus discret */
.wcpr-next-tier-info {
  text-align: center;
  margin-top: 40px;
  padding: 12px;
  background: rgba(132, 184, 118, 0.08);
  border-radius: 6px;
  border: 2px dashed rgba(132, 184, 118, 0.4);
}

.wcpr-next-tier-info p {
  margin: 0;
  color: #666;
  font-size: 13px;
  font-weight: 500;
}

/* Modal Styles */
.wcpr-modal {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.wcpr-modal.show {
  opacity: 1;
  visibility: visible;
}

.wcpr-modal-content {
  background: white;
  border-radius: 8px;
  width: 90%;
  max-width: 600px;
  max-height: 80vh;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  transform: scale(0.7);
  transition: transform 0.3s ease;
}

.wcpr-modal.show .wcpr-modal-content {
  transform: scale(1);
}

.wcpr-modal-header {
  padding: 20px;
  border-bottom: 1px solid #e1e1e1;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.wcpr-modal-header h4 {
  margin: 0;
  color: #333;
  font-size: 20px;
}

.wcpr-modal-close {
  background: none;
  border: none;
  font-size: 24px;
  cursor: pointer;
  color: #999;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.wcpr-modal-close:hover {
  color: #333;
}

.wcpr-modal-body {
  padding: 20px;
}

/* Product Selection Grid */
.wcpr-product-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 15px;
  margin-top: 15px;
}

.wcpr-product-item {
  border: 2px solid #e1e1e1;
  border-radius: 6px;
  padding: 15px;
  text-align: center;
  cursor: pointer;
  transition: all 0.3s ease;
}

.wcpr-product-item:hover {
  border-color: #84b876;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(132, 184, 118, 0.3);
}

.wcpr-product-item.selected {
  border-color: #84b876;
  background: rgba(132, 184, 118, 0.1);
}

.wcpr-product-image {
  width: 80px;
  height: 80px;
  object-fit: cover;
  border-radius: 4px;
  margin-bottom: 10px;
}

.wcpr-product-name {
  font-weight: 600;
  color: #333;
  margin-bottom: 5px;
  font-size: 14px;
}

.wcpr-variation-badge {
  background: #e7f3ff;
  border: 1px solid #72aee6;
  border-radius: 12px;
  color: #0073aa;
  font-size: 10px;
  font-weight: 500;
  margin-left: 6px;
  padding: 2px 6px;
  text-transform: uppercase;
  display: inline-block;
}

.wcpr-no-image {
  width: 60px;
  height: 60px;
  background: #f0f0f1;
  border-radius: 4px;
  color: #646970;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto;
}

.wcpr-product-price {
  color: #666;
  font-size: 13px;
}

/* Confetti Animation */
.wcpr-confetti {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 10000;
}

.wcpr-confetti-piece {
  position: absolute;
  width: 12px;
  height: 12px;
  background: #fce452;
  animation: wcpr-confetti-fall 4s linear forwards;
  border-radius: 50%;
}

@keyframes wcpr-confetti-fall {
  0% {
    transform: translateY(-100vh) rotate(0deg);
    opacity: 1;
  }
  100% {
    transform: translateY(100vh) rotate(720deg);
    opacity: 0;
  }
}

/* Achievement Notification */
.wcpr-achievement-notification {
  position: fixed;
  top: 20px;
  right: 20px;
  background: #84b876;
  color: white;
  padding: 15px 20px;
  border-radius: 8px;
  box-shadow: 0 4px 20px rgba(132, 184, 118, 0.5);
  z-index: 9998;
  transform: translateX(100%);
  transition: all 0.3s ease;
  max-width: 300px;
  margin-bottom: 10px;
}

/* Système de pile pour les notifications multiples */
.wcpr-achievement-notification:nth-child(1) {
  top: 20px;
}

.wcpr-achievement-notification:nth-child(2) {
  top: calc(20px + 80px + 10px);
}

.wcpr-achievement-notification:nth-child(3) {
  top: calc(20px + 160px + 20px);
}

.wcpr-achievement-notification:nth-child(4) {
  top: calc(20px + 240px + 30px);
}

.wcpr-achievement-notification:nth-child(5) {
  top: calc(20px + 320px + 40px);
}

.wcpr-achievement-notification.show {
  transform: translateX(0);
}

.wcpr-achievement-notification h5 {
  margin: 0 0 5px 0;
  font-size: 16px;
  font-weight: 600;
}

.wcpr-achievement-notification p {
  margin: 0;
  font-size: 14px;
  opacity: 0.9;
}

/* Responsive Design */
@media (max-width: 768px) {
  .wcpr-progress-container {
    padding: 12px;
  }

  .wcpr-progress-bar-wrapper {
    margin: 16px 0;
    position: relative;
    min-height: 120px;
  }

  .wcpr-progress-bar {
    margin: 50px 0 25px 0;
  }

  .wcpr-tier-milestone {
    top: -55px;
    min-width: 60px;
    max-width: 90px;
    white-space: nowrap;
  }

  /* Empêcher les chevauchements avec un système de rangées */
  .wcpr-tier-milestone:nth-child(odd) {
    top: -80px;
  }

  .wcpr-tier-milestone:nth-child(even) {
    top: -45px;
  }

  .wcpr-tier-description {
    font-size: 10px;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .wcpr-tier-amount {
    font-size: 10px;
    padding: 2px 6px;
  }

  .wcpr-tier-icon {
    font-size: 16px;
  }

  .wcpr-select-reward-btn,
  .wcpr-claim-reward-btn {
    font-size: 9px;
    padding: 3px 6px;
  }

  .wcpr-modal-content {
    width: 95%;
    margin: 10px;
  }

  .wcpr-product-grid {
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 10px;
  }

  .wcpr-achievement-notification {
    right: 10px;
    left: 10px;
    max-width: none;
  }
}

/* Gestion des superpositions sur petites largeurs */
@media (max-width: 480px) {
  .wcpr-tier-milestone {
    min-width: 50px;
    max-width: 70px;
    position: relative;
    display: inline-block;
    margin: 0 5px;
    top: 0;
    transform: none;
  }

  .wcpr-progress-bar-wrapper {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-around;
  }

  .wcpr-tier-description {
    font-size: 9px;
    max-height: 24px;
    overflow: hidden;
  }

  .wcpr-tier-amount {
    font-size: 9px;
    padding: 1px 4px;
  }

  .wcpr-progress-bar {
    order: -1;
    width: 100%;
    margin: 10px 0;
  }
}

/* Loading State */
.wcpr-progress-container.wcpr-loading {
  opacity: 0.7;
  pointer-events: none;
  position: relative;
}

.wcpr-progress-container.wcpr-loading::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 24px;
  height: 24px;
  margin: -12px 0 0 -12px;
  border: 3px solid #e1e1e1;
  border-top: 3px solid #84b876;
  border-radius: 50%;
  animation: wcpr-spin 1s linear infinite;
  z-index: 10;
}

@keyframes wcpr-spin {
  0% {
    transform: rotate(0deg);
  }
  100% {
    transform: rotate(360deg);
  }
}

/* Animation Disabled State */
.wcpr-progress-container[data-animations="false"] .wcpr-progress-fill::after,
.wcpr-progress-container[data-animations="false"] .wcpr-tier-milestone,
.wcpr-progress-container[data-animations="false"] .wcpr-select-reward-btn {
  animation: none;
  transition: none;
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
  .wcpr-progress-container {
    border: 2px solid #000;
  }

  .wcpr-tier-milestone.achieved {
    border-color: #000;
  }

  .wcpr-progress-fill {
    background: #000;
  }

  .wcpr-tier-amount,
  .wcpr-select-reward-btn {
    background: #000;
  }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  .wcpr-progress-fill,
  .wcpr-tier-milestone,
  .wcpr-select-reward-btn,
  .wcpr-modal,
  .wcpr-modal-content,
  .wcpr-achievement-notification,
  .wcpr-product-item {
    animation: none;
    transition: none;
  }

  .wcpr-progress-fill::after {
    display: none;
  }
}

/* Tier achievement highlight */
.wcpr-tier-just-achieved {
  animation: wcpr-tier-achievement 2s ease-in-out;
  background: linear-gradient(45deg, #ffeaa7, #fff5b8) !important;
  border: 2px solid #ffd32a !important;
  box-shadow: 0 0 20px rgba(255, 211, 42, 0.5) !important;
}

@keyframes wcpr-tier-achievement {
  0% {
    transform: scale(1);
    background: initial;
  }
  50% {
    transform: scale(1.05);
    background: linear-gradient(45deg, #ffeaa7, #fff5b8);
  }
  100% {
    transform: scale(1);
    background: linear-gradient(45deg, #ffeaa7, #fff5b8);
  }
}

/* Button pulse animation for choice prompts */
.wcpr-pulse-animation {
  animation: wcpr-pulse 1.5s ease-in-out infinite;
  box-shadow: 0 0 0 0 rgba(132, 184, 118, 0.7);
}

@keyframes wcpr-pulse {
  0% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(132, 184, 118, 0.7);
  }
  70% {
    transform: scale(1.05);
    box-shadow: 0 0 0 10px rgba(132, 184, 118, 0);
  }
  100% {
    transform: scale(1);
    box-shadow: 0 0 0 0 rgba(132, 184, 118, 0);
  }
}

/* Reward claimed state improvements */
.wcpr-reward-claimed {
  background: #e8f5e8 !important;
  color: #2e7d2e !important;
  border: 1px solid #4caf50 !important;
  padding: 8px 12px;
  border-radius: 6px;
  font-weight: 600;
  font-size: 13px;
  display: inline-block;
  animation: wcpr-claimed-glow 2s ease-in-out;
}

@keyframes wcpr-claimed-glow {
  0% {
    box-shadow: 0 0 5px rgba(76, 175, 80, 0.3);
  }
  50% {
    box-shadow: 0 0 15px rgba(76, 175, 80, 0.6);
  }
  100% {
    box-shadow: 0 0 5px rgba(76, 175, 80, 0.3);
  }
}
