/* ============================================================
   CHATBOT CSS — Clean, deduplicated, blue theme
   ============================================================ */

/* ── RESET ── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

/* ── DESIGN TOKENS ── */
:root {
  /* Backgrounds */
  --bg:        #0d0d12;
  --surface:   #16161f;
  --surface2:  #1e1e2a;
  --surface3:  #26263a;

  /* Borders */
  --border:    rgba(255, 255, 255, 0.07);
  --border2:   rgba(255, 255, 255, 0.12);

  /* Blues (primary accent) */
  --accent:    #6c63ff;
  --accent2:   #3b82f6;
  --user-bubble: linear-gradient(135deg, #2563eb, #3b82f6);
  --bot-bubble:  #1e1e2a;

  /* Text */
  --text:        #f0f0f8;
  --text-muted:  #9090b0;
  --text-dim:    #5a5a7a;

  /* Status */
  --green: #22c55e;

  /* Shape */
  --radius:    18px;
  --radius-sm: 10px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 12px 32px rgba(0, 0, 0, 0.15);
}

/* ── BASE ── */
html, body {
  height: 100%;
  font-family: 'Plus Jakarta Sans', sans-serif;
  overflow-x: hidden;
}

/* ============================================================
   FULL-PAGE CHAT (standalone page mode)
   ============================================================ */

body.chat-page {
  min-height: 100dvh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  background: var(--bg);
}

body.chat-page::before,
body.chat-page::after {
  content: '';
  position: fixed;
  border-radius: 50%;
  pointer-events: none;
  z-index: 0;
}
body.chat-page::before {
  width: 500px; height: 500px;
  top: -120px; left: -120px;
  background: radial-gradient(circle, rgba(59, 130, 246, 0.07) 0%, transparent 70%);
}
body.chat-page::after {
  width: 350px; height: 350px;
  bottom: -80px; right: -80px;
  background: radial-gradient(circle, rgba(139, 127, 255, 0.07) 0%, transparent 70%);
}

/* ── WRAP & CONTAINER ── */
.chat-wrap {
  position: relative;
  z-index: 1;
  width: 100%;
  max-width: 580px;
}

.chat-container {
  background: var(--surface);
  border: 1px solid var(--border2);
  border-radius: 24px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  height: 700px;
  box-shadow:
    0 0 0 1px rgba(108, 99, 255, 0.1),
    0 32px 64px rgba(0, 0, 0, 0.5);
}

/* ── MESSAGES AREA ── */
.chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.chat-messages::-webkit-scrollbar { width: 4px; }
.chat-messages::-webkit-scrollbar-track { background: transparent; }
.chat-messages::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

/* Date separator */
.chat-date {
  text-align: center;
  font-size: 11px;
  color: var(--text-dim);
  margin-bottom: 4px;
}

/* ── MESSAGE ROW ── */
.msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  animation: fadeSlide 0.22s ease both;
}
.msg.user { flex-direction: row-reverse; }

