/* Variables de couleur du site - Palette OmniStock */
:root {
  --primary-500: #5F2827;
  --primary-hover: #4a1f1e;
  --muted-100: #faf6f2;
  --muted-300: #e8ddd2;
  --beige: #DBB68F;
  --input-bg: #fef9f5;
  --card-bg: #ffffff;
  --text-500: #000000;
  --muted: #6b5b5b;
  --border-light: #e8ddd2;
  --error-color: #dc3545;
  --success-color: #28a745;
  --gradient-bg: linear-gradient(45deg, transparent, var(--muted-300), #fdfdfd, transparent);
}

/* Reset pour la page de connexion */
.login-page {
  margin: 0;
  padding: 0;
  font-family: 'Poppins', system-ui, Arial, sans-serif;
  color: var(--text-500);
  min-height: 100vh;
  overflow-x: hidden;
}

/* Container principal - Split Screen */
.login-container {
  display: flex;
  min-height: 100vh;
  width: 100%;
}

/* Section formulaire (gauche) */
.login-form-section {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--beige);
  padding: 40px;
  position: relative;
}

.login-form-content {
  width: 100%;
  max-width: 450px;
}

/* Logo et nom de l'application */
.login-brand {
  display: flex;
  align-items: center;
  gap: 18px;
  margin-bottom: 60px;
}

.login-logo {
  width: 66px;
  height: 66px;
  border-radius: 50px;
  background: #bd9378;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 12px;
  object-fit: contain;
}

.login-app-name {
  font-family: 'Poppins', sans-serif;
  font-size: 28px;
  margin: 0;
  color: var(--primary-500);
  letter-spacing: 0.5px;
  font-weight: 800;
}

/* Messages d'accueil */
.login-messages {
  margin-bottom: 40px;
}

.login-welcome {
  font-size: 32px;
  font-weight: 700;
  color: #8d4948;
  margin: 0 0 12px 0;
  line-height: 1.2;
}

.login-subtitle {
  font-size: 16px;
  color: #8d4948;
  margin: 0;
  font-weight: 400;
  line-height: 1.5;
}

/* Messages toast - Conteneur */
.messages-container {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 12px;
  max-width: 400px;
}

/* Alertes toast avec barre de progression (uniquement dans .messages-container) */
.messages-container .alert {
  position: relative;
  padding: 16px 20px;
  border-radius: 12px;
  color: #fff;
  font-weight: 500;
  font-size: 14px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.15);
  overflow: hidden;
  animation: slideInRight 0.3s ease forwards;
  min-width: 300px;
  margin-bottom: 0;
}

/* Barre de progression en haut (uniquement pour les messages toast) */
.messages-container .alert::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  height: 4px;
  width: 100%;
  background: rgba(255, 255, 255, 0.3);
  transform-origin: left;
  animation: progressBar 5s linear forwards;
}

.messages-container .alert-danger {
  background-color: #dc3545;
  border-left: 4px solid #c82333;
}

.messages-container .alert-danger::before {
  background: rgba(255, 255, 255, 0.4);
}

.messages-container .alert-success {
  background-color: #28a745;
  border-left: 4px solid #1e7e34;
}

.messages-container .alert-success::before {
  background: rgba(255, 255, 255, 0.4);
}

.messages-container .alert ul {
  margin: 8px 0 0 0;
  padding-left: 20px;
}

.messages-container .alert li {
  margin-bottom: 4px;
}

/* Messages d'erreur du formulaire (dans le formulaire, pas toast) */
.login-form-content > .alert {
  padding: 12px 16px;
  margin-bottom: 20px;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  background-color: #ffebee;
  color: #b71c1c;
  border: 1px solid #f5c2c7;
  position: static;
  animation: none;
  min-width: auto;
  box-shadow: none;
}

.login-form-content > .alert::before {
  display: none;
}

.login-form-content > .alert ul {
  margin: 8px 0 0 0;
  padding-left: 20px;
}

.login-form-content > .alert li {
  margin-bottom: 4px;
}

/* Animation d'entrée */
@keyframes slideInRight {
  from {
    opacity: 0;
    transform: translateX(100%);
  }
  to {
    opacity: 1;
    transform: translateX(0);
  }
}

/* Animation de la barre de progression */
@keyframes progressBar {
  from {
    transform: scaleX(1);
  }
  to {
    transform: scaleX(0);
  }
}

