/* ============================================
   VocalMinds — Design System & Styles
   ============================================ */

/* ── CSS Variables (Design Tokens) ──────────── */
:root {
  /* Colors — Dark Mode Primary */
  --bg-primary: #0a0a12;
  --bg-secondary: #12121e;
  --bg-card: rgba(22, 22, 38, 0.7);
  --bg-card-hover: rgba(30, 30, 52, 0.85);
  --bg-glass: rgba(18, 18, 30, 0.55);

  /* Accent Palette */
  --accent-violet: #a78bfa;
  --accent-violet-dim: rgba(167, 139, 250, 0.15);
  --accent-mint: #6ee7b7;
  --accent-mint-dim: rgba(110, 231, 183, 0.15);
  --accent-blue: #60a5fa;
  --accent-rose: #f472b6;
  --gradient-primary: linear-gradient(135deg, #a78bfa 0%, #6ee7b7 100%);
  --gradient-warm: linear-gradient(135deg, #f472b6 0%, #a78bfa 100%);

  /* Text */
  --text-primary: #f0f0f5;
  --text-secondary: #9999b3;
  --text-muted: #5a5a7a;

  /* Border */
  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-glow: rgba(167, 139, 250, 0.3);

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

  /* Fonts */
  --font-display: 'Outfit', sans-serif;
  --font-body: 'Inter', sans-serif;

  /* Transitions */
  --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
  --transition-fast: 150ms var(--ease-out);
  --transition-normal: 300ms var(--ease-out);
  --transition-slow: 500ms var(--ease-out);

  /* Shadows */
  --shadow-card: 0 4px 30px rgba(0, 0, 0, 0.3);
  --shadow-glow: 0 0 40px rgba(167, 139, 250, 0.12);
}

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

html {
  font-size: 16px;
  scroll-behavior: smooth;
}

body {
  font-family: var(--font-body);
  background: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

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

.orb {
  position: absolute;
  border-radius: 50%;
  filter: blur(100px);
  opacity: 0.25;
  animation: orbFloat 20s ease-in-out infinite;
}

.orb-1 {
  width: 500px;
  height: 500px;
  background: var(--accent-violet);
  top: -10%;
  left: -5%;
  animation-duration: 22s;
}

.orb-2 {
  width: 400px;
  height: 400px;
  background: var(--accent-mint);
  bottom: -10%;
  right: -5%;
  animation-duration: 18s;
  animation-delay: -5s;
}

.orb-3 {
  width: 300px;
  height: 300px;
  background: var(--accent-rose);
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  animation-duration: 25s;
  animation-delay: -10s;
  opacity: 0.12;
}

@keyframes orbFloat {
  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(40px, 30px) scale(1.03); }
}

/* ── Header ─────────────────────────────────── */
#app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(20px) saturate(1.5);
  background: var(--bg-glass);
  border-bottom: 1px solid var(--border-subtle);
}

.header-inner {
  max-width: 900px;
  margin: 0 auto;
  padding: 14px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

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

.logo-text {
  font-family: var(--font-display);
  font-size: 1.3rem;
  font-weight: 600;
  background: var(--gradient-primary);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.nav-status {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: var(--text-secondary);
}

.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--accent-mint);
  box-shadow: 0 0 8px var(--accent-mint);
  animation: pulse 2s ease-in-out infinite;
}

.status-dot.processing {
  background: var(--accent-violet);
  box-shadow: 0 0 8px var(--accent-violet);
}

.status-dot.error {
  background: #ef4444;
  box-shadow: 0 0 8px #ef4444;
  animation: none;
}

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.4; }
}

/* ── Main Content ───────────────────────────── */
#app-main {
  position: relative;
  z-index: 1;
  max-width: 900px;
  margin: 0 auto;
  padding: 40px 24px 80px;
  min-height: calc(100vh - 120px);
}

/* ── Steps ──────────────────────────────────── */
.step {
  display: none;
  animation: fadeSlideIn 0.5s var(--ease-out);
}

.step-active {
  display: block;
}

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

.step-header {
  margin-bottom: 36px;
  text-align: center;
}

.step-number {
  display: inline-block;
  font-family: var(--font-display);
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--accent-violet);
  letter-spacing: 2px;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.step-header h1 {
  font-family: var(--font-display);
  font-size: 2rem;
  font-weight: 600;
  line-height: 1.2;
  margin-bottom: 8px;
}

.step-subtitle {
  color: var(--text-secondary);
  font-size: 0.95rem;
}

/* ── Profile Cards ──────────────────────────── */
.profile-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 20px;
}

