/* ═══════════════════════════════════════════════════════════════════════
   CHATBOT WIDGET — dark sci-fi, glass-morphism (T7), T10 shimmer
   Shared by all 4 demos. Accent colour driven by [data-demo] attribute.
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Accent tokens per demo ─────────────────────────────────────────── */

.chatbot-panel[data-demo="presales"] {
  --cb-accent:       #22D3EE;
  --cb-accent-dim:   rgba(34, 211, 238, 0.15);
  --cb-accent-glow:  rgba(34, 211, 238, 0.20);
  --cb-accent-glow2: rgba(34, 211, 238, 0.10);
  --cb-accent-ring:  rgba(34, 211, 238, 0.60);
  --cb-header-grad:  rgba(34, 211, 238, 0.06);
}
.chatbot-panel[data-demo="megacorp"] {
  --cb-accent:       #A855F7;
  --cb-accent-dim:   rgba(168, 85, 247, 0.15);
  --cb-accent-glow:  rgba(168, 85, 247, 0.20);
  --cb-accent-glow2: rgba(168, 85, 247, 0.10);
  --cb-accent-ring:  rgba(168, 85, 247, 0.60);
  --cb-header-grad:  rgba(168, 85, 247, 0.06);
}
.chatbot-panel[data-demo="loan"] {
  --cb-accent:       #10F2A6;
  --cb-accent-dim:   rgba(16, 242, 166, 0.15);
  --cb-accent-glow:  rgba(16, 242, 166, 0.20);
  --cb-accent-glow2: rgba(16, 242, 166, 0.10);
  --cb-accent-ring:  rgba(16, 242, 166, 0.60);
  --cb-header-grad:  rgba(16, 242, 166, 0.06);
}
.chatbot-panel[data-demo="readiness"] {
  --cb-accent:       #F59E0B;
  --cb-accent-dim:   rgba(245, 158, 11, 0.15);
  --cb-accent-glow:  rgba(245, 158, 11, 0.20);
  --cb-accent-glow2: rgba(245, 158, 11, 0.10);
  --cb-accent-ring:  rgba(245, 158, 11, 0.60);
  --cb-header-grad:  rgba(245, 158, 11, 0.06);
}

/* ── Animated border ring — mirrors orb-breathe ────────────────────── */

@property --cb-ring-alpha {
  syntax: '<number>';
  initial-value: 0.20;
  inherits: false;
}

@keyframes cb-ring-breathe {
  0%, 100% { --cb-ring-alpha: 0.20; outline-offset: 0px;  outline-width: 1px; }
  50%       { --cb-ring-alpha: 0.80; outline-offset: 12px; outline-width: 1px; }
}

/* Outer glow pulse — second ring via box-shadow spread, offset phase like orb__ring--2 */
@keyframes cb-glow-breathe {
  0%, 100% {
    box-shadow:
      0 24px 60px rgba(0, 0, 0, 0.65),
      0 0 0 1px rgba(255, 255, 255, 0.04),
      0 0 0 0px   color-mix(in srgb, var(--cb-accent) 18%, transparent),
      0 0 40px var(--cb-accent-glow),
      0 0 80px  var(--cb-accent-glow2);
  }
  50% {
    box-shadow:
      0 24px 60px rgba(0, 0, 0, 0.65),
      0 0 0 1px rgba(255, 255, 255, 0.04),
      0 0 0 18px  color-mix(in srgb, var(--cb-accent) 10%, transparent),
      0 0 60px var(--cb-accent-glow),
      0 0 120px var(--cb-accent-glow2);
  }
}

/* ── Panel ──────────────────────────────────────────────────────────── */

