/* ═══════════════════════════════════════════════════════════════
   QTSI — copilot.css
   Self-contained styles for the QTSI Copilot widget (injected by
   js/copilot.js on every page). The widget's CSS used to live split
   across sections3.css + enterprise.css, which the service pages don't
   load — so the widget rendered unstyled there. This file consolidates
   the EXACT same rules (base + premium overrides, in cascade order) so
   the Copilot looks and behaves identically on every page.
   Load this on every page that injects #copilot-placeholder.
═══════════════════════════════════════════════════════════════ */

/* The widget's keyframes (copilotBob, typingDot, fadeUp, fadeIn) live in
   animations.css, which every page already loads — we intentionally do NOT
   redefine them here so behaviour stays byte-identical to the homepage. The
   only widget keyframe unique to the premium layer (advisorPulse) is defined
   in the overrides section below. */

/* The dots + bob animation triggers (mirrors animations.css) */
.copilot-fab-inner { animation: copilotBob 3.2s ease-in-out infinite; }
.copilot-dot:nth-child(1) { animation: typingDot 1.2s ease-in-out infinite 0.00s; }
.copilot-dot:nth-child(2) { animation: typingDot 1.2s ease-in-out infinite 0.20s; }
.copilot-dot:nth-child(3) { animation: typingDot 1.2s ease-in-out infinite 0.40s; }

/* ══════════════════════════════════════════
   BASE WIDGET (from sections3.css)
══════════════════════════════════════════ */

/* FAB wrapper — holds button + tooltip */
.copilot-fab-wrapper {
  position: fixed;
  bottom: 28px;
  right: 28px;
  z-index: var(--z-copilot);
  display: flex;
  align-items: center;
  gap: 12px;
  /* Tooltip sits to the left of the FAB */
  flex-direction: row-reverse;
}

/* Tooltip label — desktop only */
.copilot-fab-label {
  background: var(--glass-bg);
  backdrop-filter: blur(16px) saturate(160%);
  -webkit-backdrop-filter: blur(16px) saturate(160%);
  border: 1px solid var(--glass-border);
  border-radius: var(--r-full);
  padding: 8px 16px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-secondary);
  white-space: nowrap;
  opacity: 0;
  transform: translateX(8px);
  transition: opacity 200ms var(--ease-expo), transform 200ms var(--ease-expo);
  pointer-events: none;
  box-shadow: var(--shadow-md);
}

.copilot-fab-wrapper:hover .copilot-fab-label {
  opacity: 1;
  transform: translateX(0);
}

@media (max-width: 768px) {
  .copilot-fab-label { display: none; }
  .copilot-fab-wrapper { bottom: 20px; right: 20px; }
}

/* FAB */
.copilot-fab {
  width: 60px; height: 60px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--blue) 0%, var(--blue-dark) 100%);
  box-shadow:
    0 0 0 0 rgba(0,112,243,.4),
    0 8px 28px rgba(0,112,243,.45),
    0 2px 8px rgba(0,0,0,.6);
  transition:
    transform    200ms cubic-bezier(0.34,1.56,0.64,1),
    box-shadow   250ms var(--ease-expo);
  outline: none;
  flex-shrink: 0;
}

.copilot-fab:hover {
  transform: scale(1.08);
  box-shadow:
    0 0 0 8px rgba(0,112,243,.12),
    0 12px 36px rgba(0,112,243,.55),
    0 2px 8px rgba(0,0,0,.6);
}

.copilot-fab:focus-visible {
  outline: 2px solid var(--blue-light);
  outline-offset: 4px;
}

/* Notification dot */
.copilot-fab-dot {
  position: absolute;
  top: 6px; right: 6px;
  width: 11px; height: 11px;
  border-radius: 50%;
  background: var(--green);
  border: 2px solid var(--bg-base);
  box-shadow: 0 0 8px rgba(93,185,55,.7);
}

/* Panel */
.copilot-panel {
  position: fixed;
  bottom: 108px;
  right: 28px;
  z-index: var(--z-copilot);
  width: 388px;
  max-height: 620px;
  display: flex;
  flex-direction: column;
  border-radius: var(--r-xl);
  overflow: hidden;
  background: rgba(10,10,18,.88);
  backdrop-filter: blur(28px) saturate(180%);
  -webkit-backdrop-filter: blur(28px) saturate(180%);
  border: 1px solid rgba(0,112,243,.22);
  box-shadow:
    0 0 0 1px rgba(255,255,255,.06),
    0 24px 64px rgba(0,0,0,.75),
    0 0 80px rgba(0,112,243,.14),
    0 0 160px rgba(93,185,55,.08);
  transform-origin: bottom right;
  transform: scale(0.92) translateY(12px);
  opacity: 0;
  pointer-events: none;
  transition:
    transform 350ms cubic-bezier(0.34,1.56,0.64,1),
    opacity   280ms var(--ease-expo);
}

