/* Widget chat (auto-hébergé) — couleurs alignées sur la palette du site (terracotta / nude / pêche). */
.ds-chat-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 99999;
  font-family: var(--font, 'DM Sans', 'Inter', system-ui, -apple-system, sans-serif);
}

/* Bouton circulaire : uniquement l'icône. */
.ds-chat-button {
  list-style: none;
  position: relative;
  width: 60px;
  height: 60px;
  padding: 0;
  border-radius: 50%;
  background: linear-gradient(160deg, #b06553, #94493b);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 24px rgba(176, 101, 83, .45);
  cursor: pointer;
  transition: transform .2s ease, box-shadow .2s ease;
}
.ds-chat-button svg { width: 28px; height: 28px; flex: 0 0 auto; }
.ds-chat-button:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 12px 28px rgba(148, 73, 59, .55); }
.ds-chat-button::-webkit-details-marker { display: none; }

/* Badge « nouveau message » (parité maquette Node : compteur visible widget fermé). */
.ds-chat-button__badge {
  position: absolute;
  top: -2px;
  right: -2px;
  min-width: 20px;
  height: 20px;
  padding: 0 5px;
  border-radius: 999px;
  background: #94493b;
  color: #fff;
  font-size: .72rem;
  font-weight: 700;
  line-height: 20px;
  text-align: center;
  box-shadow: 0 0 0 2px #fbf7f2;
}
.ds-chat-button__badge[hidden] { display: none !important; }

/* Panneau : masqué par défaut, visible quand le <details> est ouvert. */
.ds-chat-panel {
  position: absolute;
  bottom: 72px;
  right: 0;
  width: min(400px, calc(100vw - 32px));
  background: #fbf7f2;
  background-image:
    radial-gradient(circle at 25% 15%, rgba(176,101,83,.14) 0 1.5px, transparent 2px),
    radial-gradient(circle at 70% 60%, rgba(176,101,83,.11) 0 1.5px, transparent 2px);
  background-size: 40px 40px;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(26, 26, 26, .3);
  display: none;
  flex-direction: column;
  overflow: hidden;
}
.ds-chat-widget[open] .ds-chat-panel { display: flex; }

