/* Assistant MNSTR — thème sombre
   Couleurs : remplace --accent par la couleur de l'agence si elle en a une. */
:root {
  --black: #000;
  --white: #fff;
  --bg: #0e0e0d;             /* fond de page */
  --surface: #1b1b1a;        /* code, tableaux */
  --field: #161615;          /* zone de saisie */
  --bubble: #262624;         /* messages de l'utilisateur */
  --line: #2c2c2a;
  --line-strong: #3d3d3a;
  --hover: #8a8a85;          /* bordures au survol / au focus */
  --muted: #9a9a94;
  --text: #ecece8;
  --dot: #4a4a47;
  --accent: #7b8cff;
  --danger: #ff6b5e;
  --column: 46rem;
  --radius: 14px;
  color-scheme: dark;
}

*, *::before, *::after { box-sizing: border-box; }

html, body { height: 100%; margin: 0; }

body {
  font-family: "DM Sans", system-ui, -apple-system, "Segoe UI", sans-serif;
  font-optical-sizing: auto;
  font-size: 16px;
  line-height: 1.6;
  color: var(--text);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); }
button { font: inherit; }

:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.visually-hidden {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); white-space: nowrap;
}

/* ---------- Connexion ---------- */

body.login {
  background: var(--black);
  color: var(--white);
  display: grid;
  place-items: center;
  padding: max(2rem, env(safe-area-inset-top)) 1.5rem max(2rem, env(safe-area-inset-bottom));
}

.login-panel { width: 100%; max-width: 26rem; }

.login-logo { display: block; width: min(16rem, 70%); height: auto; }

.login-title {
  margin: 1.25rem 0 0;
  font-size: 1.5rem;
  font-weight: 500;
  letter-spacing: -0.01em;
}

