/* ==========================================================================
   AI Chatbot Widget — ai_chatbot.css
   ========================================================================== */

/* ── Variables ─────────────────────────────────────────────────────────── */
:root {
  --chatbot-accent:      #2563eb;
  --chatbot-accent-dark: #1d4ed8;
  --chatbot-bg:          #ffffff;
  --chatbot-header-bg:   #1e40af;
  --chatbot-header-fg:   #ffffff;
  --chatbot-user-bg:     #2563eb;
  --chatbot-user-fg:     #ffffff;
  --chatbot-bot-bg:      #f1f5f9;
  --chatbot-bot-fg:      #1e293b;
  --chatbot-border:      #e2e8f0;
  --chatbot-shadow:      0 8px 32px rgba(0, 0, 0, 0.18);
  --chatbot-radius:      16px;
  --chatbot-z:           9999;
}

/* ── Wrapper ────────────────────────────────────────────────────────────── */
#ai-chatbot-widget {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: var(--chatbot-z);
  font-family: system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
}

/* ── Toggle bubble ──────────────────────────────────────────────────────── */
#ai-chatbot-toggle {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: var(--chatbot-accent);
  border: none;
  cursor: pointer;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--chatbot-shadow);
  transition: background 0.2s, transform 0.15s;
  margin-left: auto;
}

#ai-chatbot-toggle:hover,
#ai-chatbot-toggle:focus-visible {
  background: var(--chatbot-accent-dark);
  transform: scale(1.08);
  outline: 3px solid #93c5fd;
  outline-offset: 2px;
}

/* ── Panel ──────────────────────────────────────────────────────────────── */
#ai-chatbot-panel {
  position: absolute;
  bottom: 68px;
  right: 0;
  width: 360px;
  max-width: calc(100vw - 32px);
  border-radius: var(--chatbot-radius);
  background: var(--chatbot-bg);
  box-shadow: var(--chatbot-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--chatbot-border);
  animation: chatbot-slide-in 0.22s ease;
}

@keyframes chatbot-slide-in {
  from { opacity: 0; transform: translateY(12px); }
  to   { opacity: 1; transform: translateY(0);    }
}

#ai-chatbot-panel[hidden] { display: none; }

/* ── Header ─────────────────────────────────────────────────────────────── */
#ai-chatbot-header {
  background: var(--chatbot-header-bg);
  color: var(--chatbot-header-fg);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

#ai-chatbot-title {
  font-weight: 700;
  font-size: 15px;
  letter-spacing: 0.01em;
}

#ai-chatbot-close {
  background: transparent;
  border: none;
  color: inherit;
  font-size: 22px;
  line-height: 1;
  cursor: pointer;
  padding: 2px 6px;
  border-radius: 6px;
  opacity: 0.8;
  transition: opacity 0.15s, background 0.15s;
}

#ai-chatbot-close:hover,
#ai-chatbot-close:focus-visible {
  opacity: 1;
  background: rgba(255, 255, 255, 0.15);
  outline: none;
}

/* ── Messages area ──────────────────────────────────────────────────────── */
#ai-chatbot-messages {
  flex: 1;
  height: 340px;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

/* ── Individual messages ────────────────────────────────────────────────── */
.ai-chatbot-msg {
  display: flex;
}

.ai-chatbot-msg--user {
  justify-content: flex-end;
}

.ai-chatbot-msg--assistant {
  justify-content: flex-start;
}

.ai-chatbot-bubble {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 14px;
  word-wrap: break-word;
  white-space: pre-wrap;
}

.ai-chatbot-msg--user .ai-chatbot-bubble {
  background: var(--chatbot-user-bg);
  color: var(--chatbot-user-fg);
  border-bottom-right-radius: 4px;
}

.ai-chatbot-msg--assistant .ai-chatbot-bubble {
  background: var(--chatbot-bot-bg);
  color: var(--chatbot-bot-fg);
  border-bottom-left-radius: 4px;
}

/* ── Typing indicator ───────────────────────────────────────────────────── */
.ai-chatbot-typing .ai-chatbot-bubble {
  display: flex;
  gap: 5px;
  align-items: center;
  padding: 12px 16px;
}

.ai-chatbot-typing span {
  display: block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #94a3b8;
  animation: chatbot-bounce 1.2s infinite ease-in-out;
}

.ai-chatbot-typing span:nth-child(2) { animation-delay: 0.2s; }
.ai-chatbot-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes chatbot-bounce {
  0%, 80%, 100% { transform: translateY(0);    opacity: 0.5; }
  40%            { transform: translateY(-6px); opacity: 1;   }
}

/* ── Input row ──────────────────────────────────────────────────────────── */
#ai-chatbot-form {
  display: flex;
  align-items: center;
  padding: 10px 12px;
  border-top: 1px solid var(--chatbot-border);
  gap: 8px;
  background: var(--chatbot-bg);
}

#ai-chatbot-input {
  flex: 1;
  padding: 9px 14px;
  border: 1px solid var(--chatbot-border);
  border-radius: 24px;
  font-size: 14px;
  outline: none;
  transition: border-color 0.2s;
  color: #1e293b;
  background: #f8fafc;
}

#ai-chatbot-input:focus {
  border-color: var(--chatbot-accent);
  background: #fff;
}

#ai-chatbot-send {
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border: none;
  border-radius: 50%;
  background: var(--chatbot-accent);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, transform 0.1s;
}

#ai-chatbot-send:hover,
#ai-chatbot-send:focus-visible {
  background: var(--chatbot-accent-dark);
  transform: scale(1.07);
  outline: 3px solid #93c5fd;
  outline-offset: 2px;
}

#ai-chatbot-send:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  #ai-chatbot-widget {
    bottom: 16px;
    right: 12px;
  }

  #ai-chatbot-panel {
    width: calc(100vw - 24px);
    right: -12px;
    bottom: 64px;
  }

  #ai-chatbot-messages {
    height: 280px;
  }
}
