/* ─────────────────────────────────────────────
   SAV Destrian — espace client (mobile)
   Tokens repris de la maquette Claude Design
   ───────────────────────────────────────────── */
:root {
  --navy: #262251;
  --orange: #E8461E;
  --orange-dark: #C33A15;
  --orange-soft: #FDF0EC;
  --text: #262251;
  --text-2: #4A4E68;
  --muted: #6B6F86;
  --muted-2: #9498AC;
  --border: #D7D9E3;
  --border-2: #E4E6EE;
  --line: #EDEEF2;
  --fill: #F0F1F6;
  --fill-2: #F4F5F9;
  --bg: #F7F8FB;
  --page: #EDEEF2;
  --white: #fff;
  --green-bg: #E9F5EF;
  --green: #237552;
  --blue-bg: #E8ECF7;
  --blue: #2A4B9B;
  --radius: 10px;
  --radius-lg: 14px;
  --shadow: 0 12px 40px rgba(38, 34, 81, .14);
  --phone-w: 390px;
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  background: var(--page);
  font-family: 'Poppins', system-ui, -apple-system, sans-serif;
  color: var(--text);
  -webkit-font-smoothing: antialiased;
  font-size: 15px;
  line-height: 1.5;
}
button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; border: 0; background: none; padding: 0; }
a { color: var(--orange); text-decoration: none; }
img { display: block; }

/* ── Cadre téléphone (sur grand écran) ── */
.app {
  height: 100dvh;
  display: flex;
  flex-direction: column;
  background: var(--white);
  overflow: hidden;
}
.screen {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  background: var(--white);
  animation: fade .18s ease-out;
}
.screen.tinted { background: var(--bg); }
@keyframes fade { from { opacity: 0; transform: translateY(4px); } to { opacity: 1; transform: none; } }

@media (min-width: 560px) {
  body { padding: 32px 0; min-height: 100dvh; }
  .app {
    width: var(--phone-w);
    margin: 0 auto;
    height: min(844px, calc(100dvh - 64px));
    border-radius: 28px;
    box-shadow: var(--shadow);
  }
  .statusbar { display: flex !important; }
}

/* ── Barre de statut factice (desktop seulement) ── */
.statusbar {
  display: none;
  height: 44px;
  align-items: center;
  justify-content: space-between;
  padding: 0 22px;
  font-size: 13px;
  font-weight: 600;
  color: var(--navy);
  flex: none;
}
.statusbar .signal { letter-spacing: .1em; }

