/* ═══════════════════════════════════════════════════════════════════════
   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.14);
  --cb-accent-glow: rgba(34, 211, 238, 0.20);
  --cb-accent-ring: rgba(34, 211, 238, 0.25);
}
.chatbot-panel[data-demo="megacorp"] {
  --cb-accent:      #A855F7;
  --cb-accent-dim:  rgba(168, 85, 247, 0.14);
  --cb-accent-glow: rgba(168, 85, 247, 0.20);
  --cb-accent-ring: rgba(168, 85, 247, 0.25);
}
.chatbot-panel[data-demo="loan"] {
  --cb-accent:      #10F2A6;
  --cb-accent-dim:  rgba(16, 242, 166, 0.14);
  --cb-accent-glow: rgba(16, 242, 166, 0.20);
  --cb-accent-ring: rgba(16, 242, 166, 0.25);
}
.chatbot-panel[data-demo="readiness"] {
  --cb-accent:      #F59E0B;
  --cb-accent-dim:  rgba(245, 158, 11, 0.14);
  --cb-accent-glow: rgba(245, 158, 11, 0.20);
  --cb-accent-ring: rgba(245, 158, 11, 0.25);
}

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

.chatbot-panel {
  /* Default tokens (before data-demo is set) */
  --cb-accent:      #22D3EE;
  --cb-accent-dim:  rgba(34, 211, 238, 0.14);
  --cb-accent-glow: rgba(34, 211, 238, 0.20);
  --cb-accent-ring: rgba(34, 211, 238, 0.25);

  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 48px var(--cb-accent-glow);

  /* Reveal from orb corner (bottom-right), close = collapse back */
  clip-path: circle(0% at calc(100% - 60px) 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 calc(100% - 60px) 100%);
  opacity: 1;
  pointer-events: auto;
  transition:
    clip-path  0.40s cubic-bezier(0.34, 1.56, 0.64, 1),
    opacity    0.28s ease,
    border-color 0.3s ease,
    box-shadow   0.3s ease;
}

/* ── Mobile: full-screen slide up ──────────────────────────────────── */

@media (max-width: 600px) {
  .chatbot-panel {
    bottom: 0;
    right:  0;
    left:   0;
    width:  100%;
    height: 100dvh;
    max-height: 100dvh;
    border-radius: 20px 20px 0 0;
    clip-path: none;
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.28s ease;
  }
  .chatbot-panel.is-open {
    clip-path: none;
    transform: translateY(0);
    border-radius: 20px 20px 0 0;
  }
}

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

.chatbot-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 18px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.06);
  background: rgba(10, 10, 15, 0.40);
  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;
  font-size: 1.25rem;
  flex-shrink: 0;
  box-shadow: 0 0 18px var(--cb-accent-glow);
  transition: box-shadow 0.3s;
}

.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;
}

/* ── Backdrop (mobile closes chatbot; hidden on desktop) ─────────────── */

.chatbot-backdrop {
  position: fixed;
  inset: 0;
  z-index: 1000;
  background: rgba(0, 0, 0, 0.55);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.28s ease;
}
.chatbot-backdrop.is-visible {
  opacity: 1;
  pointer-events: auto;
}

@media (min-width: 601px) {
  /* On desktop the panel is a corner widget — no backdrop needed */
  .chatbot-backdrop { display: none !important; }
}

/* ── 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;    }
}
