/* chat-widget.css — extracted from admin.css so the floating chat works on the main dashboard */
/* --- :root design tokens the chat needs --- */
:root {
  /* Color: layered dark surface (deep → mid → frosted) */
  --b-bg-deep:      #060914;
  --b-bg-base:      #0a0f1e;
  --b-bg-elevated:  #111728;
  --b-bg-overlay:   rgba(17, 23, 40, 0.85);

  /* Glass cards */
  --b-glass-bg:     rgba(255, 255, 255, 0.04);
  --b-glass-bg-strong: rgba(255, 255, 255, 0.06);
  --b-glass-border: rgba(255, 255, 255, 0.08);
  --b-glass-border-strong: rgba(255, 255, 255, 0.14);
  --b-glass-blur:   18px;

  /* Brand — indigo gradient family */
  --b-brand-50:  #eef2ff;
  --b-brand-300: #818cf8;
  --b-brand-400: #6366f1;
  --b-brand-500: #4f46e5;
  --b-brand-600: #4338ca;
  --b-brand-gradient: linear-gradient(135deg, #6366f1 0%, #8b5cf6 50%, #d946ef 100%);

  /* Semantic */
  --b-success:   #10b981;
  --b-warn:      #f59e0b;
  --b-danger:    #ef4444;
  --b-info:      #3b82f6;
  --b-success-bg: rgba(16, 185, 129, 0.12);
  --b-warn-bg:    rgba(245, 158, 11, 0.12);
  --b-danger-bg:  rgba(239, 68, 68, 0.12);
  --b-info-bg:    rgba(59, 130, 246, 0.12);

  /* Text — all WCAG-AA verified against --b-bg-base */
  --b-text-strong: rgba(255, 255, 255, 0.96);
  --b-text:        rgba(255, 255, 255, 0.82);
  --b-text-soft:   rgba(255, 255, 255, 0.62);
  --b-text-faint:  rgba(255, 255, 255, 0.38);

  /* Borders */
  --b-border:      rgba(255, 255, 255, 0.08);
  --b-border-strong: rgba(255, 255, 255, 0.16);

  /* Focus */
  --b-focus-ring:  #22d3ee;  /* cyan-400 — high contrast on dark */

  /* Radii */
  --b-r-sm: 6px;
  --b-r:    10px;
  --b-r-lg: 16px;
  --b-r-xl: 22px;
  --b-r-pill: 999px;

  /* Shadows — layered for depth, soft on dark */
  --b-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.4);
  --b-shadow:    0 8px 24px rgba(0, 0, 0, 0.32);
  --b-shadow-lg: 0 24px 60px rgba(0, 0, 0, 0.48), 0 4px 12px rgba(0, 0, 0, 0.24);
  --b-glow:      0 0 0 1px rgba(99, 102, 241, 0.4), 0 8px 24px rgba(99, 102, 241, 0.24);

  /* Motion */
  --b-ease:        cubic-bezier(0.16, 1, 0.3, 1);   /* ease-out-expo for entrances */
  --b-ease-in:     cubic-bezier(0.7, 0, 0.84, 0);
  --b-fast:        150ms;
  --b-base:        200ms;
  --b-slow:        320ms;

  /* Type scale */
  --b-fs-xs: 0.75rem;   /* 12 */
  --b-fs-sm: 0.875rem;  /* 14 */
  --b-fs-base: 1rem;    /* 16 */
  --b-fs-md: 1.125rem;  /* 18 */
  --b-fs-lg: 1.375rem;  /* 22 */
  --b-fs-xl: 1.75rem;   /* 28 */
  --b-fs-2xl: 2.25rem;  /* 36 */
  --b-fs-3xl: 3rem;     /* 48 */

  /* Layout */
  --b-sidebar-w: 268px;
  --b-topbar-h: 64px;

  /* Z-index scale */
  --b-z-bg: 0;
  --b-z-base: 10;
  --b-z-fixed: 100;
  --b-z-modal: 1000;
  --b-z-toast: 2000;
  --b-z-chat: 1500;
}

