/* ================= v2.7 Assistant redesign: Angel AI mascot, FAB, pending-action tray, thread sidebar ================= */
/* All colors reference the existing theme tokens defined in index.html's inline <style> — nothing here is hardcoded, so it recolors automatically across Light/Dark/Night/Gold/Slate. */

/* ---- Angel AI mascot (halo + wingtips + particles), reused at three sizes: FAB, message avatar, screen header ---- */
.angel-mascot { color: var(--blue); display: inline-block; overflow: visible; }
.angel-mascot .angel-halo { transform-origin: 50% 50%; animation: angelHaloSpin 10s linear infinite; }
.angel-mascot .angel-wing { fill: currentColor; opacity: 0.85; }
.angel-mascot .angel-particle { fill: currentColor; transform-origin: center; animation: angelTwinkle 2.6s ease-in-out infinite; }
.angel-mascot .angel-particle:nth-child(2) { animation-delay: 0.3s; }
.angel-mascot .angel-particle:nth-child(3) { animation-delay: 0.6s; }
.angel-mascot .angel-particle:nth-child(4) { animation-delay: 0.9s; }
.angel-mascot .angel-particle:nth-child(5) { animation-delay: 1.2s; }

/* "Thinking" state — toggled by JS while a reply is streaming/pending: halo spins faster, particles pulse brighter/faster. */
.angel-mascot.thinking .angel-halo { animation: angelHaloSpin 2.4s linear infinite; }
.angel-mascot.thinking .angel-particle { animation: angelTwinkleActive 0.9s ease-in-out infinite; }

@keyframes angelHaloSpin { from { transform: rotate(0deg); } to { transform: rotate(360deg); } }
@keyframes angelTwinkle { 0%, 100% { opacity: 0.35; transform: scale(0.85); } 50% { opacity: 0.95; transform: scale(1.15); } }
@keyframes angelTwinkleActive { 0%, 100% { opacity: 0.55; transform: scale(0.9); } 50% { opacity: 1; transform: scale(1.35); } }

@media (prefers-reduced-motion: reduce) {
  .angel-mascot .angel-halo, .angel-mascot .angel-particle { animation: none !important; }
}

/* ---- Floating action button — present on every screen ---- */
#assistant-fab {
  position: fixed; right: 22px; bottom: 22px; z-index: 900;
  width: 56px; height: 56px; border-radius: 50%;
  background: var(--surface); border: 1px solid var(--border-2); box-shadow: var(--shadow-lg);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
  transition: transform .15s ease;
}
#assistant-fab:hover { transform: scale(1.06); }
#assistant-fab.hidden { display: none; }

/* ---- FAB slide-over ---- */
#assistant-flyout {
  position: fixed; right: 16px; bottom: 90px; z-index: 901;
  width: min(400px, calc(100vw - 32px)); max-height: min(640px, calc(100vh - 130px));
  background: var(--surface); border: 1px solid var(--border); border-radius: 20px; box-shadow: var(--shadow-lg);
  display: none; flex-direction: column; overflow: hidden;
}
#assistant-flyout.open { display: flex; }
.assistant-flyout-head {
  display: flex; align-items: center; gap: 10px; padding: 14px 16px; border-bottom: 1px solid var(--border);
}
.assistant-flyout-head .flyout-title { font-weight: 600; font-size: 14.5px; color: var(--text); flex: 1; }
.assistant-flyout-close { cursor: pointer; color: var(--text-3); font-size: 18px; background: none; border: none; padding: 4px; }

/* ---- Assistant full-page screen layout: sidebar + main pane ---- */
.assistant-shell { display: flex; gap: 16px; min-height: 560px; }
.assistant-sidebar {
  width: 220px; flex-shrink: 0; display: flex; flex-direction: column; gap: 8px;
  border-right: 1px solid var(--border); padding-right: 14px;
}
.assistant-thread-item {
  padding: 9px 10px; border-radius: 10px; font-size: 13px; color: var(--text-2); cursor: pointer;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; border: 1px solid transparent;
}
.assistant-thread-item:hover { background: var(--surface-2); }
.assistant-thread-item.active { background: var(--blue-soft); color: var(--text); border-color: var(--border-2); font-weight: 600; }
.assistant-main { flex: 1; display: flex; flex-direction: column; gap: 12px; min-width: 0; }

