/* ══════════════════════════════════════════════
   VoiceForge — Azure AI Speech Studio
   style.css  |  Deep-space bioluminescent theme
══════════════════════════════════════════════ */

/* ── 0. DESIGN TOKENS ── */
:root {
  --bg-void:        #05060f;
  --bg-deep:        #090c1a;
  --bg-card:        rgba(12, 16, 36, 0.72);
  --bg-card-hover:  rgba(16, 22, 50, 0.85);
  --bg-input:       rgba(8, 12, 28, 0.8);

  --accent-cyan:    #00e5ff;
  --accent-violet:  #9b5eff;
  --accent-pink:    #ff3cac;
  --accent-green:   #00ffa3;

  --glow-cyan:      0 0 20px rgba(0,229,255,0.35), 0 0 60px rgba(0,229,255,0.12);
  --glow-violet:    0 0 20px rgba(155,94,255,0.4),  0 0 60px rgba(155,94,255,0.15);
  --glow-pink:      0 0 20px rgba(255,60,172,0.35), 0 0 60px rgba(255,60,172,0.12);

  --text-primary:   #e8eeff;
  --text-secondary: #8892b0;
  --text-muted:     #4a5568;

  --border:         rgba(0,229,255,0.12);
  --border-active:  rgba(0,229,255,0.45);

  --radius-sm:      8px;
  --radius-md:      14px;
  --radius-lg:      20px;
  --radius-xl:      28px;

  --font-display:   'Syne', sans-serif;
  --font-body:      'DM Sans', sans-serif;

  --transition:     0.25s cubic-bezier(0.4, 0, 0.2, 1);
  --transition-slow:0.45s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ── LIGHT THEME ── */
[data-theme="light"] {
  --bg-void:        #eef0f8;
  --bg-deep:        #f5f6fc;
  --bg-card:        rgba(255,255,255,0.75);
  --bg-card-hover:  rgba(255,255,255,0.92);
  --bg-input:       rgba(240,242,255,0.9);

  --text-primary:   #0d1130;
  --text-secondary: #4a5480;
  --text-muted:     #9aa0be;

  --border:         rgba(100,120,255,0.18);
  --border-active:  rgba(0,140,255,0.5);
  --glow-cyan:      0 0 18px rgba(0,140,255,0.2);
  --glow-violet:    0 0 18px rgba(130,80,255,0.2);
}

/* ── 1. RESET & BASE ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { scroll-behavior: smooth; }

body {
  font-family: var(--font-body);
  background: var(--bg-void);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  transition: background var(--transition-slow), color var(--transition-slow);
}

/* ── 2. BACKGROUND CANVAS ── */
#bgCanvas {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 0;
  pointer-events: none;
  opacity: 0.55;
}

/* ── 3. THEME TOGGLE ── */
.theme-toggle {
  position: fixed;
  top: 18px;
  right: 18px;
  z-index: 200;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 50%;
  width: 42px; height: 42px;
  font-size: 18px;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  backdrop-filter: blur(12px);
  transition: var(--transition);
}
.theme-toggle:hover { transform: scale(1.1); border-color: var(--accent-cyan); }