/* Animation de disparition */
@keyframes fadeOut {
  from {
    opacity: 1;
    transform: translateX(0);
    max-height: 200px;
    margin-bottom: 12px;
  }
  to {
    opacity: 0;
    transform: translateX(100%);
    max-height: 0;
    margin-bottom: 0;
    padding-top: 0;
    padding-bottom: 0;
  }
}

.alert.fade-out {
  animation: fadeOut 0.3s ease forwards;
}

/* Formulaire */
.login-form {
  width: 100%;
}

.form-group {
  position: relative;
  margin-bottom: 24px;
}

.form-group input {
  width: 100%;
  padding: 20px 48px 12px 16px;
  border: 2px solid #c0987f;
  border-radius: 8px;
  font-size: 15px;
  font-family: 'Poppins', system-ui, Arial, sans-serif;
  color: var(--text-500);
  background: var(--beige);
  transition: all 0.3s ease;
  outline: none;
  box-sizing: border-box;
}

.form-group input[type="password"],
.form-group input[type="text"][id*="password"],
.form-group input[type="text"][id*="Password"] {
  padding-right: 48px;
}

/* Icône de toggle pour le mot de passe */
.password-toggle {
  position: absolute;
  right: 16px;
  top: 50%;
  transform: translateY(calc(-50% + 2px));
  cursor: pointer;
  color: #996d52;
  font-size: 18px;
  transition: all 0.3s ease;
  z-index: 10;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
  pointer-events: auto;
  user-select: none;
}

.password-toggle:hover {
  color: var(--primary-500);
}

.password-toggle:active {
  transform: translateY(calc(-50% + 2px)) scale(0.9);
}

.form-group label {
  position: absolute;
  left: 16px;
  top: 50%;
  transform: translateY(-50%);
  font-size: 15px;
  font-weight: 400;
  color: #996d52;
  opacity: 1;
  pointer-events: none;
  transition: all 0.3s ease;
  background: transparent;
  padding: 0;
  margin: 0;
  z-index: 1;
}

/* État flottant du label (focus ou valeur présente) */
.form-group input:focus + label,
.form-group.has-value label {
  top: 0;
  transform: translateY(-50%);
  font-size: 12px;
  font-weight: 600;
  color: var(--primary-500);
  opacity: 1;
  background: var(--beige);
  padding: 0 4px;
  z-index: 2;
}

/* État focus de l'input */
.form-group input:focus {
  border-color: var(--primary-500);
  box-shadow: 0 0 0 3px rgba(215, 122, 97, 0.2);
}

.form-group input:focus + label {
  color: var(--primary-500);
}

/* Correction du style autofill du navigateur */
.form-group input:-webkit-autofill,
.form-group input:-webkit-autofill:hover,
.form-group input:-webkit-autofill:focus,
.form-group input:-webkit-autofill:active {
  -webkit-box-shadow: 0 0 0 30px var(--beige) inset !important;
  box-shadow: 0 0 0 30px var(--beige) inset !important;
  -webkit-text-fill-color: var(--text-500) !important;
  transition: background-color 5000s ease-in-out 0s;
}

/* Lien mot de passe oublié */
.form-footer {
  display: flex;
  justify-content: flex-end;
  margin-bottom: 32px;
}

.forgot-password-link {
  color: var(--primary-500);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: color 0.3s ease;
}

.forgot-password-link:hover {
  color: var(--primary-hover);
  text-decoration: underline;
}

/* Bouton de connexion */
.btn-login {
  width: 100%;
  padding: 14px 24px;
  background-color: var(--primary-500);
  color: #fff;
  border: none;
  border-radius: 30px;
  font-size: 16px;
  font-weight: 600;
  font-family: 'Poppins', system-ui, Arial, sans-serif;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(95, 40, 39, 0.2);
}

.btn-login:hover {
  background-color: var(--primary-hover);
  box-shadow: 0 4px 12px rgba(95, 40, 39, 0.3);
  transform: translateY(-1px);
}

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

/* Section visuelle (droite) */
.login-visual-section {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #e6f6f5 0%, #d8f0ee 100%);
  padding: 0;
  position: relative;
  overflow: hidden;
}

.login-visual-content {
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: center;
  animation: fadeInUp 0.8s ease;
}

@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ============================================
   RESPONSIVE DESIGN - BREAKPOINTS OPTIMISÉS
   ============================================ */

/* Très grands écrans (1400px et plus) */
@media (min-width: 1400px) {
  .login-form-content {
    max-width: 500px;
  }

  .login-form-section {
    padding: 60px 80px;
  }

  .login-visual-section {
    padding: 0;
  }

  .login-brand {
    margin-bottom: 70px;
  }

  .login-welcome {
    font-size: 36px;
  }

  .login-subtitle {
    font-size: 18px;
  }
}

