/* ── Variables ── */
:root {
  --bg:         #040404;
  --bg-chat:    #0a0a0a;
  --accent:     #D8ACD0;
  --accent-dim: rgba(216, 172, 208, 0.15);
  --accent-border: rgba(216, 172, 208, 0.25);
  --bubble-bot: #131313;
  --bubble-bot-border: rgba(216, 172, 208, 0.12);
  --bubble-user: #D8ACD0;
  --text-main:  #ececec;
  --text-muted: #555;
  --input-bg:   #ffffff;
  --input-text: #111111;
  --input-placeholder: #aaaaaa;
  --bar-bg:     #ffffff;
  --bar-border: rgba(216, 172, 208, 0.3);
  --radius-bubble: 18px;
  --max-w: 760px;
}

/* ── Reset & base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html, body {
  height: 100%;
  background: var(--bg);
  color: var(--text-main);
  font-family: 'Open Sans', sans-serif;
  font-size: 15px;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Layout ── */
.layout {
  display: flex;
  flex-direction: column;
  height: 100vh;
  max-width: var(--max-w);
  margin: 0 auto;
}

/* ── Header ── */
.header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.2rem 0.9rem;
  border-bottom: 1px solid var(--accent-border);
  flex-shrink: 0;
  background: var(--bg);
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.header-logo {
  height: 32px;
  filter: invert(1);
}

.header-title {
  font-family: 'Poppins', sans-serif;
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--accent);
  letter-spacing: 0.07em;
  text-transform: uppercase;
  line-height: 1.2;
}