/* --- chat widget (FAB + panel + messages) --- */
.b-chat-fab {
  position: fixed;
  right: 24px; bottom: 24px;
  width: 56px; height: 56px;
  border-radius: var(--b-r-pill);
  background: var(--b-brand-gradient);
  color: white;
  border: none;
  cursor: pointer;
  box-shadow: 0 12px 30px rgba(99,102,241,0.5), 0 0 0 1px rgba(255,255,255,0.06);
  display: grid; place-items: center;
  z-index: var(--b-z-chat);
  transition: transform var(--b-base) var(--b-ease),
              box-shadow var(--b-base) var(--b-ease);
}
.b-chat-fab:hover { transform: translateY(-2px) scale(1.04); box-shadow: 0 16px 36px rgba(99,102,241,0.65); }
.b-chat-fab:active { transform: scale(0.96); }
.b-chat-fab__pulse {
  position: absolute;
  inset: 0;
  border-radius: var(--b-r-pill);
  background: var(--b-brand-gradient);
  animation: b-pulse 2.4s ease-out infinite;
  opacity: 0.5;
  z-index: -1;
}
@keyframes b-pulse {
  0%   { transform: scale(1);   opacity: 0.6; }
  100% { transform: scale(1.6); opacity: 0; }
}

.b-chat {
  position: fixed;
  right: 24px; bottom: 92px;
  width: min(380px, calc(100vw - 48px));
  height: min(560px, calc(100vh - 140px));
  background: var(--b-bg-elevated);
  border: 1px solid var(--b-glass-border-strong);
  border-radius: var(--b-r-lg);
  box-shadow: var(--b-shadow-lg);
  display: flex; flex-direction: column;
  z-index: var(--b-z-chat);
  overflow: hidden;
  transform: scale(0.94) translateY(20px);
  transform-origin: bottom right;
  opacity: 0;
  pointer-events: none;
  transition: transform var(--b-base) var(--b-ease),
              opacity var(--b-base) var(--b-ease);
}
.b-chat.is-open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: auto;
}
.b-chat__header {
  padding: 14px 16px;
  display: flex; align-items: center; gap: 12px;
  border-bottom: 1px solid var(--b-border);
  background: linear-gradient(180deg, rgba(99,102,241,0.08), transparent);
}
.b-chat__avatar {
  width: 32px; height: 32px;
  border-radius: var(--b-r-pill);
  background: var(--b-brand-gradient);
  display: grid; place-items: center;
  font-weight: 700; color: white;
  flex-shrink: 0;
}
.b-chat__title { font-family: 'Outfit', sans-serif; font-weight: 600; color: var(--b-text-strong); font-size: var(--b-fs-sm); }
.b-chat__status { font-size: 0.7rem; color: var(--b-success); display: flex; align-items: center; gap: 5px; }
.b-chat__status::before {
  content: '';
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--b-success);
  box-shadow: 0 0 6px var(--b-success);
}
.b-chat__close {
  margin-left: auto;
  width: 32px; height: 32px;
  background: transparent;
  border: none;
  color: var(--b-text-soft);
  cursor: pointer;
  border-radius: var(--b-r-sm);
  display: grid; place-items: center;
}
.b-chat__close:hover { background: var(--b-glass-bg); color: var(--b-text-strong); }

.b-chat__log {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
  scroll-behavior: smooth;
}
.b-chat__log::-webkit-scrollbar { width: 6px; }
.b-chat__log::-webkit-scrollbar-track { background: transparent; }
.b-chat__log::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 3px; }

.b-msg {
  display: flex; gap: 8px;
  max-width: 88%;
  animation: b-msg-in var(--b-base) var(--b-ease);
}
@keyframes b-msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.b-msg.is-user { align-self: flex-end; flex-direction: row-reverse; }
.b-msg__bubble {
  padding: 10px 13px;
  border-radius: 12px;
  font-size: var(--b-fs-sm);
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.b-msg.is-bot .b-msg__bubble {
  background: var(--b-glass-bg-strong);
  color: var(--b-text-strong);
  border: 1px solid var(--b-glass-border);
  border-bottom-left-radius: 4px;
}
.b-msg.is-user .b-msg__bubble {
  background: var(--b-brand-gradient);
  color: white;
  border-bottom-right-radius: 4px;
}

.b-typing { display: flex; gap: 4px; padding: 14px 14px; }
.b-typing span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--b-text-soft);
  animation: b-typing 1.2s ease-in-out infinite;
}
.b-typing span:nth-child(2) { animation-delay: 0.15s; }
.b-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes b-typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.5; }
  30% { transform: translateY(-4px); opacity: 1; }
}

