/* --- VARIABLES & PALETTE (Thème Noir/Violet Neon) --- */
:root {
  /* Arrière-plans */
  --bg-app: #050505; /* Noir profond pour le fond global */
  --bg-panel: #121212; /* Noir légèrement moins profond pour les conteneurs (login, header) */
  --bg-input: #1a1a1a; /* Fond des champs de saisie */

  /* Couleurs d'accentuation (Violet) */
  --accent-primary: #7c3aed; /* Violet vibrant principal */
  --accent-hover: #6d28d9; /* Violet un peu plus sombre au survol */
  --accent-gradient: linear-gradient(
    135deg,
    #7c3aed,
    #a855f7
  ); /* Dégradé pour les éléments actifs */
  --accent-glow: rgba(124, 58, 237, 0.4); /* Lueur violette pour les ombres */

  /* Textes */
  --text-primary: #ffffff; /* Blanc pur pour la lisibilité maximale */
  --text-secondary: #a1a1aa; /* Gris clair pour les infos secondaires (pseudos, placeholders) */

  /* Bulles */
  --bubble-me-bg: var(--accent-gradient); /* Dégradé violet pour mes messages */
  --bubble-other-bg: #262626; /* Gris foncé pour les autres */
}

/* RESET & BASE UX */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  /* Utilisation d'une police système moderne sans-serif */
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica,
    Arial, sans-serif;
  /* Rendu des polices plus net sur fond sombre */
  -webkit-font-smoothing: antialiased;
}

body {
  background-color: var(--bg-app);
  height: 100vh;
  display: flex;
  justify-content: center;
  align-items: center;
  color: var(--text-primary);
  /* Petit effet de vignette pour focus le centre */
  background-image: radial-gradient(circle at center, #1a1a1a 0%, #050505 100%);
}

/* --- ÉCRAN DE LOGIN (UI Moderne) --- */
#login-screen {
  background: var(--bg-panel);
  padding: 40px;
  border-radius: 24px; /* Coins très arrondis modernes */
  text-align: center;
  width: 100%;
  max-width: 380px;
  /* Ombre portée avec une légère lueur violette pour la profondeur */
  box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.5), 0 0 20px var(--accent-glow);
  border: 1px solid rgba(255, 255, 255, 0.05); /* Bordure subtile */
  /* Animation d'entrée fluide */
  animation: slideUpFade 0.5s ease-out;
}

#login-screen h2 {
  color: var(--text-primary) !important; /* On force le blanc */
  margin-bottom: 30px;
  font-weight: 800;
  letter-spacing: -0.5px;
}

#login-screen input {
  background: var(--bg-input);
  padding: 16px;
  width: 100%;
  margin-bottom: 20px;
  border: 2px solid transparent; /* Bordure transparente par défaut */
  border-radius: 12px;
  outline: none;
  color: var(--text-primary);
  font-size: 1rem;
  transition: all 0.3s ease; /* Transition fluide pour le focus */
}

/* UX: Feedback visuel au focus */
#login-screen input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 15px var(--accent-glow);
  background: #202020;
}

#login-screen button {
  background: var(--accent-gradient);
  color: white;
  border: none;
  padding: 16px 20px;
  border-radius: 12px;
  cursor: pointer;
  width: 100%;
  font-weight: 700;
  font-size: 1rem;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px var(--accent-glow);
}

/* UX: Feedback au survol et clic */
#login-screen button:hover {
  transform: translateY(-2px); /* Léger soulèvement */
  box-shadow: 0 8px 25px var(--accent-glow);
}
#login-screen button:active {
  transform: translateY(0); /* Retour à la normale au clic */
}

/* --- ÉCRAN DE CHAT --- */
#chat-screen {
  display: none;
  width: 100%;
  max-width: 550px; /* Un peu plus large pour le confort */
  height: 100vh;
  /* Sur mobile, plein écran. Sur desktop, une "carte" flottante */
  max-height: 90vh;
  border-radius: 24px;
  background-color: var(--bg-app);
  flex-direction: column;
  overflow: hidden; /* Important pour les coins arrondis */
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.05);
  /* Animation d'entrée */
  animation: fadeIn 0.5s ease-out;
}