.profile-card {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 32px 24px;
  cursor: pointer;
  text-align: center;
  transition: all var(--transition-normal);
  backdrop-filter: blur(10px);
  position: relative;
  overflow: hidden;
  font-family: inherit;
  color: var(--text-primary);
}

.profile-card::before {
  content: '';
  position: absolute;
  inset: 0;
  border-radius: inherit;
  background: var(--gradient-primary);
  opacity: 0;
  transition: opacity var(--transition-normal);
}

.profile-card:hover {
  border-color: var(--border-glow);
  transform: translateY(-4px);
  box-shadow: var(--shadow-glow);
}

.profile-card:hover::before {
  opacity: 0.06;
}

.profile-card.selected {
  border-color: var(--accent-violet);
  background: var(--bg-card-hover);
  box-shadow: var(--shadow-glow), inset 0 0 0 1px var(--border-glow);
}

.profile-card.selected::before {
  opacity: 0.1;
}

.profile-icon {
  font-size: 2.5rem;
  margin-bottom: 16px;
  position: relative;
  z-index: 1;
}

.profile-card h3 {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 600;
  margin-bottom: 8px;
  position: relative;
  z-index: 1;
}

.profile-card p {
  font-size: 0.85rem;
  color: var(--text-secondary);
  line-height: 1.4;
  margin-bottom: 12px;
  position: relative;
  z-index: 1;
}

.profile-duration {
  font-size: 0.75rem;
  color: var(--accent-violet);
  font-weight: 500;
  background: var(--accent-violet-dim);
  padding: 4px 12px;
  border-radius: 20px;
  position: relative;
  z-index: 1;
}

/* ── Config Form ────────────────────────────── */
.config-form {
  max-width: 600px;
  margin: 0 auto;
}

.form-group {
  margin-bottom: 24px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 8px;
  color: var(--text-secondary);
}

.label-optional {
  color: var(--text-muted);
  font-weight: 400;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-family: var(--font-body);
  font-size: 0.95rem;
  transition: border-color var(--transition-fast);
  outline: none;
}

.form-group input::placeholder,
.form-group textarea::placeholder {
  color: var(--text-muted);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--accent-violet);
  box-shadow: 0 0 0 3px var(--accent-violet-dim);
}

.form-group select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24' fill='%239999b3'%3E%3Cpath d='M7 10l5 5 5-5z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 14px center;
  padding-right: 36px;
}

.form-group textarea {
  resize: vertical;
  min-height: 80px;
}

.form-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 32px;
}

/* ── Buttons ────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 28px;
  border-radius: var(--radius-sm);
  font-family: var(--font-body);
  font-size: 0.95rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  transition: all var(--transition-fast);
  text-decoration: none;
}

.btn-primary {
  background: var(--gradient-primary);
  color: #0a0a12;
  font-weight: 600;
}

.btn-primary:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 25px rgba(167, 139, 250, 0.3);
}

.btn-primary:active {
  transform: translateY(0);
}

.btn-ghost {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border-subtle);
}

.btn-ghost:hover {
  color: var(--text-primary);
  border-color: var(--text-muted);
}

.btn-text .btn-loader[hidden] {
  display: none;
}

.spinner {
  display: inline-block;
  width: 16px;
  height: 16px;
  border: 2px solid rgba(10, 10, 18, 0.3);
  border-top-color: #0a0a12;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ── Progress Section ───────────────────────── */
.progress-container {
  max-width: 600px;
  margin: 0 auto;
  text-align: center;
}

/* Waveform Animation */
.waveform-animation {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 3px;
  height: 80px;
  margin-bottom: 32px;
}

.wave-bar {
  width: 4px;
  border-radius: 4px;
  background: var(--gradient-primary);
  animation: waveAnim 1.2s ease-in-out infinite;
  opacity: 0.6;
}

@keyframes waveAnim {
  0%, 100% { height: 8px; opacity: 0.3; }
  50% { height: 60px; opacity: 0.9; }
}

/* Progress bar */
.progress-bar-container {
  display: flex;
  align-items: center;
  gap: 14px;
  margin-bottom: 32px;
}

.progress-bar {
  flex: 1;
  height: 6px;
  background: var(--bg-card);
  border-radius: 10px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: var(--gradient-primary);
  border-radius: 10px;
  transition: width 0.5s var(--ease-out);
}

.progress-percent {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--accent-violet);
  min-width: 40px;
  text-align: right;
}

/* Stage indicators */
.progress-stages {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0;
  margin-bottom: 24px;
}

