/**
 * ============================================================================
 * MODALS - Styles pour tous les modals du site
 * ============================================================================
 * 
 * Ce fichier contient les styles pour :
 * - Modal de connexion/inscription (account.js)
 * - Modal de commande (menu.js)
 * - Autres modals futurs
 * 
 * À charger sur TOUTES les pages du site
 */

/* =====================================================================
   🪟 MODAL - Structure de base
   ===================================================================== */
.checkout-modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.7);
  z-index: 100000;
  justify-content: center;
  align-items: center;
  animation: fadeIn 0.3s ease;
}

.checkout-modal.is-open {
  display: flex;
}

.checkout-modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: transparent;
  cursor: pointer;
}

.checkout-modal-content {
  background: white;
  border-radius: 16px;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  margin-top: 90px;
  position: relative;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  animation: slideUp 0.3s ease;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 100001;
}

.modal-header {
  padding: 0.75rem 1rem;
  border-bottom: 1px solid #e0e0e0;
  flex-shrink: 0;
  position: relative;
  min-height: 50px;
}

.modal-header h3 {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  color: var(--forest-green);
  margin: 0 0 0.3rem 0;
}

.modal-header p {
  color: var(--text-secondary);
  margin: 0;
  font-size: 0.9rem;
}

.modal-body {
  padding: 1.5rem 2rem 2rem 2rem;
  overflow-y: auto;
  flex: 1;
}

.modal-body h3 {
  font-family: var(--font-heading);
  font-size: 1.4rem;
  color: var(--forest-green);
  margin: 0 0 0.3rem 0;
}

.modal-body > p {
  color: var(--text-secondary);
  margin-bottom: 1.2rem;
  font-size: 0.9rem;
}

/* =====================================================================
   🎬 ANIMATIONS
   ===================================================================== */
@keyframes fadeIn {
  from { opacity: 0; }
  to { opacity: 1; }
}

@keyframes slideUp {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* =====================================================================
   ❌ BOUTON DE FERMETURE
   ===================================================================== */
.checkout-modal-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: none;
  border: none;
  font-size: 1.8rem;
  color: var(--text-secondary);
  cursor: pointer;
  line-height: 1;
  padding: 0;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color 0.3s ease;
  z-index: 10;
}

.checkout-modal-close:hover {
  color: var(--forest-green);
}

/* =====================================================================
   📝 FORMULAIRES DANS LES MODALS
   ===================================================================== */
#checkoutForm,
#createAccountForm,
#loginForm,
#globalLoginForm,
#guestOrderForm {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
}

.form-section {
  margin-bottom: 1.5rem;
}

.form-actions {
  margin-top: 0.8rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
  margin-bottom: 0.4rem;
}

.form-group label {
  font-weight: 500;
  color: var(--forest-green);
  font-size: 0.95rem;
}

.form-group input,
.form-group textarea,
.form-group select {
  padding: 0.8rem;
  border: 2px solid rgba(30, 66, 53, 0.2);
  border-radius: 8px;
  font-family: inherit;
  font-size: 1rem;
  transition: border-color 0.3s ease;
  background: white;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--forest-green);
}

.form-group select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%231e4235' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.8rem center;
  background-size: 12px;
  padding-right: 2.5rem;
}

.form-group textarea {
  resize: vertical;
  min-height: 60px;
}

/* =====================================================================
   �️ PASSWORD TOGGLE (bouton œil)
   ===================================================================== */
.password-input-container {
  position: relative;
  display: block;
  width: 100%;
}

.password-input-container input[type="password"],
.password-input-container input[type="text"] {
  width: 100%;
  padding: 0.8rem 3rem 0.8rem 0.8rem !important;
}

.password-toggle {
  position: absolute;
  right: 0.8rem;
  top: 50%;
  transform: translateY(-50%);
  background: transparent;
  border: none;
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 4px;
  transition: background-color 0.15s ease, transform 0.1s ease;
  z-index: 10;
  width: 2rem;
  height: 2rem;
}

.password-toggle:hover {
  background-color: rgba(0, 0, 0, 0.06);
}

.password-toggle:active {
  background-color: rgba(30, 66, 53, 0.15);
  transform: translateY(-50%) scale(0.95);
}

.password-toggle:focus {
  outline: 2px solid var(--forest-green);
  outline-offset: 2px;
}

/* =====================================================================
   PASSWORD TOGGLE - Bouton œil pour afficher/masquer le mot de passe
   ===================================================================== */

