/*
Effets principaux gérés dans ce fichier :
- Apparition animée de la modale d'authentification (animation modalSlideIn)
- Animation de fermeture/ouverture du fond de la modale (opacity/blur)
- Animation de chargement (spinner) sur les boutons et pendant la soumission
- Effet de survol sur les boutons (changement de couleur/fond)
- Apparition/disparition des messages d'erreur ou succès (transition)
- Badge admin stylisé (gradient, couleur, arrondi)
- Boutons de la navbar stylisés (hover, couleur, arrondi)
- Responsive pour la modale et les boutons
*/

/* Styles pour le composant d'authentification */

/* Modale d'authentification */
.auth-modal {
  display: none;
  position: fixed;
  z-index: 2000;
  left: 0;
  top: 0;
  width: 100vw;
  height: 100vh;
  background: linear-gradient(
    135deg,
    rgba(0, 0, 0, 0.5) 0%,
    rgba(26, 42, 108, 0.3) 100%
  );
  -webkit-backdrop-filter: blur(8px);
  backdrop-filter: blur(8px);
}

.auth-modal-content {
  max-width: 400px;
  margin: 0 auto;
  background: rgba(248, 250, 252, 0.75);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 12px;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.15), 0 4px 16px rgba(106, 90, 249, 0.1);
  padding: 24px 32px 32px 32px;
  animation: modalSlideIn 0.3s ease-out;
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
}

@keyframes modalSlideIn {
  from {
    opacity: 0;
    transform: translateY(-50px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.auth-modal-header {
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  padding: 20px;
  border-radius: 12px 12px 0 0;
  text-align: center;
  position: relative;
}

.auth-modal-header h2 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
}

.auth-close {
  position: absolute;
  top: 15px;
  right: 20px;
  color: white;
  font-size: 24px;
  font-weight: bold;
  cursor: pointer;
  background: none;
  border: none;
  padding: 0;
  width: 30px;
  height: 30px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background-color 0.2s;
}

.auth-close:hover {
  background-color: rgba(255, 255, 255, 0.2);
}

.auth-modal-body {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 30px;
}

#auth-form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.auth-form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.auth-form-group label {
  font-weight: 500;
  margin-bottom: 2px;
}

.auth-form-group input {
  padding: 8px 10px;
  border: 1px solid #c3c3c3;
  border-radius: 6px;
  font-size: 1em;
  transition: border-color 0.2s, box-shadow 0.2s;
  box-sizing: border-box;
}

.auth-form-group input:focus {
  outline: none;
  border-color: #667eea;
  box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.auth-form-group input.error {
  border-color: #e74c3c;
}

.auth-submit-btn {
  margin-top: 12px;
  padding: 10px 0;
  background: linear-gradient(90deg, #6a5af9 0%, #8f6af9 100%);
  color: #fff; /* Lisibilité optimale sur fond violet */
  border: none;
  border-radius: 6px;
  font-size: 1.1em;
  font-weight: bold;
  cursor: pointer;
  transition: background 0.2s;
  width: 100%;
}

.auth-submit-btn:hover {
  background: linear-gradient(90deg, #8f6af9 0%, #6a5af9 100%);
}

.auth-submit-btn:active {
  transform: translateY(0);
}

.auth-submit-btn:disabled {
  background: #95a5a6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

.auth-switch-mode {
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 6px;
  margin-top: 10px;
  padding-top: 20px;
  border-top: 1px solid #e1e5e9;
}

#auth-switch-btn {
  background: none;
  border: none;
  font-weight: bold;
  cursor: pointer;
  text-decoration: underline;
  font-size: 1em;
  padding: 0 4px;
}

/* Palette texte élégante dans la modale (hors header & bouton principal) */
.auth-modal .auth-modal-body label {
  color: #374151 !important;
  font-weight: 600;
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.3);
  letter-spacing: 0.2px;
}

.auth-modal .auth-modal-body #auth-switch-text {
  color: #6b7280 !important;
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.2);
}

.auth-modal .auth-modal-body #auth-switch-btn {
  color: #6a5af9 !important;
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.1);
  font-weight: 600;
}

.auth-modal .auth-modal-body #auth-switch-btn:hover {
  color: #553ce8 !important;
  text-shadow: 0 1px 2px rgba(255, 255, 255, 0.2);
}

/* Messages avec meilleur contraste */
.auth-modal .auth-modal-body #auth-message {
  text-shadow: 0 1px 1px rgba(255, 255, 255, 0.1);
}

/* Préserver lisibilité du bouton primaire */
.auth-modal .auth-modal-body .auth-submit-btn {
  color: #fff !important;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.15);
  font-weight: 600;
  letter-spacing: 0.3px;
}

/* Messages d'erreur */
.auth-error-message {
  color: #d32f2f;
  background: #ffeaea;
  border-radius: 4px;
  padding: 6px 10px;
  margin-bottom: 6px;
  font-size: 0.97em;
}

.auth-success-message {
  color: #388e3c;
  background: #eaffea;
  border-radius: 4px;
  padding: 6px 10px;
  margin-bottom: 6px;
  font-size: 0.97em;
}

/* Badge admin dans la navbar */
.admin-badge {
  background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%);
  color: white;
  padding: 4px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 600;
  margin-left: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Boutons de la navbar */
.auth-nav-button {
  background: none;
  border: 1px solid #667eea;
  color: #667eea;
  padding: 8px 16px;
  border-radius: 20px;
  cursor: pointer;
  font-size: 14px;
  transition: all 0.2s;
  margin-left: 10px;
}

.auth-nav-button:hover {
  background: #667eea;
  color: white;
}

.auth-nav-button.logout {
  background: #e74c3c;
  color: white;
}

/* .auth-nav-button.logout:hover {
  background: #e74c3c;
  color: white;
} */

/* États de chargement */
.auth-loading {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid #ffffff;
  border-radius: 50%;
  border-top-color: transparent;
  animation: spin 0.8s linear infinite;
  margin-right: 8px;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Styles spécifiques au composant d'authentification */

/* S'assurer que le bouton de déconnexion affiche le bon texte */
.user-nav .logout-btn {
  min-width: 130px;
  text-align: center;
}

/* Forcer le contenu du bouton */
.user-nav .logout-btn::after {
  content: none !important; /* Supprimer la flèche si nécessaire */
}

/* Style pour l'affichage du nom à côté du bouton */
.user-nav .user-info {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Animation de chargement pendant la connexion/déconnexion */
.user-nav button.loading {
  pointer-events: none;
  opacity: 0.7;
}

.user-nav button.loading::after {
  content: "";
  display: inline-block;
  width: 12px;
  height: 12px;
  margin-left: 8px;
  border: 2px solid transparent;
  border-top-color: currentColor;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

/* Forcer le texte du bouton via JavaScript - directive CSS */
.user-nav .logout-btn[data-text="logout"]::before {
  content: "Déconnexion";
}

/* Cacher tout autre texte dans le bouton */
.user-nav .logout-btn span,
.user-nav .logout-btn .username {
  display: none !important;
}

/* Responsive */
@media (max-width: 480px) {
  .auth-modal-content {
    margin: 10% auto;
    width: 95%;
    padding: 16px 8px 24px 8px;
  }

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