/* ============================================================
   AI ChatBot Pro - Frontend Styles
   ============================================================ */

:root {
  --aicb-primary: #4F46E5;
  --aicb-primary-dark: #3730A3;
  --aicb-secondary: #7C3AED;
  --aicb-radius: 20px;
  --aicb-shadow: 0 20px 60px rgba(0,0,0,0.18), 0 4px 16px rgba(0,0,0,0.1);
  --aicb-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --aicb-transition: 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
  --aicb-chat-bg: #F8F9FF;
  --aicb-user-bubble: #4F46E5;
  --aicb-bot-bubble: #FFFFFF;
  --aicb-text-dark: #1e1b4b;
  --aicb-text-mid: #64748b;
  --aicb-border: #E8EAFB;
}

/* ── Launcher Button ────────────────────────────────────── */
#aicb-launcher {
  position: fixed;
  bottom: 28px;
  left: 28px;
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--aicb-primary) 0%, var(--aicb-secondary) 100%);
  box-shadow: 0 8px 24px rgba(79,70,229,0.45), 0 2px 8px rgba(0,0,0,0.15);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  z-index: 99998;
  transition: transform 0.25s ease, box-shadow 0.25s ease;
  outline: none;
}

#aicb-launcher:hover {
  transform: scale(1.08);
  box-shadow: 0 12px 32px rgba(79,70,229,0.55), 0 4px 12px rgba(0,0,0,0.2);
}

#aicb-launcher:active { transform: scale(0.96); }

#aicb-launcher.aicb-position-right {
  left: auto;
  right: 28px;
}

#aicb-launcher .aicb-robot-icon {
  width: 34px;
  height: 34px;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

#aicb-launcher .aicb-close-icon {
  width: 22px;
  height: 22px;
  display: none;
  opacity: 0;
  transition: opacity 0.2s ease;
}

#aicb-launcher.is-open .aicb-robot-icon { opacity: 0; transform: scale(0.7); display: none; }
#aicb-launcher.is-open .aicb-close-icon { display: block; opacity: 1; }

/* Pulse ring */
#aicb-launcher::before {
  content: '';
  position: absolute;
  inset: -6px;
  border-radius: 50%;
  border: 2px solid var(--aicb-primary);
  opacity: 0;
  animation: aicb-pulse 2.4s ease-out 1.5s infinite;
}

@keyframes aicb-pulse {
  0% { transform: scale(0.85); opacity: 0.6; }
  70% { transform: scale(1.25); opacity: 0; }
  100% { opacity: 0; }
}

/* Notification dot */
#aicb-launcher .aicb-notif-dot {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 10px;
  height: 10px;
  background: #EF4444;
  border-radius: 50%;
  border: 2px solid #fff;
}

/* ── Chat Window ────────────────────────────────────────── */
#aicb-window {
  position: fixed;
  bottom: 104px;
  left: 28px;
  width: 380px;
  max-height: 600px;
  border-radius: var(--aicb-radius);
  background: #fff;
  box-shadow: var(--aicb-shadow);
  display: flex;
  flex-direction: column;
  z-index: 99999;
  font-family: var(--aicb-font);
  overflow: hidden;
  transform: scale(0.9) translateY(16px);
  transform-origin: bottom left;
  opacity: 0;
  pointer-events: none;
  transition: transform var(--aicb-transition), opacity 0.25s ease;
}

#aicb-window.aicb-position-right {
  left: auto;
  right: 28px;
  transform-origin: bottom right;
}

#aicb-window.is-open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* ── Header ─────────────────────────────────────────────── */
.aicb-header {
  background: linear-gradient(135deg, var(--aicb-primary) 0%, var(--aicb-secondary) 100%);
  padding: 18px 18px 16px;
  display: flex;
  align-items: center;
  gap: 12px;
  position: relative;
  flex-shrink: 0;
}

.aicb-header-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  border: 2px solid rgba(255,255,255,0.3);
}