@keyframes fadeSlide {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.msg-avatar {
  width: 28px; height: 28px;
  border-radius: 9px;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  flex-shrink: 0;
}
.msg.user .msg-avatar { display: none; }

/* ── BUBBLES ── */
.bubble {
  max-width: 82%;
  padding: 11px 15px;
  border-radius: var(--radius);
  font-size: 14px;
  line-height: 1.65;
  word-break: break-word;
}
.user .bubble {
  background: var(--user-bubble);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.bot .bubble {
  background: var(--bot-bubble);
  color: var(--text);
  border: 1px solid var(--border);
  border-bottom-left-radius: 4px;
}

/* ── PLAIN TEXT (FAQ / AI response without markdown) ── */
.plain-text {
  font-size: 13px;
  line-height: 1.8;
  color: var(--text-muted);
  white-space: pre-wrap;
  word-break: break-word;
}
.plain-text b,
.plain-text strong { color: var(--text); font-weight: 600; }
.plain-text i,
.plain-text em     { color: var(--text-muted); font-style: italic; }
.plain-text a      { color: var(--accent2); text-decoration: none; }
.plain-text a:hover { text-decoration: underline; }
.plain-text code {
  font-family: monospace;
  font-size: 12px;
  background: rgba(108, 99, 255, 0.1);
  border: 1px solid rgba(108, 99, 255, 0.2);
  border-radius: 4px;
  padding: 1px 6px;
  color: var(--accent2);
}

/* ── MARKDOWN BODY ── */
.md-body { font-size: 13px; line-height: 1.8; color: var(--text-muted); }

.md-body .md-h1 {
  font-size: 15px; font-weight: 600; color: var(--text);
  margin: 0 0 12px; padding-bottom: 8px;
  border-bottom: 1px solid var(--border);
}
.md-body .md-h2 {
  font-size: 11px; font-weight: 600; color: var(--accent2);
  text-transform: uppercase; letter-spacing: 0.08em;
  margin: 16px 0 8px;
  display: flex; align-items: center; gap: 6px;
}
.md-body .md-h2::before {
  content: '';
  display: block;
  width: 3px; height: 12px;
  border-radius: 2px;
  background: var(--accent);
  flex-shrink: 0;
}
.md-body .md-h3 {
  font-size: 13px; font-weight: 600; color: var(--text);
  margin: 12px 0 6px;
}
.md-body .md-p { margin: 0 0 8px; color: var(--text-muted); }
.md-body .md-p:last-child { margin-bottom: 0; }

.md-body .md-ul,
.md-body .md-ol { list-style: none; margin: 4px 0 10px; padding: 0; }

.md-body .md-ul li {
  display: flex; align-items: flex-start; gap: 8px;
  font-size: 13px; color: var(--text-muted); padding: 3px 0;
}
.md-body .md-ul li::before {
  content: '';
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--accent2);
  flex-shrink: 0; margin-top: 7px;
}

.md-body .md-ol { counter-reset: md-ol; }
.md-body .md-ol li {
  counter-increment: md-ol;
  display: flex; align-items: flex-start; gap: 8px;
  font-size: 13px; color: var(--text-muted);
  padding: 5px 0; border-bottom: 1px solid var(--border);
}
.md-body .md-ol li:last-child { border-bottom: none; }
.md-body .md-ol li::before {
  content: counter(md-ol);
  min-width: 20px; height: 20px; border-radius: 6px;
  background: rgba(108, 99, 255, 0.12);
  border: 1px solid rgba(108, 99, 255, 0.25);
  color: var(--accent2); font-size: 10px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-top: 2px;
}

.md-body strong { color: var(--text); font-weight: 600; }
.md-body em     { color: var(--text-muted); font-style: italic; }
.md-body code {
  font-family: monospace; font-size: 12px;
  background: rgba(108, 99, 255, 0.1);
  border: 1px solid rgba(108, 99, 255, 0.2);
  border-radius: 4px; padding: 1px 6px;
  color: var(--accent2);
}
.md-body .md-hr {
  border: none;
  border-top: 1px solid var(--border);
  margin: 10px 0;
}
.md-body .md-blockquote {
  border-left: 3px solid var(--accent);
  padding: 6px 12px; margin: 8px 0;
  background: rgba(108, 99, 255, 0.06);
  border-radius: 0 6px 6px 0;
  font-size: 13px; color: var(--text-muted);
}
.md-footer-note {
  margin-top: 10px; padding-top: 8px;
  border-top: 1px solid var(--border);
  font-size: 11px; color: var(--text-dim);
  display: flex; align-items: center; gap: 5px;
  font-style: italic;
}
.md-footer-note::before {
  content: '';
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--accent2); flex-shrink: 0;
}

/* Source badge */
.source-badge {
  display: inline-block; font-size: 10px;
  padding: 2px 7px; border-radius: 20px; margin-top: 6px;
  border: 1px solid var(--border2);
  color: var(--text-dim); background: var(--surface3);
}

/* ── TYPING INDICATOR ── */
.typing-dots { display: flex; gap: 5px; padding: 14px 16px; }
.typing-dots span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--accent2); opacity: 0.4;
  animation: bounce 1.2s infinite;
}
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }

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

