/*
 * EA Chatbot Styles — v4
 * Appearance is controlled via CSS custom properties injected inline by PHP.
 * This file provides the structural / layout foundation only.
 * Colors, size, shadow, radius come from --ea-chat-* vars set per-instance.
 */

/* ── CSS variable defaults (overridden by inline <style> from PHP) ──── */
:root {
  --ea-chat-primary:    #0f2d52;
  --ea-chat-accent:     #f59e0b;
  --ea-chat-user-bg:    #0f2d52;
  --ea-chat-user-fg:    #ffffff;
  --ea-chat-bot-bg:     #f1f5f9;
  --ea-chat-bot-fg:     #1e293b;
  --ea-chat-font-size:  0.88rem;
  --ea-chat-shadow:     0 8px 40px rgba(15,45,82,0.18);
  --ea-chat-w:          360px;
  --ea-chat-h:          520px;
  --ea-chat-radius:     16px;
  --ea-chat-z:          99999;

  /* Static colors that don't need customization */
  --ea-chat-white:      #ffffff;
  --ea-chat-gray-50:    #f8fafc;
  --ea-chat-gray-100:   #f1f5f9;
  --ea-chat-gray-200:   #e2e8f0;
  --ea-chat-gray-500:   #64748b;
  --ea-chat-radius-sm:  10px;
}

/* ── Float wrapper ──────────────────────────────────────────────────── */
.ea-chat-float {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: var(--ea-chat-z);
  display: flex;
  flex-direction: column;
  gap: 12px;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  /* align-items is set by position rule in inline style */
}

/* ── Inline wrapper ─────────────────────────────────────────────────── */
.ea-chat-inline {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  max-width: var(--ea-chat-w);
  margin: 0 auto;
}

/* ── Toggle button ──────────────────────────────────────────────────── */
.ea-chat-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 13px 20px;
  background: var(--ea-chat-primary);
  color: var(--ea-chat-white);
  border: none;
  border-radius: 100px;
  cursor: pointer;
  font-size: var(--ea-chat-font-size);
  font-weight: 700;
  box-shadow: var(--ea-chat-shadow);
  transition: all 0.2s ease;
  position: relative;
  white-space: nowrap;
}
.ea-chat-toggle:hover { filter: brightness(1.12); transform: translateY(-2px); }
.ea-chat-toggle svg   { width: 18px; height: 18px; flex-shrink: 0; }

.ea-chat-unread-dot {
  position: absolute;
  top: 0; right: 0;
  width: 12px; height: 12px;
  background: var(--ea-chat-accent);
  border-radius: 50%;
  border: 2px solid var(--ea-chat-white);
}

/* ── Chat window ────────────────────────────────────────────────────── */
.ea-chat-window {
  width: var(--ea-chat-w);
  height: var(--ea-chat-h);
  background: var(--ea-chat-white);
  border-radius: var(--ea-chat-radius);
  box-shadow: var(--ea-chat-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1.5px solid var(--ea-chat-gray-200);
  opacity: 0;
  transform: translateY(16px) scale(0.97);
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
}
.ea-chat-inline .ea-chat-window {
  opacity: 1;
  transform: none;
  pointer-events: all;
  height: auto;
  min-height: 400px;
}
.ea-chat-window--open {
  opacity: 1 !important;
  transform: none !important;
  pointer-events: all !important;
}

/* ── Header ─────────────────────────────────────────────────────────── */
.ea-chat-header {
  background: var(--ea-chat-primary);
  color: var(--ea-chat-white);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}
.ea-chat-header-info { display: flex; align-items: center; gap: 10px; }
.ea-chat-avatar      { width: 36px; height: 36px; flex-shrink: 0; }
.ea-chat-avatar svg  { width: 36px; height: 36px; border-radius: 50%; }
.ea-chat-header strong { display: block; font-size: 0.95rem; }
.ea-chat-status      { font-size: 0.72rem; color: #86efac; letter-spacing: 0.02em; }
.ea-chat-close-btn {
  background: rgba(255,255,255,0.12); border: none; color: #fff;
  width: 28px; height: 28px; border-radius: 50%; cursor: pointer;
  font-size: 0.85rem; display: flex; align-items: center; justify-content: center;
  transition: background 0.15s;
}
.ea-chat-close-btn:hover { background: rgba(255,255,255,0.22); }

/* ── Message list ───────────────────────────────────────────────────── */
.ea-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
  font-size: var(--ea-chat-font-size);
}
.ea-chat-messages::-webkit-scrollbar       { width: 4px; }
.ea-chat-messages::-webkit-scrollbar-track { background: transparent; }
.ea-chat-messages::-webkit-scrollbar-thumb { background: var(--ea-chat-gray-200); border-radius: 4px; }

/* ── Message bubbles ────────────────────────────────────────────────── */
.ea-chat-msg       { display: flex; }
.ea-chat-msg--user { justify-content: flex-end; }
.ea-chat-msg--bot  { justify-content: flex-start; }

.ea-chat-bubble {
  max-width: 82%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: var(--ea-chat-font-size);
  line-height: 1.55;
  word-break: break-word;
}
.ea-chat-msg--user .ea-chat-bubble {
  background: var(--ea-chat-user-bg);
  color: var(--ea-chat-user-fg);
  border-bottom-right-radius: 4px;
}
.ea-chat-msg--bot .ea-chat-bubble {
  background: var(--ea-chat-bot-bg);
  color: var(--ea-chat-bot-fg);
  border-bottom-left-radius: 4px;
}
.ea-chat-bubble a { color: var(--ea-chat-primary); font-weight: 600; }
.ea-chat-msg--user .ea-chat-bubble a { color: rgba(255,255,255,0.85); }
.ea-chat-bubble strong { font-weight: 700; }

/* ── Typing indicator ───────────────────────────────────────────────── */
.ea-chat-bubble--typing {
  display: flex; align-items: center; gap: 5px; padding: 12px 16px;
}
.ea-chat-bubble--typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--ea-chat-gray-500);
  display: block;
  animation: ea-typing-bounce 1.2s infinite ease-in-out;
}
.ea-chat-bubble--typing span:nth-child(2) { animation-delay: 0.15s; }
.ea-chat-bubble--typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes ea-typing-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30%           { transform: translateY(-6px); opacity: 1; }
}

