/* ═══════════════════════════════════════════════
   BuzzVoice — Premium Audio Browser Theme
   ═══════════════════════════════════════════════ */

/* ─── Design Tokens ─── */
:root {
  --bg-deep: #050810;
  --bg-base: #0a0e1a;
  --bg-surface: #0f1629;
  --bg-elevated: #151d33;
  --bg-glass: rgba(15, 22, 41, 0.65);
  --bg-glass-hover: rgba(20, 30, 55, 0.75);

  --accent-blue: #3b82f6;
  --accent-cyan: #06b6d4;
  --accent-purple: #8b5cf6;
  --accent-gradient: linear-gradient(135deg, #3b82f6 0%, #06b6d4 50%, #8b5cf6 100%);
  --accent-glow: 0 0 30px rgba(59, 130, 246, 0.3);

  --text-primary: #f1f5f9;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  --text-accent: #7dd3fc;

  --border-subtle: rgba(148, 163, 184, 0.08);
  --border-glass: rgba(148, 163, 184, 0.12);

  --mic-size: 88px;
  --mic-recording: #ef4444;

  --radius-sm: 8px;
  --radius-md: 14px;
  --radius-lg: 20px;
  --radius-full: 9999px;

  --font: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  --transition: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ─── Reset & Base ─── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html {
  font-size: 16px;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

body {
  font-family: var(--font);
  background: var(--bg-deep);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  line-height: 1.6;
}

/* ─── Ambient Background ─── */
.ambient-bg {
  position: fixed;
  inset: 0;
  z-index: 0;
  overflow: hidden;
  pointer-events: none;
}

.ambient-orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(120px);
  opacity: 0.4;
  animation: ambientFloat 20s ease-in-out infinite;
}

.ambient-orb--1 {
  width: 500px; height: 500px;
  background: radial-gradient(circle, rgba(59,130,246,0.35), transparent 70%);
  top: -10%; left: -5%;
  animation-duration: 25s;
}

.ambient-orb--2 {
  width: 400px; height: 400px;
  background: radial-gradient(circle, rgba(6,182,212,0.25), transparent 70%);
  bottom: -10%; right: -5%;
  animation-duration: 30s;
  animation-delay: -8s;
}

.ambient-orb--3 {
  width: 350px; height: 350px;
  background: radial-gradient(circle, rgba(139,92,246,0.2), transparent 70%);
  top: 40%; left: 50%;
  animation-duration: 22s;
  animation-delay: -14s;
}

@keyframes ambientFloat {
  0%, 100% { transform: translate(0, 0) scale(1); }
  25% { transform: translate(30px, -40px) scale(1.05); }
  50% { transform: translate(-20px, 20px) scale(0.95); }
  75% { transform: translate(15px, 35px) scale(1.02); }
}

/* ─── Header ─── */
.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: rgba(5, 8, 16, 0.8);
  backdrop-filter: blur(24px) saturate(1.4);
  -webkit-backdrop-filter: blur(24px) saturate(1.4);
  border-bottom: 1px solid var(--border-subtle);
}

.header-brand {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-icon svg {
  width: 36px;
  height: 36px;
}

.logo-text {
  font-size: 1.35rem;
  font-weight: 800;
  letter-spacing: -0.02em;
  color: var(--text-primary);
}

.logo-accent {
  background: var(--accent-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.header-status {
  display: flex;
  align-items: center;
  gap: 14px;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 8px rgba(34, 197, 94, 0.5);
  transition: var(--transition);
}

.status-dot--disconnected {
  background: #ef4444;
  box-shadow: 0 0 8px rgba(239, 68, 68, 0.5);
}

.voice-select {
  background: var(--bg-elevated);
  color: var(--text-secondary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  padding: 6px 12px;
  font-family: var(--font);
  font-size: 0.8rem;
  font-weight: 500;
  outline: none;
  cursor: pointer;
  transition: var(--transition);
}

.voice-select:hover,
.voice-select:focus {
  border-color: var(--accent-blue);
  color: var(--text-primary);
}

/* ─── Main Content ─── */
.main-content {
  position: relative;
  z-index: 1;
  max-width: 720px;
  margin: 0 auto;
  padding: 24px 20px 100px;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* ─── Glass Card ─── */
.glass-card {
  background: var(--bg-glass);
  backdrop-filter: blur(20px) saturate(1.3);
  -webkit-backdrop-filter: blur(20px) saturate(1.3);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
  transition: var(--transition);
}

.glass-card:hover {
  background: var(--bg-glass-hover);
  border-color: rgba(148, 163, 184, 0.18);
}

/* ─── Page Info ─── */
.page-info__header {
  display: flex;
  align-items: flex-start;
  gap: 14px;
}

.page-info__icon {
  flex-shrink: 0;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(59, 130, 246, 0.12);
  border-radius: var(--radius-md);
  color: var(--accent-blue);
}

.page-info__icon svg { width: 22px; height: 22px; }

.page-info__title {
  font-size: 1.1rem;
  font-weight: 700;
  line-height: 1.3;
  color: var(--text-primary);
}

.page-info__url {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 400;
  margin-top: 2px;
  word-break: break-all;
}

.page-info__excerpt {
  margin-top: 14px;
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.65;
  display: none;
}

.page-info__excerpt.visible { display: block; }

/* ─── Waveform Visualizer ─── */
.visualizer-section {
  padding: 16px;
  position: relative;
  overflow: hidden;
}

.waveform-canvas {
  width: 100%;
  height: 100px;
  border-radius: var(--radius-md);
  display: block;
}

.visualizer-label {
  position: absolute;
  bottom: 22px;
  right: 28px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--text-muted);
  transition: var(--transition);
}

.visualizer-label.recording { color: var(--mic-recording); }
.visualizer-label.speaking { color: var(--accent-cyan); }
.visualizer-label.processing { color: var(--accent-purple); }

/* ─── Microphone Button ─── */
.mic-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
  padding: 8px 0;
}

.mic-button {
  position: relative;
  width: var(--mic-size);
  height: var(--mic-size);
  border-radius: 50%;
  border: none;
  background: var(--accent-gradient);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.2s ease, box-shadow 0.3s ease;
  box-shadow: var(--accent-glow), 0 8px 32px rgba(0, 0, 0, 0.4);
  z-index: 2;
}

.mic-button:hover {
  transform: scale(1.06);
  box-shadow: 0 0 50px rgba(59, 130, 246, 0.45), 0 8px 32px rgba(0, 0, 0, 0.5);
}

.mic-button:active { transform: scale(0.96); }

.mic-button__icon {
  width: 32px;
  height: 32px;
  position: relative;
  z-index: 2;
}

.mic-button__ripple {
  position: absolute;
  inset: -8px;
  border-radius: 50%;
  border: 2px solid rgba(59, 130, 246, 0.4);
  opacity: 0;
  pointer-events: none;
}

/* Recording state */
.mic-button.recording {
  background: linear-gradient(135deg, #ef4444, #dc2626);
  box-shadow: 0 0 40px rgba(239, 68, 68, 0.5), 0 8px 32px rgba(0, 0, 0, 0.4);
  animation: micPulse 1.5s ease-in-out infinite;
}

.mic-button.recording .mic-button__ripple {
  border-color: rgba(239, 68, 68, 0.5);
  animation: rippleOut 1.8s ease-out infinite;
}

.mic-button.recording .mic-button__ripple--2 {
  animation-delay: 0.6s;
}

/* Disabled / processing state */
.mic-button.processing {
  background: linear-gradient(135deg, #8b5cf6, #7c3aed);
  box-shadow: 0 0 40px rgba(139, 92, 246, 0.4), 0 8px 32px rgba(0, 0, 0, 0.4);
  cursor: wait;
}

@keyframes micPulse {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.04); }
}

@keyframes rippleOut {
  0% { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(1.8); opacity: 0; }
}

.mic-hint {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-weight: 500;
  transition: var(--transition);
}

/* ─── Transcript Feed ─── */
.section-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--text-muted);
  margin-bottom: 14px;
}

.section-icon {
  width: 16px;
  height: 16px;
  opacity: 0.7;
}

.transcript-feed {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 400px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--bg-elevated) transparent;
}

.transcript-feed::-webkit-scrollbar { width: 4px; }
.transcript-feed::-webkit-scrollbar-track { background: transparent; }
.transcript-feed::-webkit-scrollbar-thumb { background: var(--bg-elevated); border-radius: 4px; }

.transcript-item {
  padding: 12px 16px;
  border-radius: var(--radius-md);
  font-size: 0.88rem;
  line-height: 1.55;
  animation: fadeSlideIn 0.35s ease-out;
}

.transcript-item--user {
  background: rgba(59, 130, 246, 0.1);
  border-left: 3px solid var(--accent-blue);
}

.transcript-item--system {
  background: rgba(6, 182, 212, 0.08);
  border-left: 3px solid var(--accent-cyan);
}

.transcript-item--error {
  background: rgba(239, 68, 68, 0.1);
  border-left: 3px solid #ef4444;
}

.transcript-item--reading {
  background: rgba(139, 92, 246, 0.08);
  border-left: 3px solid var(--accent-purple);
}

.transcript-badge {
  display: inline-block;
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  margin-bottom: 6px;
}

.transcript-item--user .transcript-badge {
  background: rgba(59, 130, 246, 0.2);
  color: #93c5fd;
}

.transcript-item--system .transcript-badge {
  background: rgba(6, 182, 212, 0.15);
  color: #67e8f9;
}

.transcript-item--error .transcript-badge {
  background: rgba(239, 68, 68, 0.2);
  color: #fca5a5;
}

.transcript-item--reading .transcript-badge {
  background: rgba(139, 92, 246, 0.15);
  color: #c4b5fd;
}

@keyframes fadeSlideIn {
  from { opacity: 0; transform: translateY(8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ─── Links List ─── */
.links-list {
  list-style: none;
  counter-reset: link-counter;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.links-list li {
  counter-increment: link-counter;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 0.84rem;
  color: var(--text-secondary);
  transition: var(--transition);
  cursor: pointer;
}

.links-list li::before {
  content: counter(link-counter);
  flex-shrink: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background: rgba(59, 130, 246, 0.12);
  color: var(--accent-blue);
  font-size: 0.72rem;
  font-weight: 700;
}

.links-list li:hover {
  background: rgba(59, 130, 246, 0.08);
  color: var(--text-primary);
}

/* ─── Favorites ─── */
.favorites-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.favorites-empty {
  font-size: 0.84rem;
  color: var(--text-muted);
  text-align: center;
  padding: 16px 0;
}

.favorite-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-radius: var(--radius-md);
  background: rgba(139, 92, 246, 0.06);
  border: 1px solid rgba(139, 92, 246, 0.1);
  cursor: pointer;
  transition: var(--transition);
}

.favorite-item:hover {
  background: rgba(139, 92, 246, 0.12);
  border-color: rgba(139, 92, 246, 0.2);
}

.favorite-item__info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}

.favorite-item__title {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.favorite-item__keywords {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.favorite-keyword {
  font-size: 0.68rem;
  font-weight: 600;
  padding: 1px 7px;
  border-radius: var(--radius-full);
  background: rgba(139, 92, 246, 0.15);
  color: #c4b5fd;
}

.favorite-item__url {
  font-size: 0.72rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 280px;
}

.favorite-item__delete {
  flex-shrink: 0;
  width: 28px;
  height: 28px;
  border-radius: 6px;
  border: none;
  background: rgba(239, 68, 68, 0.1);
  color: #f87171;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  opacity: 0;
}

.favorite-item:hover .favorite-item__delete { opacity: 1; }

.favorite-item__delete:hover {
  background: rgba(239, 68, 68, 0.25);
}

/* ─── Status Bar ─── */
.status-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 24px;
  background: rgba(5, 8, 16, 0.85);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-top: 1px solid var(--border-subtle);
  font-size: 0.75rem;
}

.status-text {
  color: var(--text-muted);
  font-weight: 500;
}

.status-webmcp {
  display: flex;
  align-items: center;
  gap: 5px;
  color: #22c55e;
  font-weight: 600;
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* ─── Responsive ─── */
@media (max-width: 600px) {
  .main-content { padding: 16px 14px 100px; }
  .glass-card { padding: 16px 18px; }
  .app-header { padding: 12px 16px; }
  .logo-text { font-size: 1.15rem; }
  :root { --mic-size: 76px; }
  .mic-button__icon { width: 28px; height: 28px; }
  .waveform-canvas { height: 80px; }
}

/* ─── Add Favorite Form ─── */
.add-fav-form {
  margin-bottom: 16px;
}

.add-fav-row {
  display: flex;
  gap: 8px;
  align-items: center;
}

.fav-input {
  flex: 1;
  background: var(--bg-elevated);
  color: var(--text-primary);
  border: 1px solid var(--border-glass);
  border-radius: var(--radius-sm);
  padding: 9px 13px;
  font-family: var(--font);
  font-size: 0.82rem;
  outline: none;
  transition: var(--transition);
  min-width: 0;
}

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

.fav-input:focus {
  border-color: var(--accent-blue);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}

.add-fav-btn {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  border: none;
  background: var(--accent-gradient);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--transition);
  box-shadow: 0 2px 12px rgba(59, 130, 246, 0.3);
}

.add-fav-btn:hover { opacity: 0.85; transform: scale(1.05); }
.add-fav-btn:active { transform: scale(0.96); }

.add-fav-error {
  margin-top: 6px;
  font-size: 0.78rem;
  color: #f87171;
}

/* ─── Utility: Hidden ─── */
.u-hidden { display: none !important; }

/* ─── Loading spinner ─── */
.loading-dots {
  display: inline-flex;
  gap: 4px;
}

.loading-dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--accent-cyan);
  animation: dotBounce 1.2s ease-in-out infinite;
}

.loading-dots span:nth-child(2) { animation-delay: 0.15s; }
.loading-dots span:nth-child(3) { animation-delay: 0.3s; }

@keyframes dotBounce {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.4; }
  40% { transform: scale(1); opacity: 1; }
}