/* Header moderne */
.header {
  background-color: var(--bg-panel);
  padding: 20px 25px;
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  backdrop-filter: blur(10px); /* Effet "verre dépoli" si supporté */
}

/* Liste des messages */
.messages-list {
  flex: 1;
  overflow-y: auto;
  padding: 25px;
  display: flex;
  flex-direction: column;
  gap: 12px; /* Plus d'espace entre les messages */
  background-color: var(--bg-app);
  /* Scrollbar personnalisée pour Chrome/Safari/Edge */
  scrollbar-width: thin;
  scrollbar-color: var(--accent-primary) var(--bg-app);
}

/* --- BULLES DE MESSAGES (Ergonomie poussée) --- */
.message {
  max-width: 80%;
  padding: 14px 18px;
  border-radius: 20px; /* Très arrondi */
  font-size: 15px;
  position: relative;
  line-height: 1.5;
  word-wrap: break-word;
  /* Animation d'apparition des messages */
  animation: msgSlideIn 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}

/* C'est MOI (Violet dégradé, à droite) */
.message.me {
  align-self: flex-end;
  background: var(--bubble-me-bg);
  color: white;
  /* Petit détail ergonomique : coin inférieur droit moins arrondi */
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 15px var(--accent-glow);
}

/* C'est L'AUTRE (Gris foncé, à gauche) */
.message.other {
  align-self: flex-start;
  background-color: var(--bubble-other-bg);
  color: var(--text-primary);
  border-bottom-left-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

/* Pseudo des autres */
.pseudo-label {
  display: block;
  /* Couleur violet clair pour le nom */
  color: #a78bfa;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
}

/* Messages système */
.system-msg {
  align-self: center;
  background-color: rgba(
    124,
    58,
    237,
    0.1
  ); /* Fond violet très léger transparent */
  color: var(--text-secondary);
  padding: 8px 16px;
  border-radius: 50px; /* Forme "pilule" */
  font-size: 0.85rem;
  margin: 15px 0;
  border: 1px solid var(--accent-glow);
}

/* ZONE DE SAISIE (Input Area) */
.input-area {
  background-color: var(--bg-panel);
  padding: 20px;
  display: flex;
  align-items: center;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.input-area input {
  flex: 1;
  padding: 14px 20px;
  border: none;
  outline: none;
  font-size: 1rem;
  background-color: var(--bg-input);
  border-radius: 50px; /* Champ de saisie très rond */
  color: var(--text-primary);
  margin-right: 15px;
  transition: all 0.3s ease;
  border: 2px solid transparent;
}

/* UX: Feedback focus input chat */
.input-area input:focus {
  background-color: #202020;
  border-color: var(--accent-primary);
  box-shadow: 0 0 15px var(--accent-glow);
}

/* UX: Placeholder stylisé */
.input-area input::placeholder {
  color: #666;
}

.send-btn {
  /* Bouton rond violet */
  background: var(--accent-gradient);
  color: white;
  border: none;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 10px var(--accent-glow);
}

.send-btn:hover {
  transform: scale(1.1) rotate(-10deg); /* Petite rotation dynamique au survol */
  background: var(--accent-hover);
}

/* --- ANIMATIONS KEYFRAMES --- */
/* Apparition fluide vers le haut */
@keyframes slideUpFade {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* Simple fondu */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

/* Apparition dynamique des messages */
@keyframes msgSlideIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

/* --- RESPONSIVE --- */
/* Adaptation pour que ça prenne tout l'écran sur mobile */
@media (max-width: 600px) {
  #chat-screen {
    max-width: 100%;
    max-height: 100vh;
    border-radius: 0;
  }
  #login-screen {
    width: 90%;
  }
}

/* LOGIN */
#login-screen {
  background: var(--bg-panel);
  padding: 40px;
  border-radius: 24px;
  text-align: center;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 20px 40px -10px rgba(0, 0, 0, 0.5), 0 0 20px var(--accent-glow);
  border: 1px solid rgba(255, 255, 255, 0.05);
  animation: slideUpFade 0.5s ease-out;
}
#login-screen h2 {
  color: var(--text-primary);
}
#login-screen input {
  background: var(--bg-input);
  padding: 16px;
  width: 100%;
  margin-bottom: 20px;
  border: 2px solid transparent;
  border-radius: 12px;
  outline: none;
  color: white;
  transition: 0.3s;
}
#login-screen input:focus {
  border-color: var(--accent-primary);
  box-shadow: 0 0 15px var(--accent-glow);
}
#login-screen button {
  background: var(--accent-gradient);
  color: white;
  border: none;
  padding: 16px;
  border-radius: 12px;
  cursor: pointer;
  width: 100%;
  font-weight: 700;
  transition: 0.3s;
}
#login-screen button:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px var(--accent-glow);
}

