/* ─── Theme Variables ────────────────────────────────────────── */
:root,
[data-theme="lagoon"] {
  --bg-base:        #0d1b2e;
  --hero-from:      #0a1628;
  --hero-mid:       #0f2a4a;
  --hero-to:        #1a3a5c;
  --hero-glow1:     rgba(37,99,235,0.18);
  --hero-glow2:     rgba(245,158,11,0.12);
  --accent:         #2563eb;
  --accent-hover:   #3b82f6;
  --accent-rgb:     37,99,235;
  --card-border:    rgba(255,255,255,0.09);
  --card-bg:        rgba(255,255,255,0.04);
  --theme-dot-bg:   #2563eb;
  --theme-name-txt: "Lagoon";
}

[data-theme="tropical"] {
  --bg-base:        #071a0a;
  --hero-from:      #040f06;
  --hero-mid:       #0b2210;
  --hero-to:        #143018;
  --hero-glow1:     rgba(22,163,74,0.22);
  --hero-glow2:     rgba(234,179,8,0.1);
  --accent:         #16a34a;
  --accent-hover:   #22c55e;
  --accent-rgb:     22,163,74;
  --card-border:    rgba(255,255,255,0.08);
  --card-bg:        rgba(255,255,255,0.04);
  --theme-dot-bg:   #16a34a;
}

[data-theme="sunset"] {
  --bg-base:        #160a03;
  --hero-from:      #120800;
  --hero-mid:       #2d1206;
  --hero-to:        #3a1808;
  --hero-glow1:     rgba(234,88,12,0.22);
  --hero-glow2:     rgba(251,191,36,0.14);
  --accent:         #ea580c;
  --accent-hover:   #f97316;
  --accent-rgb:     234,88,12;
  --card-border:    rgba(255,255,255,0.08);
  --card-bg:        rgba(255,255,255,0.04);
  --theme-dot-bg:   #ea580c;
}

[data-theme="ocean"] {
  --bg-base:        #031520;
  --hero-from:      #020d16;
  --hero-mid:       #053348;
  --hero-to:        #074560;
  --hero-glow1:     rgba(8,145,178,0.22);
  --hero-glow2:     rgba(20,184,166,0.12);
  --accent:         #0891b2;
  --accent-hover:   #06b6d4;
  --accent-rgb:     8,145,178;
  --card-border:    rgba(255,255,255,0.08);
  --card-bg:        rgba(255,255,255,0.04);
  --theme-dot-bg:   #0891b2;
}

[data-theme="aurora"] {
  --bg-base:        #0e0820;
  --hero-from:      #080516;
  --hero-mid:       #160a3a;
  --hero-to:        #1e1050;
  --hero-glow1:     rgba(124,58,237,0.22);
  --hero-glow2:     rgba(219,39,119,0.12);
  --accent:         #7c3aed;
  --accent-hover:   #8b5cf6;
  --accent-rgb:     124,58,237;
  --card-border:    rgba(255,255,255,0.09);
  --card-bg:        rgba(255,255,255,0.04);
  --theme-dot-bg:   #7c3aed;
}

/* ─── Base ─────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Poppins', sans-serif;
  background: var(--bg-base);
  color: #e2e8f0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: background 0.5s ease;
}

/* ─── Navbar ────────────────────────────────────────────────── */
.studio-nav {
  background: rgba(0,0,0,0.55);
  backdrop-filter: blur(14px);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  padding: 0.85rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
}
.studio-nav .navbar-brand { font-size: 1.05rem; letter-spacing: 0.2px; }
.nav-logo { font-size: 1.3rem; transition: transform 0.3s; }
.studio-nav .navbar-brand:hover .nav-logo { transform: rotate(-10deg) scale(1.15); }
.badge-ai {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #1a1a1a;
  font-weight: 600;
  font-size: 0.72rem;
  padding: 0.35rem 0.75rem;
  border-radius: 20px;
}