/* ── 4. APP WRAPPER ── */
.app-wrapper {
  position: relative;
  z-index: 1;
  max-width: 860px;
  margin: 0 auto;
  padding: 32px 20px 48px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

/* ── 5. HEADER ── */
.app-header {
  text-align: center;
  padding: 12px 0 4px;
}
.logo {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.logo-icon {
  font-size: 28px;
  color: var(--accent-cyan);
  filter: drop-shadow(0 0 12px var(--accent-cyan));
  animation: spinGlow 8s linear infinite;
}
@keyframes spinGlow {
  0%   { filter: drop-shadow(0 0 10px var(--accent-cyan)); }
  33%  { filter: drop-shadow(0 0 14px var(--accent-violet)); }
  66%  { filter: drop-shadow(0 0 14px var(--accent-pink)); }
  100% { filter: drop-shadow(0 0 10px var(--accent-cyan)); }
}
.logo-text {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 800;
  background: linear-gradient(135deg, var(--accent-cyan) 0%, var(--accent-violet) 60%, var(--accent-pink) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  letter-spacing: -0.5px;
}
.logo-badge {
  font-size: 0.65rem;
  font-weight: 600;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  background: rgba(0,229,255,0.12);
  color: var(--accent-cyan);
  border: 1px solid rgba(0,229,255,0.3);
  border-radius: 20px;
  padding: 3px 9px;
}
.header-tagline {
  font-size: 0.85rem;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
}

/* ── 6. GLASS CARD ── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  backdrop-filter: blur(20px) saturate(160%);
  -webkit-backdrop-filter: blur(20px) saturate(160%);
  transition: border-color var(--transition), box-shadow var(--transition);
  padding: 24px;
  position: relative;
  overflow: hidden;
}
.card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: linear-gradient(135deg, rgba(0,229,255,0.03) 0%, transparent 60%);
  pointer-events: none;
}
.card:hover { border-color: var(--border-active); }

/* ── 7. CREDENTIALS CARD ── */
.card-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 18px;
}
.card-icon { font-size: 1.1rem; }
.card-title {
  font-family: var(--font-display);
  font-size: 1rem;
  font-weight: 700;
  color: var(--text-primary);
  flex: 1;
}
.collapse-btn {
  background: none;
  border: none;
  color: var(--text-secondary);
  font-size: 0.75rem;
  cursor: pointer;
  transition: transform var(--transition), color var(--transition);
  padding: 4px 8px;
}
.collapse-btn:hover { color: var(--accent-cyan); }
.collapse-btn.collapsed { transform: rotate(-90deg); }

.credentials-body { transition: max-height 0.4s ease, opacity 0.4s ease; overflow: hidden; }
.credentials-body.collapsed { max-height: 0 !important; opacity: 0; }

.cred-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 14px;
}
@media (max-width: 560px) { .cred-row { grid-template-columns: 1fr; } }

.input-group { display: flex; flex-direction: column; gap: 6px; }
.input-label {
  font-size: 0.75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-secondary);
}
.input-wrapper { position: relative; }
.text-input {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 10px 42px 10px 14px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.88rem;
  outline: none;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.text-input:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 3px rgba(0,229,255,0.1);
}
.text-input::placeholder { color: var(--text-muted); }
.eye-btn {
  position: absolute;
  right: 10px; top: 50%;
  transform: translateY(-50%);
  background: none; border: none;
  cursor: pointer; font-size: 1rem;
  opacity: 0.5; transition: opacity var(--transition);
}
.eye-btn:hover { opacity: 1; }

.cred-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.status-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
  transition: background var(--transition), box-shadow var(--transition);
}
.status-dot.inactive  { background: var(--text-muted); }
.status-dot.active    { background: var(--accent-green); box-shadow: 0 0 8px var(--accent-green); }
.status-dot.error     { background: var(--accent-pink);  box-shadow: 0 0 8px var(--accent-pink); }
.status-dot.listening { background: var(--accent-cyan);  box-shadow: 0 0 10px var(--accent-cyan); animation: pulseGlow 1s ease-in-out infinite; }
.status-dot.speaking  { background: var(--accent-violet);box-shadow: 0 0 10px var(--accent-violet); animation: pulseGlow 0.8s ease-in-out infinite; }
@keyframes pulseGlow {
  0%,100% { transform: scale(1);   opacity: 1; }
  50%      { transform: scale(1.4); opacity: 0.7; }
}

/* ── 8. MODE TOGGLE ── */
.mode-toggle-wrapper { display: flex; justify-content: center; }
.mode-toggle {
  display: inline-flex;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 50px;
  padding: 5px;
  backdrop-filter: blur(12px);
  position: relative;
  gap: 4px;
}
.mode-btn {
  display: flex; align-items: center; gap: 8px;
  padding: 10px 24px;
  border: none; border-radius: 40px;
  background: transparent;
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: color var(--transition), background var(--transition);
  position: relative; z-index: 1;
  white-space: nowrap;
}
.mode-btn.active {
  color: var(--bg-void);
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-violet));
  box-shadow: var(--glow-cyan);
}
.mode-btn-icon { font-size: 1rem; }