.chatbot-panel {
  /* Default tokens (before data-demo is set) */
  --cb-accent:       #22D3EE;
  --cb-accent-dim:   rgba(34, 211, 238, 0.15);
  --cb-accent-glow:  rgba(34, 211, 238, 0.20);
  --cb-accent-glow2: rgba(34, 211, 238, 0.10);
  --cb-accent-ring:  rgba(34, 211, 238, 0.60);
  --cb-header-grad:  rgba(34, 211, 238, 0.06);

  position: fixed;
  z-index: 1001;
  bottom: 28px;
  right: 28px;
  width: 390px;
  max-height: 620px;
  display: flex;
  flex-direction: column;
  overflow: hidden;

  /* T7: Glass-morphism */
  background: rgba(13, 13, 20, 0.88);
  backdrop-filter: blur(24px) saturate(1.3);
  -webkit-backdrop-filter: blur(24px) saturate(1.3);
  border: 1px solid var(--cb-accent-ring);
  border-radius: 16px;
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.65),
    0 0 0 1px rgba(255, 255, 255, 0.04),
    0 0 40px var(--cb-accent-glow),
    0 0 80px var(--cb-accent-glow2);

  /* Expand from orb center — origin set dynamically via JS CSS vars */
  clip-path: circle(0% at var(--orb-origin-x, calc(100% - 60px)) var(--orb-origin-y, 100%));
  opacity: 0;
  transition:
    clip-path  0.28s ease-in,
    opacity    0.20s ease-in,
    border-color 0.3s ease,
    box-shadow   0.3s ease;
  pointer-events: none;
}

.chatbot-panel.is-open {
  clip-path: circle(150% at var(--orb-origin-x, calc(100% - 60px)) var(--orb-origin-y, 100%));
  opacity: 1;
  pointer-events: auto;
  outline: 1px solid color-mix(in srgb, var(--cb-accent) calc(var(--cb-ring-alpha) * 100%), transparent);
  animation: cb-ring-breathe 3s ease-in-out infinite, cb-glow-breathe 3s ease-in-out infinite;
  transition:
    clip-path  0.40s cubic-bezier(0.34, 1.56, 0.64, 1),
    opacity    0.28s ease,
    border-color 0.3s ease;
}

/* ── Mobile: floating bubble (92vw × 65vh) anchored to screen bottom ── */

@media (max-width: 600px) {
  .chatbot-panel {
    bottom: 16px;
    left: 4vw;
    right: 4vw;
    width: auto;
    max-height: 65vh;
    height: 65vh;
    border-radius: 24px;
    /* Expand from just below the panel, aligned to orb x-position */
    clip-path: circle(0% at var(--orb-origin-x, 50%) var(--orb-origin-y, 110%));
    transform: none;
  }
  .chatbot-panel.is-open {
    clip-path: circle(150% at var(--orb-origin-x, 50%) var(--orb-origin-y, 110%));
    transform: none;
    border-radius: 24px;
  }
}

/* ── Header ─────────────────────────────────────────────────────────── */

.chatbot-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: linear-gradient(135deg, var(--cb-header-grad, rgba(34, 211, 238, 0.06)) 0%, rgba(10, 10, 15, 0.40) 100%);
  flex-shrink: 0;
}

.chatbot-avatar {
  width:  42px;
  height: 42px;
  border-radius: 50%;
  background: var(--cb-accent-dim);
  border: 1px solid var(--cb-accent-ring);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 0 18px var(--cb-accent-glow);
  transition: box-shadow 0.3s;
}

.chatbot-avatar-icon {
  width: 26px;
  height: 26px;
  object-fit: contain;
  display: block;
  filter: drop-shadow(0 0 4px rgba(34, 211, 238, 0.5));
}

.chatbot-header__info {
  flex: 1;
  min-width: 0;
}

.chatbot-title {
  font-family: 'Syne', sans-serif;
  font-size: 0.9rem;
  font-weight: 700;
  color: #E5E7EB;
  margin: 0;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.chatbot-subtitle {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.65rem;
  color: var(--cb-accent);
  margin: 3px 0 0;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  opacity: 0.85;
}

.chatbot-close {
  background: none;
  border: none;
  color: #52525B;
  font-size: 0.95rem;
  cursor: pointer;
  padding: 7px;
  border-radius: 8px;
  line-height: 1;
  flex-shrink: 0;
  transition: color 0.15s, background 0.15s;
}
.chatbot-close:hover {
  color: #E5E7EB;
  background: rgba(255, 255, 255, 0.07);
}

/* ── Messages area ──────────────────────────────────────────────────── */

.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
  overscroll-behavior: contain;
}

.chatbot-messages::-webkit-scrollbar { width: 3px; }
.chatbot-messages::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 3px;
}

/* ── Message bubbles ────────────────────────────────────────────────── */

.chatbot-msg {
  max-width: 87%;
  padding: 10px 14px;
  font-size: 0.875rem;
  line-height: 1.6;
  word-break: break-word;
  animation: msg-in 0.22s ease both;
}

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

