/* ═══════════════════════════════════════════════════════════
   COINMALIN — discussions.css (chat client ↔ commerçant)
   Deux panneaux type WhatsApp : liste à gauche, fil à droite.
   Mobile : un seul panneau (body.chat-open bascule sur le fil).
═══════════════════════════════════════════════════════════ */
:root {
  --dc-green: #214437;
  --dc-green-soft: #DCEDE3;
  --dc-bg: #EDE9DB;
  --dc-bd: rgba(21, 98, 64, .12);
  --dc-t1: #091C10;
  --dc-t3: #607A6A;
  --dc-t4: #9BB5A8;
}

.dc-shell {
  display: grid;
  grid-template-columns: 340px 1fr;
  height: calc(100dvh - var(--dc-top, 58px));
  max-width: 1180px;
  margin: 0 auto;
  background: #fff;
  border: 1px solid var(--dc-bd);
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(9,28,16,.05);
}

/* ── Panneau gauche : conversations ── */
.dc-side {
  display: flex; flex-direction: column;
  border-right: 1px solid var(--dc-bd);
  min-width: 0;
}
.dc-side__head {
  padding: 16px 16px 10px;
  border-bottom: 1px solid var(--dc-bd);
}
.dc-side__head h1 {
  font-family: 'DM Serif Display', Georgia, serif;
  font-size: 1.25rem; color: var(--dc-t1);
  margin: 0 0 10px;
}
.dc-search {
  display: flex; align-items: center; gap: 8px;
  padding: 8px 12px;
  background: var(--dc-bg);
  border: 1px solid transparent;
  border-radius: 50px; color: var(--dc-t4);
  transition: border-color .18s;
}
.dc-search:focus-within { border-color: var(--dc-bd); }
.dc-search input {
  flex: 1; border: none; outline: none; background: transparent;
  font-size: 13px; color: var(--dc-t1); font-family: inherit; min-width: 0;
}

