/* ==========================================================================
   Buscador de canciones por ritmo y BPM para entrenamiento
   Fijate Tools • Estilos Canónicos
   ========================================================================== */

:root {
  --bg-primary: #0b0f17;
  --bg-card: #111827;
  --bg-card-subtle: #1a2234;
  --bg-input: #1f293d;
  --border-color: #27354f;
  --border-focus: #a855f7;

  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-accent: #c084fc;

  --color-purple: #a855f7;
  --color-purple-bg: rgba(168, 85, 247, 0.15);
  --color-green: #10b981;
  --color-amber: #f59e0b;
  --color-cyan: #06b6d4;
  --color-blue: #3b82f6;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.25);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.35);
}

[data-theme="light"] {
  --bg-primary: #f8fafc;
  --bg-card: #ffffff;
  --bg-card-subtle: #f1f5f9;
  --bg-input: #ffffff;
  --border-color: #cbd5e1;
  --border-focus: #9333ea;

  --text-main: #0f172a;
  --text-muted: #475569;
  --text-accent: #7e22ce;

  --color-purple: #9333ea;
  --color-purple-bg: rgba(147, 51, 234, 0.12);
  --color-green: #059669;
  --color-amber: #d97706;
  --color-cyan: #0891b2;
  --color-blue: #2563eb;

  --shadow-sm: 0 4px 12px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.08);
}

body {
  margin: 0;
  padding: 0;
  background-color: var(--bg-primary);
  color: var(--text-main);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  overflow-x: clip;
  width: 100%;
  max-width: 100%;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Outfit', sans-serif;
  margin: 0;
  font-weight: 700;
}

.tool-layout {
  max-width: 1200px;
  margin: 1.5rem auto 3rem;
  padding: 0 1rem;
  flex: 1;
  width: 100%;
  box-sizing: border-box;
}

.tool-with-sidebar {
  display: flex;
  gap: 2rem;
  align-items: flex-start;
}

.tool-main-content {
  flex: 1;
  min-width: 0;
}

/* Tarjeta principal */
.card-main {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.card-section {
  padding: 1.75rem;
}

.control-label {
  font-size: 0.875rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* Selector de BPMs */
.bpm-selector-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  margin-bottom: 1.5rem;
}

.btn-bpm-pill {
  flex: 1 1 130px;
  min-height: 48px;
  padding: 0.5rem 0.75rem;
  background: var(--bg-card-subtle);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.95rem;
  font-weight: 700;
  cursor: pointer;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.2rem;
  transition: all 0.2s;
}

.pill-hint {
  font-family: 'Inter', sans-serif;
  font-size: 0.7rem;
  font-weight: 500;
  color: var(--text-muted);
}

.btn-bpm-pill:hover {
  border-color: var(--border-focus);
  transform: translateY(-1px);
}

.btn-bpm-pill.active {
  background: var(--color-purple-bg);
  border-color: var(--color-purple);
  color: var(--color-purple);
  box-shadow: 0 0 0 1px var(--color-purple);
}

.btn-bpm-pill.active .pill-hint {
  color: var(--text-main);
}

/* Formulario buscador */
.music-search-form {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
}

.form-control-input {
  flex: 1;
  min-width: 0;
  height: 44px;
  padding: 0 1rem;
  background-color: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  box-sizing: border-box;
}

.form-control-input:focus {
  outline: none;
  border-color: var(--border-focus);
}

.btn-primary {
  height: 44px;
  padding: 0 1.5rem;
  background: var(--color-purple);
  color: #ffffff;
  border: none;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity 0.2s;
}

.btn-primary:hover {
  opacity: 0.9;
}

/* KPIs */
.kpi-strip {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(170px, 1fr));
  gap: 1rem;
  padding-top: 1.25rem;
  border-top: 1px solid var(--border-color);
}

.kpi-card {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.kpi-label {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  font-weight: 600;
}

.kpi-val {
  font-family: 'JetBrains Mono', monospace;
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1.2;
}

.kpi-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.text-purple { color: var(--color-purple) !important; }
.text-green { color: var(--color-green) !important; }
.text-cyan { color: var(--color-cyan) !important; }
.text-amber { color: var(--color-amber) !important; }

/* Reproductor de audio flotante */
.audio-player-banner {
  position: sticky;
  top: 1rem;
  z-index: 100;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.85rem 1.25rem;
  background: var(--bg-card);
  border: 1px solid var(--color-purple);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-md);
  margin-bottom: 1.5rem;
  animation: slideDown 0.3s ease-out;
}

@keyframes slideDown {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}

.player-cover {
  width: 48px;
  height: 48px;
  border-radius: var(--radius-sm);
  object-fit: cover;
  flex-shrink: 0;
}

.player-info {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  min-width: 140px;
  overflow: hidden;
}