/* ---- Suggested-prompt chips (shown only when the active thread is empty) ---- */
.assistant-chip-row { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.assistant-chip {
  border: 1px solid var(--border-2); background: var(--surface-2); color: var(--text-2);
  border-radius: 999px; padding: 8px 14px; font-size: 12.5px; cursor: pointer;
}
.assistant-chip:hover { background: var(--blue-soft); color: var(--text); }

/* ---- Pending-action tray — visually distinct from chat bubbles, on both the full screen and the flyout ---- */
.assistant-tray {
  border: 1px solid var(--border-2); background: var(--surface-2); border-radius: 16px; padding: 12px 14px;
  display: flex; flex-direction: column; gap: 10px;
}
.assistant-tray-title { font-size: 12px; font-weight: 700; letter-spacing: .04em; text-transform: uppercase; color: var(--text-3); }
.assistant-tray-empty { font-size: 12.5px; color: var(--text-3); }
.assistant-tray-card {
  background: var(--surface); border: 1px solid var(--border); border-radius: 12px; padding: 10px 12px;
}
.assistant-tray-summary { font-size: 13px; color: var(--text); margin-bottom: 8px; }
.assistant-tray-actions { display: flex; gap: 8px; }
.assistant-tray-result { margin-top: 8px; font-size: 12.5px; color: var(--text-2); }

/* ---- Chat bubbles ---- */
.assistant-bubble-row { display: flex; gap: 10px; align-items: flex-start; }
.assistant-bubble-row.user { justify-content: flex-end; }
.assistant-bubble {
  max-width: 82%; padding: 10px 13px; border-radius: 14px; font-size: 13.5px; line-height: 1.45; white-space: pre-wrap;
}
.assistant-bubble-row.assistant .assistant-bubble { background: var(--surface-2); color: var(--text); }
.assistant-bubble-row.user .assistant-bubble { background: var(--blue); color: #fff; }

@media (max-width: 720px) {
  .assistant-shell { flex-direction: column; }
  .assistant-sidebar { width: 100%; border-right: none; border-bottom: 1px solid var(--border); padding-right: 0; padding-bottom: 10px; flex-direction: row; overflow-x: auto; }
  .assistant-thread-item { white-space: nowrap; }
}

/* ---- Icon buttons on the in-progress chat input row (attach / mic) — theme-token surfaces, hover state only. ---- */
.assistant-icon-btn {
  flex-shrink: 0; width: 40px; height: 40px; border-radius: 12px; display: flex; align-items: center; justify-content: center;
  border: 1px solid var(--border); background: var(--surface); color: var(--text-2); cursor: pointer; transition: background .15s ease, color .15s ease;
}
.assistant-icon-btn:hover { background: var(--surface-2); color: var(--text); }
.assistant-icon-btn.listening { color: #fff; background: var(--red); border-color: transparent; animation: angelMicPulse 1.2s ease-in-out infinite; }
@keyframes angelMicPulse { 0%, 100% { opacity: 1; } 50% { opacity: .6; } }

/* ---- Attachment preview strip — shown above whichever input row has a pending attachment. ---- */
.assistant-attachment-preview { display: flex; align-items: center; gap: 8px; }
.assistant-attach-thumb { width: 40px; height: 40px; border-radius: 8px; object-fit: cover; border: 1px solid var(--border); }
.assistant-attach-file {
  font-size: 12.5px; color: var(--text-2); background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 8px; padding: 6px 10px; max-width: 240px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.assistant-attach-remove {
  width: 22px; height: 22px; border-radius: 50%; border: 1px solid var(--border-2); background: var(--surface);
  color: var(--text-2); cursor: pointer; font-size: 14px; line-height: 1; display: flex; align-items: center; justify-content: center;
}
.assistant-attach-remove:hover { background: var(--surface-2); color: var(--text); }
.assistant-bubble-thumb { display: block; margin-top: 8px; max-width: 220px; max-height: 220px; border-radius: 10px; }

/* =================================================================================================================
   v2.9.1 — Angel AI welcome screen (empty/new-conversation state), layered on top of .assistant-shell.
   DM's explicit call: this section's accent/glow is a FIXED violet — the one deliberate exception to this app's
   theme-token colors — while every surface/background/text color here still comes from the theme tokens above, so
   Light stays readable and Dark/Night/Gold/Slate all still look correct. Only --aai-accent/--aai-glow are fixed.
   ================================================================================================================= */
.assistant-welcome {
  --aai-accent: #8b5cf6;
  --aai-accent-2: #a855f7;
  --aai-glow: rgba(139, 92, 246, 0.35);
  --aai-glow-soft: rgba(139, 92, 246, 0.16);
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: 6px; padding: 36px 16px 28px; flex: 1;
}
.assistant-welcome-mascot-frame {
  position: relative; width: 128px; height: 128px; display: flex; align-items: center; justify-content: center; margin-bottom: 6px;
}
/* Blurred radial glow behind the existing angel mascot — bigger + softer than the FAB/avatar usages, reads like the
   reference's glowing orb while the mascot itself (halo + wingtips + particles) is untouched. */
.assistant-welcome-mascot-frame::before {
  content: ""; position: absolute; inset: 0; border-radius: 50%;
  background: radial-gradient(circle, var(--aai-glow) 0%, var(--aai-glow-soft) 45%, transparent 72%);
  filter: blur(6px); animation: angelWelcomeGlowPulse 4s ease-in-out infinite;
}
.assistant-welcome-mascot-frame::after {
  content: ""; position: absolute; inset: 14px; border-radius: 50%; border: 1px solid var(--aai-glow);
}
.assistant-welcome-mascot-frame .angel-mascot { position: relative; z-index: 1; color: var(--aai-accent); }
@keyframes angelWelcomeGlowPulse { 0%, 100% { opacity: .75; transform: scale(1); } 50% { opacity: 1; transform: scale(1.05); } }
@media (prefers-reduced-motion: reduce) { .assistant-welcome-mascot-frame::before { animation: none; } }

.assistant-welcome-eyebrow { font-size: 14px; font-weight: 600; color: var(--aai-accent); letter-spacing: .01em; }
.assistant-welcome-headline { font-size: 26px; font-weight: 700; color: var(--text); letter-spacing: -0.01em; margin-bottom: 6px; }

.assistant-welcome-cards { display: flex; flex-wrap: wrap; justify-content: center; gap: 10px; max-width: 720px; margin: 8px 0 26px; }
.assistant-welcome-card {
  flex: 1 1 200px; max-width: 260px; text-align: left; padding: 14px 16px; border-radius: 16px; font-size: 13px; line-height: 1.4;
  color: var(--text-2); background: var(--surface); border: 1px solid var(--border); cursor: pointer; transition: border-color .15s ease, transform .15s ease;
}
.assistant-welcome-card:hover {
  border-color: var(--aai-accent); color: var(--text); transform: translateY(-1px);
  box-shadow: 0 0 0 1px var(--aai-glow-soft);
}

.assistant-welcome-inputbar {
  width: min(640px, 100%); display: flex; align-items: center; gap: 8px; padding: 8px 8px 8px 18px;
  border-radius: 999px; background: var(--surface); border: 1px solid var(--aai-glow);
  box-shadow: 0 0 0 1px var(--aai-glow-soft), 0 8px 28px var(--aai-glow-soft);
}
.assistant-welcome-inputbar:focus-within {
  border-color: var(--aai-accent); box-shadow: 0 0 0 2px var(--aai-glow-soft), 0 8px 28px var(--aai-glow);
}
.assistant-welcome-textarea {
  flex: 1; border: none; background: transparent; color: var(--text); font-size: 14.5px; font-family: inherit;
  resize: none; padding: 10px 4px; max-height: 120px; outline: none;
}
.assistant-pill-icon-btn, .assistant-pill-send-btn {
  flex-shrink: 0; width: 38px; height: 38px; border-radius: 50%; border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center; transition: background .15s ease, color .15s ease, opacity .15s ease;
}
.assistant-pill-icon-btn { background: transparent; color: var(--text-3); }
.assistant-pill-icon-btn:hover { background: var(--surface-2); color: var(--text-2); }
.assistant-pill-icon-btn.listening { color: #fff; background: var(--red); animation: angelMicPulse 1.2s ease-in-out infinite; }
.assistant-pill-send-btn { background: var(--aai-accent); color: #fff; }
.assistant-pill-send-btn:hover { background: var(--aai-accent-2); }

@media (max-width: 640px) {
  .assistant-welcome-headline { font-size: 21px; }
  .assistant-welcome-cards { flex-direction: column; align-items: stretch; }
  .assistant-welcome-card { max-width: none; }
}
