/* Ajay Electric Chatbot Widget v1.0.0 */
:root {
  --ajay-primary: #e63312;
  --ajay-primary-dark: #c22a0e;
  --ajay-radius: 16px;
  --ajay-font: 'Segoe UI', system-ui, -apple-system, sans-serif;
  --ajay-z: 999999;
  --ajay-shadow: 0 8px 40px rgba(0,0,0,0.18), 0 2px 8px rgba(0,0,0,0.12);
  /* Light theme */
  --ajay-bg: #ffffff;
  --ajay-surface: #f4f6f9;
  --ajay-text: #1a1d23;
  --ajay-text-muted: #6b7280;
  --ajay-border: #e5e7eb;
  --ajay-user-bg: var(--ajay-primary);
  --ajay-user-text: #ffffff;
  --ajay-bot-bg: #f0f2f5;
  --ajay-bot-text: #1a1d23;
  --ajay-input-bg: #f9fafb;
}

@media (prefers-color-scheme: dark) {
  [data-ajay-theme="auto"],
  .ajay-chatbot-widget[data-theme="auto"] {
    --ajay-bg: #1a1d23;
    --ajay-surface: #23272f;
    --ajay-text: #f1f3f5;
    --ajay-text-muted: #9ca3af;
    --ajay-border: #374151;
    --ajay-bot-bg: #2a2d35;
    --ajay-bot-text: #f1f3f5;
    --ajay-input-bg: #23272f;
  }
}

[data-ajay-theme="dark"] {
  --ajay-bg: #1a1d23;
  --ajay-surface: #23272f;
  --ajay-text: #f1f3f5;
  --ajay-text-muted: #9ca3af;
  --ajay-border: #374151;
  --ajay-bot-bg: #2a2d35;
  --ajay-bot-text: #f1f3f5;
  --ajay-input-bg: #23272f;
}

/* ── Launcher Button ─────────────────────────────────────────────────────── */
#ajay-chatbot-root {
  position: fixed;
  z-index: var(--ajay-z);
  font-family: var(--ajay-font);
}

#ajay-chatbot-root.position-bottom-right { right: 24px; bottom: 24px; }
#ajay-chatbot-root.position-bottom-left  { left: 24px;  bottom: 24px; }

.ajay-launcher {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--ajay-primary);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: var(--ajay-shadow);
  transition: transform 0.25s cubic-bezier(.34,1.56,.64,1), background 0.2s;
  outline: none;
  position: relative;
}

.ajay-launcher:hover  { background: var(--ajay-primary-dark); transform: scale(1.08); }
.ajay-launcher:active { transform: scale(0.96); }
.ajay-launcher:focus-visible { box-shadow: 0 0 0 3px rgba(230,51,18,0.4), var(--ajay-shadow); }

.ajay-launcher svg { transition: transform 0.3s ease, opacity 0.3s ease; }
.ajay-launcher.is-open .icon-chat    { transform: scale(0) rotate(-45deg); opacity: 0; }
.ajay-launcher.is-open .icon-close   { transform: scale(1) rotate(0deg);   opacity: 1; }
.ajay-launcher .icon-close           { position: absolute; transform: scale(0) rotate(45deg); opacity: 0; }

.ajay-launcher-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 18px;
  height: 18px;
  background: #10b981;
  border-radius: 50%;
  border: 2px solid #fff;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ── Chat Window ─────────────────────────────────────────────────────────── */
.ajay-window {
  position: absolute;
  bottom: 72px;
  width: 380px;
  height: 580px;
  background: var(--ajay-bg);
  border-radius: var(--ajay-radius);
  box-shadow: var(--ajay-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom center;
  transition: transform 0.3s cubic-bezier(.34,1.3,.64,1), opacity 0.25s ease;
  border: 1px solid var(--ajay-border);
}

#ajay-chatbot-root.position-bottom-right .ajay-window { right: 0; }
#ajay-chatbot-root.position-bottom-left  .ajay-window { left: 0; }

.ajay-window[aria-hidden="true"]  { transform: scale(0.85) translateY(20px); opacity: 0; pointer-events: none; }
.ajay-window[aria-hidden="false"] { transform: scale(1) translateY(0);       opacity: 1; }

/* ── Header ──────────────────────────────────────────────────────────────── */
.ajay-header {
  background: var(--ajay-primary);
  padding: 14px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.ajay-header-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
}

.ajay-header-info { flex: 1; min-width: 0; }

.ajay-header-name {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.ajay-header-status {
  font-size: 12px;
  color: rgba(255,255,255,0.8);
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 1px;
}

.ajay-status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #10b981;
  animation: ajay-pulse 2s infinite;
}

@keyframes ajay-pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.4; }
}

