/* CharteredTeam Chatbot Styles */
:root {
  --ct-primary: #1a3c6b;
  --ct-primary-light: #2456a0;
  --ct-accent: #f59e0b;
  --ct-bg: #ffffff;
  --ct-surface: #f8fafc;
  --ct-border: #e2e8f0;
  --ct-text: #1e293b;
  --ct-text-muted: #64748b;
  --ct-radius: 16px;
  --ct-shadow: 0 20px 60px rgba(0,0,0,0.15), 0 4px 16px rgba(0,0,0,0.1);
}

/* ── Toggle Button ── */
#ct-chatbot-toggle {
  position: fixed;
  bottom: 24px;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--ct-primary);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(26,60,107,0.4);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  z-index: 99998;
}
#ct-chatbot-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 8px 28px rgba(26,60,107,0.5);
}
#ct-chatbot-toggle svg {
  width: 28px;
  height: 28px;
  fill: #fff;
  transition: transform 0.3s ease;
}
#ct-chatbot-toggle.open svg.icon-chat { display: none; }
#ct-chatbot-toggle:not(.open) svg.icon-close { display: none; }

/* Notification dot */
#ct-chatbot-toggle .ct-dot {
  position: absolute;
  top: 4px;
  right: 4px;
  width: 12px;
  height: 12px;
  background: var(--ct-accent);
  border-radius: 50%;
  border: 2px solid #fff;
  animation: ct-pulse 2s infinite;
}
@keyframes ct-pulse {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.2); opacity: 0.7; }
}

/* ── Chat Window ── */
#ct-chatbot-window {
  position: fixed;
  bottom: 96px;
  width: 380px;
  height: 560px;
  background: var(--ct-bg);
  border-radius: var(--ct-radius);
  box-shadow: var(--ct-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  z-index: 99999;
  transform: scale(0.8) translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s cubic-bezier(0.34,1.56,0.64,1), opacity 0.2s ease;
}
#ct-chatbot-window.open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* Position variants */
.ct-pos-bottom-right #ct-chatbot-toggle { right: 24px; }
.ct-pos-bottom-right #ct-chatbot-window {
  right: 24px;
  transform-origin: bottom right;
}

.ct-pos-bottom-left #ct-chatbot-toggle { left: 24px; }
.ct-pos-bottom-left #ct-chatbot-window {
  left: 24px;
  transform-origin: bottom left;
}

.ct-pos-bottom-center #ct-chatbot-toggle {
  left: 50%;
  transform: translateX(-50%);
}
.ct-pos-bottom-center #ct-chatbot-toggle:hover {
  transform: translateX(-50%) scale(1.08);
}
.ct-pos-bottom-center #ct-chatbot-window {
  left: 50%;
  transform: translateX(-50%) scale(0.8) translateY(20px);
  transform-origin: bottom center;
}
.ct-pos-bottom-center #ct-chatbot-window.open {
  transform: translateX(-50%) scale(1) translateY(0);
}

/* ── Header ── */
#ct-chat-header {
  background: var(--ct-primary);
  padding: 16px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.ct-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.ct-avatar svg { width: 22px; height: 22px; fill: #fff; }
.ct-header-info { flex: 1; }
.ct-header-info h3 {
  margin: 0;
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  font-family: 'Segoe UI', system-ui, sans-serif;
}
.ct-header-info p {
  margin: 2px 0 0;
  color: rgba(255,255,255,0.75);
  font-size: 12px;
  font-family: 'Segoe UI', system-ui, sans-serif;
}
.ct-online-dot {
  width: 8px;
  height: 8px;
  background: #4ade80;
  border-radius: 50%;
  display: inline-block;
  margin-right: 4px;
}
.ct-header-close {
  background: none;
  border: none;
  cursor: pointer;
  color: rgba(255,255,255,0.8);
  padding: 4px;
  border-radius: 6px;
  display: flex;
  transition: color 0.15s, background 0.15s;
}
.ct-header-close:hover { color: #fff; background: rgba(255,255,255,0.15); }
.ct-header-close svg { width: 18px; height: 18px; }

/* ── Quick Actions ── */
#ct-quick-actions {
  padding: 12px 14px 0;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex-shrink: 0;
}
.ct-quick-btn {
  background: #e8f0fb;
  color: var(--ct-primary);
  border: 1.5px solid #c3d6f5;
  border-radius: 20px;
  padding: 5px 12px;
  font-size: 11.5px;
  font-weight: 600;
  cursor: pointer;
  font-family: 'Segoe UI', system-ui, sans-serif;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
  white-space: nowrap;
}
.ct-quick-btn:hover {
  background: var(--ct-primary);
  color: #fff;
  border-color: var(--ct-primary);
  transform: translateY(-1px);
}

/* ── Messages ── */
#ct-messages {
  flex: 1;
  overflow-y: auto;
  padding: 14px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
#ct-messages::-webkit-scrollbar { width: 4px; }
#ct-messages::-webkit-scrollbar-track { background: transparent; }
#ct-messages::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 4px; }

.ct-msg {
  display: flex;
  flex-direction: column;
  max-width: 82%;
  animation: ct-msg-in 0.2s ease;
}
@keyframes ct-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}
.ct-msg.user { align-self: flex-end; align-items: flex-end; }
.ct-msg.bot  { align-self: flex-start; align-items: flex-start; }