/* ── Entêtes ── */
.topbar {
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 0 20px;
  border-bottom: 1px solid var(--line);
  background: var(--white);
  flex: none;
}
.topbar .left { display: flex; align-items: center; gap: 14px; min-width: 0; }
.topbar .title { font-size: 17px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar .logo { height: 26px; }
.topbar .action { font-size: 13px; color: var(--orange); font-weight: 500; flex: none; }
.back {
  width: 32px; height: 32px; margin-left: -6px;
  display: inline-flex; align-items: center; justify-content: center;
  border-radius: 8px; color: var(--navy); flex: none;
}
.back:active { background: var(--fill); }
.avatar {
  width: 38px; height: 38px; border-radius: 999px;
  background: var(--navy); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 600; flex: none;
}
.avatar.business { background: var(--blue-bg); color: var(--blue); }

/* ── Contenu ── */
.content {
  flex: 1;
  padding: 22px 20px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.content.centered { justify-content: center; padding: 0 28px 60px; gap: 32px; }
.h1 { font-size: 23px; font-weight: 600; line-height: 1.3; }
.h2 { font-size: 16px; font-weight: 600; }
.lead { font-size: 15px; color: var(--muted); line-height: 1.5; }
.section-label {
  font-size: 13px; font-weight: 600; letter-spacing: .06em;
  text-transform: uppercase; color: var(--muted);
}
.stack { display: flex; flex-direction: column; gap: 12px; }
.stack-sm { display: flex; flex-direction: column; gap: 8px; }
.row { display: flex; gap: 10px; }
.row > * { flex: 1; min-width: 0; }
.grow { margin-top: auto; }
.hint { font-size: 12px; color: var(--muted-2); line-height: 1.5; }
.note {
  padding: 12px 16px; background: var(--fill-2); border-radius: var(--radius);
  font-size: 13px; color: var(--text-2); line-height: 1.5;
}
.center { text-align: center; }
.small-muted { font-size: 13px; color: var(--muted); }

/* ── Formulaires ── */
.field { display: flex; flex-direction: column; gap: 7px; }
.field > span { font-size: 13px; font-weight: 500; color: var(--text-2); }
.input {
  width: 100%;
  height: 52px;
  padding: 0 16px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 16px;
  background: var(--white);
  outline: none;
  transition: border-color .15s;
}
.input::placeholder { color: var(--muted-2); }
.input:focus { border-color: var(--navy); }
.input.compact { height: 48px; padding: 0 14px; font-size: 15px; }
.input.error { border-color: var(--orange-dark); }
.input-wrap { position: relative; display: flex; align-items: center; }
.input-wrap .input { padding-right: 84px; }
.input-wrap .suffix {
  position: absolute; right: 16px;
  font-size: 13px; color: var(--orange); font-weight: 500;
}
.input-wrap .suffix-icon { position: absolute; right: 14px; color: var(--orange); display: inline-flex; }
textarea.input {
  min-height: 150px; padding: 14px 16px; resize: vertical; line-height: 1.55; font-size: 15px;
}
select.input {
  appearance: none; -webkit-appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' fill='none' stroke='%236B6F86' stroke-width='1.6'/%3E%3C/svg%3E");
  background-repeat: no-repeat; background-position: right 16px center; padding-right: 40px;
}
.error-msg { font-size: 13px; color: var(--orange-dark); }
.link-right { align-self: flex-end; font-size: 13px; color: var(--muted); }

.segmented { display: flex; gap: 10px; }
.segmented button {
  flex: 1; height: 48px; border-radius: var(--radius);
  border: 1.5px solid var(--border); color: var(--muted); font-size: 15px; font-weight: 500;
}
.segmented button.on {
  border-color: var(--orange); background: var(--orange-soft); color: var(--navy); font-weight: 600;
}

/* ── Boutons ── */
.btn {
  height: 54px; width: 100%;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border-radius: var(--radius); font-size: 16px; font-weight: 600;
  transition: transform .08s, opacity .15s;
}
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .5; cursor: default; }
.btn-primary { background: var(--orange); color: #fff; }
.btn-outline { border: 1.5px solid var(--navy); color: var(--navy); }
.btn-ghost { color: var(--orange-dark); height: 44px; font-size: 14px; }
.btn-dashed {
  height: 52px; border: 1.5px dashed #C9CCDA; border-radius: 12px;
  color: var(--navy); font-size: 15px; font-weight: 600;
}

/* ── Upload factice ── */
.uploads { display: flex; gap: 10px; flex-wrap: wrap; }
.upload-add {
  width: 82px; height: 82px; border-radius: var(--radius);
  border: 1.5px dashed #C9CCDA; color: var(--muted);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 4px;
  font-size: 11px;
}
.upload-add.lg { width: 100px; height: 100px; }
.upload-add svg { width: 20px; height: 20px; }
.thumb {
  width: 82px; height: 82px; border-radius: var(--radius); background: #E9EBF2;
  display: flex; align-items: center; justify-content: center; font-size: 11px; color: var(--muted-2);
  position: relative; overflow: hidden;
}
.thumb.sm { width: 70px; height: 70px; }
.thumb .rm {
  position: absolute; top: 4px; right: 4px; width: 20px; height: 20px; border-radius: 999px;
  background: rgba(38,34,81,.75); color: #fff; font-size: 12px; line-height: 20px; text-align: center;
}

/* ── Cartes ── */
.card {
  background: var(--white); border-radius: var(--radius-lg); border: 1px solid var(--border-2);
  padding: 16px 18px; display: flex; flex-direction: column; gap: 8px; text-align: left; width: 100%;
}
.card.accent { border-left: 3px solid var(--orange); }
.card.clickable:active { background: var(--fill-2); }
.card-row { display: flex; align-items: center; gap: 14px; }
.card-row .texts { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 3px; }
.card-row .name { font-size: 16px; font-weight: 600; }
.card-row .sub { font-size: 13px; color: var(--muted); }
.card-row .alert { font-size: 12px; color: var(--orange-dark); font-weight: 500; }
.chev { color: var(--orange); flex: none; display: inline-flex; }
.robot-photo {
  width: 48px; height: 48px; border-radius: var(--radius); background: var(--fill);
  display: flex; align-items: center; justify-content: center; font-size: 10px; color: var(--muted-2); flex: none;
  overflow: hidden;
}
.robot-photo.sm { width: 44px; height: 44px; border-radius: 8px; background: #E4E6EE; }
.robot-photo svg { width: 26px; height: 26px; color: var(--muted-2); }
.robot-hero {
  height: 150px; border-radius: var(--radius-lg); background: #E9EBF2;
  display: flex; align-items: center; justify-content: center; font-size: 13px; color: var(--muted-2);
}
.robot-hero svg { width: 56px; height: 56px; color: #B9BCCB; }
.robot-pill {
  display: flex; align-items: center; gap: 12px; padding: 12px 14px;
  background: var(--fill-2); border-radius: var(--radius);
}
.robot-pill .texts { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.robot-pill .name { font-size: 14px; font-weight: 600; }
.robot-pill .sub { font-size: 12px; color: var(--muted); }

.kv { background: var(--white); border-radius: var(--radius-lg); border: 1px solid var(--border-2); overflow: hidden; }
.kv > div {
  padding: 14px 18px; display: flex; justify-content: space-between; gap: 16px; font-size: 14px;
  border-bottom: 1px solid var(--line);
}
.kv > div:last-child { border-bottom: 0; }
.kv > div span:first-child { color: var(--muted); }
.kv > div span:last-child { font-weight: 500; text-align: right; }

.ticket-mini {
  background: var(--white); border-radius: 12px; border: 1px solid var(--border-2);
  padding: 14px 16px; display: flex; align-items: center; justify-content: space-between; gap: 12px;
  text-align: left; width: 100%;
}
.ticket-mini .t { font-size: 14px; font-weight: 500; }
.ticket-mini .d { font-size: 12px; color: var(--muted); }
.ticket-mini:active { background: var(--fill-2); }

.badge {
  display: inline-flex; align-items: center; padding: 3px 10px; border-radius: 999px;
  font-size: 12px; font-weight: 600; white-space: nowrap; flex: none;
}
.badge.open { background: var(--orange-soft); color: var(--orange-dark); }
.badge.closed { background: var(--fill); color: var(--muted); }
.badge.pending { background: #FFF9E8; color: #8A6D1F; }
.meta { font-size: 13px; color: var(--muted); }
.ticket-title { font-size: 15px; font-weight: 500; line-height: 1.45; }
.ticket-head { display: flex; align-items: center; gap: 10px; }

/* ── Filtres ── */
.chips { display: flex; gap: 8px; padding: 14px 20px; background: var(--white); flex: none; }
.chips button {
  padding: 7px 14px; border-radius: 999px; border: 1px solid var(--border);
  color: var(--text-2); font-size: 13px; font-weight: 500;
}
.chips button.on { background: var(--navy); border-color: var(--navy); color: #fff; }

/* ── Navigation basse ── */
.tabbar {
  height: 76px; background: var(--white); border-top: 1px solid var(--border-2);
  display: flex; align-items: center; padding: 0 24px 12px; flex: none;
  padding-bottom: max(12px, env(safe-area-inset-bottom));
}
.tabbar button {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: 5px; padding-top: 12px;
  color: var(--muted-2); font-size: 11px; font-weight: 500; position: relative;
}
.tabbar button svg { width: 22px; height: 22px; }
.tabbar button.on { color: var(--orange); font-weight: 600; }
.tabbar .dot {
  position: absolute; top: 8px; right: calc(50% - 18px);
  min-width: 16px; height: 16px; padding: 0 4px; border-radius: 999px;
  background: var(--orange); color: #fff; font-size: 10px; font-weight: 600; line-height: 16px; text-align: center;
}

/* ── Conversation ── */
.chat-head {
  padding: 12px 20px 14px; border-bottom: 1px solid var(--line); background: var(--white);
  display: flex; gap: 10px; align-items: flex-start; flex: none;
}
.chat-head .texts { display: flex; flex-direction: column; gap: 5px; min-width: 0; }
.chat-head .t { font-size: 16px; font-weight: 600; }
.chat-head .sub { display: flex; align-items: center; gap: 8px; font-size: 12px; color: var(--muted); }
.messages {
  flex: 1; padding: 18px 20px; display: flex; flex-direction: column; gap: 12px; overflow-y: auto;
}
.day { align-self: center; font-size: 12px; color: var(--muted-2); padding: 4px 0; }
.msg { max-width: 84%; display: flex; flex-direction: column; gap: 6px; }
.msg.client { align-self: flex-end; align-items: flex-end; }
.msg.auto, .msg.tech { align-self: flex-start; align-items: flex-start; }
.bubble { padding: 12px 14px; font-size: 14px; line-height: 1.5; white-space: pre-wrap; word-break: break-word; }
.msg.client .bubble { background: var(--navy); color: #fff; border-radius: 14px 14px 4px 14px; }
.msg.auto .bubble { background: var(--fill); color: var(--text-2); border-radius: 14px 14px 14px 4px; }
.msg.tech .bubble { background: var(--white); border: 1px solid var(--border-2); color: var(--text); border-radius: 14px 14px 14px 4px; }
.msg.system { align-self: center; max-width: 80%; }
.msg.system .bubble {
  background: var(--fill); color: var(--muted); border-radius: 10px; font-size: 12px; text-align: center; padding: 10px 14px;
}
.msg .stamp { font-size: 11px; color: var(--muted-2); }
.msg .attachments { display: flex; gap: 8px; }
.typing .bubble { display: flex; gap: 4px; align-items: center; padding: 14px 16px; }
.typing i { width: 6px; height: 6px; border-radius: 999px; background: var(--muted-2); animation: blink 1.2s infinite; }
.typing i:nth-child(2) { animation-delay: .2s; }
.typing i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }

.composer {
  background: var(--white); border-top: 1px solid var(--border-2);
  padding: 14px 16px; padding-bottom: max(22px, env(safe-area-inset-bottom));
  display: flex; align-items: flex-end; gap: 10px; flex: none;
}
.composer .attach {
  width: 44px; height: 44px; border-radius: var(--radius); background: var(--fill);
  display: inline-flex; align-items: center; justify-content: center; color: var(--muted); flex: none;
}
.composer textarea {
  flex: 1; min-height: 44px; max-height: 120px; padding: 10px 14px;
  border: 1.5px solid var(--border); border-radius: 22px; font-size: 14px; resize: none; outline: none;
  line-height: 1.5;
}
.composer textarea:focus { border-color: var(--navy); }
.composer .send {
  width: 44px; height: 44px; border-radius: 999px; background: var(--orange); color: #fff;
  display: inline-flex; align-items: center; justify-content: center; flex: none;
}
.composer .send:disabled { background: #F2B4A1; }
.composer-attachments { display: flex; gap: 8px; padding: 10px 16px 0; background: var(--white); border-top: 1px solid var(--border-2); }
.composer-attachments + .composer { border-top: 0; padding-top: 10px; }
.closed-banner {
  background: var(--white); border-top: 1px solid var(--border-2);
  padding: 16px 20px; padding-bottom: max(22px, env(safe-area-inset-bottom));
  display: flex; flex-direction: column; gap: 10px; align-items: center; text-align: center; flex: none;
}
.closed-banner p { margin: 0; font-size: 13px; color: var(--muted); }

/* ── Compte ── */
.profile { display: flex; align-items: center; gap: 14px; }
.profile .avatar { width: 56px; height: 56px; font-size: 20px; }
.profile .name { font-size: 18px; font-weight: 600; }
.profile .email { font-size: 13px; color: var(--muted); }
.list-item {
  display: flex; align-items: center; justify-content: space-between; gap: 12px;
  padding: 14px 18px; font-size: 14px; width: 100%; text-align: left;
  border-bottom: 1px solid var(--line); background: var(--white);
}
.list-item:last-child { border-bottom: 0; }
.list-item .l { display: flex; flex-direction: column; gap: 2px; min-width: 0; }
.list-item .s { font-size: 12px; color: var(--muted); }
.list-group { border: 1px solid var(--border-2); border-radius: var(--radius-lg); overflow: hidden; background: var(--white); }

/* ── Vide ── */
.empty { padding: 40px 20px; text-align: center; color: var(--muted); font-size: 14px; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.empty svg { width: 36px; height: 36px; color: #C9CCDA; }

/* ── Toast ── */
.toast {
  position: fixed; left: 50%; bottom: 96px; transform: translateX(-50%) translateY(16px);
  background: var(--navy); color: #fff; padding: 12px 18px; border-radius: 12px;
  font-size: 13px; font-weight: 500; max-width: min(340px, calc(100vw - 32px));
  box-shadow: 0 10px 30px rgba(38,34,81,.25); opacity: 0; pointer-events: none;
  transition: opacity .2s, transform .2s; z-index: 50; text-align: center;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ── Démo ── */
.demo-box {
  border: 1px dashed #C9CCDA; border-radius: var(--radius); padding: 12px 14px;
  display: flex; flex-direction: column; gap: 8px; font-size: 12px; color: var(--muted);
}
.demo-box .t { font-weight: 600; color: var(--text-2); letter-spacing: .04em; text-transform: uppercase; font-size: 11px; }
.demo-box button {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 10px; border-radius: 8px; background: var(--fill-2); text-align: left; width: 100%;
  font-size: 12px; color: var(--text-2);
}
.demo-box button b { font-weight: 600; color: var(--navy); }
.demo-box button:active { background: var(--fill); }
.danger { color: var(--orange-dark); }
