/* ============================================================
   AI Site Chatbot – CSS
   ============================================================ */

:root {
  --aiscb-accent: #2563eb;          /* overridden by JS */
  --aiscb-accent-dark: #1d4ed8;
  --aiscb-radius: 18px;
  --aiscb-shadow: 0 8px 40px rgba(0,0,0,.18);
  --aiscb-font: 'Segoe UI', system-ui, sans-serif;
}

/* ── Launcher button ─────────────────────────────────────── */
#aiscb-launcher {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: 999998;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: var(--aiscb-accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: var(--aiscb-shadow);
  transition: transform .25s cubic-bezier(.34,1.56,.64,1), background .2s;
}
#aiscb-launcher:hover { background: var(--aiscb-accent-dark); transform: scale(1.1); }
#aiscb-launcher.hidden { display: none; }

/* Pulse ring */
#aiscb-launcher::after {
  content: '';
  position: absolute;
  width: 100%; height: 100%;
  border-radius: 50%;
  border: 3px solid var(--aiscb-accent);
  animation: aiscb-pulse 2.5s ease infinite;
}
@keyframes aiscb-pulse {
  0%   { transform: scale(1); opacity: .6; }
  70%  { transform: scale(1.5); opacity: 0; }
  100% { opacity: 0; }
}

/* ── Chat window ─────────────────────────────────────────── */
#aiscb-window {
  position: fixed;
  bottom: 100px;
  right: 28px;
  z-index: 999999;
  width: 370px;
  max-width: calc(100vw - 32px);
  border-radius: var(--aiscb-radius);
  background: #fff;
  box-shadow: var(--aiscb-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: var(--aiscb-font);
  font-size: 14px;
  color: #1a1a2e;
  transform: scale(.9) translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: transform .3s cubic-bezier(.34,1.56,.64,1), opacity .2s;
  max-height: 85vh;
}
#aiscb-window.open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* ── Header ──────────────────────────────────────────────── */
#aiscb-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  background: var(--aiscb-accent);
  color: #fff;
  flex-shrink: 0;
}
#aiscb-header-avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,.25) url('') center/cover no-repeat;
  flex-shrink: 0;
  display: flex; align-items: center; justify-content: center;
  font-size: 18px;
}
#aiscb-header-info { flex: 1; }
#aiscb-header-info strong { display: block; font-size: 15px; }
#aiscb-status { font-size: 11px; opacity: .85; }
#aiscb-close {
  background: none; border: none; color: #fff; cursor: pointer;
  font-size: 18px; line-height: 1; padding: 4px;
  border-radius: 50%; transition: background .15s;
}
#aiscb-close:hover { background: rgba(255,255,255,.2); }

/* ── Body ────────────────────────────────────────────────── */
#aiscb-body {
  flex: 1;
  overflow: hidden;
  position: relative;
  min-height: 300px;
}
.aiscb-step {
  position: absolute;
  inset: 0;
  overflow-y: auto;
  padding: 16px;
  display: none;
  flex-direction: column;
  gap: 10px;
  transition: opacity .2s;
}
.aiscb-step.active { display: flex; }

/* ── Welcome bubble ──────────────────────────────────────── */
#aiscb-welcome-bubble {
  background: #f1f5f9;
  border-radius: 4px 18px 18px 18px;
  padding: 12px 14px;
  color: #334155;
  line-height: 1.55;
  margin-bottom: 4px;
}

/* ── Info form ───────────────────────────────────────────── */
#aiscb-info-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}
#aiscb-info-form label {
  display: flex;
  flex-direction: column;
  gap: 4px;
  font-size: 12px;
  font-weight: 600;
  color: #64748b;
  text-transform: uppercase;
  letter-spacing: .5px;
}
.req { color: var(--aiscb-accent); }
#aiscb-info-form input {
  padding: 10px 12px;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  font-size: 14px;
  font-family: var(--aiscb-font);
  color: #1e293b;
  transition: border-color .15s;
  outline: none;
}
#aiscb-info-form input:focus { border-color: var(--aiscb-accent); }
#aiscb-start-btn {
  margin-top: 4px;
  padding: 12px;
  background: var(--aiscb-accent);
  color: #fff;
  border: none;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: background .2s, transform .15s;
}
#aiscb-start-btn:hover { background: var(--aiscb-accent-dark); transform: translateY(-1px); }

/* ── Messages ────────────────────────────────────────────── */
#aiscb-messages {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 16px;
  overflow-y: auto;
  max-height: 380px;
}
.aiscb-msg {
  display: flex;
  flex-direction: column;
  max-width: 82%;
  animation: aiscb-pop-in .2s ease;
}
@keyframes aiscb-pop-in {
  from { transform: translateY(6px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
.aiscb-msg.user { align-self: flex-end; align-items: flex-end; }
.aiscb-msg.bot  { align-self: flex-start; align-items: flex-start; }

.aiscb-bubble {
  padding: 10px 14px;
  border-radius: 18px;
  line-height: 1.55;
  word-break: break-word;
}
.aiscb-msg.user .aiscb-bubble {
  background: var(--aiscb-accent);
  color: #fff;
  border-radius: 18px 18px 4px 18px;
}
.aiscb-msg.bot .aiscb-bubble {
  background: #f1f5f9;
  color: #1e293b;
  border-radius: 4px 18px 18px 18px;
}
.aiscb-meta {
  font-size: 10px;
  color: #94a3b8;
  margin-top: 3px;
  padding: 0 4px;
}

/* Typing indicator */
.aiscb-typing .aiscb-bubble {
  display: flex;
  gap: 4px;
  align-items: center;
  padding: 12px 16px;
}
.aiscb-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #94a3b8;
  animation: aiscb-bounce .9s ease infinite;
}
.aiscb-dot:nth-child(2) { animation-delay: .15s; }
.aiscb-dot:nth-child(3) { animation-delay: .3s; }
@keyframes aiscb-bounce {
  0%, 80%, 100% { transform: translateY(0); }
  40%           { transform: translateY(-6px); }
}

/* ── Footer input ────────────────────────────────────────── */
#aiscb-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid #e2e8f0;
  background: #fff;
  flex-shrink: 0;
}
#aiscb-input {
  flex: 1;
  border: 1.5px solid #e2e8f0;
  border-radius: 24px;
  padding: 10px 16px;
  font-size: 14px;
  font-family: var(--aiscb-font);
  color: #1e293b;
  outline: none;
  transition: border-color .15s;
}
#aiscb-input:focus { border-color: var(--aiscb-accent); }
#aiscb-input:disabled { opacity: .5; }
#aiscb-send {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: var(--aiscb-accent);
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background .2s, transform .15s;
}
#aiscb-send:hover { background: var(--aiscb-accent-dark); transform: scale(1.08); }
#aiscb-send:disabled { opacity: .5; cursor: not-allowed; transform: none; }

/* ── Step 2 active ───────────────────────────────────────── */
#aiscb-step-chat.active {
  display: flex;
  padding: 0;
}
#aiscb-step-chat.active #aiscb-messages {
  width: 100%;
}

/* ── Scrollbar ───────────────────────────────────────────── */
#aiscb-messages::-webkit-scrollbar { width: 4px; }
#aiscb-messages::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 2px; }

/* ── Mobile ──────────────────────────────────────────────── */
@media (max-width: 480px) {
  #aiscb-window {
    bottom: 0; right: 0;
    width: 100%; max-width: 100%;
    border-radius: 20px 20px 0 0;
    max-height: 90vh;
  }
  #aiscb-launcher { bottom: 20px; right: 20px; }
}
