:root {
  --brand: #1f4e86;       /* bleu Moustachir (boutons / accents) */
  --brand-dark: #152e4f;  /* navy de l'en-tête = fond du logo */
  --bg: #e9edf3;          /* fond clair froid */
  --agent-bubble: #ffffff;
  --user-bubble: #dae7f7; /* bleu clair */
  --ink: #12233a;
  --muted: #64748b;
  --line: #dbe1ea;
}

* { box-sizing: border-box; }
html, body { height: 100%; margin: 0; }
body {
  font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: linear-gradient(135deg, #1f3d63, #112744);
  display: flex; align-items: center; justify-content: center;
  padding: 16px; color: var(--ink);
}

.phone {
  width: 100%; max-width: 440px; height: min(88vh, 820px);
  background: var(--bg); border-radius: 20px; overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: 0 24px 60px rgba(0,0,0,.35);
}

/* En-tête */
.chat-head {
  background: var(--brand-dark); color: #fff;
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
}
.logo-img { height: 30px; width: auto; display: block; }
.ci { display: flex; flex-direction: column; line-height: 1.25; flex: 1; }
.ci small { color: #a9c0e0; font-size: 12px; display: inline-flex; align-items: center; gap: 6px; }
.ci small::before { content: ""; width: 8px; height: 8px; border-radius: 50%; background: #35d07f; box-shadow: 0 0 0 2px rgba(53,208,127,.25); }
.gear {
  background: transparent; border: 0; color: #fff; font-size: 22px;
  cursor: pointer; opacity: .9;
}
.gear:hover { opacity: 1; }

/* Bandeau d'info / erreur */
.banner {
  background: #fff3cd; color: #7a5b00; font-size: 13px;
  padding: 8px 14px; border-bottom: 1px solid #f0e2ad;
}
.banner.err { background: #fde2e1; color: #9b2c25; border-color: #f5c3bf; }

/* Zone de conversation */
.chat {
  flex: 1; overflow-y: auto; padding: 16px 14px;
  display: flex; flex-direction: column; gap: 8px;
  background-image: radial-gradient(rgba(0,0,0,.03) 1px, transparent 0);
  background-size: 18px 18px;
}
.row { display: flex; }
.row.user { justify-content: flex-end; }
.bubble {
  max-width: 80%; padding: 9px 12px; border-radius: 12px;
  font-size: 14.5px; line-height: 1.45; white-space: pre-wrap;
  box-shadow: 0 1px 1px rgba(0,0,0,.08); position: relative;
}
.row.agent .bubble { background: var(--agent-bubble); border-top-left-radius: 3px; }
.row.user .bubble { background: var(--user-bubble); border-top-right-radius: 3px; }
.bubble.rtl { direction: rtl; text-align: right; }
.time { display: block; font-size: 10px; color: var(--muted); margin-top: 3px; }

/* Indicateur de saisie */
.typing .bubble { display: inline-flex; gap: 4px; padding: 12px 14px; }
.dot { width: 7px; height: 7px; border-radius: 50%; background: #b7c2bd; animation: b 1.2s infinite; }
.dot:nth-child(2){ animation-delay:.2s } .dot:nth-child(3){ animation-delay:.4s }
@keyframes b { 0%,60%,100%{ transform: translateY(0); opacity:.5 } 30%{ transform: translateY(-4px); opacity:1 } }

/* Zone de saisie */
.composer { display: flex; gap: 8px; padding: 10px; background: #f3ede4; border-top: 1px solid var(--line); }
.composer input {
  flex: 1; border: 1px solid var(--line); border-radius: 22px;
  padding: 11px 16px; font-size: 15px; outline: none; background: #fff;
}
.composer input:focus { border-color: var(--brand); }
.composer button {
  width: 46px; border: 0; border-radius: 50%; background: var(--brand);
  color: #fff; font-size: 18px; cursor: pointer;
}
.composer button:disabled { opacity: .5; cursor: default; }

/* Modale réglages */
.modal { position: fixed; inset: 0; background: rgba(0,0,0,.45); display: grid; place-items: center; padding: 16px; }
.modal-card { background: #fff; border-radius: 14px; padding: 20px; width: 100%; max-width: 380px; }
.modal-card h3 { margin: 0 0 14px; }
.modal-card label { display: block; font-size: 13px; font-weight: 600; margin: 10px 0 5px; }
.modal-card input, .modal-card select { width: 100%; padding: 10px; border: 1px solid var(--line); border-radius: 8px; font-size: 14px; }
.hint { font-size: 12px; color: var(--muted); margin: 6px 0 0; line-height: 1.5; }
.modal-actions { display: flex; justify-content: space-between; gap: 10px; margin-top: 18px; }
.btn { background: var(--brand); color: #fff; border: 0; border-radius: 8px; padding: 10px 16px; font-size: 14px; cursor: pointer; }
.btn.ghost { background: #eef2f0; color: var(--ink); }
.hidden { display: none !important; }