.chatbot-msg--bot {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.08);
  color: #D4D4D8;
  align-self: flex-start;
  border-radius: 4px 14px 14px 14px;
}

.chatbot-msg--user {
  background: var(--cb-accent-dim);
  border: 1px solid var(--cb-accent-ring);
  color: #F4F4F5;
  align-self: flex-end;
  border-radius: 14px 4px 14px 14px;
}

/* ── T10: Loading shimmer ───────────────────────────────────────────── */

.chatbot-shimmer {
  display: flex;
  flex-direction: column;
  gap: 7px;
  padding: 14px 16px;
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.07);
  border-radius: 4px 14px 14px 14px;
  align-self: flex-start;
  max-width: 70%;
  animation: msg-in 0.22s ease both;
}

.chatbot-shimmer span {
  display: block;
  height: 9px;
  border-radius: 5px;
  background: linear-gradient(
    90deg,
    rgba(34, 211, 238, 0.05) 0%,
    rgba(34, 211, 238, 0.20) 40%,
    rgba(34, 211, 238, 0.05) 80%
  );
  background-size: 200% 100%;
  animation: shimmer-sweep 1.5s infinite ease-in-out;
}
.chatbot-shimmer span:nth-child(1) { width: 88%; }
.chatbot-shimmer span:nth-child(2) { width: 62%; animation-delay: 0.18s; }
.chatbot-shimmer span:nth-child(3) { width: 74%; animation-delay: 0.36s; }

@keyframes shimmer-sweep {
  0%   { background-position: -200% 0; }
  100% { background-position:  200% 0; }
}

/* ── Input row ──────────────────────────────────────────────────────── */

.chatbot-input-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 16px 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(10, 10, 15, 0.40);
  flex-shrink: 0;
}

.chatbot-input {
  flex: 1;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.10);
  border-radius: 10px;
  color: #E5E7EB;
  font-family: 'DM Sans', sans-serif;
  font-size: 0.875rem;
  padding: 10px 14px;
  resize: none;
  outline: none;
  line-height: 1.45;
  min-height: 40px;
  max-height: 120px;
  overflow-y: auto;
  transition: border-color 0.2s, background 0.2s;
}
.chatbot-input::placeholder { color: #3F3F46; }
.chatbot-input:focus {
  border-color: var(--cb-accent-ring);
  background: rgba(255, 255, 255, 0.07);
}

.chatbot-send {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  background: var(--cb-accent);
  border: none;
  border-radius: 10px;
  color: #0A0A0F;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s, transform 0.15s;
}
.chatbot-send svg {
  width: 16px;
  height: 16px;
}
.chatbot-send:hover:not(:disabled) {
  opacity: 0.85;
  transform: scale(1.06);
}
.chatbot-send:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}


/* ── Orb launch animations ──────────────────────────────────────────── */

@keyframes orb-pulse {
  0%   { transform: scale(1); }
  55%  { transform: scale(1.16); }
  100% { transform: scale(1); }
}

.orb-launching {
  animation: orb-pulse 0.18s ease-out;
}

/* ── Particle burst ──────────────────────────────────────────────────── */

.chatbot-particle {
  position: fixed;
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #22D3EE;
  pointer-events: none;
  z-index: 9999;
  animation: particle-burst 0.30s ease-out forwards;
}

@keyframes particle-burst {
  0%   { transform: translate(0, 0) scale(1);                       opacity: 0.85; }
  100% { transform: translate(var(--tx), var(--ty)) scale(0);       opacity: 0;    }
}

/* ── Inline chatbot mode (Contact section "Chat with our AI" card) ───── */

.chatbot-panel--inline {
  position: static !important;
  width: 100% !important;
  max-height: 380px !important;
  height: 380px !important;
  bottom: auto !important;
  right: auto !important;
  border-radius: 8px !important;
  clip-path: none !important;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease !important;
  animation: none !important;
  outline: none !important;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.04),
    0 0 40px var(--cb-accent-glow),
    0 0 80px var(--cb-accent-glow2) !important;
}

.chatbot-panel--inline.is-open {
  opacity: 1 !important;
  pointer-events: auto !important;
  animation: none !important;
  outline: none !important;
  clip-path: none !important;
}

.contact-channel--chatting {
  padding: 0 !important;
  overflow: hidden;
  transform: none !important;
  gap: 0 !important;
}

.contact-channel--chatting > :not(#chatbot-panel) {
  display: none !important;
}