.ajay-header-close {
  background: none;
  border: none;
  color: rgba(255,255,255,0.8);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  transition: background 0.2s, color 0.2s;
}

.ajay-header-close:hover { background: rgba(255,255,255,0.15); color: #fff; }

/* ── GDPR Banner ─────────────────────────────────────────────────────────── */
.ajay-gdpr {
  background: var(--ajay-surface);
  padding: 16px;
  border-bottom: 1px solid var(--ajay-border);
  font-size: 13px;
  color: var(--ajay-text-muted);
}

.ajay-gdpr p { margin: 0 0 10px; line-height: 1.5; }

.ajay-gdpr-accept {
  display: inline-block;
  padding: 8px 18px;
  background: var(--ajay-primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.ajay-gdpr-accept:hover { background: var(--ajay-primary-dark); }

/* ── Messages ────────────────────────────────────────────────────────────── */
.ajay-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

.ajay-messages::-webkit-scrollbar { width: 4px; }
.ajay-messages::-webkit-scrollbar-thumb { background: var(--ajay-border); border-radius: 2px; }

.ajay-msg {
  max-width: 82%;
  display: flex;
  flex-direction: column;
  gap: 2px;
  animation: ajay-msg-in 0.25s ease;
}

@keyframes ajay-msg-in {
  from { opacity: 0; transform: translateY(10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.ajay-msg.user   { align-self: flex-end; align-items: flex-end; }
.ajay-msg.bot    { align-self: flex-start; align-items: flex-start; }

.ajay-bubble {
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.55;
  word-break: break-word;
  white-space: pre-wrap;
}

.ajay-msg.user .ajay-bubble {
  background: var(--ajay-primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}

.ajay-msg.bot .ajay-bubble {
  background: var(--ajay-bot-bg);
  color: var(--ajay-bot-text);
  border-bottom-left-radius: 4px;
}

.ajay-msg-time {
  font-size: 11px;
  color: var(--ajay-text-muted);
  padding: 0 4px;
}

/* Typing indicator */
.ajay-typing .ajay-bubble {
  padding: 12px 16px;
}

.ajay-typing-dots {
  display: flex;
  gap: 4px;
  align-items: center;
}

.ajay-typing-dots span {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--ajay-text-muted);
  animation: ajay-dot 1.2s infinite ease-in-out;
}

.ajay-typing-dots span:nth-child(1) { animation-delay: 0s; }
.ajay-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.ajay-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes ajay-dot {
  0%, 80%, 100% { transform: scale(0.7); opacity: 0.5; }
  40%           { transform: scale(1);   opacity: 1; }
}

/* ── Lead Form ───────────────────────────────────────────────────────────── */
.ajay-lead-form {
  margin: 8px 0;
  background: var(--ajay-surface);
  border: 1px solid var(--ajay-border);
  border-radius: 12px;
  padding: 14px;
  font-size: 13px;
}

.ajay-lead-form h4 { margin: 0 0 10px; font-size: 13px; color: var(--ajay-text); }

.ajay-lead-form input, .ajay-lead-form select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--ajay-border);
  border-radius: 8px;
  font-size: 13px;
  color: var(--ajay-text);
  background: var(--ajay-input-bg);
  margin-bottom: 8px;
  box-sizing: border-box;
  outline: none;
  font-family: var(--ajay-font);
}

.ajay-lead-form input:focus, .ajay-lead-form select:focus {
  border-color: var(--ajay-primary);
  box-shadow: 0 0 0 2px rgba(230,51,18,0.15);
}

.ajay-lead-submit {
  width: 100%;
  padding: 9px;
  background: var(--ajay-primary);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
}

.ajay-lead-submit:hover    { background: var(--ajay-primary-dark); }
.ajay-lead-submit:disabled { opacity: 0.6; cursor: not-allowed; }
.ajay-lead-skip  { display: block; text-align: center; margin-top: 6px; font-size: 12px; color: var(--ajay-text-muted); cursor: pointer; text-decoration: underline; background: none; border: none; }
.ajay-lead-skip:hover { color: var(--ajay-text); }

/* ── Input Area ──────────────────────────────────────────────────────────── */
.ajay-input-area {
  border-top: 1px solid var(--ajay-border);
  padding: 12px;
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
  background: var(--ajay-bg);
}

.ajay-input {
  flex: 1;
  padding: 10px 14px;
  border: 1px solid var(--ajay-border);
  border-radius: 22px;
  font-size: 14px;
  font-family: var(--ajay-font);
  background: var(--ajay-input-bg);
  color: var(--ajay-text);
  resize: none;
  outline: none;
  max-height: 120px;
  line-height: 1.4;
  transition: border-color 0.2s, box-shadow 0.2s;
}

.ajay-input:focus {
  border-color: var(--ajay-primary);
  box-shadow: 0 0 0 3px rgba(230,51,18,0.12);
}

.ajay-input::placeholder { color: var(--ajay-text-muted); }

.ajay-send-btn {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--ajay-primary);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.15s;
}

.ajay-send-btn:hover    { background: var(--ajay-primary-dark); }
.ajay-send-btn:active   { transform: scale(0.92); }
.ajay-send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.ajay-footer-note {
  text-align: center;
  font-size: 10px;
  color: var(--ajay-text-muted);
  padding: 0 12px 8px;
  flex-shrink: 0;
}

/* ── Quick Replies ───────────────────────────────────────────────────────── */
.ajay-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 4px 16px 8px;
}

.ajay-qr-btn {
  padding: 6px 12px;
  border: 1px solid var(--ajay-primary);
  background: transparent;
  color: var(--ajay-primary);
  border-radius: 14px;
  font-size: 12px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
  font-family: var(--ajay-font);
}

.ajay-qr-btn:hover { background: var(--ajay-primary); color: #fff; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .ajay-window {
    position: fixed !important;
    bottom: 0 !important;
    left: 0 !important;
    right: 0 !important;
    width: 100% !important;
    height: 100svh !important;
    border-radius: 0 !important;
    border-bottom-left-radius: 0 !important;
    border-bottom-right-radius: 0 !important;
  }

  #ajay-chatbot-root.position-bottom-right,
  #ajay-chatbot-root.position-bottom-left {
    right: 20px !important;
    left: auto !important;
    bottom: 20px !important;
  }
}