/* ── QUICK REPLIES ── */
.quick-replies { padding: 12px 18px 0; flex-shrink: 0; }
.quick-label {
  font-size: 10px; font-weight: 600; color: var(--text-dim);
  text-transform: uppercase; letter-spacing: 0.08em;
  margin-bottom: 8px;
}
.quick-list { display: flex; flex-wrap: wrap; gap: 7px; }
.quick-btn {
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 12px; font-weight: 500;
  color: var(--accent2);
  background: rgba(108, 99, 255, 0.08);
  border: 1px solid rgba(108, 99, 255, 0.25);
  border-radius: 20px; padding: 6px 13px;
  cursor: pointer; transition: all 0.18s ease; white-space: nowrap;
}
.quick-btn:hover {
  background: rgba(108, 99, 255, 0.18);
  border-color: rgba(108, 99, 255, 0.5);
  color: #fff; transform: translateY(-1px);
}
.quick-btn:active { transform: translateY(0); }

/* ── INPUT AREA ── */
.chat-input-wrap { padding: 12px 18px 18px; flex-shrink: 0; }
.chat-input {
  display: flex; align-items: center; gap: 8px;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 14px; padding: 8px 8px 8px 16px;
  transition: border-color 0.2s;
}
.chat-input:focus-within {
  border-color: rgba(108, 99, 255, 0.5);
  box-shadow: 0 0 0 3px rgba(108, 99, 255, 0.1);
}
.chat-input input {
  flex: 1; border: none; background: transparent;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 14px; color: var(--text); outline: none;
}
.chat-input input::placeholder { color: var(--text-dim); }

.send-btn {
  width: 36px; height: 36px; border-radius: 10px;
  background: var(--user-bubble);
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all 0.18s; flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.35);
}
.send-btn:hover  { transform: scale(1.05); box-shadow: 0 6px 16px rgba(37, 99, 235, 0.45); }
.send-btn:active { transform: scale(0.96); }
.send-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; }
.send-btn svg { fill: #fff; width: 16px; height: 16px; }

/* ── PLAN / PRODUCT CARDS ── */
.product-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
}

.plan-card {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 12px 14px;
  margin-bottom: 8px;
  transition: border-color 0.2s, transform 0.2s, box-shadow 0.2s;
}
.plan-card:hover {
  border-color: rgba(59, 130, 246, 0.4);
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.15);
}
.plan-card-name     { font-size: 13px; font-weight: 600; color: var(--text); }
.plan-card-price    { font-size: 19px; font-weight: 600; color: var(--accent2); margin: 4px 0 2px; }
.plan-card-duration { font-size: 11px; color: var(--text-dim); }
.plan-card-features { margin-top: 8px; list-style: none; }
.plan-card-features li {
  font-size: 12px; color: var(--text-muted);
  padding: 2px 0; display: flex; align-items: center; gap: 6px;
}
.plan-card-features li::before {
  content: '';
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--green); flex-shrink: 0;
}
.buy-btn {
  margin-top: 10px; width: 100%;
  font-family: 'Plus Jakarta Sans', sans-serif;
  font-size: 12px; font-weight: 600; padding: 8px;
  border-radius: 8px;
  border: 1px solid rgba(59, 130, 246, 0.4);
  background: rgba(59, 130, 246, 0.1);
  color: var(--accent2);
  cursor: pointer; transition: all 0.18s;
}
.buy-btn:hover {
  background: var(--accent2);
  color: #fff;
  border-color: var(--accent2);
}

/* ── AI ANSWER BLOCK ── */
.ai-answer { width: 100%; font-size: 13px; line-height: 1.7; color: var(--text); }

.ai-answer .ai-header {
  display: flex; align-items: center; gap: 8px;
  margin-bottom: 12px; padding-bottom: 10px;
  border-bottom: 1px solid var(--border);
}
.ai-answer .ai-icon {
  width: 28px; height: 28px; border-radius: 8px;
  background: rgba(59, 130, 246, 0.15);
  border: 1px solid rgba(59, 130, 246, 0.3);
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; flex-shrink: 0;
}
.ai-answer .ai-title    { font-size: 13px; font-weight: 600; color: var(--text); }
.ai-answer .ai-subtitle { font-size: 11px; color: var(--text-dim); margin-top: 1px; }

