@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@500;600;700;800&display=swap');

:root {
  --bg-main: #090d16;
  --bg-card: rgba(22, 30, 46, 0.75);
  --bg-card-hover: rgba(30, 41, 59, 0.85);
  --border-card: rgba(255, 255, 255, 0.08);
  --border-focus: rgba(99, 102, 241, 0.5);
  
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-glow: rgba(99, 102, 241, 0.35);
  
  --accent-emerald: #10b981;
  --accent-emerald-glow: rgba(16, 185, 129, 0.3);
  
  --accent-rose: #f43f5e;
  --accent-rose-glow: rgba(244, 63, 94, 0.4);
  
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --text-dim: #64748b;
  
  --radius-lg: 18px;
  --radius-md: 12px;
  --radius-sm: 8px;
  
  --shadow-main: 0 12px 32px -8px rgba(0, 0, 0, 0.5);
  --shadow-glow: 0 0 25px -5px var(--primary-glow);
  
  --font-display: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;
  --font-body: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-main);
  background-image: 
    radial-gradient(circle at 15% 15%, rgba(99, 102, 241, 0.12) 0%, transparent 40%),
    radial-gradient(circle at 85% 85%, rgba(16, 185, 129, 0.08) 0%, transparent 40%);
  background-attachment: fixed;
  color: var(--text-main);
  font-family: var(--font-body);
  line-height: 1.6;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header & Top Navigation */
header {
  background: rgba(15, 23, 42, 0.85);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-card);
  position: sticky;
  top: 0;
  z-index: 100;
  padding: 0.4rem 1rem;
}

.header-container {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.brand {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  text-decoration: none;
}

.brand-logo {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, var(--primary), #a855f7);
  border-radius: var(--radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.brand-text h1 {
  font-family: var(--font-display);
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
  letter-spacing: -0.02em;
}

.brand-text span {
  font-size: 0.7rem;
  color: var(--text-muted);
  display: block;
}

/* Nav Tabs */
nav.nav-tabs {
  display: flex;
  gap: 0.35rem;
  background: rgba(15, 23, 42, 0.6);
  padding: 0.2rem;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-card);
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  padding: 0.35rem 0.8rem;
  border-radius: var(--radius-sm);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  transition: all 0.2s ease;
  min-height: 36px;
}

.tab-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.05);
}

.tab-btn.active {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 4px 12px var(--primary-glow);
}

/* Main Container */
main {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0.5rem auto;
  padding: 0 0.75rem;
}

.tab-content {
  display: none;
  animation: fadeIn 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.tab-content.active {
  display: block;
}

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

/* Common Card Styling */
.card {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 0.85rem 1rem;
  box-shadow: var(--shadow-main);
  margin-bottom: 0.65rem;
}

/* Lesson Selector Bar */
.selector-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 0.65rem;
  padding: 0.5rem 0.85rem;
}

.selector-group {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex: 1;
  min-width: 260px;
}

label.select-label {
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.85rem;
  color: var(--text-muted);
  white-space: nowrap;
}

select.custom-select {
  width: 100%;
  padding: 0.4rem 0.75rem;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  color: var(--text-main);
  font-size: 0.88rem;
  font-family: var(--font-body);
  outline: none;
  cursor: pointer;
  transition: border-color 0.2s ease;
  min-height: 38px;
}

select.custom-select:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-glow);
}

/* Activity 1: Listen & Read */
.audio-player-card {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: linear-gradient(135deg, rgba(30, 41, 59, 0.7), rgba(15, 23, 42, 0.85));
}

.track-info {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.75rem;
}

.track-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
}

.track-badge {
  background: rgba(99, 102, 241, 0.2);
  color: #818cf8;
  padding: 0.2rem 0.6rem;
  border-radius: 12px;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid rgba(99, 102, 241, 0.3);
}

/* Custom Player Controls */
.player-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.btn-icon {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--primary);
  border: none;
  color: #ffffff;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 4px 14px var(--primary-glow);
  flex-shrink: 0;
}

.btn-icon:hover {
  transform: scale(1.06);
  background: var(--primary-hover);
}

.timeline-container {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 180px;
}

.time-display {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: 500;
  min-width: 40px;
}

input[type="range"].seekbar {
  flex: 1;
  height: 5px;
  -webkit-appearance: none;
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
  outline: none;
  cursor: pointer;
}

input[type="range"].seekbar::-webkit-slider-thumb {
  -webkit-appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--primary);
  box-shadow: 0 0 8px var(--primary);
  transition: transform 0.1s ease;
}

input[type="range"].seekbar::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

.speed-toggle {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-card);
  color: var(--text-main);
  padding: 0.25rem 0.6rem;
  border-radius: var(--radius-sm);
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.2s;
  min-height: 36px;
}

.speed-toggle:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* Transcript Display */
.transcript-box {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-sm);
  padding: 1rem 1.1rem;
  max-height: calc(100vh - 240px);
  min-height: 380px;
  overflow-y: auto;
  scroll-behavior: smooth;
}

.transcript-box::-webkit-scrollbar {
  width: 6px;
}

.transcript-box::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.2);
  border-radius: 4px;
}

.transcript-box::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.15);
  border-radius: 4px;
}

.speaker-line {
  margin-bottom: 0.45rem;
  line-height: 1.4;
  font-size: 0.95rem;
}

.speaker-name {
  font-weight: 700;
  font-family: var(--font-display);
  color: var(--primary);
  margin-right: 0.35rem;
  display: inline-block;
}