.login-text { margin: 0.75rem 0 2rem; color: #b5b5b0; }

.login-error {
  margin: 0 0 1.5rem;
  padding: 0.75rem 1rem;
  border-left: 3px solid #ff6b5e;
  background: #1c1c1c;
  color: #ffd2cd;
}

.login-button {
  display: inline-flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.85rem 1.4rem;
  border-radius: 999px;
  background: var(--white);
  color: var(--black);
  font-weight: 600;
  text-decoration: none;
}
.login-button:hover { background: #e9e9e6; }

/* ---------- Application ---------- */

body.app { display: flex; flex-direction: column; min-height: 100%; }

.topbar {
  position: sticky;
  top: 0;
  z-index: 5;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: calc(0.9rem + env(safe-area-inset-top)) 1.5rem 0.9rem;
  background: var(--black);
  color: var(--white);
  border-bottom: 1px solid var(--line);
}

.brand { display: flex; align-items: center; gap: 0.8rem; text-decoration: none; color: inherit; }
.brand img { display: block; height: 20px; width: auto; }
.brand-label {
  padding-left: 0.8rem;
  border-left: 1px solid #3a3a3a;
  font-size: 0.95rem;
  color: #c9c9c4;
}

.topbar-actions { display: flex; align-items: center; gap: 1.25rem; font-size: 0.9rem; }
.user-name { color: #c9c9c4; }

.link-button {
  padding: 0;
  border: 0;
  background: none;
  color: var(--white);
  cursor: pointer;
  text-decoration: none;
}
.link-button:hover { text-decoration: underline; }
.link-button { white-space: nowrap; }
.label-short { display: none; }

.stage {
  flex: 1;
  width: 100%;
  max-width: var(--column);
  margin: 0 auto;
  padding: 0 1.5rem 2rem;
}

/* Accueil */

.intro { padding: clamp(3rem, 12vh, 7rem) 0 2rem; }

.intro h1 {
  margin: 0;
  max-width: 18em;
  font-size: clamp(2rem, 5vw, 2.9rem);
  font-weight: 600;
  line-height: 1.08;
  letter-spacing: -0.03em;
}

.intro p { max-width: 34rem; margin: 1.1rem 0 2.25rem; color: var(--muted); font-size: 1.05rem; }

.suggestions { display: flex; flex-direction: column; align-items: flex-start; gap: 0.6rem; }

.suggestion {
  padding: 0.6rem 1rem;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  text-align: left;
  cursor: pointer;
}
.suggestion:hover { border-color: var(--hover); }

/* Fil de discussion */

.thread { list-style: none; margin: 0; padding: 2rem 0 0; display: flex; flex-direction: column; gap: 2rem; }

.msg-user {
  align-self: flex-end;
  max-width: 85%;
  padding: 0.7rem 1.1rem;
  border-radius: var(--radius) var(--radius) 4px var(--radius);
  background: var(--bubble);
  color: var(--text);
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.msg-assistant { align-self: stretch; }

.steps { list-style: none; margin: 0 0 0.9rem; padding: 0; font-size: 0.88rem; color: var(--muted); }
.steps:empty { display: none; }
.step { display: flex; align-items: baseline; gap: 0.6rem; padding: 0.15rem 0; }
.step::before {
  content: "";
  flex: none;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--dot);
  transform: translateY(-1px);
}
.step.running::before { background: var(--accent); animation: pulse 1s ease-in-out infinite alternate; }
.step.done::before { background: var(--text); }
.step.error { color: var(--danger); }
.step.error::before { background: var(--danger); }

@keyframes pulse { from { opacity: 0.25; } to { opacity: 1; } }

.answer { overflow-wrap: anywhere; }
.answer > :first-child { margin-top: 0; }
.answer > :last-child { margin-bottom: 0; }
.answer p, .answer ul, .answer ol { margin: 0 0 0.9em; }
.answer ul, .answer ol { padding-left: 1.3em; }
.answer ul { list-style: disc; }
.answer ol { list-style: decimal; }
.answer li + li { margin-top: 0.25em; }
.answer h1, .answer h2, .answer h3 { font-size: 1.05rem; font-weight: 600; margin: 1.3em 0 0.4em; }
.answer code { font-size: 0.9em; padding: 0.1em 0.35em; border-radius: 4px; background: var(--surface); }
.answer pre { padding: 0.9rem 1rem; border-radius: 8px; background: var(--surface); overflow-x: auto; }
.answer pre code { padding: 0; background: none; }
.answer table { border-collapse: collapse; margin: 0 0 1em; display: block; overflow-x: auto; }
.answer th, .answer td { padding: 0.4rem 0.7rem; border-bottom: 1px solid var(--line); text-align: left; }

.thinking { color: var(--muted); }

.error-box { color: var(--danger); }
.error-box a { color: inherit; font-weight: 600; }

.sources { margin-top: 1.1rem; padding-top: 0.9rem; border-top: 1px solid var(--line); }
.sources-title { margin: 0 0 0.5rem; font-size: 0.85rem; color: var(--muted); }
.sources-list { display: flex; flex-wrap: wrap; gap: 0.45rem; list-style: none; margin: 0; padding: 0; }
.sources-list a {
  display: block;
  max-width: 22rem;
  padding: 0.3rem 0.75rem;
  border: 1px solid var(--line);
  border-radius: 6px;
  color: var(--text);
  font-size: 0.85rem;
  text-decoration: none;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sources-list a:hover { border-color: var(--hover); }

/* Zone de saisie */

.composer-wrap {
  position: sticky;
  bottom: 0;
  padding: 0.75rem 1.5rem calc(0.75rem + env(safe-area-inset-bottom));
  background: linear-gradient(to bottom, rgba(14,14,13,0), var(--bg) 1.25rem);
}

.composer {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  max-width: calc(var(--column) - 3rem);
  margin: 0 auto;
  padding: 0.45rem 0.45rem 0.45rem 1.1rem;
  border: 1px solid var(--line-strong);
  border-radius: 1.6rem;
  background: var(--field);
}
.composer:focus-within { border-color: var(--hover); }

.composer textarea {
  flex: 1;
  min-height: 2.4rem;
  max-height: 12rem;
  padding: 0.45rem 0;
  border: 0;
  outline: none;
  resize: none;
  background: transparent;
  font: inherit;
  color: inherit;
}

.composer button {
  flex: none;
  height: 2.4rem;
  padding: 0 1.15rem;
  border: 0;
  border-radius: 999px;
  background: var(--white);
  color: var(--black);
  font-weight: 600;
  cursor: pointer;
}
.composer button:disabled { background: var(--line-strong); color: var(--muted); cursor: default; }

.composer-note { max-width: var(--column); margin: 0.45rem auto 0; font-size: 0.78rem; color: var(--muted); text-align: center; }

@media (max-width: 560px) {
  .topbar { padding-left: 1rem; padding-right: 1rem; }
  .brand-label, .user-name, .label-long { display: none; }
  .label-short { display: inline; }
  .brand img { height: 17px; }
  .topbar-actions { gap: 1rem; }
  .stage { padding-left: 1rem; padding-right: 1rem; }
  .composer-wrap { padding-left: 0.75rem; padding-right: 0.75rem; }
  .msg-user { max-width: 92%; }
}

@media (prefers-reduced-motion: reduce) {
  .step.running::before { animation: none; }
}
