/* Modern Nature & Audio Book Theme for Northern Vietnam Bird Audio Book */
:root {
  --primary: #1e5631;
  --primary-light: #4c9a2a;
  --primary-dark: #143620;
  --accent: #d4a373;
  --accent-light: #faedcd;
  --accent-dark: #bc6c25;
  --bg-main: #f8f9fa;
  --bg-card: #ffffff;
  --text-main: #2b2d42;
  --text-muted: #6c757d;
  --border: #e2e8f0;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.1);
  --radius: 12px;
  --radius-sm: 8px;
  --transition: all 0.2s ease-in-out;
}

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

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.app-header {
  background: var(--primary-dark);
  color: white;
  padding: 0.75rem 1.5rem;
  box-shadow: 0 2px 8px rgba(0,0,0,0.15);
  position: sticky;
  top: 0;
  z-index: 100;
}

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

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

.brand-icon {
  font-size: 2rem;
}

.brand-title {
  font-size: 1.25rem;
  font-weight: 700;
  line-height: 1.2;
}

.brand-subtitle {
  font-size: 0.8rem;
  color: var(--accent-light);
  opacity: 0.9;
}

.app-nav {
  display: flex;
  gap: 0.35rem;
  overflow-x: auto;
  padding-bottom: 2px;
}

.nav-tab {
  background: transparent;
  color: rgba(255,255,255,0.8);
  border: 1px solid transparent;
  padding: 0.45rem 0.85rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-weight: 500;
  font-size: 0.9rem;
  white-space: nowrap;
  transition: var(--transition);
}

.nav-tab:hover {
  background: rgba(255,255,255,0.1);
  color: white;
}

.nav-tab.active {
  background: var(--primary-light);
  color: white;
  border-color: rgba(255,255,255,0.2);
}

.user-status {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
}

.who-text {
  color: rgba(255,255,255,0.85);
}

/* Buttons & Badges */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.35rem;
  padding: 0.5rem 1rem;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: var(--transition);
}

.btn-primary {
  background: var(--primary);
  color: white;
}
.btn-primary:hover {
  background: var(--primary-dark);
}

.btn-secondary {
  background: #edf2f7;
  color: var(--text-main);
  border: 1px solid var(--border);
}
.btn-secondary:hover {
  background: #e2e8f0;
}

.btn-outline {
  background: transparent;
  color: white;
  border: 1px solid rgba(255,255,255,0.3);
}
.btn-outline:hover {
  background: rgba(255,255,255,0.15);
}

.btn-sm {
  padding: 0.25rem 0.65rem;
  font-size: 0.8rem;
}

.btn-play {
  padding: 0.65rem 1.5rem;
  font-size: 1rem;
  background: var(--primary-light);
  box-shadow: 0 4px 10px rgba(76, 154, 42, 0.3);
}
.btn-play:hover {
  background: var(--primary);
}

.btn-icon, .btn-icon-toggle {
  background: #edf2f7;
  border: 1px solid var(--border);
  padding: 0.45rem 0.75rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 1.1rem;
}
.btn-icon-toggle.active {
  background: var(--accent-light);
  border-color: var(--accent);
}

.badge {
  display: inline-block;
  padding: 0.2rem 0.55rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
}

.habitat-badge {
  background: rgba(30, 86, 49, 0.9);
  color: white;
}

.density-badge {
  background: rgba(188, 108, 37, 0.9);
  color: white;
}

/* Layout */
.app-main {
  max-width: 1200px;
  width: 100%;
  margin: 1.5rem auto;
  padding: 0 1rem;
  flex: 1;
}

.tab-pane {
  display: none;
}
.tab-pane.active {
  display: block;
}

.card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  padding: 1.25rem;
  margin-bottom: 1.25rem;
}

/* TAB 1: PLAYER LAYOUT */
.player-layout {
  display: grid;
  grid-template-columns: 420px 1fr;
  gap: 1.5rem;
  align-items: start;
}

@media (max-width: 900px) {
  .player-layout {
    grid-template-columns: 1fr;
  }
}