/* ── 9. SETTINGS ROW ── */
.settings-row {
  display: grid;
  grid-template-columns: 1.4fr 1.6fr 1.2fr 1.2fr;
  gap: 18px;
  padding: 18px 24px;
  align-items: end;
}
@media (max-width: 700px) {
  .settings-row { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 420px) {
  .settings-row { grid-template-columns: 1fr; }
}

.setting-group { display: flex; flex-direction: column; gap: 7px; }

.select-input {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.85rem;
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition);
}
.select-input:focus { border-color: var(--accent-cyan); }
.select-input option { background: #0c1020; }

.range-input {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 4px;
  background: linear-gradient(to right, var(--accent-cyan) var(--pct, 50%), var(--border) var(--pct, 50%));
  border-radius: 4px;
  outline: none;
  cursor: pointer;
}
.range-input::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 16px; height: 16px;
  background: var(--accent-cyan);
  border-radius: 50%;
  box-shadow: 0 0 8px rgba(0,229,255,0.6);
  transition: transform var(--transition);
}
.range-input::-webkit-slider-thumb:hover { transform: scale(1.3); }

/* ── 10. MAIN PANEL ── */
.main-panel {
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 28px;
}
.hidden { display: none !important; }

/* ── 11. MIC ZONE ── */
.mic-zone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 20px 0 8px;
}

.sound-wave-ring {
  position: relative;
  width: 110px; height: 110px;
  display: flex; align-items: center; justify-content: center;
}
.wave-ring {
  position: absolute;
  border-radius: 50%;
  border: 1.5px solid var(--accent-cyan);
  opacity: 0;
  animation: none;
  transition: opacity 0.3s;
}
.wave-ring.r1 { width: 110px; height: 110px; }
.wave-ring.r2 { width: 140px; height: 140px; }
.wave-ring.r3 { width: 172px; height: 172px; }

/* Active recording: waves pulse outward */
.recording .wave-ring { opacity: 1; }
.recording .r1 { animation: ripple 1.6s ease-out infinite 0s; }
.recording .r2 { animation: ripple 1.6s ease-out infinite 0.35s; }
.recording .r3 { animation: ripple 1.6s ease-out infinite 0.7s; }
@keyframes ripple {
  0%   { transform: scale(0.9); opacity: 0.8; }
  100% { transform: scale(1.4); opacity: 0; }
}

.mic-btn {
  width: 80px; height: 80px;
  border-radius: 50%;
  border: 2px solid var(--accent-cyan);
  background: linear-gradient(135deg, rgba(0,229,255,0.18), rgba(155,94,255,0.18));
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.8rem;
  transition: transform var(--transition), box-shadow var(--transition), background var(--transition);
  box-shadow: var(--glow-cyan);
  position: relative; z-index: 1;
}
.mic-btn:hover {
  transform: scale(1.07);
  box-shadow: 0 0 30px rgba(0,229,255,0.6), 0 0 70px rgba(0,229,255,0.2);
}
.mic-btn.active {
  background: linear-gradient(135deg, rgba(255,60,172,0.3), rgba(155,94,255,0.3));
  border-color: var(--accent-pink);
  box-shadow: var(--glow-pink);
  animation: micPulse 1s ease-in-out infinite;
}
@keyframes micPulse {
  0%,100% { transform: scale(1); }
  50%      { transform: scale(1.05); }
}

.mic-label {
  font-size: 0.82rem;
  color: var(--text-secondary);
  letter-spacing: 0.3px;
}

