/* ── TS AI Chatbot by Techsche – Widget CSS ──────────────────────
   ALL selectors use #tsai-* or .tsai-*
   JS toggles class "tsai-open" to show/hide the window
   CSS variables are --tsai-*
──────────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&display=swap');

:root {
  --tsai-primary:   #2563eb;
  --tsai-primary-d: #1d4ed8;
  --tsai-bg:        #ffffff;
  --tsai-surface:   #f1f5f9;
  --tsai-text:      #0f172a;
  --tsai-muted:     #64748b;
  --tsai-border:    #e2e8f0;
  --tsai-radius:    18px;
  --tsai-font:      'Plus Jakarta Sans', sans-serif;
  --tsai-shadow:    0 16px 56px rgba(0,0,0,.2), 0 2px 8px rgba(0,0,0,.08);
}

/* ══════════════════════════ LAUNCHER ═══════════════════════════ */
#tsai-launcher {
  position: fixed;
  bottom: 24px;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: var(--tsai-primary);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  z-index: 2147483646;
  box-shadow: 0 4px 24px rgba(37,99,235,.55);
  border: none;
  outline: none;
  user-select: none;
  transition: transform .2s ease, background .2s ease;
}
#tsai-launcher.tsai-right { right: 24px; }
#tsai-launcher.tsai-left  { left: 24px; }
#tsai-launcher:hover       { transform: scale(1.1); background: var(--tsai-primary-d); }
#tsai-launcher:focus-visible { outline: 3px solid #93c5fd; outline-offset: 3px; }

/* Pulse ring */
.tsai-pulse {
  position: absolute; inset: 0;
  border-radius: 50%;
  background: var(--tsai-primary);
  opacity: .45;
  animation: tsai-pulse-anim 2.3s ease-out infinite;
  pointer-events: none;
}
@keyframes tsai-pulse-anim {
  0%   { transform: scale(1);    opacity: .5; }
  75%  { transform: scale(1.7);  opacity: 0;  }
  100% { transform: scale(1.7);  opacity: 0;  }
}
#tsai-launcher.tsai-open .tsai-pulse { display: none; }

/* Bubble icons */
#tsai-launcher svg,
#tsai-bubble-img {
  width: 28px; height: 28px;
  position: relative; z-index: 1;
  transition: opacity .2s, transform .2s;
  border-radius: 50%;
  object-fit: cover;
  flex-shrink: 0;
}
#tsai-bubble-close {
  position: absolute !important;
  opacity: 0;
  transform: rotate(-90deg);
}
#tsai-launcher.tsai-open #tsai-bubble-svg   { opacity: 0; transform: rotate(90deg); }
#tsai-launcher.tsai-open #tsai-bubble-img   { opacity: 0; transform: rotate(90deg); }
#tsai-launcher.tsai-open #tsai-bubble-close { opacity: 1; transform: rotate(0deg); }

/* ═══════════════════════ CHAT WINDOW ════════════════════════════ */
#tsai-window {
  position: fixed;
  bottom: 100px;
  width: 375px;
  max-height: 590px;
  background: var(--tsai-bg);
  border-radius: var(--tsai-radius);
  box-shadow: var(--tsai-shadow);
  display: flex;
  flex-direction: column;
  z-index: 2147483645;
  font-family: var(--tsai-font);
  overflow: hidden;
  /* Default hidden */
  opacity: 0;
  pointer-events: none;
  transform: translateY(18px) scale(.95);
  transition: opacity .28s ease, transform .3s cubic-bezier(.34,1.56,.64,1);
}
#tsai-window.tsai-right { right: 24px; }
#tsai-window.tsai-left  { left:  24px; }
/* JS adds .tsai-open to make it visible */
#tsai-window.tsai-open {
  opacity: 1;
  pointer-events: all;
  transform: translateY(0) scale(1);
}

/* ─── Header ─────────────────────────────────────────── */
#tsai-header {
  background: var(--tsai-primary);
  color: #fff;
  padding: 13px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
#tsai-avatar-wrap { position: relative; flex-shrink: 0; }
#tsai-bot-avatar  {
  width: 42px; height: 42px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255,255,255,.35);
  background: rgba(255,255,255,.2);
  display: block;
}
#tsai-online-dot {
  position: absolute; bottom: 1px; right: 1px;
  width: 12px; height: 12px;
  background: var(--tsai-dot-color, #4ade80);
  border-radius: 50%;
  border: 2px solid var(--tsai-primary);
  transition: background .3s;
}
#tsai-header-info { flex: 1; min-width: 0; }
#tsai-bot-name    { font-weight: 700; font-size: 15px; line-height: 1.2; }
#tsai-bot-status  { font-size: 11px; opacity: .75; margin-top: 2px; }
#tsai-minimize-btn {
  margin-left: auto;
  background: rgba(255,255,255,.15);
  border: none; color: #fff;
  width: 30px; height: 30px;
  border-radius: 8px; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: background .15s; flex-shrink: 0;
}
#tsai-minimize-btn:hover { background: rgba(255,255,255,.3); }
#tsai-minimize-btn svg   { width: 16px; height: 16px; }

/* ─── Messages ───────────────────────────────────────── */
#tsai-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
  min-height: 0;
}
#tsai-messages::-webkit-scrollbar       { width: 4px; }
#tsai-messages::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