/* En-tête : terracotta, couleur primaire du site. */
.ds-chat-head {
  background: linear-gradient(160deg, #b06553, #94493b);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
}
.ds-chat-head__avatar {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: #f4e4d9;
  color: #7c3a2e;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex: 0 0 auto;
}
.ds-chat-head__info { min-width: 0; }
.ds-chat-head__info strong { display: block; font-size: 1rem; line-height: 1.2; }
.ds-chat-head__status { font-size: .76rem; opacity: .94; display: flex; align-items: center; gap: 5px; margin-top: 2px; }
.ds-chat-head__status i {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #f4e4d9;
  box-shadow: 0 0 6px #f4e4d9;
  animation: ds-blink 1.6s infinite;
}
@keyframes ds-blink { 0%,100% { opacity: 1; } 50% { opacity: .4; } }

/* Barre des contacts groupés par catégorie (Équipe VAULTIKA / Les vendeurs). */
.ds-chat-contacts {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 8px 0 4px;
  background: #fbf7f2;
  max-height: 168px;
  overflow-y: auto;
  scrollbar-width: thin;
}
.ds-chat-contacts::-webkit-scrollbar { height: 6px; width: 6px; }
.ds-chat-contacts::-webkit-scrollbar-thumb { background: #e5d4c6; border-radius: 6px; }
.ds-chat-contacts__group { display: flex; flex-direction: column; }
.ds-chat-contacts__label {
  font-size: .64rem;
  text-transform: uppercase;
  letter-spacing: .08em;
  font-weight: 700;
  color: #8d8577;
  padding: 2px 14px 4px;
}
.ds-chat-contacts__chips { display: flex; gap: 6px; overflow-x: auto; padding: 0 12px 8px; scrollbar-width: thin; }
.ds-chat-contacts__chips::-webkit-scrollbar { height: 4px; }
.ds-chat-contacts__chips::-webkit-scrollbar-thumb { background: #e5d4c6; border-radius: 6px; }
.ds-chat-contact {
  flex: 0 0 auto;
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  gap: 2px;
  max-width: 190px;
  padding: 8px 12px;
  border-radius: 12px;
  border: 1px solid #e5d4c6;
  background: #fff;
  color: #2c2c2c;
  font: inherit;
  font-size: .82rem;
  font-weight: 700;
  cursor: pointer;
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
}
.ds-chat-contact:hover { border-color: #b06553; background: #f6ece5; }
.ds-chat-contact.is-active {
  border-color: #94493b;
  background: #f4e4d9;
  box-shadow: 0 0 0 1px #94493b;
}
.ds-chat-contact__pin {
  font-weight: 500;
  font-size: .7rem;
  color: #b0613f;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 100%;
}
.ds-chat-contact__badge {
  position: absolute;
  top: 5px;
  right: 6px;
  min-width: 17px;
  height: 17px;
  padding: 0 4px;
  border-radius: 999px;
  background: #b06553;
  color: #fff;
  font-size: .66rem;
  font-weight: 700;
  line-height: 17px;
  text-align: center;
}

/* Zone des messages — HAUTEUR AGRANDIE. */
.ds-chat-body {
  max-height: 520px;
  min-height: 300px;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  flex: 1;
}
.ds-chat-body::-webkit-scrollbar { width: 6px; }
.ds-chat-body::-webkit-scrollbar-thumb { background: rgba(0,0,0,.18); border-radius: 6px; }
.ds-chat-empty { text-align: center; color: #8d8577; font-size: .85rem; padding: 40px 12px; margin: auto; }

/* Bulles — palette du site : les entrées à gauche (blanc, bordure pêche), les sorties à droite (pêche). */
.ds-chat-msg { max-width: 86%; display: flex; flex-direction: column; }
.ds-chat-msg--staff.is-in { align-self: flex-start; align-items: flex-start; }
.ds-chat-msg--client.is-out { align-self: flex-end; align-items: flex-end; }
.ds-chat-msg__sender { font-size: .72rem; font-weight: 700; color: #b06553; margin-bottom: 2px; padding-left: 6px; }

.ds-chat-msg__bubble {
  position: relative;
  padding: 7px 10px 5px 12px;
  border-radius: 12px;
  font-size: .9rem;
  line-height: 1.45;
  word-break: break-word;
  white-space: normal;
  box-shadow: 0 1px 1px rgba(10,10,10,.1);
  min-width: 44px;
}
/* Sortants (moi) : pêche (#f4e4d9), couleur accent du site. */
.ds-chat-msg--client.is-out .ds-chat-msg__bubble {
  background: #f4e4d9;
  color: #1a1a1a;
  border-bottom-right-radius: 4px;
}
/* Entrants (équipe/vendeur) : blanc, bord pêche-clair. */
.ds-chat-msg--staff.is-in .ds-chat-msg__bubble {
  background: #fff;
  color: #1a1a1a;
  border: 1px solid #eadccd;
  border-bottom-left-radius: 4px;
}
.ds-chat-msg__text { white-space: pre-wrap; }

/* Photo jointe. */
.ds-chat-msg__image {
  display: block;
  margin-bottom: 4px;
  border-radius: 8px;
  overflow: hidden;
  max-width: 240px;
}
.ds-chat-msg__image img {
  width: 100%;
  height: auto;
  display: block;
  border-radius: 8px;
}

/* Heure + coches, dans le coin bas droit de la bulle. */
.ds-chat-msg__meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  font-size: .64rem;
  color: #8d8577;
  margin-top: 1px;
  margin-left: 10px;
  float: right;
  padding-top: 1px;
}
.ds-chat-msg__ticks { color: #b06553; font-size: .68rem; }

/* ================================================================
   Inbox vendeur (page mes-messages) — fil aux couleurs du site.
   ================================================================ */
.ds-chat-thread {
  display: flex;
  flex-direction: column;
  gap: 4px;
  background-color: #fbf7f2;
  background-image: radial-gradient(rgba(176,101,83,.12) 0 1.5px, transparent 2px);
  background-size: 18px 18px;
  border: 1px solid #eadccd;
  border-radius: 14px;
  padding: 14px 12px;
  max-height: 440px;
  overflow-y: auto;
}
.ds-chat-thread::-webkit-scrollbar { width: 6px; }
.ds-chat-thread::-webkit-scrollbar-thumb { background: rgba(0,0,0,.18); border-radius: 6px; }

.ds-chat-bubble { max-width: 82%; display: flex; flex-direction: column; }
.ds-chat-bubble.is-in { align-self: flex-start; align-items: flex-start; }
.ds-chat-bubble.is-out { align-self: flex-end; align-items: flex-end; }
.ds-chat-bubble__sender { font-size: .7rem; font-weight: 700; color: #b06553; margin-bottom: 1px; padding-left: 6px; }
.ds-chat-bubble__bubble {
  position: relative;
  padding: 7px 10px 5px 12px;
  border-radius: 12px;
  font-size: .9rem;
  line-height: 1.45;
  word-break: break-word;
  white-space: normal;
  box-shadow: 0 1px 1px rgba(10,10,10,.1);
  min-width: 44px;
}
.ds-chat-bubble.is-in .ds-chat-bubble__bubble {
  background: #fff;
  color: #1a1a1a;
  border: 1px solid #eadccd;
  border-bottom-left-radius: 4px;
}
.ds-chat-bubble.is-out .ds-chat-bubble__bubble {
  background: #f4e4d9;
  color: #1a1a1a;
  border-bottom-right-radius: 4px;
}
.ds-chat-bubble__body { white-space: pre-wrap; }
.ds-chat-bubble__image { margin-bottom: 4px; border-radius: 8px; overflow: hidden; max-width: 240px; }
.ds-chat-bubble__image img { width: 100%; height: auto; display: block; border-radius: 8px; }
.ds-chat-bubble__meta {
  display: flex;
  align-items: center;
  justify-content: flex-end;
  gap: 4px;
  font-size: .64rem;
  color: #8d8577;
  margin-top: 1px;
  margin-left: 10px;
  float: right;
  padding-top: 1px;
}
.ds-chat-bubble__ticks { color: #b06553; font-size: .68rem; }
.ds-chat-thread__end { height: 1px; }

/* Notes. */
.ds-chat-note {
  margin: 0;
  padding: 8px 14px;
  font-size: .8rem;
  background: #f4e4d9;
  color: #7c3a2e;
  border-top: 1px solid #e9c9ba;
}
.ds-chat-note--error { background: #f9e8e4; color: #a14337; border-top-color: #f0d0c7; }

/* Formulaire de saisie. */
.ds-chat-form {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 10px 12px;
  background: #fbf7f2;
  flex-wrap: wrap;
}
.ds-chat-form input[type="text"] {
  padding: 12px 14px;
  border: none;
  border-radius: 10px;
  font-size: .9rem;
  outline: none;
  background: #fff;
  box-shadow: inset 0 0 0 1px #e5d4c6;
}
.ds-chat-form input[type="text"]:focus { box-shadow: inset 0 0 0 2px #b06553; }
.ds-chat-form__row { display: flex; gap: 8px; align-items: center; }
.ds-chat-form__row input[name="ds_chat_message"] { flex: 1 1 auto; min-width: 0; }

/* Bouton joindre une photo. */
.ds-chat-form__attach {
  flex: 0 0 44px;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #fff;
  color: #b06553;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: inset 0 0 0 1px #e5d4c6;
  transition: background .15s ease, color .15s ease;
}
.ds-chat-form__attach:hover { background: #f4e4d9; color: #7c3a2e; }

/* Bouton envoi : terracotta, couleur principale du site. */
.ds-chat-form__row button {
  flex: 0 0 46px;
  width: 46px;
  height: 46px;
  border: none;
  border-radius: 50%;
  background: #b06553;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background .2s ease, transform .1s ease;
}
.ds-chat-form__row button:hover { background: #94493b; }
.ds-chat-form__row button:active { transform: scale(.94); }
.ds-chat-form__row button:disabled { opacity: .6; cursor: default; }

/* Aperçu de l'image à joindre. */
.ds-chat-form__preview {
  display: block;
  position: relative;
  width: 64px;
  height: 64px;
  border-radius: 10px;
  overflow: hidden;
  border: 1px solid #d9c9ae;
}
.ds-chat-form__preview img { width: 100%; height: 100%; object-fit: cover; display: block; }

@media (max-width: 480px) {
  .ds-chat-widget { bottom: 16px; right: 16px; }
  .ds-chat-panel { bottom: 66px; width: calc(100vw - 32px); }
}
