/* ==========================================================================
   SAPIENSIA CLAN — REPRODUCTOR WEB DE AUDIOLIBROS (CSS/AUDIO.CSS V2.0)
   Descripción: Interfaz oscura de alto contraste, legible y sin resplandor cegador.
   ========================================================================== */

/* --- CUERPO Y FONDO OSCURO SÓLIDO --- */
.audio-body {
  background-color: #08080a !important;
  color: #f4f4f5 !important;
  font-family: var(--font-sans);
  min-height: 100vh;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  overflow-x: hidden;
  position: relative;
}

/* Control del resplandor de la aurora (Atenuado y bajo control) */
.audio-aurora {
  opacity: 0.18 !important;
  filter: blur(140px);
  z-index: -2;
  position: fixed;
  inset: 0;
  pointer-events: none;
}

/* --- NAVEGACIÓN SUPERIOR --- */
.audio-navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  background: rgba(8, 8, 10, 0.92);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding: 12px 24px;
}

.obra-switcher-tabs {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.04);
  padding: 4px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.tab-btn {
  font-family: var(--font-mono);
  font-size: 0.78rem;
  font-weight: 600;
  color: var(--text-secondary);
  text-decoration: none;
  padding: 6px 14px;
  border-radius: 4px;
  transition: all 0.2s ease;
}

.tab-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.08);
}

.tab-btn.active {
  background: var(--amber-primary);
  color: #000;
  font-weight: 700;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.4);
}

.btn-back-clan, .btn-switch-reader {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.8rem;
  font-weight: 600;
  text-decoration: none;
  transition: all 0.2s ease;
}

.btn-back-clan:hover, .btn-switch-reader:hover {
  background: rgba(245, 158, 11, 0.15);
  border-color: var(--amber-primary);
  color: var(--amber-glow);
}

@media (max-width: 768px) {
  .audio-navbar {
    padding: 10px 14px;
  }
  .audio-navbar .nav-container {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 10px;
  }
  .obra-switcher-tabs {
    order: 3;
    width: 100%;
    justify-content: center;
  }
  .tab-btn {
    flex: 1;
    text-align: center;
    padding: 8px 10px;
    font-size: 0.74rem;
  }
  .btn-back-clan, .btn-switch-reader {
    padding: 6px 12px;
    font-size: 0.75rem;
  }
}

/* --- CONTENEDOR PRINCIPAL --- */
.audio-container {
  flex: 1;
  max-width: 1200px;
  width: 100%;
  margin: 0 auto;
  padding: 32px 24px 80px;
  position: relative;
  z-index: 10;
}

/* --- TARJETA PRINCIPAL DEL REPRODUCTOR (DARK GLASS DE ALTO CONTRASTE) --- */
.player-card {
  display: grid;
  grid-template-columns: 320px 1fr;
  gap: 40px;
  background: #0e0f14;
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: var(--radius-md);
  padding: 36px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.9), 0 0 40px rgba(0, 0, 0, 0.6);
  position: relative;
}

@media (max-width: 900px) {
  .player-card {
    grid-template-columns: 1fr;
    padding: 24px;
    gap: 32px;
  }
}

/* --- BARRA LATERAL (PORTADA & METADATOS) --- */
.player-sidebar {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

.player-cover-wrap {
  position: relative;
  border-radius: var(--radius-sm);
  overflow: hidden;
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.8);
  border: 1px solid rgba(255, 255, 255, 0.15);
}

.player-cover-img {
  width: 100%;
  height: auto;
  display: block;
  object-fit: cover;
}

.player-cover-badge {
  position: absolute;
  bottom: 10px;
  left: 10px;
  background: rgba(8, 8, 10, 0.9);
  border: 1px solid rgba(245, 158, 11, 0.4);
  color: var(--amber-glow);
  font-family: var(--font-mono);
  font-size: 0.65rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 4px;
  letter-spacing: 0.08em;
}

.sidebar-meta-box {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.meta-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  font-family: var(--font-mono);
  font-size: 0.75rem;
}

.meta-label {
  color: var(--text-muted);
}

