/* ==========================================================================
   Design System & Theme Tokens (media.edukids.ovh)
   ========================================================================== */
@import url('https://fonts.googleapis.com/css2?family=JetBrains+Mono:wght@400;500;600&family=Outfit:wght@300;400;500;600;700;800&display=swap');

:root {
  --font-main: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  /* Color Palette */
  --bg-dark: #0a0e17;
  --bg-card: rgba(18, 24, 38, 0.75);
  --bg-card-hover: rgba(26, 34, 54, 0.85);
  --bg-surface: #111827;
  --bg-input: rgba(15, 23, 42, 0.8);

  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(139, 92, 246, 0.35);
  --border-active: rgba(99, 102, 241, 0.6);

  --primary: #8b5cf6;
  --primary-hover: #7c3aed;
  --primary-light: #a78bfa;
  --secondary: #3b82f6;
  --secondary-glow: rgba(59, 130, 246, 0.25);
  --accent: #06b6d4;
  --accent-glow: rgba(6, 182, 212, 0.3);
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;

  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --gradient-brand: linear-gradient(135deg, #8b5cf6 0%, #3b82f6 50%, #06b6d4 100%);
  --gradient-surface: linear-gradient(180deg, rgba(30, 41, 59, 0.5) 0%, rgba(15, 23, 42, 0.7) 100%);
  --gradient-glow: radial-gradient(circle at 50% 0%, rgba(139, 92, 246, 0.15) 0%, transparent 70%);

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

  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.3);
  --shadow-md: 0 8px 24px -4px rgba(0, 0, 0, 0.4), 0 0 1px 1px rgba(255, 255, 255, 0.05);
  --shadow-glow: 0 0 30px -5px rgba(139, 92, 246, 0.3);

  --transition-fast: 0.15s ease;
  --transition-normal: 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

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

body {
  font-family: var(--font-main);
  background-color: var(--bg-dark);
  color: var(--text-main);
  min-height: 100vh;
  line-height: 1.6;
  background-image: 
    radial-gradient(circle at 10% 20%, rgba(139, 92, 246, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 90% 80%, rgba(6, 182, 212, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 50% 50%, rgba(59, 130, 246, 0.04) 0%, transparent 60%);
  background-attachment: fixed;
  overflow-x: hidden;
}

/* ==========================================================================
   Header & Navigation
   ========================================================================== */
.header {
  position: sticky;
  top: 0;
  z-index: 100;
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  background: rgba(10, 14, 23, 0.85);
  border-bottom: 1px solid var(--border-subtle);
  padding: 0.85rem 2rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.85rem;
  text-decoration: none;
  color: var(--text-main);
}

.brand-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: var(--gradient-brand);
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 15px rgba(139, 92, 246, 0.4);
}

.brand-icon svg {
  width: 24px;
  height: 24px;
  stroke: #ffffff;
}

.brand-title {
  font-size: 1.25rem;
  font-weight: 700;
  letter-spacing: -0.02em;
  background: linear-gradient(135deg, #ffffff 40%, #a78bfa 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.brand-badge {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-full);
  background: rgba(139, 92, 246, 0.15);
  border: 1px solid rgba(139, 92, 246, 0.3);
  color: var(--primary-light);
  margin-left: 0.25rem;
}

.nav-tabs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: rgba(255, 255, 255, 0.03);
  padding: 0.3rem;
  border-radius: var(--radius-full);
  border: 1px solid var(--border-subtle);
}

.nav-tab {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-main);
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.45rem 1rem;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all var(--transition-fast);
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.nav-tab:hover {
  color: var(--text-main);
}

.nav-tab.active {
  background: var(--gradient-brand);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 2px 10px rgba(139, 92, 246, 0.3);
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.status-pill {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.78rem;
  font-weight: 500;
  color: var(--text-muted);
  padding: 0.35rem 0.8rem;
  border-radius: var(--radius-full);
  background: rgba(16, 185, 129, 0.1);
  border: 1px solid rgba(16, 185, 129, 0.2);
}

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

@keyframes pulse-dot {
  0% { transform: scale(0.95); opacity: 0.8; }
  50% { transform: scale(1.2); opacity: 1; }
  100% { transform: scale(0.95); opacity: 0.8; }
}

/* ==========================================================================
   Container & Layout
   ========================================================================== */
.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem 5rem;
}

.hero {
  text-align: center;
  margin-bottom: 2.5rem;
}

.hero-tag {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--primary-light);
  background: rgba(139, 92, 246, 0.1);
  border: 1px solid rgba(139, 92, 246, 0.25);
  padding: 0.35rem 0.9rem;
  border-radius: var(--radius-full);
  margin-bottom: 1rem;
}

.hero-title {
  font-size: 2.5rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  line-height: 1.2;
  margin-bottom: 0.75rem;
}

.hero-title .highlight {
  background: var(--gradient-brand);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
}

.hero-subtitle {
  color: var(--text-muted);
  font-size: 1.05rem;
  max-width: 650px;
  margin: 0 auto;
}

/* ==========================================================================
   Glassmorphic Cards
   ========================================================================== */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  box-shadow: var(--shadow-md);
  margin-bottom: 2rem;
  position: relative;
  overflow: hidden;
  transition: border-color var(--transition-normal);
}

