/* ═══════════════════════════════════════════════════════════════════
   Clara UI — Design System
   Accent:  Royal blue   #3B60F0
   Online:  Green        #22c55e
   Panel:   White cards  #ffffff / soft shadow
   Chat bg: Lavender-gray #f2f3f8
   Bubbles: User  #e9eaee  |  Clara white #ffffff
   Font:    Manrope (existing)
═══════════════════════════════════════════════════════════════════ */

:root {
  --accent:        #3B60F0;
  --accent-dark:   #2545d4;
  --accent-light:  #eef1fe;
  --green:         #22c55e;
  --text:          #1a1d27;
  --muted:         #6b7280;
  --muted-light:   #9ca3af;
  --line:          rgba(0,0,0,0.07);
  --bubble-clara:  #ffffff;
  --bubble-user:   #e9eaee;
  --panel-bg:      #f2f3f8;
  --shell-bg:      #e8ecf5;
  --card-shadow:   0 4px 24px rgba(59,96,240,0.10), 0 1px 4px rgba(0,0,0,0.06);
  --card-radius:   18px;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  height: 100%;
}

body {
  font-family: "Manrope", sans-serif;
  color: var(--text);
  overflow: hidden;
  background: var(--shell-bg);
}

/* ─── Layout shell ──────────────────────────────────────────────── */

.page-shell {
  display: grid;
  grid-template-columns: 1.38fr 1fr;
  gap: 0.75rem;
  height: 100vh;
  padding: 0.75rem;
}

/* ═══════════════════════════════════════════════════════════════════
   LEFT PANEL — Avatar stage
═══════════════════════════════════════════════════════════════════ */

.stage-panel {
  display: flex;
  align-items: stretch;
  justify-content: stretch;
  min-width: 0;
  min-height: 0;
}

.stage-frame {
  position: relative;
  width: 100%;
  height: 100%;
  overflow: hidden;
  border-radius: 24px;
  background:
    radial-gradient(circle at top, rgba(235,241,248,0.95), transparent 40%),
    linear-gradient(180deg, #edf1f7 0%, #c6d0dd 100%);
  box-shadow: var(--card-shadow);
}

#scene {
  display: block;
  width: 100%;
  height: 100%;
}

/* ── Brand card (top-left overlay) ─────────────────────────────── */

.avatar-brand-card {
  position: absolute;
  top: 1rem;
  left: 1rem;
  display: flex;
  align-items: center;
  gap: 0.6rem;
  padding: 0.55rem 0.9rem 0.55rem 0.6rem;
  background: rgba(255,255,255,0.88);
  backdrop-filter: blur(10px);
  border-radius: 50px;
  box-shadow: 0 2px 12px rgba(59,96,240,0.12), 0 1px 3px rgba(0,0,0,0.06);
  pointer-events: none;
  user-select: none;
}

.brand-avatar-icon {
  width: 28px;
  height: 28px;
  flex-shrink: 0;
}

.brand-avatar-icon svg { width: 100%; height: 100%; display: block; }

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.brand-name {
  font-weight: 800;
  font-size: 0.9rem;
  color: var(--text);
  letter-spacing: -0.01em;
}

.brand-subtitle {
  font-size: 0.68rem;
  font-weight: 500;
  color: var(--muted);
}

/* ── Bottom card (quick-actions + stats overlay) ────────────────── */

.avatar-bottom-card {
  position: absolute;
  bottom: 1rem;
  left: 1rem;
  right: 1rem;
  padding: 0.9rem 1rem 0.85rem;
  /* cool-tinted glass — blends with the gray corporate office background */
  background: rgba(248,250,253,0.82);
  backdrop-filter: blur(18px) saturate(1.4);
  border: 1px solid rgba(150,168,195,0.30);
  border-radius: var(--card-radius);
  box-shadow:
    0 8px 32px rgba(45,70,110,0.12),
    0 1px 4px rgba(45,70,110,0.08);
}

.ask-label {
  margin: 0 0 0.6rem;
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #64748b;  /* cool slate — matches the gray office background */
}

.quick-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  margin-bottom: 0.85rem;
}

.quick-pill {
  display: inline-flex;
  align-items: center;
  gap: 0.32rem;
  padding: 0.38rem 0.72rem;
  border-radius: 999px;
  /* cool-neutral pill background — soft white with a blue accent border */
  border: 1.5px solid rgba(59,96,240,0.22);
  background: rgba(250,252,255,0.92);
  color: var(--accent);
  font-family: inherit;
  font-size: 0.72rem;
  font-weight: 700;
  cursor: pointer;
  transition: background 140ms ease, border-color 140ms ease, transform 120ms ease,
              box-shadow 140ms ease;
}