.hero-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}

.hero-image-wrapper {
  position: relative;
  width: 100%;
  height: 380px;
  background: #111;
  overflow: hidden;
}

.hero-image {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.4s ease;
}
.hero-image:hover {
  transform: scale(1.03);
}

.hero-image-wrapper .badge {
  position: absolute;
  backdrop-filter: blur(4px);
}
.hero-image-wrapper .habitat-badge {
  top: 12px;
  left: 12px;
}
.hero-image-wrapper .density-badge {
  top: 12px;
  right: 12px;
}

.hero-meta {
  padding: 1.25rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.hero-vi-name {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--primary-dark);
}

.hero-subnames {
  font-size: 0.9rem;
  color: var(--text-muted);
  margin-top: 0.15rem;
}

/* Audio Control Card */
.audio-control-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-lg);
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.audio-section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border);
  padding-bottom: 0.75rem;
}

.live-indicator {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--primary);
}

.pulsing-dot {
  width: 10px;
  height: 10px;
  background-color: var(--primary-light);
  border-radius: 50%;
  display: inline-block;
  animation: pulse 1.8s infinite;
}

@keyframes pulse {
  0% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(76, 154, 42, 0.7); }
  70% { transform: scale(1.1); box-shadow: 0 0 0 8px rgba(76, 154, 42, 0); }
  100% { transform: scale(0.95); box-shadow: 0 0 0 0 rgba(76, 154, 42, 0); }
}

.speed-btn {
  background: #edf2f7;
  border: 1px solid var(--border);
  padding: 0.2rem 0.5rem;
  border-radius: var(--radius-sm);
  font-size: 0.75rem;
  cursor: pointer;
  font-weight: 600;
}
.speed-btn.active {
  background: var(--primary);
  color: white;
}

/* Mnemonic Box */
.mnemonic-box {
  background: var(--accent-light);
  border-left: 4px solid var(--accent-dark);
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
  padding: 0.9rem 1.15rem;
}

.mnemonic-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 700;
  color: var(--accent-dark);
}

.mnemonic-vi {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--primary-dark);
  margin-top: 0.25rem;
  font-style: italic;
}

.mnemonic-en {
  font-size: 0.9rem;
  color: #555;
  margin-top: 0.15rem;
}

/* Waveform Canvas */
.waveform-container {
  background: #18231c;
  border-radius: var(--radius);
  padding: 1rem;
  color: #e2e8f0;
}

.waveform-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  margin-bottom: 0.5rem;
  color: #94a3b8;
}

.waveform-freq {
  color: var(--accent);
  font-weight: 600;
}

.canvas-wrapper {
  width: 100%;
  height: 90px;
  background: #0f1712;
  border-radius: var(--radius-sm);
  overflow: hidden;
}

#waveform-canvas {
  width: 100%;
  height: 100%;
  display: block;
}

.time-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  margin-top: 0.4rem;
  color: #94a3b8;
  font-family: monospace;
}

/* Playback Controls */
.playback-controls {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.auto-advance-label {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  font-size: 0.85rem;
  margin-left: auto;
  color: var(--text-muted);
  cursor: pointer;
}

/* Narration Box */
.narration-box {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.narration-tabs {
  display: flex;
  background: #edf2f7;
  border-bottom: 1px solid var(--border);
}

.narration-tab {
  padding: 0.5rem 1rem;
  background: transparent;
  border: none;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
}
.narration-tab.active {
  background: #f8fafc;
  color: var(--primary);
  border-bottom: 2px solid var(--primary);
}

.narration-content {
  padding: 1rem;
  font-size: 0.95rem;
  line-height: 1.6;
  max-height: 160px;
  overflow-y: auto;
}

/* TAB 2: CATALOG */
.catalog-header-bar {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.search-box input {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  font-size: 1rem;
  background: white;
  box-shadow: var(--shadow);
}
.search-box input:focus {
  outline: 2px solid var(--primary-light);
}

.habitat-filters {
  display: flex;
  gap: 0.5rem;
  flex-wrap: wrap;
}

.filter-pill {
  background: white;
  border: 1px solid var(--border);
  padding: 0.4rem 0.85rem;
  border-radius: 20px;
  font-size: 0.85rem;
  cursor: pointer;
  font-weight: 500;
  box-shadow: var(--shadow);
  transition: var(--transition);
}
.filter-pill:hover {
  background: #f1f5f9;
}
.filter-pill.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

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

.species-card {
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  cursor: pointer;
}
.species-card:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-lg);
}
.species-card.active-card {
  outline: 3px solid var(--primary-light);
}

.card-img-wrapper {
  position: relative;
  width: 100%;
  height: 180px;
  background: #1a1a1a;
}

.card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.card-content {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  flex: 1;
}

.card-vi-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--primary-dark);
}

