/* Styles pour transformer les modals en cartes qui se retournent */

/* Style de base pour tous les modals de carte */
.modal.card-modal {
  display: none;
  position: fixed;
  z-index: 9999;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: rgba(0, 0, 0, 0.7);
  perspective: 1500px;
}

/* Le contenu du modal devient une carte qui peut se retourner */
.modal.card-modal .modal-content {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%) rotateY(0deg);
  width: 420px;
  height: 600px;
  transform-style: preserve-3d;
  transition: transform 0.8s ease-in-out;
  border-radius: 28px;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.4), 
              0 15px 30px rgba(0, 0, 0, 0.3),
              0 5px 15px rgba(0, 0, 0, 0.2);
  /* S'assurer que la perspective est bien appliquée */
  transform-origin: center center;
}

/* La face avant de la carte modal */
.modal.card-modal .card-front {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: 28px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  gap: 24px;
  padding: 40px;
  box-sizing: border-box;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 50%, #667eea 100%);
  border: 3px solid rgba(255, 255, 255, 0.15);
  z-index: 2;
  overflow: hidden;
}

/* Effet de brillance animé permanent sur la face avant */
.modal.card-modal .card-front::after {
  content: '';
  position: absolute;
  top: -50%;
  left: -50%;
  width: 200%;
  height: 200%;
  background: conic-gradient(transparent, rgba(255, 255, 255, 0.1), transparent 30%);
  animation: rotate 6s linear infinite;
  border-radius: 50%;
}

/* La face arrière de la carte modal (le contenu existant) */
.modal.card-modal .card-back {
  position: absolute;
  width: 100%;
  height: 100%;
  backface-visibility: hidden;
  border-radius: 28px;
  transform: rotateY(180deg);
  padding: 40px;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 50%, #cbd5e1 100%);
  border: 3px solid rgba(255, 255, 255, 0.4);
  overflow-y: auto;
  z-index: 1;
  backdrop-filter: blur(20px);
}

/* Le logo sur la face avant */
.modal.card-modal .card-logo {
  width: 160px;
  height: 160px;
  margin: 0 auto;
  filter: drop-shadow(0 6px 12px rgba(0, 0, 0, 0.3));
  z-index: 10;
  position: relative;
  flex-shrink: 0;
}

/* Texte du type de carte sur la face avant */
.modal.card-modal .card-type {
  color: white;
  font-size: 22px;
  font-weight: 700;
  text-align: center;
  text-shadow: 0 3px 6px rgba(0, 0, 0, 0.4);
  letter-spacing: 1px;
  text-transform: uppercase;
  z-index: 10;
  position: relative;
  margin: 0;
  flex-shrink: 0;
}

/* Animation pour faire apparaître la carte */
@keyframes cardAppear {
  from {
    opacity: 0;
    transform: translate(-50%, -50%) scale(0.7) rotateY(0deg);
  }
  to {
    opacity: 1;
    transform: translate(-50%, -50%) scale(1) rotateY(0deg);
  }
}

/* .modal.card-modal .modal-content {
} */

/* État retourné avec animation */
.modal.card-modal .modal-content.flipped {
  transform: translate(-50%, -50%) rotateY(180deg) !important;
  /* Force la transition même avec !important */
  transition: transform 0.8s ease-in-out !important;
}

/* S'assurer que les faces sont correctement cachées */
.modal.card-modal .card-front,
.modal.card-modal .card-back {
  -webkit-backface-visibility: hidden;
  backface-visibility: hidden;
}

/* Fallback pour les navigateurs qui ne supportent pas backface-visibility */
.modal.card-modal .modal-content:not(.flipped) .card-back {
  opacity: 0;
  pointer-events: none;
}

.modal.card-modal .modal-content.flipped .card-front {
  opacity: 0;
  pointer-events: none;
}

.modal.card-modal .modal-content.flipped .card-back {
  opacity: 1;
  pointer-events: auto;
}