.card:hover {
  border-color: var(--border-glow);
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-subtle);
  padding-bottom: 0.9rem;
}

.card-title {
  font-size: 1.2rem;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.card-title svg {
  color: var(--primary);
}

/* ==========================================================================
   Playground Form Inputs
   ========================================================================== */
.form-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1.25rem;
}

.input-label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 0.45rem;
}

.text-area {
  width: 100%;
  min-height: 95px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 1.05rem;
  padding: 0.9rem 1rem;
  resize: vertical;
  transition: all var(--transition-fast);
  outline: none;
}

.text-area:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
}

.quick-samples {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-wrap: wrap;
  margin-top: 0.5rem;
}

.quick-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-full);
  color: var(--text-dim);
  font-size: 0.75rem;
  padding: 0.25rem 0.65rem;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.quick-btn:hover {
  background: rgba(139, 92, 246, 0.15);
  color: var(--text-main);
  border-color: var(--primary);
}

.controls-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1.25rem;
  align-items: end;
}

.select-control {
  width: 100%;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-family: var(--font-main);
  font-size: 0.95rem;
  padding: 0.65rem 0.85rem;
  outline: none;
  cursor: pointer;
  transition: border-color var(--transition-fast);
}

.select-control:focus {
  border-color: var(--primary);
}

.speed-control {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.speed-slider {
  flex: 1;
  accent-color: var(--primary);
  cursor: pointer;
}

.speed-badge {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  background: rgba(255, 255, 255, 0.07);
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-sm);
  color: var(--accent);
  min-width: 48px;
  text-align: center;
}

.btn-primary {
  background: var(--gradient-brand);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-md);
  font-family: var(--font-main);
  font-size: 1rem;
  font-weight: 600;
  padding: 0.75rem 1.75rem;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(139, 92, 246, 0.4);
  transition: all var(--transition-fast);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.6rem;
  white-space: nowrap;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(139, 92, 246, 0.5);
}

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

.btn-primary.loading {
  opacity: 0.8;
  cursor: wait;
  animation: pulse-btn 1.5s infinite;
}

@keyframes pulse-btn {
  0% { filter: brightness(1); }
  50% { filter: brightness(1.25); }
  100% { filter: brightness(1); }
}

/* ==========================================================================
   Synchronized Word Highlight Display (Karaoke Engine)
   ========================================================================== */
.player-container {
  margin-top: 1.5rem;
  background: rgba(10, 15, 29, 0.9);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-glow);
  padding: 1.5rem;
}

.reading-passage {
  font-size: 1.4rem;
  line-height: 1.9;
  letter-spacing: -0.01em;
  padding: 1.5rem;
  background: rgba(255, 255, 255, 0.02);
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  margin-bottom: 1.5rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem 0.5rem;
  min-height: 90px;
  align-items: center;
}

.karaoke-word {
  display: inline-block;
  padding: 0.15rem 0.4rem;
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.12s ease-out;
  position: relative;
  color: var(--text-muted);
}

.karaoke-word:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
}

/* Active Highlight State */
.karaoke-word.active {
  background: linear-gradient(135deg, rgba(139, 92, 246, 0.4) 0%, rgba(6, 182, 212, 0.4) 100%);
  color: #ffffff;
  font-weight: 700;
  transform: scale(1.08);
  box-shadow: 0 0 16px rgba(139, 92, 246, 0.6);
  border: 1px solid rgba(139, 92, 246, 0.8);
}

.karaoke-word.passed {
  color: var(--text-main);
  opacity: 0.9;
}

/* Audio Player Controls */
.audio-controls {
  display: flex;
  flex-direction: column;
  gap: 0.85rem;
}

.timeline-row {
  display: flex;
  align-items: center;
  gap: 0.85rem;
}

.time-display {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--text-dim);
  min-width: 48px;
}

.progress-bar-container {
  flex: 1;
  height: 8px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-full);
  position: relative;
  cursor: pointer;
  overflow: hidden;
}

.progress-bar-fill {
  height: 100%;
  width: 0%;
  background: var(--gradient-brand);
  border-radius: var(--radius-full);
  transition: width 0.05s linear;
}

.buttons-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.playback-buttons {
  display: flex;
  align-items: center;
  gap: 0.6rem;
}

.icon-btn {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all var(--transition-fast);
}

.icon-btn:hover {
  background: rgba(139, 92, 246, 0.2);
  border-color: var(--primary);
}

.play-pause-btn {
  width: 46px;
  height: 46px;
  background: var(--gradient-brand);
  border: none;
  box-shadow: 0 0 15px rgba(139, 92, 246, 0.4);
}

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

.meta-tags {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.8rem;
}

