/* ============================================================
   TactiForce — Live Chat Widget
   ============================================================ */

#tf-chat {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  font-family: var(--font, 'Inter', sans-serif);
}

/* ── Bouton flottant ──────────────────────────────────────── */
.tf-chat__btn {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--clr-accent, #4f7942);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 16px rgba(0,0,0,.25);
  transition: transform .2s, box-shadow .2s;
  position: relative;
}
.tf-chat__btn:hover { transform: scale(1.08); box-shadow: 0 6px 20px rgba(0,0,0,.3); }
.tf-chat__btn svg   { pointer-events: none; }

.tf-chat__badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #e53e3e;
  color: #fff;
  font-size: .68rem;
  font-weight: 700;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  border: 2px solid #fff;
}

/* ── Fenêtre chat ──────────────────────────────────────────── */
.tf-chat__window {
  position: absolute;
  bottom: 70px;
  right: 0;
  width: 340px;
  max-height: 520px;
  background: var(--clr-bg, #fff);
  border-radius: 16px;
  box-shadow: 0 8px 40px rgba(0,0,0,.18);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform: scale(0.92) translateY(10px);
  opacity: 0;
  pointer-events: none;
  transition: transform .25s ease, opacity .25s ease;
  transform-origin: bottom right;
}
.tf-chat__window.open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* ── Header ────────────────────────────────────────────────── */
.tf-chat__header {
  background: var(--clr-accent, #4f7942);
  color: #fff;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.tf-chat__header-info { display: flex; align-items: center; gap: 10px; }
.tf-chat__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: rgba(255,255,255,.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .8rem;
}
.tf-chat__header-name   { font-weight: 700; font-size: .9rem; }
.tf-chat__header-status { font-size: .75rem; opacity: .85; }
.tf-chat__close {
  background: none;
  border: none;
  color: rgba(255,255,255,.8);
  cursor: pointer;
  font-size: 1.1rem;
  padding: 2px 6px;
  border-radius: 6px;
  transition: background .15s;
}
.tf-chat__close:hover { background: rgba(255,255,255,.15); color: #fff; }

/* ── Messages ─────────────────────────────────────────────── */
.tf-chat__messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 12px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  scrollbar-width: thin;
  scrollbar-color: var(--clr-accent, #4f7942) transparent;
}
.tf-chat__welcome {
  text-align: center;
  color: var(--clr-text-muted, #888);
  font-size: .82rem;
  padding: 12px 0;
}
.tf-chat__welcome p { margin: 0; }

/* Bulle de message */
.tf-chat__msg {
  max-width: 80%;
  padding: 8px 12px;
  border-radius: 14px;
  font-size: .85rem;
  line-height: 1.45;
  word-break: break-word;
}
.tf-chat__msg--user {
  background: var(--clr-accent, #4f7942);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}
.tf-chat__msg--admin {
  background: var(--clr-bg-alt, #f3f4f6);
  color: var(--clr-text, #111);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.tf-chat__msg__time {
  font-size: .68rem;
  opacity: .65;
  margin-top: 3px;
  display: block;
}
.tf-chat__msg__translated {
  display: block;
  font-size: .62rem;
  opacity: .5;
  margin-top: 2px;
  font-style: italic;
}
.tf-chat__msg__translate-btn {
  display: block;
  margin-top: 4px;
  background: none;
  border: none;
  font-size: .65rem;
  opacity: .55;
  cursor: pointer;
  padding: 0;
  font-family: inherit;
  text-decoration: underline;
  text-underline-offset: 2px;
  color: inherit;
  text-align: left;
}
.tf-chat__msg__translate-btn:hover { opacity: 1; }

/* ── Indicateur "en train d'écrire" ──────────────────────── */
.tf-chat__typing {
  padding: 6px 16px 8px;
  display: flex;
  align-items: center;
  gap: 4px;
  flex-shrink: 0;
}
.tf-chat__typing span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--clr-text-muted, #aaa);
  animation: tfTyping 1.2s infinite;
}
.tf-chat__typing span:nth-child(2) { animation-delay: .2s; }
.tf-chat__typing span:nth-child(3) { animation-delay: .4s; }
@keyframes tfTyping {
  0%, 80%, 100% { transform: scale(1);   opacity: .5; }
  40%           { transform: scale(1.3); opacity: 1;  }
}

/* ── Session fermée ─────────────────────────────────────────*/
.tf-chat__closed-msg {
  text-align: center;
  font-size: .8rem;
  color: var(--clr-text-muted, #888);
  padding: 8px 12px;
  background: var(--clr-bg-alt, #f3f4f6);
  border-radius: 8px;
  margin: 4px 0;
}

/* ── Zone de saisie ────────────────────────────────────────── */
.tf-chat__input-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-top: 1px solid var(--clr-border, #e5e7eb);
  flex-shrink: 0;
}
.tf-chat__input {
  flex: 1;
  border: 1px solid var(--clr-border, #e5e7eb);
  border-radius: 20px;
  padding: 8px 14px;
  font-size: .85rem;
  font-family: inherit;
  background: var(--clr-bg, #fff);
  color: var(--clr-text, #111);
  outline: none;
  transition: border-color .15s;
}
.tf-chat__input:focus { border-color: var(--clr-accent, #4f7942); }
.tf-chat__input:disabled { opacity: .5; cursor: not-allowed; }
.tf-chat__send {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--clr-accent, #4f7942);
  color: #fff;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity .15s;
}
.tf-chat__send:hover   { opacity: .85; }
.tf-chat__send:disabled { opacity: .4; cursor: not-allowed; }

/* ── Mobile ────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .tf-chat__window {
    width: calc(100vw - 24px);
    right: 0;
    bottom: 70px;
  }
}