.dc-convs { flex: 1; overflow-y: auto; padding: 6px; }
.dc-conv {
  display: flex; align-items: center; gap: 11px; width: 100%;
  padding: 11px 12px; border-radius: 12px; text-align: left;
  background: none; border: none; cursor: pointer; font-family: inherit;
  transition: background .15s;
}
.dc-conv:hover { background: #F4F7F5; }
.dc-conv--active { background: var(--dc-green-soft); }
.dc-conv__avatar {
  width: 42px; height: 42px; border-radius: 50%; flex-shrink: 0;
  background: var(--dc-green); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; font-weight: 800;
}
.dc-conv__body { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 1px; }
.dc-conv__top { display: flex; align-items: baseline; justify-content: space-between; gap: 8px; }
.dc-conv__top strong {
  font-size: 13.5px; color: var(--dc-t1);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dc-conv__top time { font-size: 10.5px; color: var(--dc-t4); flex-shrink: 0; }
.dc-conv__sub { font-size: 10.5px; color: var(--dc-t4); }
.dc-conv__preview {
  font-size: 12px; color: var(--dc-t3);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dc-conv__badge {
  min-width: 19px; height: 19px; padding: 0 5px; flex-shrink: 0;
  background: #156240; color: #fff; border-radius: 50px;
  font-size: 10.5px; font-weight: 800;
  display: flex; align-items: center; justify-content: center;
}
.dc-empty { padding: 30px 22px; text-align: center; font-size: 13px; color: var(--dc-t3); line-height: 1.7; }
.dc-empty strong { color: var(--dc-t1); }

/* ── Panneau droit : fil ── */
.dc-main { display: flex; flex-direction: column; min-width: 0; background: #F7F5EC; }
.dc-main__placeholder {
  flex: 1; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 10px;
  color: var(--dc-t4); font-size: 13.5px; text-align: center; padding: 24px;
}
.dc-thread { flex: 1; display: flex; flex-direction: column; min-height: 0; }
.dc-thread.hidden { display: none; }

.dc-chat-head {
  display: flex; align-items: center; gap: 11px;
  padding: 11px 16px; background: #fff;
  border-bottom: 1px solid var(--dc-bd);
}
.dc-chat-head__back {
  display: none;
  width: 34px; height: 34px; border-radius: 50%;
  border: none; background: none; color: var(--dc-t3);
  align-items: center; justify-content: center; cursor: pointer;
}
.dc-chat-head__avatar {
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--dc-green); color: #fff;
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 800; flex-shrink: 0;
}
.dc-chat-head__id { flex: 1; min-width: 0; }
.dc-chat-head__id strong {
  display: block; font-size: 14px; color: var(--dc-t1);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.dc-chat-head__id span { font-size: 11px; color: var(--dc-t4); }
.dc-chat-head__fiche {
  font-size: 11.5px; font-weight: 700; color: #156240;
  text-decoration: none; padding: 6px 12px;
  border: 1.5px solid rgba(21,98,64,.25); border-radius: 50px;
  white-space: nowrap;
}

.dc-msgs { flex: 1; overflow-y: auto; padding: 16px 18px 8px; }
.dc-day { text-align: center; margin: 10px 0; }
.dc-day span {
  font-size: 10.5px; font-weight: 700; color: var(--dc-t4);
  background: #fff; border: 1px solid var(--dc-bd);
  padding: 3px 12px; border-radius: 50px;
}
.dc-msg { display: flex; margin-bottom: 6px; }
.dc-msg--mine { justify-content: flex-end; }
.dc-bubble {
  max-width: min(78%, 480px);
  background: #fff; color: var(--dc-t1);
  padding: 8px 12px 6px; border-radius: 14px 14px 14px 4px;
  font-size: 13.5px; line-height: 1.5;
  box-shadow: 0 1px 1px rgba(9,28,16,.06);
  word-break: break-word; white-space: pre-wrap;
}
.dc-msg--mine .dc-bubble {
  background: var(--dc-green-soft);
  border-radius: 14px 14px 4px 14px;
}
.dc-bubble time {
  display: flex; align-items: center; justify-content: flex-end; gap: 3px;
  font-size: 9.5px; color: var(--dc-t4); margin-top: 3px;
  white-space: nowrap;
}

/* Accusé de réception : ✓ gris = envoyé, ✓✓ vertes = lu (heure au survol) */
.dc-ticks {
  display: inline-flex; align-items: center;
  color: var(--dc-t4); cursor: default;
}
.dc-ticks--lu { color: #156240; }

/* Carte structurée Commande / Réservation */
.dc-bubble--card { border: 1.5px solid rgba(21,98,64,.25); min-width: 190px; }
.dc-card__head {
  display: flex; align-items: center; gap: 6px;
  font-size: 10.5px; font-weight: 800; letter-spacing: .06em;
  text-transform: uppercase; color: #156240; margin-bottom: 4px;
}
.dc-card__item { font-size: 14px; font-weight: 700; color: var(--dc-t1); }
.dc-card__prix { font-size: 13px; font-weight: 800; color: #156240; margin-top: 1px; }
.dc-card__note { font-size: 12.5px; color: var(--dc-t3); margin-top: 4px; }

/* ── Zone de saisie ── */
.dc-input {
  display: flex; align-items: flex-end; gap: 9px;
  padding: 10px 14px calc(10px + env(safe-area-inset-bottom, 0));
  background: #fff; border-top: 1px solid var(--dc-bd);
}
.dc-input textarea {
  flex: 1; resize: none; border: 1.5px solid var(--dc-bd);
  border-radius: 22px; padding: 10px 15px;
  font-family: inherit; font-size: 13.5px; color: var(--dc-t1);
  max-height: 110px; min-height: 42px; outline: none;
  transition: border-color .18s; background: #FBFAF6;
}
.dc-input textarea:focus { border-color: #156240; }
.dc-input button {
  width: 42px; height: 42px; border-radius: 50%; flex-shrink: 0;
  background: #156240; color: #fff; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .18s, transform .12s;
}
.dc-input button:hover { background: #0D3D2B; }
.dc-input button:active { transform: scale(.92); }

/* Bouton pièce jointe (photo) */
.dc-attach {
  width: 42px; height: 42px; border-radius: 50%; flex-shrink: 0;
  background: none; border: 1.5px solid var(--dc-bd); color: var(--dc-t3);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  transition: background .18s, color .18s;
}
.dc-attach:hover:not(:disabled) { background: var(--dc-green-soft); color: #156240; }
.dc-attach:disabled { opacity: .5; cursor: default; }

/* Bulle photo */
.dc-bubble--img { padding: 5px; max-width: min(70%, 320px); }
.dc-bubble--img a { display: block; }
.dc-bubble--img img {
  display: block; width: 100%; max-height: 320px;
  object-fit: cover; border-radius: 11px;
}
.dc-img-legende { font-size: 12.5px; color: var(--dc-t1); padding: 6px 7px 2px; }
.dc-bubble--img time { padding: 2px 7px 3px; }

/* Envoi en cours : aperçu local + spinner */
.dc-bubble--uploading { position: relative; opacity: .75; }
.dc-img-spinner {
  position: absolute; inset: 0; margin: auto;
  width: 26px; height: 26px; border-radius: 50%;
  border: 3px solid rgba(255,255,255,.5); border-top-color: #156240;
  animation: dc-spin .7s linear infinite;
}
@keyframes dc-spin { to { transform: rotate(360deg) } }

/* ── Bandeau nouvelle discussion / blocage ── */
.dc-guard {
  padding: 14px 16px calc(14px + env(safe-area-inset-bottom, 0));
  background: #fff; border-top: 1px solid var(--dc-bd);
  font-size: 13px; color: var(--dc-t3); text-align: center;
}
.dc-guard p { margin: 0 0 10px; line-height: 1.5; }
.dc-guard strong { color: var(--dc-t1); }
.dc-guard__btns { display: flex; gap: 8px; justify-content: center; flex-wrap: wrap; }
.dc-guard__btns button {
  padding: 8px 16px; border-radius: 50px; cursor: pointer;
  font-family: inherit; font-size: 12.5px; font-weight: 700;
  background: #fff; color: var(--dc-t3); border: 1.5px solid var(--dc-bd);
  transition: all .15s;
}
.dc-guard__btns button:hover { border-color: var(--dc-t3); }
.dc-guard__btns button.ok { background: #156240; border-color: #156240; color: #fff; }
.dc-guard__btns button.ok:hover { background: #0D3D2B; }
.dc-guard__btns button.danger { color: #DC2626; border-color: rgba(220,38,38,.35); }
.dc-guard__btns button.danger:hover { background: #DC2626; border-color: #DC2626; color: #fff; }

/* ── Menu ⋮ de l'en-tête ── */
.dc-chat-head { position: relative; }
.dc-head-menu-btn {
  width: 34px; height: 34px; border-radius: 50%; flex-shrink: 0;
  border: none; background: none; color: var(--dc-t3); cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.dc-head-menu-btn:hover { background: var(--dc-bg); }
.dc-head-menu {
  position: absolute; top: calc(100% - 6px); right: 12px; z-index: 50;
  background: #fff; border: 1px solid var(--dc-bd); border-radius: 12px;
  box-shadow: 0 8px 30px rgba(9,28,16,.16); padding: 5px; min-width: 190px;
}
.dc-head-menu button {
  display: block; width: 100%; text-align: left;
  padding: 9px 12px; border-radius: 8px; border: none; background: none;
  font-family: inherit; font-size: 13px; font-weight: 600; color: var(--dc-t1);
  cursor: pointer;
}
.dc-head-menu button:hover { background: var(--dc-bg); }
.dc-head-menu button.danger { color: #DC2626; }

/* ── Mobile : un panneau à la fois ── */
@media (max-width: 860px) {
  .dc-shell { grid-template-columns: 1fr; border-radius: 0; border: none; height: calc(100dvh - var(--dc-top, 58px)); }
  .dc-main { display: none; }
  body.chat-open .dc-main { display: flex; }
  body.chat-open .dc-side { display: none; }
  .dc-chat-head__back { display: flex; }
}