.tag {
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.tag.primary {
  color: var(--primary-light);
  border-color: rgba(139, 92, 246, 0.3);
  background: rgba(139, 92, 246, 0.1);
}

.tag.accent {
  color: var(--accent);
  border-color: rgba(6, 182, 212, 0.3);
  background: rgba(6, 182, 212, 0.1);
}

/* ==========================================================================
   Queue / Pending State Card
   ========================================================================== */
.pending-card {
  margin-top: 1.5rem;
  background: rgba(245, 158, 11, 0.06);
  border: 1px solid rgba(245, 158, 11, 0.3);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.25rem;
}

.pending-spinner {
  width: 44px;
  height: 44px;
  border: 3px solid rgba(245, 158, 11, 0.2);
  border-top-color: var(--warning);
  border-radius: 50%;
  animation: spin 1s infinite linear;
  flex-shrink: 0;
}

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

.pending-title {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--warning);
  margin-bottom: 0.25rem;
}

.pending-desc {
  font-size: 0.85rem;
  color: var(--text-muted);
}

/* ==========================================================================
   Media Catalog Grid
   ========================================================================== */
.catalog-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.search-input {
  flex: 1;
  min-width: 250px;
  background: var(--bg-input);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-family: var(--font-main);
  padding: 0.65rem 1rem;
  outline: none;
}

.search-input:focus {
  border-color: var(--primary);
}

.catalog-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.25rem;
}

.media-item-card {
  background: rgba(18, 24, 38, 0.6);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  gap: 1rem;
  transition: all var(--transition-fast);
}

.media-item-card:hover {
  background: var(--bg-card-hover);
  border-color: var(--border-glow);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.media-card-text {
  font-size: 1rem;
  font-weight: 500;
  color: var(--text-main);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.media-card-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  border-top: 1px solid var(--border-subtle);
  padding-top: 0.85rem;
}

.card-play-btn {
  background: rgba(139, 92, 246, 0.15);
  border: 1px solid rgba(139, 92, 246, 0.3);
  color: var(--primary-light);
  border-radius: var(--radius-full);
  padding: 0.35rem 0.8rem;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.35rem;
  transition: all var(--transition-fast);
}

.card-play-btn:hover {
  background: var(--gradient-brand);
  color: #ffffff;
  border-color: transparent;
}

/* ==========================================================================
   Queue Table
   ========================================================================== */
.table-responsive {
  overflow-x: auto;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
}

.queue-table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.88rem;
}

.queue-table th {
  background: rgba(255, 255, 255, 0.03);
  padding: 0.85rem 1rem;
  color: var(--text-dim);
  font-weight: 600;
  border-bottom: 1px solid var(--border-subtle);
}

.queue-table td {
  padding: 0.85rem 1rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--text-muted);
}

.queue-table tr:hover td {
  background: rgba(255, 255, 255, 0.02);
  color: var(--text-main);
}

.status-badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: var(--radius-full);
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
}

.status-badge.pending {
  background: rgba(245, 158, 11, 0.15);
  color: var(--warning);
  border: 1px solid rgba(245, 158, 11, 0.3);
}

.status-badge.processing {
  background: rgba(59, 130, 246, 0.15);
  color: var(--secondary);
  border: 1px solid rgba(59, 130, 246, 0.3);
}

.status-badge.completed {
  background: rgba(16, 185, 129, 0.15);
  color: var(--success);
  border: 1px solid rgba(16, 185, 129, 0.3);
}

/* ==========================================================================
   Code Snippet & Worker Instructions
   ========================================================================== */
.code-block {
  background: #060910;
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  padding: 1.1rem;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: #38bdf8;
  position: relative;
  overflow-x: auto;
  margin: 1rem 0;
}

.copy-code-btn {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-dim);
  font-size: 0.7rem;
  padding: 0.2rem 0.5rem;
  cursor: pointer;
}

.copy-code-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.15);
}

/* ==========================================================================
   Modal & Toast
   ========================================================================== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition-fast);
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: auto;
}

.modal {
  background: #111827;
  border: 1px solid var(--border-glow);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 600px;
  max-height: 85vh;
  overflow-y: auto;
  padding: 1.75rem;
  box-shadow: var(--shadow-glow);
}

.toast {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background: #1e293b;
  border: 1px solid var(--border-glow);
  color: #ffffff;
  padding: 0.75rem 1.25rem;
  border-radius: var(--radius-md);
  font-size: 0.85rem;
  box-shadow: var(--shadow-md);
  z-index: 300;
  transform: translateY(100px);
  opacity: 0;
  transition: all var(--transition-normal);
}

.toast.show {
  transform: translateY(0);
  opacity: 1;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .header {
    padding: 0.75rem 1rem;
    flex-wrap: wrap;
  }
  .nav-tabs {
    order: 3;
    width: 100%;
    justify-content: center;
  }
  .hero-title {
    font-size: 1.8rem;
  }
  .controls-row {
    grid-template-columns: 1fr;
  }
}