.ai-answer .ai-section { margin-bottom: 12px; }
.ai-answer .ai-section-label {
  font-size: 10px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.08em;
  color: var(--accent2); margin-bottom: 6px;
}
.ai-answer .ai-prose { font-size: 13px; line-height: 1.75; color: var(--text-muted); }

.ai-answer .ai-steps { list-style: none; counter-reset: steps; }
.ai-answer .ai-steps li {
  counter-increment: steps;
  display: flex; align-items: flex-start; gap: 10px;
  padding: 6px 0; border-bottom: 1px solid var(--border);
  font-size: 13px; color: var(--text-muted);
}
.ai-answer .ai-steps li:last-child { border-bottom: none; }
.ai-answer .ai-steps li::before {
  content: counter(steps);
  min-width: 20px; height: 20px; border-radius: 6px;
  background: rgba(59, 130, 246, 0.12);
  border: 1px solid rgba(59, 130, 246, 0.25);
  color: var(--accent2); font-size: 10px; font-weight: 600;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0; margin-top: 2px;
}

.ai-answer .ai-bullets { list-style: none; }
.ai-answer .ai-bullets li {
  display: flex; align-items: flex-start; gap: 8px;
  padding: 5px 0; font-size: 13px; color: var(--text-muted);
}
.ai-answer .ai-bullets li::before {
  content: '';
  width: 5px; height: 5px; border-radius: 50%;
  background: var(--accent2); flex-shrink: 0; margin-top: 6px;
}

.ai-answer .ai-highlight {
  background: rgba(59, 130, 246, 0.08);
  border: 1px solid rgba(59, 130, 246, 0.2);
  border-radius: 8px; padding: 10px 12px; margin: 8px 0;
  font-size: 12px; color: var(--text-muted); line-height: 1.6;
}
.ai-answer .ai-highlight strong { color: var(--accent2); font-weight: 600; }

.ai-answer .ai-warning {
  background: rgba(239, 159, 39, 0.08);
  border: 1px solid rgba(239, 159, 39, 0.25);
  border-radius: 8px; padding: 10px 12px; margin: 8px 0;
  font-size: 12px; color: #c9903a;
  display: flex; gap: 8px;
}

.ai-answer .ai-footer {
  margin-top: 12px; padding-top: 10px;
  border-top: 1px solid var(--border);
  font-size: 11px; color: var(--text-dim);
  display: flex; align-items: center; gap: 6px;
}
.ai-answer .ai-footer::before {
  content: '';
  width: 4px; height: 4px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 4px rgba(34, 197, 94, 0.5);
}

/* ============================================================
   FLOATING CHATBOT WIDGET (popup mode)
   ============================================================ */

/* ── TRIGGER BUTTON ── */
.chatbot-trigger {
  position: fixed;
  bottom: 50px; right: 24px;
  z-index: 999;
  padding: 12px 18px;
  border-radius: 999px;
  background: var(--user-bubble);
  border: none; cursor: pointer;
  box-shadow: var(--shadow-lg);
  display: flex; align-items: center; gap: 8px;
  color: #fff; font-size: 14px; font-weight: 600;
  transition: all 0.25s ease;
}
.chatbot-trigger:hover {
  transform: scale(1.1);
  box-shadow: 0 10px 25px rgba(37, 99, 235, 0.35);
}
.chatbot-trigger:active { transform: scale(0.95); }
.chatbot-trigger.active { display: none; }

/* Notification badge */
.chatbot-badge {
  position: absolute; top: -8px; right: -8px;
  min-width: 24px; height: 24px;
  background: #ef4444; color: #fff;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 11px; font-weight: 600;
  box-shadow: var(--shadow-md);
  animation: pulse 2s infinite;
}
@keyframes pulse {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.15); }
}