.password-toggle {
  position: absolute;
  right: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.8);
  border: 1px solid rgba(0, 0, 0, 0.1);
  cursor: pointer;
  padding: 0.4rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  transition: background-color 0.2s ease, border-color 0.2s ease, color 0.2s ease;
  z-index: 10;
  width: 2rem;
  height: 2rem;
}

.password-toggle:hover {
  background-color: rgba(0, 0, 0, 0.08);
  border-color: rgba(0, 0, 0, 0.2);
}

.password-toggle:active,
.password-toggle.active {
  background-color: var(--forest-green);
  color: white;
  border-color: var(--forest-green);
}

.password-toggle:focus {
  outline: 2px solid var(--forest-green);
  outline-offset: 2px;
}

.eye-icon {
  font-size: 1rem;
  user-select: none;
  pointer-events: none;
  opacity: 0.7;
  transition: opacity 0.2s ease;
  line-height: 1;
}

.password-toggle:hover .eye-icon {
  opacity: 1;
}

.password-toggle.active .eye-icon {
  opacity: 1;
}

/* Gestion des états des icônes œil ouvert/fermé */
.eye-icon.eye-closed {
  display: block;
}

.eye-icon.eye-open {
  display: none;
}

/* Validation des mots de passe */
.password-match-status {
  font-size: 0.75rem;
  margin-top: 0.3rem;
  padding: 0.3rem 0.5rem;
  border-radius: 4px;
  transition: all 0.3s ease;
  min-height: 1.6rem;
  display: flex;
  align-items: center;
  opacity: 0;
  transform: translateY(-5px);
}

.password-match-status.match {
  background: linear-gradient(135deg, #e8f5e8, #f0f9f0);
  border: 1px solid var(--forest-green);
  color: var(--forest-green);
  opacity: 1;
  transform: translateY(0);
}

.password-match-status.no-match {
  background: linear-gradient(135deg, #ffeaea, #fff0f0);
  border: 1px solid #dc3545;
  color: #dc3545;
  opacity: 1;
  transform: translateY(0);
}

/* =====================================================================
   �� BOUTONS DU FORMULAIRE
   ===================================================================== */
.form-actions {
  display: flex;
  gap: 1rem;
  margin-top: 1rem;
}

.form-actions button {
  flex: 1;
  padding: 1rem;
  border: none;
  border-radius: 12px;
  font-family: inherit;
  font-size: 1rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-cancel {
  background: #f0f0f0;
  color: var(--text-secondary);
}

.btn-cancel:hover {
  background: #e0e0e0;
}

.btn-submit {
  background: var(--forest-green);
  color: white;
  transition: all 0.3s ease;
}

.btn-submit:hover:not(.disabled) {
  background: var(--copper-gold);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(200, 134, 13, 0.3);
}

.btn-submit.disabled,
.btn-submit:disabled {
  background: #ccc !important;
  color: #666 !important;
  cursor: not-allowed !important;
  opacity: 0.6 !important;
  pointer-events: none;
}

.btn-submit.disabled:hover,
.btn-submit:disabled:hover {
  background: #ccc !important;
  transform: none !important;
  box-shadow: none !important;
}

/* =====================================================================
   🔗 LIENS SECONDAIRES
   ===================================================================== */
.form-footer {
  margin-top: 1rem;
  text-align: center;
  font-size: 0.9rem;
}

.link-secondary {
  color: var(--copper-gold);
  text-decoration: none;
  font-weight: 500;
  transition: all 0.3s ease;
}

.link-secondary:hover {
  color: #c8860d;
  text-decoration: underline;
}

/* =====================================================================
   📱 RESPONSIVE
   ===================================================================== */
@media (max-width: 576px) {
  .checkout-modal-content {
    width: 95%;
    max-height: 85vh;
    margin-top: 70px;
  }
  
  .modal-body {
    padding: 1rem 1.5rem 1.5rem 1.5rem;
  }
  
  .modal-body h3 {
    font-size: 1.2rem;
  }
}

/* =====================================================================
   🌐 BODY AVEC MODAL OUVERT
   ===================================================================== */
body.modal-open {
  overflow: hidden;
}

/* Bloquer toutes les interactions avec le contenu en arrière-plan */
body.modal-open header,
body.modal-open main,
body.modal-open footer {
  pointer-events: none;
  user-select: none;
}

/* Permettre les interactions uniquement dans le modal */
.checkout-modal.is-open {
  pointer-events: auto;
}

.checkout-modal-content {
  pointer-events: auto;
}