.tsai-msg {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
  animation: tsai-msg-pop .22s cubic-bezier(.34,1.56,.64,1);
}
@keyframes tsai-msg-pop {
  from { transform: scale(.88) translateY(6px); opacity: 0; }
  to   { transform: scale(1)   translateY(0);   opacity: 1; }
}
.tsai-msg-bot {
  background: var(--tsai-surface);
  color: var(--tsai-text);
  align-self: flex-start;
  border-bottom-left-radius: 4px;
}
.tsai-msg-user {
  background: var(--tsai-primary);
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
}

/* ─── Typing dots ────────────────────────────────────── */
#tsai-typing-wrap { padding: 0 16px 6px; flex-shrink: 0; }
#tsai-typing-dots {
  display: inline-flex;
  gap: 4px; align-items: center;
  background: var(--tsai-surface);
  padding: 10px 14px;
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  animation: tsai-msg-pop .2s ease;
}
#tsai-typing-dots span {
  width: 7px; height: 7px;
  border-radius: 50%; background: #94a3b8;
  animation: tsai-bounce 1.1s ease-in-out infinite;
}
#tsai-typing-dots span:nth-child(2) { animation-delay: .18s; }
#tsai-typing-dots span:nth-child(3) { animation-delay: .36s; }
@keyframes tsai-bounce {
  0%,80%,100% { transform: translateY(0); }
  40%         { transform: translateY(-7px); }
}

/* ─── Quick replies ──────────────────────────────────── */
#tsai-quick-replies {
  padding: 6px 14px 2px;
  display: flex; flex-wrap: wrap; gap: 8px;
  flex-shrink: 0;
}
.tsai-qr-btn {
  padding: 7px 14px;
  border: 1.5px solid var(--tsai-primary);
  color: var(--tsai-primary);
  background: #fff;
  border-radius: 24px;
  font-size: 13px; font-weight: 600;
  font-family: var(--tsai-font);
  cursor: pointer;
  transition: all .15s;
}
.tsai-qr-btn:hover { background: var(--tsai-primary); color: #fff; }

/* ─── Input row ──────────────────────────────────────── */
#tsai-input-wrap {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--tsai-border);
  flex-shrink: 0;
}
#tsai-input {
  flex: 1;
  border: 1.5px solid var(--tsai-border);
  border-radius: 14px;
  padding: 10px 13px;
  font-size: 14px; font-family: var(--tsai-font);
  color: var(--tsai-text); background: var(--tsai-surface);
  resize: none; max-height: 120px; overflow-y: auto;
  outline: none;
  transition: border-color .15s, background .15s;
  line-height: 1.45;
}
#tsai-input:focus    { border-color: var(--tsai-primary); background: #fff; }
#tsai-input:disabled { opacity: .5; cursor: not-allowed; }

#tsai-send-btn {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: var(--tsai-primary);
  border: none; color: #fff; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background .15s, transform .15s;
}
#tsai-send-btn:hover    { background: var(--tsai-primary-d); transform: scale(1.08); }
#tsai-send-btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }
#tsai-send-btn svg { width: 17px; height: 17px; }

/* ─── GDPR ───────────────────────────────────────────── */
#tsai-gdpr-wrap {
  padding: 8px 14px 4px;
  font-size: 12px; color: var(--tsai-muted);
  border-top: 1px solid var(--tsai-border);
  display: flex; align-items: flex-start; gap: 7px;
  flex-shrink: 0;
}
#tsai-gdpr-check { margin-top: 2px; accent-color: var(--tsai-primary); flex-shrink: 0; }

/* ─── Footer ─────────────────────────────────────────── */
#tsai-footer {
  text-align: center; font-size: 11px; color: #cbd5e1;
  padding: 5px 0 8px; flex-shrink: 0;
  font-family: var(--tsai-font);
}
#tsai-footer strong { color: var(--tsai-muted); }
#tsai-footer a { color: var(--tsai-muted); text-decoration: none; }
#tsai-footer a:hover { text-decoration: underline; }

/* ═══════════════════════ MOBILE ═════════════════════════════════ */
@media (max-width: 600px) {
  /* 78% width so it doesn't swallow the whole screen */
  #tsai-window {
    width: 78vw;
    min-width: 280px;
    max-width: 360px;
    bottom: 82px;
    max-height: 72vh;
  }
  #tsai-window.tsai-right { right: 10px; }
  #tsai-window.tsai-left  { left:  10px; }
  #tsai-launcher.tsai-right { right: 14px; bottom: 16px; }
  #tsai-launcher.tsai-left  { left:  14px; bottom: 16px; }
  #tsai-launcher { width: 54px; height: 54px; }
  #tsai-bot-name  { font-size: 13px; }
  #tsai-bot-status{ font-size: 10px; }
  .tsai-msg       { font-size: 13px; }
  #tsai-input     { font-size: 13px; }
  .tsai-qr-btn    { font-size: 12px; padding: 6px 11px; }
  #tsai-send-btn  { width: 36px; height: 36px; }
  #tsai-send-btn svg { width: 15px; height: 15px; }
}

/* ── End Chat button ─────────────────────────────────────────── */
.tsai-end-chat-btn {
  border-color: #ef4444 !important;
  color: #ef4444 !important;
}
.tsai-end-chat-btn:hover {
  background: #ef4444 !important;
  color: #fff !important;
}