/* Trigger icon */
.chatbot-icon {
  width: 22px; height: 22px;
  object-fit: cover; border-radius: 50%;
  background: #fff; padding: 2px;
  border: 1px solid rgba(255, 255, 255, 0.3);
  box-shadow: 0 0 6px rgba(59, 130, 246, 0.6);
}
.chatbot-content {
  display: flex; align-items: center; gap: 6px;
}

/* ── POPUP WINDOW ── */
.chatbot-popup {
  position: fixed;
  bottom: 70px; right: 24px;
  z-index: 998;
  width: 100%; max-width: 420px;
  height: 600px;
  background: var(--surface);
  border-radius: 16px;
  box-shadow: var(--shadow-lg);
  display: none;
  flex-direction: column;
  opacity: 0;
  transform: translateY(20px) scale(0.95);
  transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  overflow: hidden;
}
.chatbot-popup.open {
  display: flex;
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* ── POPUP HEADER ── */
.chatbot-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  background: var(--surface2);
  border-bottom: 1px solid var(--border);
  color: #fff; flex-shrink: 0;
}
.chatbot-header__info {
  display: flex; align-items: center; gap: 12px;
}
.chatbot-header__avatar {
  width: 40px; height: 40px; border-radius: 10px;
  background: transparent;
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 600;
}
.chatbot-header__img {
  width: 35px; height: 35px;
  object-fit: cover; border-radius: 50%;
}
.chatbot-header__title {
  font-size: 14px; font-weight: 600; line-height: 1.2;
}
.chatbot-header__status {
  font-size: 11px; color: var(--text-muted);
  display: flex; align-items: center; gap: 5px; margin-top: 2px;
}
.chatbot-status-dot {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px rgba(34, 197, 94, 0.6);
  animation: blink 2s infinite;
}
@keyframes blink {
  0%, 100% { opacity: 1; }
  50%       { opacity: 0.6; }
}
.chatbot-header__close {
  width: 32px; height: 32px;
  border: none; background: rgba(255, 255, 255, 0.1);
  border-radius: 8px; cursor: pointer;
  color: #fff; font-size: 18px;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.2s;
}
.chatbot-header__close:hover { background: rgba(255, 255, 255, 0.2); }

/* ── IFRAME INSIDE POPUP ── */
.chatbot-iframe-container {
  flex: 1; overflow: hidden; position: relative;
}
.chatbot-iframe-container iframe {
  width: 100%; height: 100%; border: none;
}
.chatbot-loading {
  position: absolute; inset: 0;
  display: flex; align-items: center; justify-content: center;
  background: var(--surface); z-index: 10;
}
.chatbot-loading::after {
  content: '';
  width: 32px; height: 32px;
  border: 2px solid var(--border);
  border-top-color: var(--accent2);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   RESPONSIVE
   ============================================================ */
@media (min-width: 992px) {
  .product-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 620px) {
  body.chat-page {
    padding: 0;
    align-items: stretch;
  }
  body.chat-page::before,
  body.chat-page::after { display: none; }

  .chat-wrap {
    max-width: 100%; height: 100dvh;
    display: flex; flex-direction: column;
  }
  .chat-container {
    border-radius: 0; border: none;
    height: 100%; box-shadow: none; flex: 1;
  }
  .chat-messages { padding: 16px 14px; }
  .quick-replies { padding: 10px 14px 0; }
  .chat-input-wrap {
    padding: 10px 14px;
    padding-bottom: calc(12px + env(safe-area-inset-bottom));
  }
  .bubble { max-width: 88%; }
}

@media (max-width: 480px) {
  .chatbot-popup {
    max-width: calc(100% - 24px);
    height: 70vh;
    bottom: 165px; right: 12px;
  }
  .chatbot-trigger {
    bottom: 115px; right: 16px;
    padding: 10px 14px;
    font-size: 13px; gap: 6px;
  }
  .chatbot-icon { width: 18px; height: 18px; }
}

@media (max-width: 320px) {
  .chatbot-popup { max-width: calc(100% - 12px); }
}