/* ─── Hero ──────────────────────────────────────────────────── */
.hero {
  position: relative;
  padding: 4rem 0 3.5rem;
  overflow: hidden;
  background: linear-gradient(135deg,
    var(--hero-from) 0%,
    var(--hero-mid) 45%,
    var(--hero-to) 100%);
  transition: background 0.5s ease;
}
.hero::before {
  content: '';
  position: absolute;
  inset: 0;
  background:
    radial-gradient(ellipse 60% 55% at 20% 50%, var(--hero-glow1) 0%, transparent 70%),
    radial-gradient(ellipse 40% 60% at 80% 40%, var(--hero-glow2) 0%, transparent 70%);
  transition: background 0.5s ease;
}
.hero-particles {
  position: absolute;
  inset: 0;
  background-image:
    radial-gradient(1px 1px at 15% 20%, rgba(255,255,255,0.4) 0%, transparent 100%),
    radial-gradient(1px 1px at 40% 70%, rgba(255,255,255,0.3) 0%, transparent 100%),
    radial-gradient(1px 1px at 70% 25%, rgba(255,255,255,0.4) 0%, transparent 100%),
    radial-gradient(1px 1px at 85% 65%, rgba(255,255,255,0.3) 0%, transparent 100%),
    radial-gradient(1px 1px at 55% 45%, rgba(255,255,255,0.2) 0%, transparent 100%);
}
.hero-content { position: relative; z-index: 1; }
.hero-globe {
  width: 110px;
  height: 110px;
  border-radius: 50%;
  object-fit: cover;
  display: inline-block;
  box-shadow: 0 8px 24px rgba(0,0,0,0.35), 0 0 0 3px rgba(255,255,255,0.15);
  animation: float 4s ease-in-out infinite;
}
@keyframes float {
  0%, 100% { transform: translateY(0); }
  50%       { transform: translateY(-10px); }
}

/* ─── Theme Switcher ────────────────────────────────────────── */
.theme-switcher {
  background: rgba(0,0,0,0.35);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 40px;
  backdrop-filter: blur(10px);
}
.theme-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: rgba(255,255,255,0.5);
}
.theme-name {
  font-size: 0.8rem;
  font-weight: 600;
  color: rgba(255,255,255,0.8);
  min-width: 56px;
  text-align: left;
}
.theme-btn {
  width: 26px;
  height: 26px;
  border-radius: 50%;
  border: 2px solid transparent;
  padding: 0;
  background: transparent;
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}
.theme-btn .theme-dot {
  display: block;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  transition: transform 0.2s;
}
[data-theme="lagoon"]  .theme-btn[data-theme="lagoon"]  .theme-dot,
[data-theme="tropical"] .theme-btn[data-theme="tropical"] .theme-dot,
[data-theme="sunset"]  .theme-btn[data-theme="sunset"]  .theme-dot,
[data-theme="ocean"]   .theme-btn[data-theme="ocean"]   .theme-dot,
[data-theme="aurora"]  .theme-btn[data-theme="aurora"]  .theme-dot  { transform: scale(1.2); }