.speech-text {
  color: var(--text-main);
}

/* Activity 2: Practice & Record */
.record-hero {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
  text-align: center;
  padding: 1.25rem 1rem;
  gap: 0.5rem;
  height: 250px;
  min-height: 250px;
  max-height: 250px;
  flex-shrink: 0;
  background: radial-gradient(circle at center, rgba(30, 41, 59, 0.8), rgba(15, 23, 42, 0.95));
}

.recording-status {
  font-family: var(--font-display);
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  height: 28px;
  min-height: 28px;
  max-height: 28px;
  flex-shrink: 0;
}

.status-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--text-dim);
  transition: all 0.3s ease;
  flex-shrink: 0;
}

.status-dot.active {
  background: var(--accent-rose);
  box-shadow: 0 0 10px var(--accent-rose-glow);
  animation: pulseDot 1.2s infinite;
}

@keyframes pulseDot {
  0% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.3); opacity: 0.7; }
  100% { transform: scale(1); opacity: 1; }
}

.timer-large {
  font-family: var(--font-display);
  font-size: 2.4rem;
  font-weight: 800;
  letter-spacing: -0.03em;
  color: var(--text-main);
  height: 48px;
  min-height: 48px;
  max-height: 48px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
}

.visualizer-container {
  width: 100%;
  max-width: 360px;
  height: 40px;
  min-height: 40px;
  max-height: 40px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  overflow: hidden;
}

.bar {
  width: 5px;
  height: 30px;
  background: var(--primary);
  border-radius: 3px;
  transform-origin: center center;
  transform: scaleY(0.2);
  will-change: transform;
  transition: transform 0.05s ease-out;
}

.controls-row {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 1rem;
  flex-wrap: wrap;
  width: 100%;
  height: 56px;
  min-height: 56px;
  max-height: 56px;
  flex-shrink: 0;
}

.btn-record {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  background: linear-gradient(135deg, #f43f5e, #e11d48);
  border: none;
  color: #ffffff;
  font-size: 1.3rem;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 6px 18px var(--accent-rose-glow);
  transition: all 0.25s ease;
}

.btn-record:hover {
  transform: scale(1.08);
}

.btn-record.recording {
  animation: pulseRecord 1.5s infinite;
  background: linear-gradient(135deg, #e11d48, #be123c);
}

@keyframes pulseRecord {
  0% { box-shadow: 0 0 0 0 rgba(244, 63, 94, 0.6); }
  70% { box-shadow: 0 0 0 22px rgba(244, 63, 94, 0); }
  100% { box-shadow: 0 0 0 0 rgba(244, 63, 94, 0); }
}

.btn-action {
  padding: 0.8rem 1.5rem;
  border-radius: var(--radius-md);
  font-family: var(--font-display);
  font-weight: 600;
  font-size: 0.95rem;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
  min-height: 48px;
}

.btn-primary {
  background: var(--primary);
  color: #ffffff;
  box-shadow: 0 4px 14px var(--primary-glow);
}

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-emerald {
  background: var(--accent-emerald);
  color: #ffffff;
  box-shadow: 0 4px 14px var(--accent-emerald-glow);
}

.btn-emerald:hover {
  background: #059669;
  transform: translateY(-1px);
}

.btn-secondary {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
  border: 1px solid var(--border-card);
}

.btn-secondary:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* Activity 3: Review & Manage */
.recordings-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.recording-item {
  background: rgba(15, 23, 42, 0.7);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  padding: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  transition: border-color 0.2s ease;
}

.recording-item:hover {
  border-color: var(--border-focus);
}

.rec-meta {
  flex: 1;
  min-width: 220px;
}

.rec-title-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.25rem;
}

.rec-title {
  font-family: var(--font-display);
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--text-main);
}

.rec-details {
  font-size: 0.8rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 1rem;
}

.rec-actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-sm {
  padding: 0.4rem 0.8rem;
  font-size: 0.85rem;
  border-radius: var(--radius-sm);
  min-height: 38px;
}

.btn-danger {
  background: rgba(244, 63, 94, 0.15);
  color: #f43f5e;
  border: 1px solid rgba(244, 63, 94, 0.3);
}

.btn-danger:hover {
  background: rgba(244, 63, 94, 0.25);
}

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-dim);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 0.75rem;
}

/* Modal */
.modal-backdrop {
  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;
  padding: 1rem;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s ease;
}

.modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-card {
  background: #1e293b;
  border: 1px solid var(--border-card);
  border-radius: var(--radius-lg);
  padding: 1.75rem;
  width: 100%;
  max-width: 440px;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
}

.modal-header {
  font-family: var(--font-display);
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 1rem;
}

.modal-input {
  width: 100%;
  padding: 0.75rem 1rem;
  background: rgba(15, 23, 42, 0.8);
  border: 1px solid var(--border-card);
  border-radius: var(--radius-md);
  color: var(--text-main);
  font-size: 1rem;
  margin-bottom: 1.5rem;
  outline: none;
}

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

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
}

/* Responsive adjustments */
@media (max-width: 768px) {
  .header-container {
    flex-direction: column;
    align-items: stretch;
  }
  
  nav.nav-tabs {
    justify-content: space-around;
  }
  
  .tab-btn {
    flex: 1;
    justify-content: center;
    padding: 0.5rem 0.5rem;
    font-size: 0.82rem;
  }
  
  .recording-item {
    flex-direction: column;
    align-items: stretch;
  }
  
  .rec-actions {
    justify-content: flex-end;
  }
}