.player-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-artist {
  font-size: 0.8125rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.player-bpm-badge {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  background: var(--color-purple-bg);
  color: var(--color-purple);
  border: 1px solid rgba(168, 85, 247, 0.3);
  white-space: nowrap;
}

.player-controls {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.btn-player-play {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: var(--color-purple);
  color: #ffffff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  flex-shrink: 0;
  transition: transform 0.15s;
}

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

.player-progress-wrap {
  flex: 1;
  height: 6px;
  background: var(--border-color);
  border-radius: 3px;
  overflow: hidden;
  cursor: pointer;
}

.player-progress-bar {
  height: 100%;
  width: 0%;
  background: var(--color-purple);
  transition: width 0.1s linear;
}

.player-time {
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  color: var(--text-muted);
  white-space: nowrap;
}

/* Parrilla de canciones */
.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
}

.section-title-wrap {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.section-title {
  font-size: 1.25rem;
}

.section-hint {
  font-size: 0.8125rem;
  color: var(--text-muted);
}

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

.track-card {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  transition: transform 0.2s, border-color 0.2s;
  position: relative;
}

.track-card:hover {
  transform: translateY(-2px);
  border-color: var(--border-focus);
}

.track-cover-wrap {
  position: relative;
  width: 100%;
  aspect-ratio: 1;
  border-radius: var(--radius-sm);
  overflow: hidden;
  background: #000;
}

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

.btn-track-play-overlay {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #ffffff;
  opacity: 0;
  border: none;
  cursor: pointer;
  transition: opacity 0.2s;
}

.track-card:hover .btn-track-play-overlay,
.track-card.is-playing .btn-track-play-overlay {
  opacity: 1;
}

.track-badge-bpm {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.75rem;
  font-weight: 800;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
  background: rgba(11, 15, 23, 0.85);
  color: var(--color-purple);
  border: 1px solid var(--color-purple);
  backdrop-filter: blur(4px);
}

.track-details {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  flex: 1;
}

.track-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.track-artist {
  font-size: 0.8125rem;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.btn-add-playlist {
  height: 38px;
  width: 100%;
  background: var(--bg-card);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  transition: all 0.2s;
}

.btn-add-playlist:hover {
  background: var(--border-color);
  border-color: var(--color-cyan);
}

/* Playlist guardada */
.playlist-actions {
  display: flex;
  gap: 0.5rem;
}

.btn-secondary {
  height: 36px;
  padding: 0 1rem;
  background: var(--bg-card-subtle);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-secondary:hover {
  background: var(--border-color);
}

.btn-danger-outline {
  height: 36px;
  padding: 0 0.85rem;
  background: transparent;
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.4);
  border-radius: var(--radius-sm);
  font-size: 0.8125rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
}

.btn-danger-outline:hover {
  background: rgba(239, 68, 68, 0.1);
}

.playlist-items-wrap {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.playlist-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.75rem 1rem;
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
}

.playlist-item-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.playlist-item-cover {
  width: 40px;
  height: 40px;
  border-radius: 4px;
  object-fit: cover;
}

.playlist-item-info {
  display: flex;
  flex-direction: column;
  gap: 0.1rem;
  min-width: 0;
}

.playlist-item-title {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.playlist-item-artist {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.playlist-item-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.btn-remove-track {
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1.1rem;
}

.btn-remove-track:hover {
  color: #ef4444;
}

/* Modal exportar */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 9999;
  padding: 1rem;
}

.modal-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  max-width: 500px;
  width: 100%;
  box-shadow: var(--shadow-md);
  overflow: hidden;
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
}

.modal-title {
  font-size: 1.15rem;
}

.btn-close-modal {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.5rem;
  cursor: pointer;
  line-height: 1;
}

.modal-body {
  padding: 1.5rem;
}

.export-textarea {
  width: 100%;
  height: 160px;
  background: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 0.75rem;
  font-family: 'JetBrains Mono', monospace;
  font-size: 0.8125rem;
  box-sizing: border-box;
  resize: none;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
}

/* FAQ y SEO */
.seo-lead {
  font-size: 1rem;
  line-height: 1.6;
  color: var(--text-muted);
  margin-top: 0.75rem;
  margin-bottom: 1.5rem;
}

.faq-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 1.25rem;
}

.faq-card {
  background: var(--bg-card-subtle);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  padding: 1.25rem;
}

.faq-question {
  font-size: 1rem;
  margin-bottom: 0.5rem;
  color: var(--text-main);
}

.faq-answer {
  font-size: 0.875rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin: 0;
}

/* Responsivo */
@media (max-width: 768px) {
  .music-search-form {
    flex-direction: column;
  }

  .btn-search-music {
    width: 100%;
  }

  .audio-player-banner {
    flex-wrap: wrap;
  }

  .player-controls {
    width: 100%;
  }

  .tracks-grid {
    grid-template-columns: 1fr;
  }
}