.stage {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  opacity: 0.35;
  transition: opacity var(--transition-normal);
}

.stage.active {
  opacity: 1;
}

.stage.done {
  opacity: 0.7;
}

.stage-icon {
  font-size: 1.4rem;
}

.stage span {
  font-size: 0.72rem;
  color: var(--text-secondary);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 1px;
}

.stage-connector {
  width: 40px;
  height: 2px;
  background: var(--border-subtle);
  margin: 0 8px;
  margin-bottom: 20px;
}

.progress-detail {
  color: var(--text-secondary);
  font-size: 0.9rem;
}

/* ── Player ─────────────────────────────────── */
.player-container {
  max-width: 500px;
  margin: 0 auto;
  text-align: center;
}

.player-artwork {
  position: relative;
  width: 160px;
  height: 160px;
  margin: 0 auto 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.artwork-pulse {
  position: absolute;
  inset: 0;
  border-radius: 50%;
  background: var(--gradient-primary);
  opacity: 0.15;
  animation: artworkPulse 3s ease-in-out infinite;
}

.artwork-pulse.playing {
  animation: artworkPulse 1.5s ease-in-out infinite;
  opacity: 0.25;
}

@keyframes artworkPulse {
  0%, 100% { transform: scale(1); opacity: 0.15; }
  50% { transform: scale(1.15); opacity: 0.08; }
}

.artwork-icon {
  font-size: 4rem;
  position: relative;
  z-index: 1;
}

.player-timeline {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.time-current, .time-total {
  font-size: 0.78rem;
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
  min-width: 36px;
}

.timeline-slider {
  flex: 1;
  -webkit-appearance: none;
  appearance: none;
  height: 4px;
  background: var(--bg-card);
  border-radius: 4px;
  outline: none;
  cursor: pointer;
}

.timeline-slider::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--accent-violet);
  cursor: pointer;
  box-shadow: 0 0 8px rgba(167, 139, 250, 0.4);
  transition: transform var(--transition-fast);
}

.timeline-slider::-webkit-slider-thumb:hover {
  transform: scale(1.3);
}

.player-buttons {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 24px;
  margin-bottom: 32px;
}

.btn-player {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  padding: 8px;
  border-radius: 50%;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn-player:hover {
  color: var(--text-primary);
  background: var(--bg-card);
}

.btn-play {
  width: 64px;
  height: 64px;
  background: var(--gradient-primary);
  color: #0a0a12;
}

.btn-play:hover {
  transform: scale(1.08);
  box-shadow: 0 4px 20px rgba(167, 139, 250, 0.35);
  color: #0a0a12;
  background: var(--gradient-primary);
}

.player-actions {
  display: flex;
  gap: 12px;
  justify-content: center;
}

/* ── Script Details ─────────────────────────── */
.script-details {
  max-width: 600px;
  margin: 40px auto 0;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
}

.script-details summary {
  padding: 16px 20px;
  cursor: pointer;
  font-weight: 500;
  color: var(--text-secondary);
  transition: color var(--transition-fast);
  user-select: none;
}

.script-details summary:hover {
  color: var(--text-primary);
}

.script-content {
  padding: 0 20px 20px;
}

.scene-card {
  background: var(--bg-secondary);
  border-radius: var(--radius-sm);
  padding: 16px;
  margin-bottom: 12px;
}

.scene-card:last-child {
  margin-bottom: 0;
}

.scene-card h4 {
  font-family: var(--font-display);
  font-size: 0.9rem;
  color: var(--accent-violet);
  margin-bottom: 6px;
}

.scene-card .scene-context {
  font-size: 0.78rem;
  color: var(--accent-mint);
  font-style: italic;
  margin-bottom: 8px;
}

.scene-card .scene-notes {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.scene-card .scene-text {
  font-size: 0.88rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ── Footer ─────────────────────────────────── */
#app-footer {
  position: relative;
  z-index: 1;
  text-align: center;
  padding: 20px;
  color: var(--text-muted);
  font-size: 0.78rem;
  border-top: 1px solid var(--border-subtle);
}

/* ── Responsive ─────────────────────────────── */
@media (max-width: 700px) {
  .profile-grid {
    grid-template-columns: 1fr;
    gap: 14px;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .step-header h1 {
    font-size: 1.5rem;
  }

  .form-actions {
    flex-direction: column-reverse;
    gap: 12px;
  }

  .form-actions .btn {
    width: 100%;
  }

  .player-actions {
    flex-direction: column;
  }

  .player-actions .btn {
    width: 100%;
  }
}