/* ── 12. WAVEFORM BARS ── */
.waveform-bars {
  display: flex;
  align-items: center;
  gap: 4px;
  height: 40px;
  opacity: 0;
  transition: opacity 0.3s;
}
.waveform-bars.active { opacity: 1; }
.waveform-bars span {
  width: 3px;
  background: var(--accent-cyan);
  border-radius: 3px;
  height: 8px;
  transition: height 0.1s;
}
.waveform-bars.active span { animation: waveBar 0.9s ease-in-out infinite; }
.waveform-bars span:nth-child(1)  { animation-delay: 0s; }
.waveform-bars span:nth-child(2)  { animation-delay: .07s; }
.waveform-bars span:nth-child(3)  { animation-delay: .14s; }
.waveform-bars span:nth-child(4)  { animation-delay: .21s; }
.waveform-bars span:nth-child(5)  { animation-delay: .28s; }
.waveform-bars span:nth-child(6)  { animation-delay: .21s; }
.waveform-bars span:nth-child(7)  { animation-delay: .14s; }
.waveform-bars span:nth-child(8)  { animation-delay: .07s; }
.waveform-bars span:nth-child(9)  { animation-delay: 0s; }
.waveform-bars span:nth-child(10) { animation-delay: .07s; }
.waveform-bars span:nth-child(11) { animation-delay: .14s; }
.waveform-bars span:nth-child(12) { animation-delay: .21s; }
.waveform-bars span:nth-child(13) { animation-delay: .28s; }
.waveform-bars span:nth-child(14) { animation-delay: .21s; }
.waveform-bars span:nth-child(15) { animation-delay: .14s; }
.waveform-bars span:nth-child(16) { animation-delay: .07s; }
.waveform-bars span:nth-child(17) { animation-delay: 0s; }
.waveform-bars span:nth-child(18) { animation-delay: .07s; }
.waveform-bars span:nth-child(19) { animation-delay: .14s; }
.waveform-bars span:nth-child(20) { animation-delay: .21s; }
@keyframes waveBar {
  0%,100% { height: 6px;  opacity: 0.5; }
  50%     { height: 32px; opacity: 1; }
}

/* ── 13. OUTPUT / TEXTAREA ── */
.output-section { display: flex; flex-direction: column; gap: 10px; }
.output-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 8px;
}
.output-title {
  font-family: var(--font-display);
  font-size: 0.85rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1.2px;
  color: var(--text-secondary);
}
.output-actions { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }
.char-count {
  font-size: 0.72rem;
  color: var(--text-muted);
}
.action-btn {
  background: rgba(0,229,255,0.08);
  border: 1px solid rgba(0,229,255,0.2);
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--accent-cyan);
  cursor: pointer;
  transition: background var(--transition), transform var(--transition);
}
.action-btn:hover { background: rgba(0,229,255,0.18); transform: translateY(-1px); }
.action-btn.danger { color: var(--accent-pink); border-color: rgba(255,60,172,0.25); background: rgba(255,60,172,0.06); }
.action-btn.danger:hover { background: rgba(255,60,172,0.16); }

.output-textarea {
  width: 100%;
  min-height: 140px;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 14px 16px;
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.92rem;
  line-height: 1.65;
  resize: vertical;
  outline: none;
  transition: border-color var(--transition);
}
.output-textarea.editable { resize: vertical; }
.output-textarea:focus { border-color: var(--border-active); }
.output-textarea::placeholder { color: var(--text-muted); }
.output-textarea[readonly] { cursor: default; }

.interim-text {
  font-size: 0.82rem;
  color: var(--accent-violet);
  min-height: 20px;
  padding: 4px 2px;
  font-style: italic;
  opacity: 0.8;
  transition: opacity 0.2s;
}

/* ── 14. STATUS BAR ── */
.status-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  background: rgba(0,0,0,0.2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  color: var(--text-secondary);
}
.status-right {
  margin-left: auto;
  font-family: 'Courier New', monospace;
  font-size: 0.78rem;
  color: var(--text-muted);
}

/* ── 15. TTS PANEL ── */
.tts-input-section { display: flex; flex-direction: column; gap: 10px; }

