/* Copain — styles (mobile-first, pas d'emoji, pas de framework) */
:root {
  --bg: #f4f6fa;
  --surface: #ffffff;
  --ink: #1c2434;
  --ink-soft: #5b6577;
  --line: #e3e8f0;
  --accent: #3556c8;
  --accent-ink: #ffffff;
  --bubble-user: #3556c8;
  --bubble-user-ink: #ffffff;
  --ok: #1a7f4e;
  --warn: #a05a00;
  --err: #b3261e;
  --radius: 14px;
}
@media (prefers-color-scheme: dark) {
  :root {
    --bg: #12151d;
    --surface: #1b202c;
    --ink: #e8ebf2;
    --ink-soft: #99a2b3;
    --line: #2a3140;
    --accent: #5b7bf0;
    --bubble-user: #3d55c0;
  }
}
* { box-sizing: border-box; }
html, body { height: 100%; }
body {
  margin: 0;
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  background: var(--bg);
  color: var(--ink);
  -webkit-font-smoothing: antialiased;
}
.app { display: flex; flex-direction: column; height: 100dvh; max-width: 760px; margin: 0 auto; }

/* --- topbar --- */
.topbar {
  display: flex; justify-content: space-between; align-items: center;
  padding: 10px 14px; background: var(--surface);
  border-bottom: 1px solid var(--line);
  position: sticky; top: 0; z-index: 5;
}
.topbar-left { display: flex; align-items: center; gap: 8px; }
.topbar-title { font-weight: 700; letter-spacing: .2px; }
.topbar-right { display: flex; align-items: center; gap: 10px; }
.topbar-user { color: var(--ink-soft); font-size: .9rem; }
.btn-icon {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border: 1px solid var(--line); border-radius: 10px;
  background: transparent; color: var(--ink); cursor: pointer;
}
.btn-icon:active { transform: scale(.96); }

/* --- messages --- */
.messages { flex: 1; overflow-y: auto; padding: 16px 14px 8px; }
.day-separator {
  text-align: center; color: var(--ink-soft); font-size: .78rem;
  text-transform: uppercase; letter-spacing: .6px; margin: 10px 0 4px;
}
.msg { max-width: 82%; margin: 6px 0; padding: 10px 14px; border-radius: var(--radius); line-height: 1.45; white-space: pre-wrap; word-wrap: break-word; }
.msg.user { margin-left: auto; background: var(--bubble-user); color: var(--bubble-user-ink); border-bottom-right-radius: 4px; }
.msg.assistant { background: var(--surface); border: 1px solid var(--line); border-bottom-left-radius: 4px; }
.msg a { color: var(--accent); }

/* cartes d'action */
.card {
  background: var(--surface); border: 1px solid var(--line);
  border-radius: var(--radius); padding: 12px 14px; margin: 8px 0 8px auto;
  max-width: 86%; font-size: .92rem;
}
.card-title { font-weight: 600; margin: 0 0 6px; display: flex; align-items: center; gap: 8px; }
.card-title svg { flex: none; color: var(--accent); }
.card ul { margin: 6px 0 0; padding-left: 18px; }
.card li { margin: 3px 0; }
.card a { color: var(--accent); text-decoration: none; }
.card a:hover { text-decoration: underline; }
.card-ok { color: var(--ok); font-weight: 600; }
.card-warn { color: var(--warn); font-size: .82rem; margin-top: 6px; }
.amount { font-variant-numeric: tabular-nums; }
.credit { color: var(--ok); } .debit { color: var(--err); }

/* carte reçu (confirmation) */
.card.receipt { margin-left: auto; }
.receipt-fields { display: grid; gap: 8px; margin: 8px 0; }
.receipt-fields label { font-size: .78rem; color: var(--ink-soft); display: block; margin-bottom: 2px; }
.receipt-fields input, .receipt-fields select {
  width: 100%; padding: 8px 10px; border: 1px solid var(--line); border-radius: 8px;
  background: var(--bg); color: var(--ink); font-size: .95rem;
}
.receipt-actions { display: flex; gap: 8px; margin-top: 10px; }
.btn-primary {
  flex: 1; padding: 10px; border: none; border-radius: 10px;
  background: var(--accent); color: var(--accent-ink); font-weight: 600; cursor: pointer;
}
.btn-secondary {
  padding: 10px 14px; border: 1px solid var(--line); border-radius: 10px;
  background: transparent; color: var(--ink); cursor: pointer;
}
button:disabled { opacity: .55; cursor: default; }

/* --- typing --- */
.typing { padding: 4px 18px 8px; color: var(--ink-soft); font-size: .85rem; }
.typing.slow { color: var(--accent, var(--ink-soft)); } /* réponse longue : apaise l'attente */
.typing .dot { display: inline-block; width: 6px; height: 6px; margin-right: 3px; border-radius: 50%; background: var(--ink-soft); animation: blink 1.2s infinite; }
.typing .dot:nth-child(2) { animation-delay: .2s; }
.typing .dot:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

/* --- composer --- */
.composer { padding: 8px 10px calc(10px + env(safe-area-inset-bottom)); background: var(--surface); border-top: 1px solid var(--line); }
.composer-form { display: flex; align-items: flex-end; gap: 8px; }
.composer-photo { flex: none; }
#input {
  flex: 1; resize: none; max-height: 120px; padding: 10px 12px;
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--bg); color: var(--ink); font: inherit;
}
.btn-send {
  flex: none; width: 40px; height: 40px; border: none; border-radius: 12px;
  background: var(--accent); color: var(--accent-ink); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center;
}
.composer-error { color: var(--err); font-size: .82rem; margin: 6px 2px 0; }

/* --- login --- */
.login-wrap { min-height: 100dvh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.login-card {
  width: 100%; max-width: 360px; background: var(--surface);
  border: 1px solid var(--line); border-radius: 18px; padding: 28px 24px;
  display: flex; flex-direction: column; gap: 8px;
}
.login-logo { color: var(--accent); }
.login-card h1 { margin: 0; font-size: 1.4rem; }
.login-sub { margin: 0 0 10px; color: var(--ink-soft); font-size: .9rem; }
.login-card label { font-size: .8rem; color: var(--ink-soft); margin-top: 6px; }
.login-card input {
  padding: 10px 12px; border: 1px solid var(--line); border-radius: 10px;
  background: var(--bg); color: var(--ink); font-size: 1rem;
}
.login-error { color: var(--err); font-size: .85rem; margin: 4px 0 0; }
.login-card .btn-primary { margin-top: 12px; }