.ct-msg-bubble {
  padding: 9px 13px;
  border-radius: 14px;
  font-size: 13.5px;
  line-height: 1.55;
  font-family: 'Segoe UI', system-ui, sans-serif;
  word-break: break-word;
}
.ct-msg.user .ct-msg-bubble {
  background: var(--ct-primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.ct-msg.bot .ct-msg-bubble {
  background: var(--ct-surface);
  color: var(--ct-text);
  border: 1px solid var(--ct-border);
  border-bottom-left-radius: 4px;
}
.ct-msg-bubble a {
  color: var(--ct-accent);
  text-decoration: underline;
  font-weight: 600;
}
.ct-msg.bot .ct-msg-bubble a { color: var(--ct-primary-light); }
.ct-msg-bubble strong { font-weight: 700; }

/* Typing indicator */
.ct-typing-dots {
  display: flex;
  gap: 4px;
  padding: 12px 14px;
}
.ct-typing-dots span {
  width: 7px;
  height: 7px;
  background: var(--ct-text-muted);
  border-radius: 50%;
  animation: ct-bounce 1.2s infinite;
}
.ct-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.ct-typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes ct-bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40% { transform: translateY(-6px); }
}

/* WhatsApp button in messages */
.ct-wa-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-top: 8px;
  background: #25d366;
  color: #fff !important;
  text-decoration: none !important;
  padding: 7px 14px;
  border-radius: 20px;
  font-size: 12.5px;
  font-weight: 700;
  transition: background 0.15s;
}
.ct-wa-btn:hover { background: #1daf55 !important; }
.ct-wa-btn svg { width: 15px; height: 15px; fill: #fff; }

/* ── Input Area ── */
#ct-input-area {
  padding: 10px 12px 12px;
  background: var(--ct-bg);
  border-top: 1px solid var(--ct-border);
  display: flex;
  align-items: flex-end;
  gap: 8px;
  flex-shrink: 0;
}
#ct-input {
  flex: 1;
  border: 1.5px solid var(--ct-border);
  border-radius: 22px;
  padding: 9px 16px;
  font-size: 13.5px;
  font-family: 'Segoe UI', system-ui, sans-serif;
  color: var(--ct-text);
  background: var(--ct-surface);
  resize: none;
  max-height: 100px;
  outline: none;
  transition: border-color 0.15s;
  line-height: 1.4;
}
#ct-input:focus { border-color: var(--ct-primary); }
#ct-input::placeholder { color: var(--ct-text-muted); }
#ct-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--ct-primary);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s, transform 0.1s;
}
#ct-send-btn:hover { background: var(--ct-primary-light); transform: scale(1.05); }
#ct-send-btn:disabled { background: #cbd5e1; cursor: not-allowed; transform: none; }
#ct-send-btn svg { width: 18px; height: 18px; fill: #fff; }

/* ── Footer branding ── */
#ct-chat-footer {
  text-align: center;
  padding: 4px 0 8px;
  font-size: 10.5px;
  color: var(--ct-text-muted);
  font-family: 'Segoe UI', system-ui, sans-serif;
  flex-shrink: 0;
}

/* ── Responsive ── */
@media (max-width: 480px) {
  #ct-chatbot-window {
    width: calc(100vw - 20px);
    height: calc(100vh - 100px);
    bottom: 86px;
    border-radius: 12px;
  }
  .ct-pos-bottom-right #ct-chatbot-window { right: 10px; left: auto; }
  .ct-pos-bottom-left #ct-chatbot-window { left: 10px; right: auto; }
  .ct-pos-bottom-center #ct-chatbot-window {
    left: 50%;
    transform: translateX(-50%) scale(0.8) translateY(20px);
  }
  .ct-pos-bottom-center #ct-chatbot-window.open {
    transform: translateX(-50%) scale(1) translateY(0);
  }
}