.quick-pill:hover {
  background: var(--accent);
  color: #fff;
  border-color: var(--accent);
  transform: translateY(-1px);
  box-shadow: 0 4px 14px rgba(59,96,240,0.30);
}

.pill-icon {
  width: 13px;
  height: 13px;
  flex-shrink: 0;
}

/* Stats row */

.stats-row {
  display: flex;
  align-items: center;
  gap: 0;
  padding-top: 0.7rem;
  /* warm separator line — echoes the beige palette */
  border-top: 1px solid rgba(190,145,100,0.20);
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex: 1;
  min-width: 0;
}

.stat-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}
.stat-icon svg { width: 100%; height: 100%; }

.stat-value {
  font-size: 0.8rem;
  font-weight: 800;
  color: #2b1f14;   /* deep warm brown — high contrast on warm card */
  white-space: nowrap;
}

.stat-label {
  font-size: 0.62rem;
  font-weight: 500;
  color: #64748b;   /* cool slate — softer than generic gray */
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.stat-divider {
  width: 1px;
  height: 28px;
  background: rgba(120,140,170,0.25);
  flex-shrink: 0;
  margin: 0 0.5rem;
}

/* ═══════════════════════════════════════════════════════════════════
   RIGHT PANEL — Chat
═══════════════════════════════════════════════════════════════════ */

.conversation-panel {
  display: flex;
  flex-direction: column;
  min-width: 0;
  min-height: 0;
  border-radius: 24px;
  background: var(--panel-bg);
  box-shadow: var(--card-shadow);
  overflow: hidden;
}

/* ── Chat header ────────────────────────────────────────────────── */

.chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.85rem 1rem 0.8rem;
  background: #fff;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}

.chat-header-left {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}

.chat-logo-icon {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
}
.chat-logo-icon svg { width: 100%; height: 100%; display: block; }

.chat-header-info {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
  gap: 0.05rem;
}

.chat-header-name {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  font-size: 0.95rem;
  letter-spacing: 0.08em;
  color: var(--text);
}

.chat-header-status {
  display: flex;
  align-items: center;
  gap: 0.3rem;
}

.status-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--green);
  box-shadow: 0 0 0 0 rgba(34,197,94,0.5);
  animation: pulse-green 2.4s ease-out infinite;
  flex-shrink: 0;
}

@keyframes pulse-green {
  0%   { box-shadow: 0 0 0 0 rgba(34,197,94,0.5); }
  70%  { box-shadow: 0 0 0 5px rgba(34,197,94,0); }
  100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); }
}

.status-text {
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--green);
}

.chat-header-sub {
  font-size: 0.65rem;
  color: var(--muted-light);
  font-weight: 500;
}

.chat-header-more {
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: background 150ms ease;
}
.chat-header-more:hover { background: var(--line); }
.chat-header-more svg { width: 18px; height: 18px; }

/* ── Message list ───────────────────────────────────────────────── */

.chat-log {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
  overflow-x: hidden;
  padding: 1rem 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
  scroll-behavior: smooth;
}

.chat-log::-webkit-scrollbar { width: 4px; }
.chat-log::-webkit-scrollbar-track { background: transparent; }
.chat-log::-webkit-scrollbar-thumb { background: rgba(59,96,240,0.15); border-radius: 99px; }

/* Chat bubbles — app.js writes .transcript-line.assistant / .user */

.transcript-line {
  display: flex;
  flex-direction: column;
  max-width: 85%;
  animation: bubble-in 220ms ease;
}

@keyframes bubble-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Clara — left-aligned white bubble */
.transcript-line.assistant {
  align-self: flex-start;
  align-items: flex-start;
}

/* User — right-aligned gray bubble */
.transcript-line.user {
  align-self: flex-end;
  align-items: flex-end;
}

/* Speaker label above bubble */
.transcript-line .speaker {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  font-size: 0.63rem;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  margin-bottom: 0.28rem;
  padding: 0 0.25rem;
}

.transcript-line.assistant .speaker { color: var(--accent); }
.transcript-line.user      .speaker { color: var(--muted); }

/* Bubble body */
.transcript-line .text {
  padding: 0.65rem 0.9rem;
  border-radius: 16px;
  font-size: 0.875rem;
  line-height: 1.55;
  word-break: break-word;
  white-space: pre-wrap;
}

.transcript-line.assistant .text {
  background: var(--bubble-clara);
  color: var(--text);
  border-radius: 4px 16px 16px 16px;
  box-shadow: 0 1px 6px rgba(0,0,0,0.07);
}