.b-chat__compose {
  padding: 12px;
  border-top: 1px solid var(--b-border);
  display: flex; gap: 8px;
  align-items: flex-end;
  background: rgba(0,0,0,0.2);
}
.b-chat__input {
  flex: 1;
  min-height: 40px;
  max-height: 120px;
  padding: 10px 12px;
  border-radius: var(--b-r);
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--b-glass-border);
  color: var(--b-text-strong);
  font: inherit;
  font-size: var(--b-fs-sm);
  resize: none;
}
.b-chat__input:focus {
  outline: none;
  border-color: var(--b-brand-400);
  background: rgba(255,255,255,0.06);
}
.b-chat__send {
  width: 40px; height: 40px;
  border-radius: var(--b-r);
  background: var(--b-brand-gradient);
  color: white;
  border: none;
  cursor: pointer;
  display: grid; place-items: center;
  transition: transform var(--b-fast) var(--b-ease);
  flex-shrink: 0;
}
.b-chat__send:hover { transform: scale(1.05); }
.b-chat__send:active { transform: scale(0.94); }
.b-chat__send:disabled { opacity: 0.4; cursor: not-allowed; }

/* Streaming cursor */
.b-chat__cursor {
  display: inline-block;
  width: 2px;
  height: 1em;
  margin-left: 1px;
  background: currentColor;
  vertical-align: text-bottom;
  animation: b-cursor-blink 1s steps(2) infinite;
}
@keyframes b-cursor-blink {
  to { opacity: 0; }
}
@media (prefers-reduced-motion: reduce) {
  .b-chat__cursor { animation: none; }
}

/* ─── Empty states ──────────────────────────────────────────────── */
.b-empty {
  text-align: center;
  padding: 48px 24px;
  color: var(--b-text-soft);
  display: flex; flex-direction: column; align-items: center; gap: 12px;
}
.b-empty svg { width: 48px; height: 48px; opacity: 0.4; }
.b-empty__title { font-size: var(--b-fs-md); color: var(--b-text-strong); font-weight: 600; }

/* ─── Misc helpers ──────────────────────────────────────────────── */
.b-row { display: flex; gap: 10px; align-items: center; }
.b-stack { display: flex; flex-direction: column; gap: 10px; }
.b-stack-lg { display: flex; flex-direction: column; gap: 18px; }
.b-spread { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.b-grow { flex: 1; }
.b-truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.b-muted { color: var(--b-text-soft); }
.b-tiny { font-size: var(--b-fs-xs); }
.b-numeric { font-variant-numeric: tabular-nums; }
.b-divider { height: 1px; background: var(--b-border); margin: 14px 0; }
.b-hide-mobile { }
@media (max-width: 640px) { .b-hide-mobile { display: none !important; } }
.b-sr-only {
  position: absolute; width: 1px; height: 1px;
  padding: 0; margin: -1px; overflow: hidden;
  clip: rect(0, 0, 0, 0); white-space: nowrap; border: 0;
}

/* ─── Status indicators ─────────────────────────────────────────── */
.b-pulse-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.b-pulse-dot.ok { background: var(--b-success); box-shadow: 0 0 10px var(--b-success); }
.b-pulse-dot.warn { background: var(--b-warn); box-shadow: 0 0 10px var(--b-warn); }
.b-pulse-dot.danger { background: var(--b-danger); box-shadow: 0 0 10px var(--b-danger); animation: b-pulse-warn 1.4s ease-in-out infinite; }
.b-pulse-dot.unknown { background: var(--b-text-faint); }
@keyframes b-pulse-warn {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.6; transform: scale(1.15); }
}

/* ─── Respect reduced motion ────────────────────────────────────── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
  .b-chat-fab__pulse { display: none; }