.card-en-name {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.card-mnemonic {
  font-size: 0.85rem;
  font-style: italic;
  color: var(--accent-dark);
  margin-top: 0.35rem;
  font-weight: 600;
}

.card-footer {
  margin-top: auto;
  padding-top: 0.75rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* TAB 3: PATTERNS & SPECTRUM */
.spectrum-bars {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-top: 1rem;
}

.spectrum-row {
  display: grid;
  grid-template-columns: 140px 1fr 100px;
  align-items: center;
  gap: 1rem;
  font-size: 0.85rem;
}

.spectrum-track {
  position: relative;
  height: 16px;
  background: #e2e8f0;
  border-radius: 8px;
  overflow: hidden;
}

.spectrum-range-fill {
  position: absolute;
  height: 100%;
  background: linear-gradient(90deg, #4c9a2a, #d4a373);
  border-radius: 8px;
}

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

/* TAB 4: HOTSPOTS */
.hotspots-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 1.25rem;
}

.hotspot-card {
  background: white;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  padding: 1.25rem;
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.hotspot-province {
  font-size: 0.75rem;
  text-transform: uppercase;
  color: var(--accent-dark);
  font-weight: 700;
}

.hotspot-title {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--primary-dark);
}

.hotspot-coords {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-family: monospace;
}

.hotspot-species-list {
  display: flex;
  flex-wrap: wrap;
  gap: 0.35rem;
  margin-top: 0.5rem;
}

.species-tag {
  background: #edf2f7;
  color: var(--primary-dark);
  padding: 0.2rem 0.5rem;
  border-radius: 12px;
  font-size: 0.75rem;
  cursor: pointer;
}
.species-tag:hover {
  background: var(--accent-light);
}

/* TAB 5: NOTES */
.notes-layout {
  display: grid;
  grid-template-columns: 360px 1fr;
  gap: 1.5rem;
}
@media (max-width: 800px) {
  .notes-layout {
    grid-template-columns: 1fr;
  }
}

.form-group {
  margin-bottom: 0.85rem;
}
.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  margin-bottom: 0.25rem;
}
.form-group input, .form-group select, .form-group textarea {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
}
.form-check {
  margin-bottom: 1rem;
  font-size: 0.85rem;
}

.notes-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  max-height: 480px;
  overflow-y: auto;
}

.note-item {
  border-left: 3px solid var(--primary);
  background: #f8fafc;
  padding: 0.75rem 1rem;
  border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}
.note-item-header {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  color: var(--text-muted);
}
.note-item-species {
  font-weight: 700;
  color: var(--primary-dark);
}
.note-item-body {
  font-size: 0.9rem;
  margin-top: 0.35rem;
}

/* Mini Player Bar */
.mini-player-bar {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: white;
  border-top: 1px solid var(--border);
  box-shadow: 0 -4px 12px rgba(0,0,0,0.08);
  padding: 0.5rem 1.5rem;
  z-index: 90;
}
.mini-player-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 1rem;
}
.mini-thumb {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  object-fit: cover;
}
.mini-info {
  flex: 1;
  display: flex;
  flex-direction: column;
}
.mini-name {
  font-weight: 700;
  font-size: 0.95rem;
}
.mini-mnemonic {
  font-size: 0.75rem;
  color: var(--accent-dark);
  font-style: italic;
}
