/* ════════════ SNTG AI CHATBOT WIDGET ════════════ */

/* ── Floating trigger button ── */
.sntg-chat-trigger {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 24px rgba(99,102,241,.45);
  z-index: 9990;
  transition: transform .2s ease, box-shadow .2s ease;
}
.sntg-chat-trigger:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 32px rgba(99,102,241,.6);
}
.sntg-chat-trigger svg { width: 24px; height: 24px; color: #fff; transition: opacity .2s; }
.sntg-chat-trigger .icon-chat  { opacity: 1; position: absolute; }
.sntg-chat-trigger .icon-close { opacity: 0; position: absolute; }
.sntg-chat-trigger.open .icon-chat  { opacity: 0; }
.sntg-chat-trigger.open .icon-close { opacity: 1; }

/* Unread badge */
.sntg-chat-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: #ef4444;
  color: #fff;
  font-size: .65rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg, #0f172a);
  opacity: 0;
  transform: scale(0);
  transition: all .2s;
}
.sntg-chat-badge.show { opacity: 1; transform: scale(1); }

/* ── Chat window ── */
.sntg-chat-window {
  position: fixed;
  bottom: 96px;
  right: 28px;
  width: 360px;
  max-height: 560px;
  background: #0f172a;
  border: 1px solid #1e293b;
  border-radius: 16px;
  box-shadow: 0 20px 60px rgba(0,0,0,.5);
  z-index: 9989;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(16px) scale(.97);
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
}
.sntg-chat-window.open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: all;
}

/* ── Header ── */
.sntg-chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  background: linear-gradient(135deg, #1e1b4b, #1e293b);
  border-bottom: 1px solid #1e293b;
  flex-shrink: 0;
}
.sntg-chat-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sntg-chat-avatar svg { width: 20px; height: 20px; color: #fff; }
.sntg-chat-header-info { flex: 1; min-width: 0; }
.sntg-chat-header-name {
  font-size: .88rem;
  font-weight: 700;
  color: #f1f5f9;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.sntg-chat-header-status {
  font-size: .72rem;
  color: #22c55e;
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}
.sntg-chat-header-status::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #22c55e;
  flex-shrink: 0;
}
.sntg-chat-header-close {
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: none;
  background: rgba(255,255,255,.07);
  color: #94a3b8;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
  flex-shrink: 0;
}
.sntg-chat-header-close:hover { background: rgba(255,255,255,.14); color: #f1f5f9; }
.sntg-chat-header-close svg { width: 14px; height: 14px; }

/* ── Messages area ── */
.sntg-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
.sntg-chat-messages::-webkit-scrollbar { width: 4px; }
.sntg-chat-messages::-webkit-scrollbar-track { background: transparent; }
.sntg-chat-messages::-webkit-scrollbar-thumb { background: #334155; border-radius: 99px; }

/* ── Message bubbles ── */
.sntg-msg {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  animation: msgIn .2s ease;
}
@keyframes msgIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.sntg-msg--bot { justify-content: flex-start; }
.sntg-msg--user { justify-content: flex-end; }

.sntg-msg__avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.sntg-msg__avatar svg { width: 15px; height: 15px; color: #fff; }

.sntg-msg__bubble {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: .84rem;
  line-height: 1.55;
}
.sntg-msg--bot  .sntg-msg__bubble {
  background: #1e293b;
  color: #e2e8f0;
  border-bottom-left-radius: 4px;
}
.sntg-msg--user .sntg-msg__bubble {
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* ── Typing indicator ── */
.sntg-typing .sntg-msg__bubble {
  padding: 12px 16px;
  display: flex;
  align-items: center;
  gap: 4px;
}
.sntg-typing-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #6366f1;
  animation: typingPulse 1.2s ease infinite;
}
.sntg-typing-dot:nth-child(2) { animation-delay: .2s; }
.sntg-typing-dot:nth-child(3) { animation-delay: .4s; }
@keyframes typingPulse {
  0%, 60%, 100% { transform: translateY(0); opacity: .4; }
  30% { transform: translateY(-5px); opacity: 1; }
}

/* ── Quick reply chips ── */
.sntg-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 14px 12px;
}
.sntg-quick-btn {
  padding: 5px 12px;
  border-radius: 99px;
  border: 1px solid #334155;
  background: transparent;
  color: #94a3b8;
  font-size: .76rem;
  font-weight: 600;
  cursor: pointer;
  transition: all .15s;
  white-space: nowrap;
}
.sntg-quick-btn:hover {
  border-color: #6366f1;
  color: #6366f1;
  background: rgba(99,102,241,.08);
}

/* ── Input area ── */
.sntg-chat-input-wrap {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid #1e293b;
  background: #0f172a;
  flex-shrink: 0;
}
.sntg-chat-input {
  flex: 1;
  background: #1e293b;
  border: 1px solid #334155;
  border-radius: 10px;
  color: #f1f5f9;
  font-size: .84rem;
  padding: 9px 12px;
  resize: none;
  min-height: 38px;
  max-height: 100px;
  font-family: inherit;
  line-height: 1.4;
  outline: none;
  transition: border-color .2s;
}
.sntg-chat-input::placeholder { color: #475569; }
.sntg-chat-input:focus { border-color: #6366f1; }

.sntg-chat-send {
  width: 36px;
  height: 36px;
  border-radius: 9px;
  border: none;
  background: linear-gradient(135deg, #6366f1, #8b5cf6);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity .15s, transform .15s;
}
.sntg-chat-send:hover { opacity: .85; }
.sntg-chat-send:active { transform: scale(.93); }
.sntg-chat-send:disabled { opacity: .4; cursor: not-allowed; }
.sntg-chat-send svg { width: 16px; height: 16px; }

/* ── Powered by ── */
.sntg-chat-powered {
  text-align: center;
  font-size: .66rem;
  color: #334155;
  padding: 0 0 10px;
  letter-spacing: .02em;
}
.sntg-chat-powered span { color: #6366f1; font-weight: 600; }

/* ── Responsive ── */
@media (max-width: 480px) {
  .sntg-chat-window {
    right: 0;
    bottom: 0;
    width: 100%;
    max-height: 85vh;
    border-radius: 20px 20px 0 0;
  }
  .sntg-chat-trigger { bottom: 20px; right: 20px; }
}

/* ── Mobile PWA overrides (≤768px) ── */
@media (max-width: 768px) {
  /* Chat trigger: float above bottom tab bar */
  .sntg-chat-trigger {
    bottom: calc(80px + env(safe-area-inset-bottom));
    right: 20px;
  }

  /* Chat window: full-width bottom sheet that slides up */
  .sntg-chat-window {
    position: fixed;
    bottom: 0;
    right: 0;
    left: 0;
    width: 100%;
    height: 85vh;
    max-height: 85vh;
    border-radius: 20px 20px 0 0;
    /* hidden state: pushed down off screen */
    opacity: 1;
    transform: translateY(100%);
    transition: transform .3s ease;
    pointer-events: none;
  }
  .sntg-chat-window.open {
    transform: translateY(0);
    pointer-events: all;
  }
}