.aicb-header-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.aicb-header-avatar svg {
  width: 22px;
  height: 22px;
  fill: #fff;
}

.aicb-header-info { flex: 1; min-width: 0; }
.aicb-header-title {
  color: #fff;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: -0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.aicb-header-subtitle {
  color: rgba(255,255,255,0.8);
  font-size: 12px;
  margin-top: 2px;
}

.aicb-status-dot {
  display: inline-block;
  width: 7px;
  height: 7px;
  background: #86EFAC;
  border-radius: 50%;
  margin-right: 5px;
  box-shadow: 0 0 0 2px rgba(134,239,172,0.3);
}

.aicb-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.aicb-header-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: rgba(255,255,255,0.15);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s;
  color: #fff;
}
.aicb-header-btn:hover { background: rgba(255,255,255,0.28); }
.aicb-header-btn svg { width: 16px; height: 16px; }

.aicb-voice-btn.voice-active {
  background: rgba(134,239,172,0.25);
  box-shadow: 0 0 0 2px rgba(134,239,172,0.4);
}

/* ── Messages ───────────────────────────────────────────── */
.aicb-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  background: var(--aicb-chat-bg);
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}

.aicb-messages::-webkit-scrollbar { width: 4px; }
.aicb-messages::-webkit-scrollbar-track { background: transparent; }
.aicb-messages::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 4px; }

/* Message bubbles */
.aicb-msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  animation: aicb-slide-in 0.3s ease;
}

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

.aicb-msg.aicb-msg-user { flex-direction: row-reverse; }

.aicb-msg-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--aicb-primary), var(--aicb-secondary));
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.aicb-msg-avatar svg { width: 14px; height: 14px; fill: #fff; }

.aicb-msg-bubble {
  max-width: 78%;
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.5;
  word-break: break-word;
}

.aicb-msg-bot .aicb-msg-bubble {
  background: var(--aicb-bot-bubble);
  color: var(--aicb-text-dark);
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

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

/* Typing indicator */
.aicb-typing-dots {
  display: flex;
  gap: 4px;
  padding: 12px 14px;
  background: var(--aicb-bot-bubble);
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,0.08);
  width: fit-content;
}
.aicb-typing-dots span {
  width: 7px;
  height: 7px;
  background: #c7d0e8;
  border-radius: 50%;
  animation: aicb-bounce 1.3s ease-in-out infinite;
}
.aicb-typing-dots span:nth-child(2) { animation-delay: 0.15s; }
.aicb-typing-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes aicb-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-6px); }
}

/* ── Starter Questions ──────────────────────────────────── */
.aicb-starters {
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  padding: 4px 0 2px;
}

.aicb-starter-btn {
  padding: 7px 12px;
  border-radius: 20px;
  border: 1.5px solid var(--aicb-primary);
  background: rgba(79,70,229,0.06);
  color: var(--aicb-primary);
  font-size: 12px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.2s, transform 0.15s;
  white-space: nowrap;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
}
.aicb-starter-btn:hover {
  background: var(--aicb-primary);
  color: #fff;
  transform: translateY(-1px);
}

/* ── Promo Banners ──────────────────────────────────────── */
.aicb-banner {
  border-radius: 14px;
  overflow: hidden;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  animation: aicb-slide-in 0.4s ease;
  flex-shrink: 0;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}
.aicb-banner:hover { transform: translateY(-2px); box-shadow: 0 6px 20px rgba(0,0,0,0.14); }

.aicb-banner-inner {
  display: flex;
  align-items: center;
  padding: 12px 14px;
  gap: 12px;
}

.aicb-banner-img {
  width: 50px;
  height: 50px;
  border-radius: 10px;
  object-fit: cover;
  flex-shrink: 0;
}

.aicb-banner-content { flex: 1; min-width: 0; }
.aicb-banner-title {
  font-weight: 700;
  font-size: 13px;
  line-height: 1.3;
  margin-bottom: 2px;
}
.aicb-banner-desc {
  font-size: 11.5px;
  opacity: 0.8;
  line-height: 1.4;
}