/* CHAT SCREEN */
#chat-screen {
  display: none;
  width: 100%;
  max-width: 550px;
  height: 100vh;
  max-height: 90vh;
  border-radius: 24px;
  background-color: var(--bg-app);
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7);
  border: 1px solid rgba(255, 255, 255, 0.05);
  animation: fadeIn 0.5s ease-out;
}
.header {
  background-color: var(--bg-panel);
  padding: 20px 25px;
  font-weight: 700;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}
.messages-list {
  flex: 1;
  overflow-y: auto;
  padding: 25px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scrollbar-width: thin;
  scrollbar-color: var(--accent-primary) var(--bg-app);
}

/* MESSAGES */
.message {
  max-width: 80%;
  padding: 14px 18px;
  border-radius: 20px;
  font-size: 15px;
  position: relative;
  line-height: 1.5;
  word-wrap: break-word;
  animation: msgSlideIn 0.3s cubic-bezier(0.25, 0.46, 0.45, 0.94) both;
}
.message.me {
  align-self: flex-end;
  background: var(--bubble-me-bg);
  color: white;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 15px var(--accent-glow);
  cursor: pointer;
}
.message.other {
  align-self: flex-start;
  background-color: var(--bubble-other-bg);
  color: white;
  border-bottom-left-radius: 4px;
  border: 1px solid rgba(255, 255, 255, 0.05);
}

.pseudo-label {
  display: block;
  color: #a78bfa;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 6px;
}

/* LABEL MODIFIÉ */
.edited-label {
  display: block;
  font-size: 0.7rem;
  font-style: italic;
  opacity: 0.7;
  margin-top: 4px;
  text-align: right;
}

/* IMAGES DANS LE CHAT */
.message img {
  max-width: 100%;
  border-radius: 12px;
  margin-top: 5px;
  display: block;
}

/* INPUT AREA */
.input-area {
  background-color: var(--bg-panel);
  padding: 15px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.input-area input[type="text"] {
  flex: 1;
  padding: 14px 20px;
  border: none;
  outline: none;
  font-size: 1rem;
  background-color: var(--bg-input);
  border-radius: 50px;
  color: white;
  transition: 0.3s;
}
.input-area input[type="text"]:focus {
  background-color: #202020;
  box-shadow: 0 0 10px var(--accent-glow);
}

/* BOUTONS ICONES (+ et Envoyer) */
.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 45px;
  height: 45px;
  border-radius: 50%;
  cursor: pointer;
  transition: 0.3s;
  border: none;
  color: white;
}
.add-btn {
  background-color: #333;
  color: var(--accent-primary);
}
.add-btn:hover {
  background-color: #444;
  color: white;
}

.send-btn {
  background: var(--accent-gradient);
  box-shadow: 0 4px 10px var(--accent-glow);
}
.send-btn:hover {
  transform: scale(1.1);
}

/* ANIMATIONS */
@keyframes slideUpFade {
  from {
    opacity: 0;
    transform: translateY(30px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}
@keyframes msgSlideIn {
  from {
    opacity: 0;
    transform: translateY(20px) scale(0.95);
  }
  to {
    opacity: 1;
    transform: translateY(0) scale(1);
  }
}

@media (max-width: 600px) {
  #chat-screen {
    max-width: 100%;
    max-height: 100vh;
    border-radius: 0;
  }
}
