/**
 * Ts-Immo Chatbot de fiche — styles du bouton lanceur et de la fenêtre flottante.
 * Tout est namespacé `.tsc-*` ; la couleur d'accent passe par `--tsc-accent`.
 */

:root {
  --tsc-accent: var(--tsv-color-accent, #0369a1);
}

/* --------------------------------------------------------------------- */
/* Bouton lanceur (rendu par le shortcode, inline dans la fiche)          */
/* --------------------------------------------------------------------- */

.tsc-launch {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 11px 18px;
  border: 0;
  border-radius: 999px;
  background: var(--tsc-accent);
  color: #fff;
  font-size: 15px;
  font-weight: 600;
  line-height: 1.2;
  cursor: pointer;
  transition: filter 0.15s ease, transform 0.05s ease, box-shadow 0.15s ease;
  box-shadow: 0 2px 8px rgba(15, 23, 42, 0.18);
}

.tsc-launch:hover { filter: brightness(0.94); }
.tsc-launch:active { transform: translateY(1px); }
.tsc-launch:focus-visible { outline: 3px solid color-mix(in srgb, var(--tsc-accent) 45%, white); outline-offset: 2px; }

.tsc-launch__icon { display: inline-flex; }

/* Variante flottante (attribut float="1") : pastille fixe bas-droite. */
.tsc-launch--float {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 99990;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.28);
}

.tsc-inline { margin: 24px 0; }

/* --------------------------------------------------------------------- */
/* Fenêtre de dialogue                                                    */
/* --------------------------------------------------------------------- */

.tsc-panel {
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 99999;
  display: flex;
  flex-direction: column;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 44px);
  background: var(--tsv-color-bg, #fff);
  border-radius: var(--tsv-radius, 16px);
  box-shadow: 0 18px 50px rgba(15, 23, 42, 0.30);
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(0.98);
  transform-origin: bottom right;
  transition: opacity 0.2s ease, transform 0.2s ease;
  font-size: 15px;
  color: var(--tsv-color-fg, #0f172a);
  -webkit-font-smoothing: antialiased;
}

.tsc-panel--open { opacity: 1; transform: translateY(0) scale(1); }

/* En-tête */
.tsc-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 16px;
  background: var(--tsc-accent);
  color: #fff;
}

.tsc-panel__title { font-weight: 700; font-size: 16px; font-family: var(--tsv-font-head, inherit); }
.tsc-panel__actions { display: flex; gap: 4px; }

.tsc-icon-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border: 0;
  border-radius: var(--tsv-radius-sm, 10px);
  background: transparent;
  color: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
}
.tsc-icon-btn:hover { background: rgba(255, 255, 255, 0.18); }
.tsc-icon-btn:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }

/* Fil de discussion */
.tsc-log {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px;
  background: var(--tsv-color-bg-alt, #f8fafc);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.tsc-context {
  align-self: center;
  max-width: 100%;
  padding: 4px 12px;
  border-radius: 999px;
  background: #e2e8f0;
  color: #475569;
  font-size: 12px;
  font-weight: 600;
  text-align: center;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.tsc-msg { display: flex; max-width: 85%; }
.tsc-msg--user { align-self: flex-end; justify-content: flex-end; }
.tsc-msg--bot { align-self: flex-start; }

.tsc-msg__bubble {
  padding: 10px 14px;
  border-radius: var(--tsv-radius, 14px);
  line-height: 1.45;
  white-space: pre-wrap;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.tsc-msg--bot .tsc-msg__bubble {
  background: var(--tsv-color-bg, #fff);
  border: 1px solid var(--tsv-color-border, #e5e7eb);
  border-bottom-left-radius: 4px;
}

.tsc-msg--user .tsc-msg__bubble {
  background: var(--tsc-accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* Indicateur de saisie (trois points) */
.tsc-msg--typing .tsc-msg__bubble { display: flex; gap: 4px; align-items: center; }
.tsc-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #94a3b8;
  animation: tsc-bounce 1.2s infinite ease-in-out;
}
.tsc-dot:nth-child(2) { animation-delay: 0.15s; }
.tsc-dot:nth-child(3) { animation-delay: 0.3s; }
@keyframes tsc-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

/* Suggestions cliquables */
.tsc-suggestions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 2px; }
.tsc-chip {
  padding: 7px 12px;
  border: 1px solid color-mix(in srgb, var(--tsc-accent) 35%, #cbd5e1);
  border-radius: 999px;
  background: var(--tsv-color-bg, #fff);
  color: var(--tsc-accent);
  font-size: 13px;
  cursor: pointer;
  transition: background 0.15s ease;
}
.tsc-chip:hover { background: color-mix(in srgb, var(--tsc-accent) 8%, #fff); }

/* Mini-formulaire de contact (garde-fou lead) */
.tsc-contact {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 4px;
  padding: 14px;
  background: var(--tsv-color-bg, #fff);
  border: 1px solid var(--tsv-color-border, #e5e7eb);
  border-radius: var(--tsv-radius, 12px);
}
.tsc-contact__intro { margin: 0 0 2px; font-size: 13px; color: #475569; }
.tsc-contact__field {
  width: 100%;
  padding: 9px 11px;
  border: 1px solid #cbd5e1;
  border-radius: var(--tsv-radius-sm, 8px);
  font-size: 14px;
  box-sizing: border-box;
}
.tsc-contact__field:focus { outline: 2px solid var(--tsc-accent); outline-offset: -1px; border-color: var(--tsc-accent); }
.tsc-contact__submit {
  padding: 9px 14px;
  border: 0;
  border-radius: var(--tsv-radius-sm, 8px);
  background: var(--tsc-accent);
  color: #fff;
  font-weight: 600;
  font-size: 14px;
  cursor: pointer;
}
.tsc-contact__submit:hover { filter: brightness(0.94); }
.tsc-contact__feedback { margin: 0; font-size: 13px; color: #b91c1c; min-height: 0; }
.tsc-contact__feedback:empty { display: none; }

/* Zone de saisie */
.tsc-input {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--tsv-color-border, #e5e7eb);
  background: var(--tsv-color-bg, #fff);
}
.tsc-input__field {
  flex: 1 1 auto;
  resize: none;
  max-height: 120px;
  padding: 10px 12px;
  border: 1px solid #cbd5e1;
  border-radius: var(--tsv-radius-sm, 10px);
  font: inherit;
  font-size: 14px;
  line-height: 1.4;
  box-sizing: border-box;
}
.tsc-input__field:focus { outline: 2px solid var(--tsc-accent); outline-offset: -1px; border-color: var(--tsc-accent); }
.tsc-input__send {
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 42px;
  height: 42px;
  border: 0;
  border-radius: var(--tsv-radius-sm, 10px);
  background: var(--tsc-accent);
  color: #fff;
  cursor: pointer;
  transition: filter 0.15s ease;
}
.tsc-input__send:hover { filter: brightness(0.94); }
.tsc-input__send:disabled { opacity: 0.55; cursor: default; }

.tsc-disclaimer {
  padding: 0 12px 10px;
  background: var(--tsv-color-bg, #fff);
  font-size: 11px;
  color: #94a3b8;
  text-align: center;
}

/* --------------------------------------------------------------------- */
/* Mobile : plein largeur, ancré en bas (wide bottom sheet)               */
/* --------------------------------------------------------------------- */

@media (max-width: 600px) {
  .tsc-panel {
    right: 0;
    left: 0;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    height: 88vh;
    height: 88dvh;
    max-height: 100vh;
    border-radius: 18px 18px 0 0;
    transform-origin: bottom center;
    transform: translateY(100%);
  }
  .tsc-panel--open { transform: translateY(0); }

  /* Quand la fenêtre est ouverte, on fige le défilement de fond. */
  body.tsc-open { overflow: hidden; }

  .tsc-launch--float { right: 16px; bottom: 16px; }
}

/* Respect des préférences de mouvement réduit. */
@media (prefers-reduced-motion: reduce) {
  .tsc-panel, .tsc-launch { transition: none; }
  .tsc-dot { animation: none; }
}
