/* ===== CHATBOT ===== */
.chat-fab {
  position: fixed; bottom: 32px; right: 32px; z-index: 700;
  display: flex; align-items: center; gap: 10px;
  padding: 14px 22px;
  background: linear-gradient(135deg, #6b35d9, #9b4de8);
  border-radius: 100px;
  color: white; font-size: 13px; font-weight: 700; letter-spacing: 1px;
  cursor: pointer;
  box-shadow: 0 8px 32px rgba(107,53,217,0.4);
  transition: transform .3s, box-shadow .3s;
  border: 1px solid rgba(255,255,255,0.15);
  user-select: none;
  animation: chatFabPulse 2.4s ease-in-out infinite,
             chatFabHue 6s linear infinite;
}
.chat-fab::before {
  content: "";
  position: absolute;
  inset: -3px;
  border-radius: 100px;
  background: linear-gradient(90deg, #6b35d9, #c9a84c, #28c8dc, #9b4de8, #6b35d9);
  background-size: 300% 100%;
  z-index: -1;
  filter: blur(14px);
  opacity: 0.85;
  animation: chatFabRing 4s linear infinite;
}
.chat-fab::after {
  content: "";
  position: absolute;
  inset: -10px;
  border-radius: 100px;
  background: radial-gradient(closest-side,
    rgba(107,53,217,0.45) 0%,
    rgba(201,168,76,0.30) 35%,
    rgba(40,200,220,0.20) 60%,
    transparent 80%);
  z-index: -2;
  pointer-events: none;
  animation: chatFabGlow 2.4s ease-in-out infinite;
}
.chat-fab:hover {
  transform: translateY(-3px) scale(1.04);
  box-shadow: 0 14px 48px rgba(107,53,217,0.7),
              0 0 22px rgba(201,168,76,0.55);
  animation-play-state: paused;
}
.chat-fab-icon {
  font-size: 18px;
  animation: spin 8s linear infinite, chatFabStar 1.8s ease-in-out infinite;
  filter: drop-shadow(0 0 6px rgba(255,255,255,0.65));
  display: inline-block;
}
@keyframes chatFabPulse {
  0%, 100% { box-shadow: 0 8px 28px rgba(107,53,217,0.45),
                       0 0 18px rgba(201,168,76,0.35); }
  50%      { box-shadow: 0 8px 44px rgba(107,53,217,0.85),
                       0 0 32px rgba(40,200,220,0.55),
                       0 0 18px rgba(201,168,76,0.55); }
}
@keyframes chatFabRing {
  0%   { background-position:   0% 50%; }
  100% { background-position: 300% 50%; }
}
@keyframes chatFabHue {
  0%   { filter: hue-rotate(0deg); }
  100% { filter: hue-rotate(360deg); }
}
@keyframes chatFabGlow {
  0%, 100% { transform: scale(1);   opacity: 0.65; }
  50%      { transform: scale(1.18); opacity: 1; }
}
@keyframes chatFabStar {
  0%, 100% { text-shadow: 0 0 4px rgba(255,255,255,0.55); }
  50%      { text-shadow: 0 0 12px rgba(255,255,255,0.95),
                         0 0 18px rgba(201,168,76,0.85); }
}
@keyframes spin { from{transform:rotate(0)} to{transform:rotate(360deg)} }

.chat-overlay {
  position: fixed; inset: 0; z-index: 800;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  display: none; align-items: flex-end; justify-content: flex-end;
  padding: 32px;
}
.chat-overlay.open { display: flex; }
.chat-overlay.open ~ .chat-fab,
body.chat-locked .chat-fab {
  opacity: 0;
  transform: translateY(8px) scale(0.92);
  pointer-events: none;
  transition: opacity .25s, transform .25s;
}

.chat-panel {
  width: 420px; max-width: 95vw;
  background: #13161A;
  border: 1px solid rgba(147,112,219,0.3);
  border-radius: 20px;
  overflow: hidden;
  display: flex; flex-direction: column;
  box-shadow: 0 24px 80px rgba(0,0,0,0.6);
  max-height: 80vh;
}
.chat-header {
  padding: 18px 20px;
  background:
    linear-gradient(90deg,
      rgba(107,53,217,0.45)  0%,
      rgba(201,168,76,0.40) 35%,
      rgba(40,200,220,0.40) 70%,
      rgba(155,77,232,0.45) 100%);
  border-bottom: 2px solid transparent;
  border-image: linear-gradient(90deg, #6b35d9, #c9a84c, #28c8dc, #9b4de8) 1;
  display: flex; align-items: center; justify-content: space-between;
  position: relative;
}
.chat-header::after {
  content: "";
  position: absolute; left: 0; right: 0; bottom: -2px; height: 2px;
  background: linear-gradient(90deg, #6b35d9, #c9a84c, #28c8dc, #9b4de8);
  filter: drop-shadow(0 0 6px rgba(201,168,76,0.55));
  pointer-events: none;
}
.chat-header .chat-title {
  background: linear-gradient(90deg, #ffffff 0%, #c9a84c 50%, #28c8dc 100%);
  -webkit-background-clip: text; background-clip: text; color: transparent;
  -webkit-text-fill-color: transparent;
  letter-spacing: 0.5px;
}
.chat-header .chat-subtitle {
  background: linear-gradient(90deg, rgba(201,168,76,0.95), rgba(40,200,220,0.95));
  -webkit-background-clip: text; background-clip: text; color: transparent;
  -webkit-text-fill-color: transparent;
}
.chat-header-left { display: flex; align-items: center; gap: 12px; }
.chat-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background:
    conic-gradient(from 0deg,
      #6b35d9 0deg,
      #c9a84c 90deg,
      #28c8dc 180deg,
      #9b4de8 270deg,
      #6b35d9 360deg);
  display: flex; align-items: center; justify-content: center;
  font-family: 'Bebas Neue', sans-serif; font-size: 14px; letter-spacing: 1px;
  color: white;
  box-shadow: 0 0 14px rgba(201,168,76,0.45), 0 0 18px rgba(40,200,220,0.35);
  animation: avatarSpin 6s linear infinite;
}
@keyframes avatarSpin { from { filter: hue-rotate(0deg); } to { filter: hue-rotate(360deg); } }
.chat-title { font-size: 14px; font-weight: 700; color: var(--white); }
.chat-subtitle { font-size: 10px; letter-spacing: 1px; color: rgba(147,112,219,0.8); text-transform: uppercase; }
.chat-close {
  background: none; border: none; color: rgba(240,242,245,0.4);
  font-size: 16px; cursor: pointer; padding: 4px 8px; border-radius: 6px;
  transition: all .2s;
}
.chat-close:hover { color: white; background: rgba(255,255,255,0.1); }

.chat-header-actions {
  display: flex; align-items: center; gap: 4px;
}
.chat-icon-btn {
  background: none; border: none; color: rgba(240,242,245,0.55);
  font-size: 18px; cursor: pointer; padding: 4px 8px; border-radius: 6px;
  transition: all .2s; line-height: 1;
}
.chat-icon-btn:hover { color: white; background: rgba(255,255,255,0.1); }
.chat-icon-btn.is-active { color: #c9a84c; background: rgba(201,168,76,0.12); }

/* Fullscreen chat — covers the viewport, locks body scroll */
body.chat-locked { overflow: hidden; }
.chat-panel.is-fullscreen {
  position: fixed;
  inset: 0;
  width: 100vw; max-width: 100vw; height: 100dvh;
  border-radius: 0;
  z-index: 9999;
}
.chat-panel.is-fullscreen .chat-messages { padding: 20px clamp(16px, 4vw, 48px); }
.chat-panel.is-fullscreen .chat-input-row { padding: 14px clamp(16px, 4vw, 48px); }

/* Smooth entrance for chat bubbles */
@keyframes bubbleIn {
  from { opacity: 0; transform: translateY(6px) scale(0.985); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}
.chat-bubble { animation: bubbleIn .25s cubic-bezier(.2,.7,.2,1); }

/* Code-block copy button (used by post-stream render pass) */
.chat-bubble pre {
  position: relative;
  background: #1a1f2c !important;
  border: 1px solid rgba(201,168,76,0.25);
  border-radius: 10px;
  padding: 14px 16px 12px 16px;
  margin: 10px 0;
  overflow-x: auto;
  box-shadow: 0 4px 20px rgba(0,0,0,0.4),
              inset 0 0 0 1px rgba(255,255,255,0.02);
  font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', Menlo, Consolas, monospace;
  font-size: 12.5px;
  line-height: 1.6;
  scrollbar-width: thin;
  scrollbar-color: rgba(201,168,76,0.4) transparent;
}
.chat-bubble pre code {
  background: transparent !important;
  padding: 0 !important;
  color: #abb2bf;
  font-family: inherit;
  font-size: inherit;
  display: block;
}
/* Reset hljs token colors so they always read against the dark pre bg */
.chat-bubble .hljs-comment, .chat-bubble .hljs-quote { color: #5c6370; font-style: italic; }
.chat-bubble .hljs-keyword, .chat-bubble .hljs-selector-tag, .chat-bubble .hljs-doctag { color: #c678dd; font-weight: 600; }
.chat-bubble .hljs-string, .chat-bubble .hljs-attr, .chat-bubble .hljs-template-tag, .chat-bubble .hljs-template-variable { color: #98c379; }
.chat-bubble .hljs-number, .chat-bubble .hljs-literal, .chat-bubble .hljs-symbol { color: #d19a66; }
.chat-bubble .hljs-title, .chat-bubble .hljs-name, .chat-bubble .hljs-attribute, .chat-bubble .hljs-variable { color: #61aeee; }
.chat-bubble .hljs-built_in, .chat-bubble .hljs-meta { color: #e6c07b; }
.chat-bubble .hljs-class .hljs-title, .chat-bubble .hljs-title.class_ { color: #e6c07b; }
.chat-bubble .hljs-type { color: #d19a66; }
.chat-bubble .hljs-tag { color: #e06c75; }
.chat-bubble .hljs-regexp { color: #98c379; }
.chat-bubble .hljs-deletion { color: #e06c75; background: rgba(224,108,117,0.15); }
.chat-bubble .hljs-addition { color: #98c379; background: rgba(152,195,121,0.15); }
.chat-bubble .hljs-emphasis { font-style: italic; }
.chat-bubble .hljs-strong { font-weight: 700; }

/* Inline code (single ``...``) */
.chat-bubble :not(pre) > code {
  background: rgba(201,168,76,0.15);
  color: #c9a84c;
  border: 1px solid rgba(201,168,76,0.25);
  border-radius: 5px;
  padding: 1px 6px;
  font-family: 'JetBrains Mono', 'Fira Code', 'SF Mono', Menlo, Consolas, monospace;
  font-size: 0.92em;
}

/* Language tag (top-right colored strip) */
.chat-bubble pre .lang-tag {
  position: absolute;
  top: 6px; right: 70px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  padding: 2px 8px;
  border-radius: 100px;
  background: linear-gradient(90deg, rgba(107,53,217,0.5), rgba(40,200,220,0.5));
  color: white;
  text-shadow: 0 0 6px rgba(0,0,0,0.6);
  pointer-events: none;
  opacity: 0;
  transition: opacity .2s;
}
.chat-bubble pre:hover .lang-tag { opacity: 1; }

.chat-bubble pre .code-copy {
  position: absolute; top: 8px; right: 8px;
  background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.7);
  border: 1px solid rgba(255,255,255,0.12);
  font-size: 11px; padding: 3px 8px; border-radius: 5px;
  cursor: pointer; transition: all .15s; opacity: 0;
  z-index: 2;
}
.chat-bubble pre:hover .code-copy { opacity: 1; }
.chat-bubble pre .code-copy:hover { background: rgba(255,255,255,0.18); color: white; }
.chat-bubble pre .code-copy.is-copied { background: rgba(76,175,80,0.25); color: #b6f0bb; opacity: 1; }

.chat-messages {
  flex: 1; overflow-y: auto; padding: 16px;
  display: flex; flex-direction: column; gap: 12px;
  scrollbar-width: thin; scrollbar-color: rgba(147,112,219,0.3) transparent;
}
.chat-msg { display: flex; }
.chat-msg.user { justify-content: flex-end; }
.chat-bubble {
  max-width: 82%; padding: 10px 14px;
  border-radius: 14px; font-size: 13px; line-height: 1.55;
  font-weight: 400;
}
.chat-msg.bot .chat-bubble {
  background: var(--surface-2);
  border: 1px solid var(--border);
  color: rgba(240,242,245,0.85);
  border-bottom-left-radius: 4px;
}
.chat-msg.user .chat-bubble {
  background: linear-gradient(135deg, #6b35d9, #9b4de8);
  color: white; border-bottom-right-radius: 4px;
}
.chat-typing {
  display: flex; align-items: center; gap: 4px; padding: 8px 4px;
}
.chat-typing span {
  width: 6px; height: 6px; background: rgba(147,112,219,0.7);
  border-radius: 50%;
  animation: typing .9s ease infinite;
}
.chat-typing span:nth-child(2){animation-delay:.2s}
.chat-typing span:nth-child(3){animation-delay:.4s}
@keyframes typing {0%,100%{transform:translateY(0)} 50%{transform:translateY(-6px)}}

.chat-quick-btns {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 8px 16px;
  border-top: 1px solid var(--border);
}
.quick-btn {
  padding: 5px 12px;
  background: rgba(147,112,219,0.1);
  border: 1px solid rgba(147,112,219,0.25);
  border-radius: 100px; color: rgba(147,112,219,0.9);
  font-size: 11px; font-weight: 600; cursor: pointer;
  transition: all .2s; letter-spacing: .5px;
}
.quick-btn:hover { background: rgba(147,112,219,0.25); border-color: rgba(147,112,219,0.6); color: white; }

.chat-input-row {
  display: flex; gap: 8px; padding: 12px 16px;
  border-top: 1px solid rgba(255,255,255,0.06);
  background: var(--surface);
}
.chat-input {
  flex: 1; padding: 10px 14px;
  background: var(--surface-2);
  border: 1px solid var(--border);
  border-radius: 10px; color: var(--white);
  font-size: 13px; font-family: 'Manrope', sans-serif;
  outline: none; transition: border-color .2s;
}
.chat-input:focus { border-color: rgba(147,112,219,0.5); }
.chat-input::placeholder { color: rgba(240,242,245,0.3); }
.chat-send {
  padding: 10px 18px;
  background: linear-gradient(135deg, #6b35d9, #9b4de8);
  border: none; border-radius: 10px;
  color: white; font-size: 12px; font-weight: 700;
  cursor: pointer; letter-spacing: 1px; transition: all .2s;
}
.chat-send:hover { opacity: .9; transform: translateY(-1px); }
.chat-send:disabled { opacity: .4; cursor: default; transform: none; }

/* Visually-hidden helper for screen-reader-only labels */
.sr-only {
  position: absolute !important;
  width: 1px; height: 1px;
  padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0, 0, 0, 0);
  white-space: nowrap; border: 0;
}

