:root { color-scheme: light dark; }
* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  background:
    radial-gradient(1200px 800px at -10% -10%, rgba(219, 234, 254, 1) 0%, rgba(219, 234, 254, 0.6) 40%, transparent 60%),
    radial-gradient(900px 700px at 110% -10%, rgba(252, 231, 243, 1) 0%, rgba(252, 231, 243, 0.6) 30%, transparent 50%),
    #f8fafc;
  color: #0f172a;
  min-height: 100vh;

  /* Layout en trois zones (haut/centre/bas) */
  display: grid;
  grid-template-rows: auto 1fr auto;
}

/* ----- Header (fixe haut) ----- */
.header {
  text-align: center;
  padding: 16px;
  background: rgba(255,255,255,0.8);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid #e2e8f0;
  position: sticky;
  top: 0;
  z-index: 10;
}
.header h1 { margin: 0; font-size: 1.9rem; letter-spacing: .2px; }
.subtitle { margin: 6px 0 0; color: #475569; font-size: .98rem; }

/* ----- Chat (zone centrale scrollable) ----- */
.chat-container {
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
  padding: 16px;
  overflow-y: auto;

  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Messages */
.msg {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 12px 14px;
  box-shadow: 0 4px 12px rgba(15,23,42,.08);
  white-space: pre-wrap;
  line-height: 1.45;
  max-width: 80%;
}
.msg.user { align-self: flex-end; background: #dbeafe; }
.msg.bot  { align-self: flex-start; background: #f8fafc; }

/* ----- Input bas (fixe bas) ----- */
.input-area {
  background: rgba(255,255,255,0.9);
  backdrop-filter: blur(8px);
  border-top: 1px solid #e2e8f0;

  position: sticky;
  bottom: 0;
  z-index: 10;

  display: grid;
  grid-template-columns: 1fr;
  gap: 8px;

  padding: 12px 16px;
  max-width: 860px;
  width: 100%;
  margin: 0 auto;
}

/* Statut (thinking / erreurs) */
.status {
  min-height: 20px;
  color: #475569;
  font-size: .95rem;

  /* Amélioration visuelle pour l'attente */
  display: flex;
  align-items: center;
  gap: 10px;
}

/* Champ de saisie */
textarea {
  width: 100%;
  min-height: 60px;
  resize: vertical;
  padding: 12px 14px;
  border: 1px solid #cbd5e1;
  border-radius: 12px;
  font-size: 1rem;
  line-height: 1.4;
  background: #fff;
}

/* Boutons */
.controls {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}
.btn {
  appearance: none;
  border: none;
  cursor: pointer;
  background: #2563eb;
  color: #fff;
  font-weight: 700;
  padding: 10px 16px;
  border-radius: 12px;
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.25);
  transition: transform .06s ease, box-shadow .2s ease, opacity .2s;
}
.btn:hover   { transform: translateY(-1px); box-shadow: 0 10px 20px rgba(37, 99, 235, 0.35); }
.btn:active  { transform: translateY(0); }
.btn:disabled { opacity: .6; cursor: progress; }

/* ----- Footer légal ----- */
#legal-footer {
  font-size: 0.75rem;
  color: #888;
  text-align: center;
  margin-top: 4px;
  line-height: 1.2;
}
#legal-footer a {
  color: #777; /* même ton que le texte, légèrement plus marqué */
  text-decoration: none;
}
#legal-footer a:hover {
  color: #555; /* un peu plus sombre au survol */
  text-decoration: underline;
}

/* ----- Animation d'attente moderne ----- */
.loading-wrap {
  display: inline-flex;
  align-items: center;
  gap: 10px;
}

.loader {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  height: 16px;
}

.loader span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #2563eb;
  opacity: .45;
  animation: loader-bounce 1s infinite ease-in-out;
}
.loader span:nth-child(2) { animation-delay: .15s; }
.loader span:nth-child(3) { animation-delay: .30s; }

@keyframes loader-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: .45; }
  40%          { transform: translateY(-6px); opacity: 1; }
}

.loader-text {
  font-size: .95rem;
  color: #475569;
}

/* Respecte les préférences d’accessibilité */
@media (prefers-reduced-motion: reduce) {
  .loader span { animation: none; }
}

/* ----- Dark mode ----- */
@media (prefers-color-scheme: dark) {
  body { background: #0b1220; color: #e5e7eb; }
  .header { background: rgba(15,23,42,0.9); border-color: #1f2937; }
  .subtitle { color: #94a3b8; }
  .msg { background: #0f172a; border-color: #1f2937; }
  .msg.user { background: #1e3a8a; }
  .msg.bot  { background: #1f2937; }
  textarea { background: #0b1220; color: #e5e7eb; border-color: #1f2937; }
  .input-area { background: rgba(15,23,42,0.9); border-color: #1f2937; }
  #legal-footer { color: #94a3b8; }
  #legal-footer a { color: #a3b2c5; }
  #legal-footer a:hover { color: #cbd5e1; }

  /* Contraste loader en sombre */
  .loader span { background: #60a5fa; }
  .loader-text { color: #cbd5e1; }
}