/* ── Suggestion chips ───────────────────────────────────────────────── */
.ea-chat-suggestions {
  padding: 4px 14px 10px;
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex-shrink: 0;
}
.ea-chat-suggest {
  padding: 5px 12px;
  border: 1.5px solid var(--ea-chat-gray-200);
  border-radius: 100px;
  background: var(--ea-chat-white);
  color: var(--ea-chat-primary);
  font-size: calc(var(--ea-chat-font-size) * 0.87);
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  white-space: nowrap;
}
.ea-chat-suggest:hover { background: var(--ea-chat-primary); color: #fff; border-color: var(--ea-chat-primary); }

/* ── Input area ─────────────────────────────────────────────────────── */
.ea-chat-input-area {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 14px;
  border-top: 1.5px solid var(--ea-chat-gray-200);
  flex-shrink: 0;
  background: var(--ea-chat-white);
}
.ea-chat-input {
  flex: 1;
  border: 1.5px solid var(--ea-chat-gray-200);
  border-radius: 100px;
  padding: 9px 16px;
  font-size: var(--ea-chat-font-size);
  outline: none;
  transition: border-color 0.15s;
  background: var(--ea-chat-gray-50);
}
.ea-chat-input:focus { border-color: var(--ea-chat-primary); background: #fff; }
.ea-chat-send-btn {
  width: 38px; height: 38px; flex-shrink: 0;
  background: var(--ea-chat-primary);
  border: none; border-radius: 50%; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.15s; color: #fff;
}
.ea-chat-send-btn:hover    { filter: brightness(1.12); transform: scale(1.05); }
.ea-chat-send-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.ea-chat-send-btn svg { width: 16px; height: 16px; }

/* ── Footer ─────────────────────────────────────────────────────────── */
.ea-chat-footer {
  text-align: center;
  font-size: 0.68rem;
  color: var(--ea-chat-gray-500);
  padding: 6px 14px 10px;
  flex-shrink: 0;
}
.ea-chat-footer a { color: var(--ea-chat-gray-500); }

/* ── Admin preview ──────────────────────────────────────────────────── */
.ea-chatbot-preview-wrap { margin-top: 32px; padding-top: 24px; border-top: 2px solid #e2e8f0; }
.ea-chatbot-preview-wrap h3 { margin: 0 0 8px; }
.ea-chatbot-preview-wrap p  { color: #64748b; margin: 0 0 16px; font-size: 0.88rem; }

/* ── Responsive ─────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .ea-chat-float { bottom: 16px !important; right: 16px !important; left: auto !important; transform: none !important; }
  :root { --ea-chat-w: calc(100vw - 32px); }
  .ea-chat-toggle-label { display: none; }
  .ea-chat-toggle { padding: 13px; border-radius: 50%; }
}