.meta-val {
  color: #fff;
  font-weight: 600;
}

.btn-download-full {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 0.82rem;
  font-weight: 700;
  padding: 12px;
  border-radius: var(--radius-sm);
  text-decoration: none;
  transition: all 0.2s ease;
  text-align: center;
}

.btn-download-full:hover {
  background: rgba(245, 158, 11, 0.18);
  border-color: var(--amber-primary);
  color: var(--amber-glow);
  box-shadow: 0 0 15px rgba(245, 158, 11, 0.25);
}

/* --- CONTENIDO PRINCIPAL DEL REPRODUCTOR --- */
.player-main-content {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

.book-header-info {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.badge-status-live {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  align-self: flex-start;
  font-family: var(--font-mono);
  font-size: 0.72rem;
  font-weight: 700;
  color: var(--amber-glow);
  background: rgba(245, 158, 11, 0.12);
  border: 1px solid rgba(245, 158, 11, 0.3);
  padding: 4px 12px;
  border-radius: 20px;
  letter-spacing: 0.08em;
}

.book-main-title {
  font-family: var(--font-serif-title);
  font-size: 2.2rem;
  color: #ffffff;
  line-height: 1.15;
  margin: 0;
}

.book-main-subtitle {
  font-family: var(--font-serif-body);
  font-style: italic;
  font-size: 1.15rem;
  color: var(--amber-glow);
  margin: 0;
}

.book-author-line {
  font-family: var(--font-mono);
  font-size: 0.82rem;
  color: var(--text-muted);
}

.author-gold {
  color: var(--amber-primary);
  font-weight: 600;
}

/* Caja de "Reproduciendo Ahora" */
.now-playing-box {
  background: rgba(245, 158, 11, 0.08);
  border: 1px solid rgba(245, 158, 11, 0.25);
  border-left: 4px solid var(--amber-primary);
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.now-playing-tag {
  font-family: var(--font-mono);
  font-size: 0.68rem;
  color: var(--amber-glow);
  letter-spacing: 0.1em;
  font-weight: 700;
}

.now-playing-title {
  font-family: var(--font-sans);
  font-size: 1.05rem;
  font-weight: 600;
  color: #ffffff;
}

/* --- PANEL DE MANDOS DE AUDIO (DECK) --- */
.audio-control-deck {
  background: rgba(0, 0, 0, 0.5);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-sm);
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 22px;
}

/* Scrubber / Barra de Tiempo */
.scrubber-wrapper {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.scrubber-track {
  position: relative;
  width: 100%;
  height: 10px;
  background: rgba(255, 255, 255, 0.12);
  border-radius: 5px;
  cursor: pointer;
}

.scrubber-fill {
  position: absolute;
  top: 0;
  left: 0;
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #d97706, #fbbf24);
  border-radius: 5px;
  box-shadow: 0 0 12px rgba(245, 158, 11, 0.6);
  pointer-events: none;
}

.time-display-row {
  display: flex;
  justify-content: space-between;
  font-family: var(--font-mono);
  font-size: 0.8rem;
  color: var(--text-muted);
}

.time-text {
  font-weight: 600;
  color: #d4d4d8;
}

/* Mando Central de Botones (PLAY, REWIND, FORWARD) */
.playback-buttons-bar {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
}

.btn-step-time {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  font-family: var(--font-mono);
  font-size: 0.85rem;
  font-weight: 700;
  padding: 10px 18px;
  border-radius: 24px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.btn-step-time:hover {
  background: rgba(245, 158, 11, 0.18);
  border-color: var(--amber-primary);
  color: var(--amber-glow);
  transform: scale(1.05);
}

.btn-main-play {
  background: linear-gradient(135deg, #f59e0b, #d97706);
  color: #000;
  border: none;
  font-family: var(--font-mono);
  font-size: 0.95rem;
  font-weight: 900;
  letter-spacing: 0.08em;
  padding: 14px 32px;
  border-radius: 30px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
  box-shadow: 0 0 25px rgba(245, 158, 11, 0.5);
  transition: all 0.2s ease;
}

.btn-main-play:hover {
  transform: scale(1.06);
  box-shadow: 0 0 35px rgba(245, 158, 11, 0.8);
}

.btn-main-play:active {
  transform: scale(0.96);
}

.play-icon {
  font-size: 1.2rem;
}

/* Fila de Herramientas (Velocidad y Volumen) */
.audio-tools-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  padding-top: 14px;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
}

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

.tool-label {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--text-muted);
  font-weight: 600;
}

.speed-btn-cluster {
  display: flex;
  align-items: center;
  gap: 4px;
  background: rgba(255, 255, 255, 0.04);
  padding: 3px;
  border-radius: var(--radius-sm);
  border: 1px solid rgba(255, 255, 255, 0.08);
}

.btn-speed {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-family: var(--font-mono);
  font-size: 0.75rem;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.btn-speed:hover, .btn-speed.active {
  background: rgba(245, 158, 11, 0.25);
  color: var(--amber-glow);
  font-weight: 700;
}

.volume-slider-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.btn-vol-icon {
  background: transparent;
  border: none;
  font-size: 1rem;
  cursor: pointer;
  color: #fff;
}

.vol-range {
  -webkit-appearance: none;
  appearance: none;
  width: 90px;
  height: 5px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
  outline: none;
  cursor: pointer;
}

.vol-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--amber-primary);
  cursor: pointer;
  box-shadow: 0 0 8px rgba(245, 158, 11, 0.8);
}

/* --- TRACKLIST / ÍNDICE DE CAPÍTULOS --- */
.tracklist-container {
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.tracklist-top {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding-bottom: 8px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.tracklist-header-title {
  font-family: var(--font-serif-title);
  font-size: 1.25rem;
  color: #fff;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.tracklist-badge {
  font-family: var(--font-mono);
  font-size: 0.72rem;
  color: var(--amber-primary);
  font-weight: 700;
  background: rgba(245, 158, 11, 0.1);
  padding: 3px 8px;
  border-radius: 4px;
}

.tracklist-scroll-area {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
  max-height: 380px;
  overflow-y: auto;
  padding-right: 6px;
}

/* Scrollbar personalizada */
.tracklist-scroll-area::-webkit-scrollbar {
  width: 6px;
}
.tracklist-scroll-area::-webkit-scrollbar-track {
  background: rgba(0, 0, 0, 0.3);
  border-radius: 3px;
}
.tracklist-scroll-area::-webkit-scrollbar-thumb {
  background: rgba(245, 158, 11, 0.4);
  border-radius: 3px;
}

.track-item-card {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all 0.2s ease;
}

.track-item-card:hover {
  background: rgba(245, 158, 11, 0.1);
  border-color: rgba(245, 158, 11, 0.4);
  transform: translateX(4px);
}

.track-item-card.is-active {
  background: rgba(245, 158, 11, 0.18);
  border-color: var(--amber-primary);
  box-shadow: 0 0 15px rgba(245, 158, 11, 0.2);
}

.track-card-left {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
}

.track-index-num {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--amber-primary);
  font-weight: 700;
  min-width: 20px;
}

.track-title-text {
  font-size: 0.88rem;
  color: #e4e4e7;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-item-card.is-active .track-title-text {
  color: var(--amber-glow);
  font-weight: 700;
}

.track-time-stamp {
  font-family: var(--font-mono);
  font-size: 0.75rem;
  color: var(--text-muted);
  font-weight: 600;
}

/* Toast de reanudación */
.resume-toast-popup {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: #0e0f14;
  border: 1px solid var(--amber-primary);
  padding: 14px 22px;
  border-radius: var(--radius-sm);
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: #ffffff;
  box-shadow: 0 10px 40px rgba(0,0,0,0.9);
  z-index: 1000;
  display: flex;
  align-items: center;
  gap: 10px;
  animation: slide-up-toast 0.35s ease;
}

@keyframes slide-up-toast {
  from { opacity: 0; transform: translateY(20px); }
  to { opacity: 1; transform: translateY(0); }
}