/* Grands écrans desktop (1200px - 1399px) */
@media (min-width: 1200px) and (max-width: 1399px) {
  .login-form-content {
    max-width: 480px;
  }

  .login-form-section {
    padding: 50px 60px;
  }

  .login-visual-section {
    padding: 0;
  }
}

/* Tablettes paysage et petits desktop (1024px - 1199px) */
@media (min-width: 1024px) and (max-width: 1199px) {
  .login-form-content {
    max-width: 450px;
  }

  .login-form-section {
    padding: 40px 50px;
  }

  .login-visual-section {
    padding: 0;
  }

  .login-brand {
    margin-bottom: 50px;
  }

  .login-welcome {
    font-size: 30px;
  }
}

/* Tablettes paysage (992px - 1023px) - Passage en colonne */
@media (min-width: 992px) and (max-width: 1023px) {
  .login-container {
    flex-direction: column;
  }

  .login-form-section {
    min-height: auto;
    padding: 50px 40px;
    order: 1;
  }

  .login-visual-section {
    min-height: 350px;
    padding: 0;
    order: 2;
  }

  .login-brand {
    margin-bottom: 45px;
  }

  .login-messages {
    margin-bottom: 35px;
  }

  .login-welcome {
    font-size: 28px;
  }
}

/* Tablettes portrait (768px - 991px) */
@media (min-width: 768px) and (max-width: 991px) {
  .login-container {
    flex-direction: column;
  }

  .login-form-section {
    min-height: auto;
    padding: 45px 36px;
    order: 1;
  }

  .login-form-content {
    max-width: 500px;
    margin: 0 auto;
  }

  .login-visual-section {
    min-height: 320px;
    padding: 0;
    order: 2;
  }

  .login-brand {
    margin-bottom: 40px;
    justify-content: center;
  }

  .login-messages {
    text-align: center;
    margin-bottom: 32px;
  }

  .login-welcome {
    font-size: 28px;
  }

  .login-subtitle {
    font-size: 15px;
  }

  .form-footer {
    justify-content: center;
  }
}

/* Mobiles grands et tablettes petites (576px - 767px) */
@media (min-width: 576px) and (max-width: 767px) {
  .login-container {
    flex-direction: column;
  }

  .login-form-section {
    min-height: auto;
    padding: 40px 32px;
    order: 1;
  }

  .login-form-content {
    max-width: 100%;
  }

  .login-visual-section {
    min-height: 280px;
    padding: 0;
    order: 2;
  }

  .login-brand {
    margin-bottom: 36px;
    justify-content: center;
    gap: 16px;
  }

  .login-logo {
    width: 60px;
    height: 60px;
  }

  .login-app-name {
    font-size: 26px;
  }

  .login-messages {
    text-align: center;
    margin-bottom: 30px;
  }

  .login-welcome {
    font-size: 26px;
  }

  .login-subtitle {
    font-size: 15px;
  }

  .form-group {
    margin-bottom: 22px;
  }

  .form-group label {
    font-size: 15px;
    left: 16px;
  }

  .form-group input {
    padding: 20px 48px 12px 16px;
    font-size: 16px; /* Évite le zoom sur iOS */
  }

  .form-group input[type="password"] {
    padding-right: 48px;
  }

  .form-group input:focus + label,
  .form-group input:not(:placeholder-shown) + label,
  .form-group.has-value label {
    font-size: 12px;
  }

  .form-footer {
    justify-content: center;
    margin-bottom: 28px;
  }

  .btn-login {
    padding: 16px 24px;
    font-size: 16px;
  }
}