.header-online {
  font-size: 0.67rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.header-online::before {
  content: "● ";
  color: #6fcf6f;
}

.btn-reset {
  background: transparent;
  border: 1px solid #2a2a2a;
  color: #555;
  font-size: 0.72rem;
  font-family: 'Poppins', sans-serif;
  border-radius: 20px;
  padding: 4px 12px;
  cursor: pointer;
  transition: border-color 0.2s, color 0.2s;
}

.btn-reset:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ── Zone chat ── */
.chat-zone {
  flex: 1;
  overflow-y: auto;
  padding: 1.2rem 1rem 0.5rem;
  scroll-behavior: smooth;
}

.chat-zone::-webkit-scrollbar { width: 4px; }
.chat-zone::-webkit-scrollbar-track { background: transparent; }
.chat-zone::-webkit-scrollbar-thumb { background: #2a2a2a; border-radius: 4px; }

/* ── Rows ── */
.row {
  display: flex;
  gap: 10px;
  margin-bottom: 1rem;
  align-items: flex-start;
}

.row.user {
  flex-direction: row-reverse;
}

/* ── Avatars ── */
.avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  flex-shrink: 0;
  margin-top: 4px;
  background: #1a1a1a;
  border: 1px solid var(--accent-dim);
}

/* ── Bulles ── */
.body { max-width: 76%; }

.name {
  font-size: 0.67rem;
  font-family: 'Poppins', sans-serif;
  font-weight: 700;
  letter-spacing: 0.04em;
  color: var(--text-muted);
  margin-bottom: 3px;
}

.name.gilbert { color: var(--accent); }

.bubble {
  padding: 0.7rem 1rem;
  border-radius: var(--radius-bubble);
  font-size: 0.91rem;
  line-height: 1.58;
  word-break: break-word;
}

.bubble.bot {
  background: var(--bubble-bot);
  border: 1px solid var(--bubble-bot-border);
  border-top-left-radius: 3px;
  color: var(--text-main);
}

.bubble.user-msg {
  background: var(--bubble-user);
  color: #080808;
  border-top-right-radius: 3px;
  font-weight: 500;
}

/* ── Contenu markdown dans les bulles ── */
.bubble a { color: var(--accent); text-decoration: underline; text-underline-offset: 2px; }
.bubble strong { color: #fff; }
.bubble em { color: #ccc; }
.bubble p { margin: 0.25rem 0; }
.bubble p:first-child { margin-top: 0; }
.bubble p:last-child { margin-bottom: 0; }
.bubble ul, .bubble ol { padding-left: 1.2rem; margin: 0.3rem 0; }
.bubble li { margin-bottom: 0.2rem; }
.bubble code {
  background: #1e1e1e;
  border: 1px solid #333;
  border-radius: 4px;
  padding: 1px 5px;
  font-size: 0.83em;
  color: #e0e0e0;
  font-family: 'Fira Code', monospace;
}
.bubble pre {
  background: #111;
  border: 1px solid #2a2a2a;
  border-radius: 8px;
  padding: 0.8rem 1rem;
  overflow-x: auto;
  margin: 0.5rem 0;
}
.bubble pre code {
  background: none;
  border: none;
  padding: 0;
  font-size: 0.85em;
}
.bubble table {
  border-collapse: collapse;
  width: 100%;
  font-size: 0.85rem;
  margin: 0.5rem 0;
}
.bubble th {
  color: var(--accent);
  border-bottom: 1px solid var(--accent-border);
  padding: 4px 8px;
  text-align: left;
  font-weight: 600;
}
.bubble td {
  padding: 4px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.05);
}

/* ── Spinner ── */
.thinking {
  font-size: 0.82rem;
  color: var(--text-muted);
  font-style: italic;
  display: flex;
  align-items: center;
  gap: 6px;
}

.dot-flashing {
  display: inline-flex;
  gap: 4px;
}

.dot-flashing span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: blink 1.2s infinite;
}

.dot-flashing span:nth-child(2) { animation-delay: 0.2s; }
.dot-flashing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes blink {
  0%, 80%, 100% { opacity: 0.2; }
  40% { opacity: 1; }
}

/* ── Sources ── */
.sources {
  margin-top: 0.35rem;
  font-size: 0.68rem;
}

.sources summary {
  cursor: pointer;
  color: #444;
  list-style: none;
  user-select: none;
  transition: color 0.15s;
}

.sources summary:hover { color: var(--accent); }

.sources code {
  background: #1a1a1a;
  padding: 1px 5px;
  border-radius: 4px;
  color: #666;
  font-size: 0.68rem;
  margin: 0 2px;
}

/* ── Barre input ── */
.input-bar {
  flex-shrink: 0;
  background: var(--bar-bg);
  border-top: 1px solid var(--bar-border);
  padding: 0.75rem 1rem;
  display: flex;
  gap: 8px;
  align-items: flex-end;
}

.input-bar textarea {
  flex: 1;
  background: var(--input-bg);
  color: var(--input-text);
  border: 1px solid rgba(216, 172, 208, 0.45);
  border-radius: 22px;
  padding: 0.6rem 1rem;
  font-family: 'Open Sans', sans-serif;
  font-size: 0.9rem;
  line-height: 1.5;
  resize: none;
  outline: none;
  min-height: 42px;
  max-height: 140px;
  overflow-y: auto;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.input-bar textarea::placeholder { color: var(--input-placeholder); }

.input-bar textarea:focus {
  border-color: #D8ACD0;
  box-shadow: 0 0 0 3px rgba(216, 172, 208, 0.15);
}

.btn-send {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: #111;
  border: 1px solid #2a2a2a;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, border-color 0.2s;
}

.btn-send:hover {
  background: #1e1e1e;
  border-color: var(--accent);
}

.btn-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.btn-send svg {
  fill: var(--accent);
  width: 18px;
  height: 18px;
}

/* ── Responsive mobile ── */
@media (max-width: 600px) {
  .bubble { font-size: 0.88rem; }
  .body { max-width: 85%; }
  .header { padding: 0.8rem; }
  .chat-zone { padding: 1rem 0.75rem 0.5rem; }
  .input-bar { padding: 0.6rem 0.75rem; }
}