.transcript-line.user .text {
  background: var(--bubble-user);
  color: var(--text);
  border-radius: 16px 4px 16px 16px;
}

/* Rendered Markdown inside Clara's transcript bubbles */
.transcript-line .text p {
  margin: 0 0 0.5em;
}
.transcript-line .text p:last-child {
  margin-bottom: 0;
}
.transcript-line .text ul,
.transcript-line .text ol {
  margin: 0.3em 0 0.5em;
  padding-left: 1.3em;
}
.transcript-line .text ul:last-child,
.transcript-line .text ol:last-child {
  margin-bottom: 0;
}
.transcript-line .text li {
  margin: 0.12em 0;
}
.transcript-line .text .md-h {
  font-weight: 700;
  margin: 0.15em 0 0.35em;
}
.transcript-line .text .md-h:first-child {
  margin-top: 0;
}
.transcript-line .text strong {
  font-weight: 700;
}
.transcript-line .text em {
  font-style: italic;
}
.transcript-line .text code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
  font-size: 0.85em;
  background: rgba(59, 96, 240, 0.1);
  padding: 0.1em 0.35em;
  border-radius: 4px;
}
.transcript-line .text a {
  color: var(--accent);
  text-decoration: underline;
}

/* Live "hearing you" bubble — interim words / mic waveform while you speak */
.transcript-line.interim {
  animation: none;
}

.transcript-line.interim .text {
  font-style: italic;
  opacity: 0.65;
  border: 1px dashed rgba(100,116,139,0.45);
  background: transparent;
}

/* Thinking indicator inherits assistant styling */
.transcript-line.thinking .text {
  min-width: 56px;
}

/* Thinking dots animation — keeps app.js's existing markup */
.thinking-dots {
  display: inline-flex;
  align-items: center;
  gap: 0.28rem;
  padding: 0.1rem 0;
}

.thinking-dots span {
  width: 0.4rem;
  height: 0.4rem;
  border-radius: 999px;
  background: var(--accent);
  opacity: 0.45;
  animation: thinking-bounce 1.2s ease-in-out infinite;
}

.thinking-dots span:nth-child(2) { animation-delay: 0.2s; }
.thinking-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes thinking-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.35; }
  40%           { transform: translateY(-0.3rem); opacity: 1; }
}

/* ── Bottom bar ─────────────────────────────────────────────────── */

.chat-bottom-bar {
  flex-shrink: 0;
  padding: 0.65rem 0.75rem 0.75rem;
  background: #fff;
  border-top: 1px solid var(--line);
}

/* Idle: mic control only */
.bar-idle {
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--panel-bg);
  border-radius: 999px;
  padding: 0.45rem 1rem;
  border: 1.5px solid transparent;
  min-height: 48px;
}

.mic-status-container {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.mic-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 200ms ease, transform 200ms ease, box-shadow 200ms ease, color 200ms ease;
}

.mic-btn:hover {
  transform: scale(1.05);
}

.mic-btn svg {
  width: 18px;
  height: 18px;
  position: relative;
  z-index: 2;
}

/* Listening (Active continuous voice capture) */
.mic-btn.listening {
  background: var(--accent);
  color: #fff;
  animation: mic-pulse 2s infinite;
}

/* Thinking state */
.mic-btn.thinking {
  background: #f59e0b; /* Amber/Orange for thinking */
  color: #fff;
  animation: mic-pulse-thinking 1.2s infinite;
}

/* Stopped / Paused state */
.mic-btn.stopped {
  background: var(--muted-light);
  color: #fff;
  box-shadow: none;
}

.mic-status-text {
  font-family: inherit;
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text);
  user-select: none;
  letter-spacing: -0.01em;
}

@keyframes mic-pulse {
  0% {
    box-shadow: 0 0 0 0 rgba(59, 96, 240, 0.5);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(59, 96, 240, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(59, 96, 240, 0);
  }
}

@keyframes mic-pulse-thinking {
  0% {
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.6);
  }
  70% {
    box-shadow: 0 0 0 8px rgba(245, 158, 11, 0);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(245, 158, 11, 0);
  }
}

/* Speaking: waveform + label + stop */
.bar-speaking {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--panel-bg);
  border-radius: 999px;
  padding: 0.55rem 0.5rem 0.55rem 1rem;
}

.bar-speaking[hidden] { display: none; }
.bar-idle[hidden]     { display: none; }

.speaking-wave {
  display: flex;
  align-items: center;
  gap: 3px;
  flex-shrink: 0;
}