.copilot-panel.is-open {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: auto;
}

/* Glow strip at top of panel */
.copilot-panel-glow {
  position: absolute;
  inset-inline: 0;
  top: 0;
  height: 2px;
  background: linear-gradient(90deg, var(--blue) 0%, var(--green) 100%);
  z-index: 1;
}

/* Header */
.copilot-header {
  display: flex;
  align-items: center;
  gap: var(--sp-3);
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0;
}

.copilot-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: linear-gradient(135deg, rgba(0,112,243,.4) 0%, rgba(93,185,55,.3) 100%);
  border: 1px solid rgba(0,112,243,.4);
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  color: var(--blue-light);
  box-shadow: 0 0 16px rgba(0,112,243,.25);
}

.copilot-header-info { flex: 1; min-width: 0; }

.copilot-header-name {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-primary);
  letter-spacing: -0.01em;
}

.copilot-header-status {
  font-size: 0.72rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 5px;
  margin-top: 2px;
}

.copilot-status-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 6px rgba(93,185,55,.7);
  flex-shrink: 0;
}

.copilot-close {
  width: 32px; height: 32px;
  border-radius: var(--r-sm);
  border: 1px solid var(--border);
  background: var(--bg-surface);
  color: var(--text-muted);
  display: flex; align-items: center; justify-content: center;
  cursor: pointer;
  transition: background 150ms, color 150ms;
  flex-shrink: 0;
}
.copilot-close:hover { background: var(--bg-surface-md); color: var(--text-primary); }

/* Messages */
.copilot-messages {
  flex: 1;
  overflow-y: auto;
  padding: var(--sp-4) var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-3);
  scroll-behavior: smooth;
  /* Custom scrollbar */
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,.12) transparent;
}

.copilot-messages::-webkit-scrollbar { width: 4px; }
.copilot-messages::-webkit-scrollbar-track { background: transparent; }
.copilot-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,.12); border-radius: 4px; }

/* Message bubbles */
.copilot-msg {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-width: 88%;
  animation: fadeUp 0.3s var(--ease-expo) both;
}

.copilot-msg--bot { align-self: flex-start; }
.copilot-msg--user { align-self: flex-end; }

.copilot-bubble {
  padding: 11px 15px;
  border-radius: 16px;
  font-size: 0.855rem;
  line-height: 1.6;
}

.copilot-msg--bot .copilot-bubble {
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.08);
  color: var(--text-primary);
  border-radius: 4px 16px 16px 16px;
}

.copilot-msg--user .copilot-bubble {
  background: rgba(0,112,243,.22);
  border: 1px solid rgba(0,112,243,.30);
  color: var(--text-primary);
  border-radius: 16px 4px 16px 16px;
}

/* Typing indicator */
.copilot-typing {
  display: flex;
  align-items: center;
  gap: 5px;
  padding: 12px 16px;
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.07);
  border-radius: 4px 16px 16px 16px;
  width: fit-content;
  animation: fadeIn 0.2s var(--ease-expo) both;
}

.copilot-dot {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: var(--text-muted);
  flex-shrink: 0;
}

/* "QTSI Copilot is thinking…" label beside the animated dots */
.copilot-thinking-label {
  margin-left: 6px;
  font-size: 0.78rem;
  font-weight: 500;
  letter-spacing: 0.01em;
  color: var(--text-secondary, #9aa3b2);
  white-space: nowrap;
}

/* Suggested prompts */
.copilot-suggestions {
  padding: var(--sp-3) var(--sp-5);
  display: flex;
  flex-direction: column;
  gap: var(--sp-2);
  border-top: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
}

.copilot-suggestion-label {
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.10em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 2px;
}

.copilot-suggestion-chips {
  display: flex;
  flex-wrap: wrap;
  gap: var(--sp-2);
}

.copilot-chip-btn {
  padding: 6px 12px;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
  color: var(--text-secondary);
  background: rgba(255,255,255,.05);
  border: 1px solid rgba(255,255,255,.10);
  cursor: pointer;
  transition: background 150ms, color 150ms, border-color 150ms;
  text-align: left;
  min-height: 32px;
}

.copilot-chip-btn:hover {
  background: rgba(0,112,243,.14);
  border-color: rgba(0,112,243,.30);
  color: var(--blue-light);
}

/* Input area */
.copilot-input-area {
  display: flex;
  align-items: flex-end;
  gap: var(--sp-2);
  padding: 12px 16px 16px;
  border-top: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0;
}

.copilot-input {
  flex: 1;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.10);
  border-radius: var(--r-lg);
  padding: 10px 14px;
  font-family: inherit;
  font-size: 0.855rem;
  color: var(--text-primary);
  resize: none;
  outline: none;
  min-height: 42px;
  max-height: 120px;
  line-height: 1.5;
  transition: border-color 200ms, background 200ms;
  scrollbar-width: thin;
}