/* Les différentes couleurs pour les types de cartes */
.modal.card-modal.bonus .card-back {
  background: linear-gradient(135deg, #f5ca0b 0%, #d9c406 30%, #b49509 70%, #90920e 100%);
  color: white;
  border: 3px solid rgba(16, 185, 129, 0.4);
  box-shadow: inset 0 1px 3px rgba(255, 255, 255, 0.1);
}

.modal.card-modal.bonus .card-front {
  background: linear-gradient(135deg, #f5ca0b 0%, #d9c406 30%, #b49509 70%, #90920e 100%);

}

.modal.card-modal.facture .card-back {
  background: linear-gradient(135deg, #ef7a44 0%, #dc7826 30%, #b95b1c 70%, #99431b 100%);
  color: white;
  border: 3px solid rgba(239, 68, 68, 0.4);
  box-shadow: inset 0 1px 3px rgba(255, 255, 255, 0.1);
}

.modal.card-modal.facture .card-front {
  background: linear-gradient(135deg, #ef7a44 0%, #dc7826 30%, #b95b1c 70%, #99431b 100%);
}

.modal.card-modal.biens .card-back {
  background: linear-gradient(135deg, #ebecec 0%, #b3c3c7 30%, #767b7c 70%, #4e4f50 100%);
  color: white;
  border: 3px solid rgba(9, 32, 36, 0.4);
  box-shadow: inset 0 1px 3px rgba(255, 255, 255, 0.1);
}

.modal.card-modal.biens .card-front {
  background: linear-gradient(135deg, #ebecec 0%, #b3c3c7 30%, #767b7c 70%, #4e4f50 100%);
}

.modal.card-modal.pdb .card-back {
  background: linear-gradient(135deg, #10b981 0%, #059669 50%, #047857 100%);
  color: white;
  border: 3px solid rgba(245, 158, 11, 0.4);
  box-shadow: inset 0 1px 3px rgba(255, 255, 255, 0.1);
}

.modal.card-modal.pdb .card-front {
  background: linear-gradient(135deg, #10b981 0%, #059669 50%, #047857 100%);
}

.modal.card-modal.interaction .card-back {
  background: linear-gradient(135deg, #608ef3 0%, #3a55ed 30%, #3428d9 70%, #2b21b6 100%);
  color: white;
  border: 3px solid rgba(139, 92, 246, 0.4);
  box-shadow: inset 0 1px 3px rgba(255, 255, 255, 0.1);
}

.modal.card-modal.interaction .card-front {
  background: linear-gradient(135deg, #608ef3 0%, #3a55ed 30%, #3428d9 70%, #2b21b6 100%);
}

.modal.card-modal.property .card-back {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 30%, #1d4ed8 70%, #1e40af 100%);
  color: white;
  border: 3px solid rgba(59, 130, 246, 0.4);
  box-shadow: inset 0 1px 3px rgba(255, 255, 255, 0.1);
}

.modal.card-modal.property .card-front {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 50%, #1d4ed8 100%);
}

/* Animation de rotation pour l'effet brillant */
@keyframes rotate {
  from {
    transform: rotate(0deg);
  }
  to {
    transform: rotate(360deg);
  }
}

/* Adaptation du style des éléments dans les modals */
.modal.card-modal .card-icon {
  margin-bottom: 20px;
  width: 100px;
  height: 100px;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  background: rgba(255, 255, 255, 0.2);
  backdrop-filter: blur(15px);
  border: 3px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.15),
              0 4px 8px rgba(0, 0, 0, 0.1);
  transition: all 0.3s ease;
}

.modal.card-modal .card-icon:hover {
  transform: scale(1.1);
  box-shadow: 0 16px 32px rgba(0, 0, 0, 0.2),
              0 6px 12px rgba(0, 0, 0, 0.15);
}

.modal.card-modal .retro-button {
  margin-top: auto;
  padding: 16px 32px;
  border-radius: 20px;
  font-size: 18px;
  font-weight: 700;
  border: none;
  background: linear-gradient(135deg, #ffffff 0%, #f1f5f9 50%, #e2e8f0 100%);
  color: #334155;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.2),
              0 2px 8px rgba(0, 0, 0, 0.1);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  letter-spacing: 0.8px;
  text-transform: uppercase;
  position: relative;
  overflow: hidden;
}

.modal.card-modal .retro-button::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
  transition: left 0.5s;
}

.modal.card-modal .retro-button:hover {
  transform: translateY(-3px) scale(1.05);
  box-shadow: 0 12px 24px rgba(0, 0, 0, 0.25),
              0 4px 12px rgba(0, 0, 0, 0.15);
}

.modal.card-modal .retro-button:hover::before {
  left: 100%;
}

.modal.card-modal .retro-button:active {
  transform: translateY(-1px) scale(1.02);
}

.modal.card-modal h3 {
  font-size: 24px;
  font-weight: 700;
  margin: 0 0 16px 0;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
  letter-spacing: 0.5px;
}

.card-description {
  text-align: center;
  margin: 16px 0;
  font-style: italic;
  font-size: 15px;
  line-height: 1.5;
  opacity: 0.9;
  background: rgba(255, 255, 255, 0.1);
  padding: 12px 16px;
  border-radius: 12px;
  backdrop-filter: blur(5px);
}

.special-amount {
  font-size: 28px;
  font-weight: 800;
  margin: 20px 0;
  text-shadow: 0 3px 6px rgba(0, 0, 0, 0.2);
  letter-spacing: 1px;
}

/* Effets modernes supplémentaires */

/* Effet de brillance sur les cartes */
.modal.card-modal .card-front::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
  transition: left 0.5s;
}

.modal.card-modal .card-front:hover::before {
  left: 100%;
}

/* Micro-interactions sur hover */
.modal.card-modal .modal-content:hover {
  transform: translate(-50%, -50%) rotateY(0deg) scale(1.02);
}

.modal.card-modal .modal-content.flipped:hover {
  transform: translate(-50%, -50%) rotateY(180deg) scale(1.02);
}

/* Amélioration du backdrop */
.modal.card-modal {
  background: rgba(0, 0, 0, 0.8);
  backdrop-filter: blur(8px);
}

/* Glow effect selon le type de carte */
.modal.card-modal.bonus .modal-content {
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3), 
              0 12px 24px rgba(0, 0, 0, 0.2),
              0 0 30px rgba(74, 222, 128, 0.2);
}

.modal.card-modal.facture .modal-content {
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3), 
              0 12px 24px rgba(0, 0, 0, 0.2),
              0 0 30px rgba(239, 68, 68, 0.2);
}

.modal.card-modal.biens .modal-content {
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3), 
              0 12px 24px rgba(0, 0, 0, 0.2),
              0 0 30px rgba(6, 182, 212, 0.2);
}

.modal.card-modal.pdb .modal-content {
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3), 
              0 12px 24px rgba(0, 0, 0, 0.2),
              0 0 30px rgba(245, 158, 11, 0.2);
}

.modal.card-modal.interaction .modal-content {
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3), 
              0 12px 24px rgba(0, 0, 0, 0.2),
              0 0 30px rgba(139, 92, 246, 0.2);
}

.modal.card-modal.property .modal-content {
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.3), 
              0 12px 24px rgba(0, 0, 0, 0.2),
              0 0 30px rgba(59, 130, 246, 0.2);
}