.aicb-banner-cta {
  display: inline-block;
  margin-top: 7px;
  padding: 5px 12px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-decoration: none;
  transition: opacity 0.2s, transform 0.15s;
}
.aicb-banner-cta:hover { opacity: 0.85; transform: scale(1.03); }

.aicb-banner-close {
  position: absolute;
  top: 8px;
  right: 10px;
  background: none;
  border: none;
  cursor: pointer;
  opacity: 0.5;
  font-size: 16px;
  line-height: 1;
  padding: 2px;
}
.aicb-banner-close:hover { opacity: 1; }

/* ── Input Area ─────────────────────────────────────────── */
.aicb-input-area {
  padding: 12px 14px;
  background: #fff;
  border-top: 1px solid var(--aicb-border);
  flex-shrink: 0;
}

.aicb-input-row {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--aicb-chat-bg);
  border: 1.5px solid var(--aicb-border);
  border-radius: 26px;
  padding: 6px 8px 6px 16px;
  transition: border-color 0.2s;
}
.aicb-input-row:focus-within { border-color: var(--aicb-primary); }

#aicb-input {
  flex: 1;
  border: none;
  background: transparent;
  outline: none;
  font-size: 14px;
  color: var(--aicb-text-dark);
  font-family: var(--aicb-font);
  resize: none;
  max-height: 80px;
  line-height: 1.5;
}

#aicb-input::placeholder { color: #94a3b8; }

.aicb-input-btn {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.15s, opacity 0.15s;
}
.aicb-input-btn:hover { transform: scale(1.1); }
.aicb-input-btn:active { transform: scale(0.95); }

.aicb-mic-btn {
  background: transparent;
  color: var(--aicb-text-mid);
}
.aicb-mic-btn.recording {
  background: #FEE2E2;
  color: #EF4444;
  animation: aicb-mic-pulse 1s ease infinite;
}
@keyframes aicb-mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(239,68,68,0.3); }
  50% { box-shadow: 0 0 0 6px rgba(239,68,68,0); }
}

.aicb-send-btn {
  background: linear-gradient(135deg, var(--aicb-primary), var(--aicb-secondary));
  color: #fff;
}
.aicb-send-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }

.aicb-input-footer {
  text-align: center;
  font-size: 10.5px;
  color: #94a3b8;
  margin-top: 8px;
}
.aicb-input-footer a { color: var(--aicb-primary); text-decoration: none; }

/* ── Voice Speaking Indicator ───────────────────────────── */
.aicb-speaking-bar {
  display: none;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 6px 0 2px;
}
.aicb-speaking-bar.active { display: flex; }
.aicb-speaking-bar span {
  display: inline-block;
  width: 3px;
  background: var(--aicb-primary);
  border-radius: 3px;
  animation: aicb-speak 0.7s ease-in-out infinite alternate;
}
.aicb-speaking-bar span:nth-child(1) { height: 8px; animation-delay: 0s; }
.aicb-speaking-bar span:nth-child(2) { height: 16px; animation-delay: 0.1s; }
.aicb-speaking-bar span:nth-child(3) { height: 22px; animation-delay: 0.2s; }
.aicb-speaking-bar span:nth-child(4) { height: 16px; animation-delay: 0.3s; }
.aicb-speaking-bar span:nth-child(5) { height: 8px; animation-delay: 0.4s; }
@keyframes aicb-speak {
  from { transform: scaleY(0.4); }
  to   { transform: scaleY(1); }
}

/* ── Responsive ─────────────────────────────────────────── */
@media (max-width: 480px) {
  #aicb-window {
    width: calc(100vw - 24px);
    left: 12px;
    right: 12px;
    bottom: 90px;
    max-height: 70vh;
  }
  #aicb-window.aicb-position-right { left: 12px; right: 12px; }
  #aicb-launcher { bottom: 20px; left: 16px; }
  #aicb-launcher.aicb-position-right { left: auto; right: 16px; }
}
