/* ============================================================
   Design tokens
   ============================================================ */
:root {
  --ink: #16202a;
  --ink-soft: #24323f;
  --slate: #5b6b78;
  --fog: #eef1f3;
  --paper: #ffffff;
  --gold: #c89b3c;
  --gold-soft: #e8d19c;
  --signal: #2f8f82;
  --signal-off: #b6465a;
  --radius-lg: 18px;
  --radius-md: 12px;
  --font-display: "Fraunces", serif;
  --font-body: "Inter", -apple-system, BlinkMacSystemFont, sans-serif;
  --font-mono: "JetBrains Mono", "SFMono-Regular", monospace;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--fog);
  background-image:
    radial-gradient(circle at 15% 20%, rgba(200,155,60,0.08), transparent 45%),
    radial-gradient(circle at 85% 80%, rgba(47,143,130,0.08), transparent 45%);
  font-family: var(--font-body);
  color: var(--ink);
  padding: 24px;
}

/* ============================================================
   Widget shell
   ============================================================ */
.widget {
  width: 420px;
  max-width: 100%;
  background: var(--paper);
  border-radius: var(--radius-lg);
  box-shadow: 0 24px 48px -16px rgba(22, 32, 42, 0.28), 0 2px 8px rgba(22, 32, 42, 0.06);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  position: relative;
}

/* ---------- Header ---------- */
.widget__header {
  background: var(--ink);
  color: var(--paper);
  padding: 18px 20px 22px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
}

.brand {
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.brand__dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  margin-top: 6px;
  background: var(--slate);
  box-shadow: 0 0 0 0 rgba(47, 143, 130, 0.6);
  flex-shrink: 0;
  transition: background 0.25s ease;
}

.brand__dot.is-online {
  background: var(--signal);
  animation: pulse 2.4s infinite;
}

.brand__dot.is-offline {
  background: var(--signal-off);
}

@keyframes pulse {
  0%   { box-shadow: 0 0 0 0 rgba(47, 143, 130, 0.55); }
  70%  { box-shadow: 0 0 0 8px rgba(47, 143, 130, 0); }
  100% { box-shadow: 0 0 0 0 rgba(47, 143, 130, 0); }
}

.brand__text h1 {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 19px;
  margin: 0 0 2px;
  letter-spacing: 0.2px;
}

.brand__text p {
  margin: 0;
  font-size: 12.5px;
  color: rgba(255, 255, 255, 0.6);
}

.ticket {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 2px;
  padding: 6px 10px;
  border: 1px dashed rgba(200, 155, 60, 0.55);
  border-radius: 8px;
  flex-shrink: 0;
}

.ticket__label {
  font-size: 9px;
  letter-spacing: 1.2px;
  text-transform: uppercase;
  color: var(--gold-soft);
}

.ticket__id {
  font-family: var(--font-mono);
  font-size: 12px;
  color: var(--paper);
  letter-spacing: 0.5px;
}

/* ---------- Perforation divider (torn ticket-stub effect) ---------- */
.widget__perforation {
  position: relative;
  height: 0;
  border-top: 2px dashed rgba(200, 155, 60, 0.4);
  margin: 0 18px;
}

.widget__perforation::before,
.widget__perforation::after {
  content: "";
  position: absolute;
  top: -9px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--fog);
}

.widget__perforation::before { left: -27px; }
.widget__perforation::after  { right: -27px; }

/* ============================================================
   Thread / messages
   ============================================================ */
.thread {
  flex: 1;
  min-height: 360px;
  max-height: 420px;
  overflow-y: auto;
  padding: 22px 18px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: var(--paper);
}

.thread::-webkit-scrollbar { width: 6px; }
.thread::-webkit-scrollbar-thumb { background: #e0e4e8; border-radius: 10px; }

.thread__empty {
  margin: auto 0;
  text-align: center;
  color: var(--slate);
  font-size: 13.5px;
  line-height: 1.5;
}

.thread__empty i {
  display: block;
  font-size: 22px;
  margin-bottom: 8px;
  color: var(--gold);
}

.row {
  display: flex;
  flex-direction: column;
  max-width: 82%;
  margin: 6px 0;
  animation: rise 0.22s ease;
}

@keyframes rise {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.row--user { align-self: flex-end; align-items: flex-end; }
.row--support { align-self: flex-start; align-items: flex-start; }

.bubble {
  padding: 10px 14px;
  border-radius: var(--radius-md);
  font-size: 14px;
  line-height: 1.45;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.row--user .bubble {
  background: var(--ink);
  color: var(--paper);
  border-bottom-right-radius: 4px;
}

.row--support .bubble {
  background: var(--fog);
  color: var(--ink);
  border-bottom-left-radius: 4px;
}

.system-note {
  align-self: center;
  font-size: 11.5px;
  color: var(--slate);
  background: var(--fog);
  padding: 5px 12px;
  border-radius: 999px;
  margin: 10px 0;
  text-align: center;
}

.row__meta {
  font-size: 10.5px;
  color: var(--slate);
  margin: 4px 6px 0;
  font-family: var(--font-mono);
}

/* ============================================================
   Composer
   ============================================================ */
.composer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 14px 16px;
  border-top: 1px solid var(--fog);
  background: var(--paper);
}

#message-input {
  flex: 1;
  border: 1.5px solid var(--fog);
  background: var(--fog);
  border-radius: 999px;
  padding: 11px 16px;
  font-family: var(--font-body);
  font-size: 14px;
  color: var(--ink);
  outline: none;
  transition: border-color 0.2s ease, background 0.2s ease;
}

#message-input:focus {
  border-color: var(--gold);
  background: var(--paper);
}

#message-input:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

#send-button {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  border: none;
  background: var(--ink);
  color: var(--paper);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.2s ease, transform 0.15s ease;
  font-size: 14px;
}

#send-button:hover { background: var(--ink-soft); }
#send-button:active { transform: scale(0.92); }
#send-button:disabled { opacity: 0.5; cursor: not-allowed; }

#send-button:focus-visible,
#message-input:focus-visible {
  outline: 2px solid var(--gold);
  outline-offset: 2px;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 480px) {
  body { padding: 0; }

  .widget {
    width: 100%;
    height: 100vh;
    border-radius: 0;
    box-shadow: none;
  }

  .thread { max-height: none; }
}

@media (prefers-reduced-motion: reduce) {
  .brand__dot.is-online { animation: none; }
  .row { animation: none; }
}

/* ============================================================
   Mode "embarqué" (chat chargé dans l'iframe de la bulle)
   ============================================================ */
html.lc-embedded,
html.lc-embedded body {
  height: 100%;
}

html.lc-embedded body {
  padding: 0;
  align-items: stretch;
  justify-content: stretch;
  background-image: none;
}

html.lc-embedded .widget {
  width: 100%;
  height: 100%;
  border-radius: 0;
  box-shadow: none;
}

html.lc-embedded .thread {
  flex: 1;           /* prend tout l'espace restant */
  min-height: 0;      /* important : évite que flex force une hauteur mini */
  max-height: none;
}