.tts-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
}
.tts-btn {
  flex: 1;
  min-width: 100px;
  display: flex; align-items: center; justify-content: center;
  gap: 8px;
  padding: 12px 20px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border);
  background: var(--bg-input);
  color: var(--text-secondary);
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}
.tts-btn:hover:not(:disabled) {
  border-color: var(--accent-violet);
  color: var(--text-primary);
  transform: translateY(-2px);
}
.tts-btn:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.tts-btn.primary {
  background: linear-gradient(135deg, var(--accent-cyan), var(--accent-violet));
  border: none; color: #fff; font-weight: 600;
  box-shadow: var(--glow-cyan);
}
.tts-btn.primary:hover:not(:disabled) {
  box-shadow: 0 0 30px rgba(0,229,255,0.5), 0 0 70px rgba(155,94,255,0.2);
  transform: translateY(-2px);
}
.tts-btn.accent {
  border-color: rgba(0,255,163,0.3);
  color: var(--accent-green);
}
.tts-btn.accent:hover:not(:disabled) {
  background: rgba(0,255,163,0.08);
  border-color: var(--accent-green);
}
.btn-icon { font-size: 0.9rem; }

/* ── 16. SPEAKER VISUALIZATION ── */
.speaker-viz {
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  height: 80px;
  opacity: 0;
  transition: opacity 0.4s;
}
.speaker-viz.active { opacity: 1; }
.speaker-ring {
  position: absolute;
  border-radius: 50%;
  border: 1.5px solid var(--accent-violet);
  opacity: 0;
}
.speaker-viz.active .sr1 { width: 60px; height: 60px; animation: speakerRipple 1.4s ease-out infinite 0s; }
.speaker-viz.active .sr2 { width: 90px; height: 90px; animation: speakerRipple 1.4s ease-out infinite 0.35s; }
.speaker-viz.active .sr3 { width: 120px; height: 120px; animation: speakerRipple 1.4s ease-out infinite 0.7s; }
@keyframes speakerRipple {
  0%   { transform: scale(0.8); opacity: 0.9; }
  100% { transform: scale(1.5); opacity: 0; }
}
.speaker-icon { font-size: 1.8rem; z-index: 1; }

/* ── 17. LOADING OVERLAY ── */
.loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(5,6,15,0.75);
  backdrop-filter: blur(8px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
}
.loading-spinner {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}
.spin-ring {
  width: 52px; height: 52px;
  border-radius: 50%;
  border: 3px solid rgba(0,229,255,0.15);
  border-top-color: var(--accent-cyan);
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.spin-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  letter-spacing: 0.5px;
}

/* ── 18. TOAST ── */
.toast-container {
  position: fixed;
  bottom: 24px; right: 24px;
  z-index: 600;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}
.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  backdrop-filter: blur(16px);
  padding: 12px 18px;
  font-size: 0.82rem;
  color: var(--text-primary);
  display: flex; align-items: center; gap: 10px;
  min-width: 240px; max-width: 340px;
  transform: translateX(100%);
  opacity: 0;
  animation: toastIn 0.3s forwards, toastOut 0.3s 3.2s forwards;
  pointer-events: auto;
}
.toast.success { border-color: rgba(0,255,163,0.35); }
.toast.error   { border-color: rgba(255,60,172,0.35); }
.toast.info    { border-color: rgba(0,229,255,0.25); }
.toast-emoji   { font-size: 1rem; }
@keyframes toastIn {
  to { transform: translateX(0); opacity: 1; }
}
@keyframes toastOut {
  to { transform: translateX(110%); opacity: 0; }
}

/* ── 19. FOOTER ── */
.app-footer {
  text-align: center;
  font-size: 0.75rem;
  color: var(--text-muted);
  padding-top: 8px;
  display: flex;
  justify-content: center;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.footer-sep { color: var(--border-active); }

/* ── 20. SCROLLBAR ── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,229,255,0.2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,229,255,0.4); }

/* ── 21. SELECTION ── */
::selection { background: rgba(0,229,255,0.2); color: var(--text-primary); }

/* ── 22. MOBILE TWEAKS ── */
@media (max-width: 480px) {
  .app-wrapper { padding: 20px 14px 40px; gap: 16px; }
  .logo-text { font-size: 1.5rem; }
  .main-panel { padding: 18px; }
  .tts-controls { gap: 8px; }
  .tts-btn { min-width: 80px; padding: 10px 14px; font-size: 0.8rem; }
}