.speaking-wave span {
  width: 3px;
  border-radius: 99px;
  background: var(--accent);
  animation: wave-bar 1s ease-in-out infinite;
}
.speaking-wave span:nth-child(1) { height: 8px;  animation-delay: 0.0s; }
.speaking-wave span:nth-child(2) { height: 14px; animation-delay: 0.15s; }
.speaking-wave span:nth-child(3) { height: 20px; animation-delay: 0.3s; }
.speaking-wave span:nth-child(4) { height: 14px; animation-delay: 0.45s; }
.speaking-wave span:nth-child(5) { height: 8px;  animation-delay: 0.6s; }

@keyframes wave-bar {
  0%, 100% { transform: scaleY(0.5); opacity: 0.5; }
  50%       { transform: scaleY(1.0); opacity: 1;   }
}

.speaking-label {
  flex: 1;
  font-size: 0.83rem;
  font-weight: 600;
  color: var(--muted);
}

.speaking-stop-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: #fee2e2;
  color: #ef4444;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 150ms ease, transform 150ms ease;
}
.speaking-stop-btn:hover { background: #fca5a5; transform: scale(1.06); }
.speaking-stop-btn svg { width: 16px; height: 16px; }

/* ── Hidden real controls (app.js must find them) ─────────────── */
/* stop-toggle: app.js queries this class and toggles .stopped on it */
button.stop-toggle {
  display: none;   /* hidden — behaviour delegated to bar chrome */
}

/* ═══════════════════════════════════════════════════════════════════
   Start overlay
═══════════════════════════════════════════════════════════════════ */

.start-overlay {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1.5rem;
  background: rgba(232, 236, 245, 0.72);
  backdrop-filter: blur(14px);
  z-index: 50;
  animation: overlay-fade 220ms ease;
}

.start-overlay.hidden { display: none; }

.overlay-card {
  max-width: 380px;
  padding: 2.2rem 2rem;
  border-radius: 28px;
  background: #fff;
  border: 1px solid rgba(59,96,240,0.10);
  box-shadow: 0 24px 64px rgba(59,96,240,0.16), 0 2px 8px rgba(0,0,0,0.06);
  text-align: center;
}

.overlay-eyebrow {
  margin: 0 0 0.6rem;
  font-family: "Space Grotesk", sans-serif;
  font-size: 0.7rem;
  font-weight: 700;
  letter-spacing: 0.22em;
  text-transform: uppercase;
  color: var(--accent);
}

h2 {
  margin: 0 0 0.75rem;
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  font-size: clamp(1.5rem, 3vw, 2.1rem);
  color: var(--text);
  line-height: 1.1;
}

.overlay-card p {
  margin: 0 auto 1.6rem;
  max-width: 36ch;
  font-size: 0.9rem;
  line-height: 1.6;
  color: var(--muted);
}

/* ─── Buttons ────────────────────────────────────────────────────── */

button {
  border: 0;
  border-radius: 999px;
  font: inherit;
  cursor: pointer;
  transition: transform 150ms ease, background 150ms ease,
              color 150ms ease, opacity 150ms ease, box-shadow 150ms ease;
}

button:hover:not(:disabled) { transform: translateY(-1px); }
button:disabled { cursor: wait; opacity: 0.6; transform: none; }

button.primary {
  padding: 0.9rem 2rem;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 0.95rem;
  box-shadow: 0 6px 20px rgba(59,96,240,0.30);
}
button.primary:hover {
  background: var(--accent-dark);
  box-shadow: 0 10px 28px rgba(59,96,240,0.38);
}

button.large { min-width: 200px; }

@keyframes overlay-fade {
  from { opacity: 0; }
  to   { opacity: 1; }
}

/* ─── Accessibility ──────────────────────────────────────────────── */

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

/* ─── Responsive ─────────────────────────────────────────────────── */

@media (max-width: 900px) {
  .page-shell {
    grid-template-columns: 1fr;
    grid-template-rows: minmax(0, 1.15fr) minmax(0, 1fr);
    gap: 0.6rem;
    padding: 0.6rem;
  }

  .stage-frame { border-radius: 20px; }
  .conversation-panel { border-radius: 20px; }

  .avatar-bottom-card { bottom: 0.6rem; left: 0.6rem; right: 0.6rem; }
  .quick-pills { gap: 0.3rem; }
  .quick-pill  { font-size: 0.67rem; padding: 0.3rem 0.55rem; }
  .stat-label  { display: none; }
}

@media (max-width: 640px) {
  .stat-divider { margin: 0 0.25rem; }
  .chat-header-sub { display: none; }
}