.theme-btn[data-theme="lagoon"]   .theme-dot { background: #2563eb; }
.theme-btn[data-theme="tropical"] .theme-dot { background: #16a34a; }
.theme-btn[data-theme="sunset"]   .theme-dot { background: #ea580c; }
.theme-btn[data-theme="ocean"]    .theme-dot { background: #0891b2; }
.theme-btn[data-theme="aurora"]   .theme-dot { background: #7c3aed; }

.theme-btn:hover { transform: scale(1.15); }
.theme-btn.active {
  border-color: rgba(255,255,255,0.7);
  transform: scale(1.1);
}

/* ─── Cards ─────────────────────────────────────────────────── */
.studio-card {
  background: var(--card-bg);
  border: 1px solid var(--card-border);
  border-radius: 16px;
  overflow: hidden;
  backdrop-filter: blur(6px);
  transition: border-color 0.25s, background 0.5s;
}
.studio-card:hover { border-color: rgba(var(--accent-rgb), 0.3); }
.studio-card-header {
  background: rgba(255,255,255,0.03);
  border-bottom: 1px solid rgba(255,255,255,0.07);
  padding: 0.85rem 1.25rem;
  font-size: 0.82rem;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  color: #94a3b8;
}
.studio-card-body { padding: 1.25rem; }

/* ─── Template Buttons ──────────────────────────────────────── */
.btn-tpl {
  background: rgba(var(--accent-rgb), 0.1);
  border: 1px solid rgba(var(--accent-rgb), 0.28);
  color: #93c5fd;
  font-size: 0.8rem;
  font-weight: 500;
  padding: 0.38rem 0.85rem;
  border-radius: 20px;
  transition: all 0.2s;
}
.btn-tpl:hover {
  background: rgba(var(--accent-rgb), 0.22);
  border-color: rgba(var(--accent-rgb), 0.55);
  color: #bfdbfe;
  transform: translateY(-1px);
}
.btn-tpl:active { transform: translateY(0); }
.btn-tpl.active {
  background: rgba(var(--accent-rgb), 0.32);
  border-color: var(--accent);
  color: #fff;
  box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.22);
}

/* ─── Textarea ──────────────────────────────────────────────── */
.textarea-wrap { position: relative; }
.studio-textarea {
  width: 100%;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 12px;
  color: #e2e8f0;
  font-family: 'Poppins', sans-serif;
  font-size: 0.92rem;
  line-height: 1.75;
  padding: 1rem 1rem 2.5rem;
  resize: vertical;
  transition: border-color 0.2s, box-shadow 0.2s;
}
.studio-textarea::placeholder { color: #3d4f63; }
.studio-textarea:focus {
  outline: none;
  border-color: rgba(var(--accent-rgb), 0.5);
  box-shadow: 0 0 0 3px rgba(var(--accent-rgb), 0.12);
  background: rgba(255,255,255,0.055);
}
.char-counter {
  position: absolute;
  bottom: 0.6rem;
  right: 0.8rem;
  font-size: 0.7rem;
  color: #3d4f63;
  transition: color 0.2s;
}
.char-counter.warn   { color: #f59e0b; }
.char-counter.danger { color: #ef4444; }

/* ─── Generate Button ───────────────────────────────────────── */
.btn-generate {
  background: linear-gradient(135deg,
    rgba(var(--accent-rgb),1) 0%,
    rgba(var(--accent-rgb),0.8) 100%);
  border: none;
  border-radius: 14px;
  color: #fff;
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.3px;
  padding: 0.85rem;
  transition: all 0.25s;
  box-shadow: 0 4px 20px rgba(var(--accent-rgb), 0.38);
}
.btn-generate:hover:not(:disabled) {
  filter: brightness(1.12);
  transform: translateY(-2px);
  box-shadow: 0 8px 28px rgba(var(--accent-rgb), 0.48);
  color: #fff;
}
.btn-generate:active  { transform: translateY(0); }
.btn-generate:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none;
  box-shadow: none;
}

/* ─── Voice Cards ───────────────────────────────────────────── */
.voice-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  padding: 0.85rem 0.5rem;
  border-radius: 12px;
  background: rgba(255,255,255,0.04);
  border: 1.5px solid rgba(255,255,255,0.08);
  cursor: pointer;
  transition: all 0.2s;
  text-align: center;
}
.voice-card:hover {
  border-color: rgba(var(--accent-rgb), 0.4);
  background: rgba(var(--accent-rgb), 0.07);
}
.btn-check:checked + .voice-card {
  border-color: var(--accent);
  background: rgba(var(--accent-rgb), 0.15);
  box-shadow: 0 0 0 2px rgba(var(--accent-rgb), 0.22);
}
.voice-name { font-size: 0.88rem; font-weight: 600; color: #e2e8f0; }
.voice-desc { font-size: 0.7rem; color: #64748b; }

/* ─── Voice section labels ──────────────────────────────────── */
.voice-section-label {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.8px;
  color: #475569;
  margin-bottom: 0.6rem;
}

/* ─── Female voice card ─────────────────────────────────────── */
.voice-card-female {
  border-color: rgba(236,72,153,0.18);
  background: rgba(236,72,153,0.04);
}
.voice-card-female:hover {
  border-color: rgba(236,72,153,0.42);
  background: rgba(236,72,153,0.09);
}
.btn-check:checked + .voice-card-female {
  border-color: #ec4899;
  background: rgba(236,72,153,0.14);
  box-shadow: 0 0 0 2px rgba(236,72,153,0.22);
}

/* ─── Sliders ───────────────────────────────────────────────── */
.studio-range {
  -webkit-appearance: none;
  appearance: none;
  width: 100%;
  height: 5px;
  border-radius: 4px;
  background: rgba(255,255,255,0.1);
  outline: none;
  cursor: pointer;
  position: relative;
}
.studio-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--accent);
  border: 2px solid #fff;
  box-shadow: 0 2px 8px rgba(var(--accent-rgb), 0.5);
  cursor: pointer;
  transition: transform 0.15s;
}
.studio-range::-webkit-slider-thumb:hover { transform: scale(1.2); }
.slider-value {
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--accent-hover);
  min-width: 80px;
  text-align: right;
}
.slider-labels {
  font-size: 0.68rem;
  color: #475569;
  margin-top: 4px;
}

/* ─── Voice hint ────────────────────────────────────────────── */
.voice-hint {
  font-size: 0.73rem;
  color: #475569;
  line-height: 1.5;
  border-top: 1px solid rgba(255,255,255,0.06);
  padding-top: 0.85rem;
}

/* ─── Waveform ──────────────────────────────────────────────── */
.waveform-visual {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  height: 40px;
}
.waveform-visual span {
  display: block;
  width: 4px;
  height: 8px;
  background: var(--accent);
  border-radius: 2px;
  opacity: 0.35;
  transition: height 0.1s;
}
.waveform-visual.playing span {
  opacity: 1;
  animation: wave 1s ease-in-out infinite;
}
.waveform-visual.playing span:nth-child(1)  { animation-delay: 0s;    animation-duration: 0.9s; }
.waveform-visual.playing span:nth-child(2)  { animation-delay: 0.1s;  animation-duration: 1.1s; }
.waveform-visual.playing span:nth-child(3)  { animation-delay: 0.2s;  animation-duration: 0.8s; }
.waveform-visual.playing span:nth-child(4)  { animation-delay: 0.05s; animation-duration: 1.2s; }
.waveform-visual.playing span:nth-child(5)  { animation-delay: 0.15s; animation-duration: 0.95s; }
.waveform-visual.playing span:nth-child(6)  { animation-delay: 0.25s; animation-duration: 1.05s; }
.waveform-visual.playing span:nth-child(7)  { animation-delay: 0.08s; animation-duration: 0.85s; }
.waveform-visual.playing span:nth-child(8)  { animation-delay: 0.18s; animation-duration: 1.15s; }
.waveform-visual.playing span:nth-child(9)  { animation-delay: 0.12s; animation-duration: 0.92s; }
.waveform-visual.playing span:nth-child(10) { animation-delay: 0.22s; animation-duration: 1.08s; }
@keyframes wave {
  0%, 100% { height: 6px; }
  50%       { height: 32px; }
}

/* ─── Audio Player ──────────────────────────────────────────── */
audio {
  border-radius: 8px;
  filter: invert(1) hue-rotate(180deg);
  opacity: 0.9;
}

/* ─── Download Button ───────────────────────────────────────── */
.btn-download {
  background: linear-gradient(135deg, #059669, #047857);
  color: #fff;
  font-weight: 600;
  border-radius: 12px;
  border: none;
  padding: 0.7rem;
  font-size: 0.9rem;
  transition: all 0.2s;
  box-shadow: 0 4px 16px rgba(5,150,105,0.28);
  text-decoration: none;
  display: inline-block;
  text-align: center;
}
.btn-download:hover {
  background: linear-gradient(135deg, #10b981, #059669);
  color: #fff;
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(5,150,105,0.38);
}

/* ─── Alert ─────────────────────────────────────────────────── */
.alert-danger {
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.28);
  color: #fca5a5;
  border-radius: 12px;
  font-size: 0.88rem;
}

/* ─── Footer ────────────────────────────────────────────────── */
.studio-footer {
  margin-top: auto;
  background: rgba(0,0,0,0.35);
  border-top: 1px solid rgba(255,255,255,0.05);
  text-align: center;
  padding: 1rem;
  font-size: 0.78rem;
  color: #475569;
}

/* ─── Responsive ─────────────────────────────────────────────── */
@media (max-width: 576px) {
  .hero { padding: 2.5rem 0 2rem; }
  .hero-globe { width: 80px; height: 80px; }
  .theme-switcher { flex-wrap: wrap; justify-content: center; }
}