/* Admin styles piggyback off same file */
.ajay-admin .ajay-stats-grid { display: grid; grid-template-columns: repeat(auto-fill,minmax(160px,1fr)); gap: 16px; margin: 20px 0; }
.ajay-admin .ajay-stat-card { background: #fff; border: 1px solid #ddd; border-radius: 10px; padding: 20px; text-align: center; display: flex; flex-direction: column; align-items: center; gap: 6px; box-shadow: 0 1px 4px rgba(0,0,0,0.06); }
.ajay-admin .ajay-stat-card.highlight { border-color: #e63312; }
.ajay-admin .stat-icon   { font-size: 28px; }
.ajay-admin .stat-number { font-size: 32px; font-weight: 700; color: #1a1d23; }
.ajay-admin .stat-label  { font-size: 12px; color: #6b7280; }
.ajay-admin .ajay-chart-wrap { background: #fff; border: 1px solid #ddd; border-radius: 10px; padding: 20px; margin-bottom: 20px; }
.ajay-admin .ajay-two-col { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
.ajay-admin .ajay-card   { background: #fff; border: 1px solid #ddd; border-radius: 10px; padding: 20px; }
.ajay-badge { display: inline-block; padding: 2px 8px; background: #e63312; color: #fff; border-radius: 4px; font-size: 11px; font-weight: 600; text-transform: capitalize; }
.ajay-chat-log { max-height: 600px; overflow-y: auto; display: flex; flex-direction: column; gap: 12px; padding: 16px; background: #f9fafb; border: 1px solid #ddd; border-radius: 8px; }
.ajay-log-msg { max-width: 80%; padding: 10px 14px; border-radius: 12px; }
.ajay-log-user      { align-self: flex-end; background: #e63312; color: #fff; }
.ajay-log-assistant { align-self: flex-start; background: #fff; border: 1px solid #e5e7eb; }
.ajay-log-msg strong { display: block; font-size: 11px; margin-bottom: 4px; opacity: 0.7; }
.ajay-log-msg p  { margin: 0; font-size: 13px; }
.ajay-log-msg small { display: block; font-size: 11px; opacity: 0.5; margin-top: 4px; }
.ajay-settings-tabs .ajay-tab-content { padding-top: 16px; }