/* Mobiles moyens (480px - 575px) */
@media (min-width: 480px) and (max-width: 575px) {
  .login-container {
    flex-direction: column;
  }

  .login-form-section {
    min-height: 100vh;
    padding: 36px 28px;
    order: 1;
    justify-content: flex-start;
    padding-top: 40px;
  }

  .login-form-content {
    max-width: 100%;
    margin: 0 auto;
  }

  .login-form {
    max-width: 100%;
    margin: 0 auto;
    width: 100%;
  }

  .login-visual-section {
    display: none;
  }

  .login-brand {
    margin-bottom: 32px;
    justify-content: center;
    gap: 14px;
  }

  .login-logo {
    width: 56px;
    height: 56px;
    padding: 10px;
  }

  .login-app-name {
    font-size: 24px;
  }

  .login-messages {
    text-align: center;
    margin-bottom: 28px;
  }

  .login-welcome {
    font-size: 24px;
  }

  .login-subtitle {
    font-size: 14px;
  }

  .form-group {
    margin-bottom: 20px;
    max-width: 100%;
  }

  .form-group label {
    font-size: 15px;
    left: 16px;
  }

  .form-group input {
    padding: 20px 48px 12px 16px;
    font-size: 16px; /* Évite le zoom sur iOS */
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  .form-group input[type="password"] {
    padding-right: 48px;
  }

  .form-group input:focus + label,
  .form-group input:not(:placeholder-shown) + label,
  .form-group.has-value label {
    font-size: 12px;
  }

  .form-footer {
    justify-content: center;
    margin-bottom: 24px;
  }

  .forgot-password-link {
    font-size: 14px;
  }

  .btn-login {
    padding: 16px 24px;
    font-size: 16px;
    max-width: 100%;
    margin: 0 auto;
    display: block;
  }

  .alert {
    font-size: 13px;
    padding: 10px 14px;
    max-width: 100%;
  }
}

/* Mobiles petits (320px - 479px) */
@media (min-width: 320px) and (max-width: 479px) {
  .login-container {
    flex-direction: column;
  }

  .login-form-section {
    min-height: 100vh;
    padding: 32px 20px;
    order: 1;
    justify-content: flex-start;
    padding-top: 36px;
  }

  .login-form-content {
    max-width: 100%;
    margin: 0 auto;
    width: 100%;
  }

  .login-form {
    max-width: 100%;
    margin: 0 auto;
    width: 100%;
  }

  .login-visual-section {
    display: none;
  }

  .login-brand {
    margin-bottom: 28px;
    justify-content: center;
    gap: 12px;
    flex-wrap: wrap;
  }

  .login-logo {
    width: 50px;
    height: 50px;
    padding: 8px;
  }

  .login-app-name {
    font-size: 22px;
    letter-spacing: 0.2px;
  }

  .login-messages {
    text-align: center;
    margin-bottom: 24px;
  }

  .login-welcome {
    font-size: 22px;
    margin-bottom: 10px;
  }

  .login-subtitle {
    font-size: 13px;
    line-height: 1.4;
  }

  .form-group {
    margin-bottom: 18px;
    max-width: 100%;
  }

  .form-group label {
    font-size: 14px;
    left: 14px;
  }

  .form-group input {
    padding: 18px 44px 10px 14px;
    font-size: 16px; /* Évite le zoom sur iOS */
    border-width: 1.5px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  .form-group input[type="password"] {
    padding-right: 44px;
  }

  .form-group input:focus + label,
  .form-group input:not(:placeholder-shown) + label,
  .form-group.has-value label {
    font-size: 11px;
  }

  .form-footer {
    justify-content: center;
    margin-bottom: 20px;
  }

  .forgot-password-link {
    font-size: 13px;
  }

  .btn-login {
    padding: 14px 20px;
    font-size: 15px;
    border-radius: 6px;
    max-width: 100%;
    margin: 0 auto;
    display: block;
  }

  .alert {
    font-size: 12px;
    padding: 10px 12px;
    margin-bottom: 16px;
    max-width: 100%;
  }

  .alert ul {
    padding-left: 18px;
    margin-top: 6px;
  }

  .alert li {
    margin-bottom: 3px;
  }
}

/* Très petits écrans (< 320px) */
@media (max-width: 319px) {
  .login-form-section {
    padding: 28px 16px;
    padding-top: 32px;
  }

  .login-form-content {
    max-width: 100%;
    margin: 0 auto;
    width: 100%;
  }

  .login-form {
    max-width: 100%;
    margin: 0 auto;
    width: 100%;
  }

  .login-brand {
    margin-bottom: 24px;
    gap: 10px;
  }

  .login-logo {
    width: 44px;
    height: 44px;
    padding: 6px;
  }

  .login-app-name {
    font-size: 20px;
  }

  .login-welcome {
    font-size: 20px;
  }

  .login-subtitle {
    font-size: 12px;
  }

  .form-group {
    max-width: 100%;
  }

  .form-group label {
    font-size: 14px;
    left: 12px;
  }

  .form-group input {
    padding: 18px 42px 10px 12px;
    font-size: 16px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  .form-group input[type="password"] {
    padding-right: 42px;
  }

  .form-group input:focus + label,
  .form-group input:not(:placeholder-shown) + label,
  .form-group.has-value label {
    font-size: 11px;
  }

  .btn-login {
    padding: 12px 18px;
    font-size: 14px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }
}

/* Orientation paysage sur mobile */
@media (max-height: 600px) and (orientation: landscape) {
  .login-form-section {
    min-height: auto;
    padding: 24px 32px;
  }

  .login-form-content {
    max-width: 100%;
    margin: 0 auto;
    width: 100%;
  }

  .login-form {
    max-width: 100%;
    margin: 0 auto;
    width: 100%;
  }

  .login-brand {
    margin-bottom: 24px;
  }

  .login-messages {
    margin-bottom: 20px;
  }

  .login-welcome {
    font-size: 24px;
  }

  .login-subtitle {
    font-size: 13px;
  }

  .form-group {
    margin-bottom: 16px;
    max-width: 100%;
  }

  .form-group label {
    font-size: 14px;
    left: 16px;
  }

  .form-group input {
    padding: 20px 48px 12px 16px;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  .form-group input[type="password"] {
    padding-right: 48px;
  }

  .form-group input:focus + label,
  .form-group input:not(:placeholder-shown) + label,
  .form-group.has-value label {
    font-size: 12px;
  }

  .form-footer {
    margin-bottom: 16px;
  }

  .btn-login {
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
  }

  .login-visual-section {
    display: none;
  }
}

/* Amélioration du touch sur mobile */
@media (hover: none) and (pointer: coarse) {
  .btn-login {
    min-height: 44px; /* Taille minimale recommandée pour le touch */
  }

  .forgot-password-link {
    min-height: 44px;
    display: inline-flex;
    align-items: center;
  }

  .form-group input {
    min-height: 44px;
  }
}

/* Mode sombre (si supporté) */
@media (prefers-color-scheme: dark) {
  /* Conserver le style clair pour la page de connexion */
  .login-page {
    background: #f2d8c7;
    color: var(--text-500);
  }
}

/* Impression */
@media print {
  .login-visual-section {
    display: none;
  }

  .login-form-section {
    padding: 20px;
  }

  .btn-login {
    display: none;
  }
}

/* ============================================
   SECTION 2FA - VÉRIFICATION EN DEUX ÉTAPES
   ============================================ */

.two-factor-section {
  width: 100%;
}

.two-factor-form {
  width: 100%;
}

/* Container pour les champs de code */
.code-input-container {
  margin-bottom: 32px;
}

.code-inputs {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  margin-bottom: 24px;
}

.code-digit {
  width: 60px;
  height: 70px;
  text-align: center;
  font-size: 32px;
  font-weight: 700;
  border: 2px solid var(--border-light);
  border-radius: 12px;
  background: var(--card-bg);
  color: var(--text-500);
  font-family: 'Poppins', monospace;
  transition: all 0.3s ease;
  outline: none;
  box-sizing: border-box;
  padding: 0;
  line-height: 66px;
}

.code-digit:focus {
  border-color: var(--primary-500);
  box-shadow: 0 0 0 4px rgba(95, 40, 39, 0.15);
  transform: scale(1.05);
  background: #f8feff;
}

.code-digit.filled {
  border-color: var(--primary-500);
  background: rgba(95, 40, 39, 0.05);
}

.code-separator {
  width: 8px;
  height: 2px;
  background: var(--muted);
  border-radius: 2px;
  opacity: 0.5;
}

/* Container pour le lien de renvoi */
.resend-code-container {
  text-align: center;
  margin-top: 24px;
}

.resend-code-link {
  color: var(--primary-500);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.3s ease;
  display: inline-block;
  padding: 8px 16px;
  border-radius: 6px;
}

.resend-code-link:hover {
  color: var(--primary-hover);
  text-decoration: underline;
  background: rgba(95, 40, 39, 0.05);
}

.resend-code-link:active {
  transform: scale(0.98);
}

/* Responsive pour la section 2FA */
@media (max-width: 767px) {
  .code-inputs {
    gap: 8px;
  }

  .code-digit {
    width: 50px;
    height: 60px;
    font-size: 28px;
    line-height: 56px;
  }

  .code-separator {
    width: 6px;
  }
}

@media (max-width: 479px) {
  .code-inputs {
    gap: 6px;
  }

  .code-digit {
    width: 45px;
    height: 55px;
    font-size: 24px;
    line-height: 51px;
    border-radius: 10px;
  }

  .code-separator {
    width: 4px;
  }

  .resend-code-link {
    font-size: 13px;
    padding: 6px 12px;
  }
}