.copilot-input::placeholder { color: var(--text-muted); }

.copilot-input:focus {
  border-color: rgba(0,112,243,.40);
  background: rgba(255,255,255,.08);
}

.copilot-send {
  width: 40px; height: 40px;
  border-radius: var(--r-md);
  background: var(--blue);
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
  transition: background 150ms, transform 150ms cubic-bezier(0.34,1.56,0.64,1);
}
.copilot-send:hover  { background: var(--blue-light); transform: scale(1.06); }
.copilot-send:active { transform: scale(0.94); }
.copilot-send:disabled { background: var(--bg-surface-md); color: var(--text-muted); cursor: not-allowed; transform: none; }

/* Mobile: full screen panel */
@media (max-width: 480px) {
  .copilot-panel {
    bottom: 0; right: 0; left: 0;
    width: 100%;
    max-height: 90dvh;
    border-radius: var(--r-xl) var(--r-xl) 0 0;
    transform-origin: bottom center;
  }
}

/* ══════════════════════════════════════════
   PREMIUM OVERRIDES (from enterprise.css — load AFTER the base)
══════════════════════════════════════════ */

.copilot-panel {
  width: 408px;
  max-height: 660px;
  border-radius: var(--r-2xl);
  border-color: rgba(0,112,243,.26);
}

/* Richer header with advisor positioning */
.copilot-header {
  padding: 18px 20px;
  background: linear-gradient(135deg, rgba(0,112,243,.14) 0%, rgba(93,185,55,.08) 100%);
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.copilot-avatar {
  width: 42px; height: 42px;
  position: relative;
  box-shadow: 0 0 20px rgba(0,112,243,.35);
}

/* Live pulse ring on the advisor avatar */
.copilot-avatar::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 1.5px solid rgba(0,112,243,.4);
  animation: advisorPulse 2.6s var(--ease-expo) infinite;
}

@keyframes advisorPulse {
  0%   { transform: scale(.9);  opacity: .8; }
  70%  { transform: scale(1.25); opacity: 0; }
  100% { transform: scale(1.25); opacity: 0; }
}

.copilot-header-name {
  font-size: 0.95rem;
  display: inline-flex;
  align-items: center;
  gap: 7px;
}

/* "AI" capability pill beside the name */
.copilot-header-name::after {
  content: 'AI';
  font-size: 0.58rem;
  font-weight: 800;
  letter-spacing: 0.08em;
  padding: 2px 6px;
  border-radius: 5px;
  color: #fff;
  background: var(--grad-brand);
}

.copilot-header-status { font-size: 0.75rem; color: var(--text-secondary); }

/* Bubbles — a touch larger and more legible */
.copilot-bubble { font-size: 0.875rem; padding: 12px 16px; }

.copilot-msg--bot .copilot-bubble {
  background: rgba(255,255,255,.055);
  border-color: rgba(255,255,255,.09);
}

/* Suggested prompts feel like product chips */
.copilot-chip-btn {
  padding: 7px 13px;
  font-size: 0.76rem;
}
.copilot-chip-btn:hover { transform: translateY(-1px); }

/* Advisor disclaimer strip under the input */
.copilot-disclaimer {
  padding: 8px 16px 12px;
  font-size: 0.66rem;
  line-height: 1.4;
  color: var(--text-muted);
  text-align: center;
  border-top: 1px solid rgba(255,255,255,.05);
  flex-shrink: 0;
}
.copilot-disclaimer strong { color: var(--text-secondary); font-weight: 600; }

/* FAB — slightly larger, premium gradient + ring */
.copilot-fab { width: 64px; height: 64px; }

@media (max-width: 480px) {
  .copilot-panel { width: 100%; max-height: 92dvh; border-radius: var(--r-2xl) var(--r-2xl) 0 0; }
}
