:root {
  --bg-dark: #121212;
  --bg-panel: #1a1a1a;
  --bg-hover: #252525;
  --bg-selected: #0d3b4a;
  --bg-selected-hover: #124b5e;
  --text-main: #e0e0e0;
  --text-muted: #888;
  --accent: #00d2ff;
  --accent-green: #00ff88;
  --accent-yellow: #ffcc00;
  --border: #2a2a2a;
  --font-main: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

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

body {
  font-family: var(--font-main);
  background: var(--bg-dark);
  color: var(--text-main);
  height: 100vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* Header */
header {
  background: #151515;
  border-bottom: 1px solid var(--border);
  padding: 6px 16px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
  height: 52px;
}
header h1 { font-size: 1rem; color: var(--accent); letter-spacing: 1px; font-weight: 600; flex-shrink:0; white-space:nowrap; }

#download-bar { flex:1; display:flex; align-items:center; gap:8px; }
#bc-url {
  flex:1;
  background: #1f1f1f;
  border: 1px solid #333;
  color: var(--text-main);
  padding: 6px 12px;
  border-radius: 4px;
  font-size: 0.85rem;
  outline:none;
  max-width: 480px;
}
#bc-url:focus { border-color: var(--accent); }
#btn-download {
  background: var(--accent);
  border: none;
  color: #000;
  padding: 6px 14px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.8rem;
  transition: opacity 0.15s;
  flex-shrink:0;
}
#btn-download:hover { opacity: 0.85; }
#btn-download:disabled { background:#333; color:#666; cursor:not-allowed; }
#dl-status {
  font-size: 0.78rem;
  color: var(--accent-green);
  max-width: 220px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
#dl-status.hidden { display:none; }
#dl-status.error { color: #ff5555; }

/* Main layout */
#main {
  display: flex;
  flex: 1;
  overflow: hidden;
}

/* Sidebar */
#sidebar {
  width: 220px;
  background: var(--bg-panel);
  border-right: 1px solid var(--border);
  overflow-y: auto;
  padding: 10px;
  display:flex;
  flex-direction:column;
}
#sidebar h3 {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
  padding-left: 4px;
  letter-spacing: 1px;
  font-weight: 700;
}
.album-item {
  padding: 7px 10px;
  cursor: pointer;
  border-radius: 4px;
  font-size: 0.82rem;
  margin-bottom: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  transition: background 0.1s;
  border-left: 3px solid transparent;
}
.album-item:hover { background: var(--bg-hover); }
.album-item.active {
  background: var(--bg-selected);
  color: var(--accent);
  border-left-color: var(--accent);
  font-weight: 600;
}

/* Track panel */
#track-panel {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  min-width: 0;
}
#toolbar {
  padding: 8px 12px;
  background: #181818;
  border-bottom: 1px solid var(--border);
  display: flex;
  gap: 10px;
  align-items: center;
  flex-shrink: 0;
}
#search {
  background: #252525;
  border: 1px solid #333;
  color: var(--text-main);
  padding: 5px 10px;
  border-radius: 4px;
  width: 220px;
  font-size: 0.85rem;
  outline: none;
}
#search:focus { border-color: var(--accent); }
.toolbar-hint { font-size: 0.75rem; color: var(--text-muted); }

/* Table */
#track-table-container { flex: 1; overflow: auto; }
table { width: 100%; border-collapse: collapse; font-size: 0.82rem; }
thead th {
  position: sticky;
  top: 0;
  background: #1f1f1f;
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid #333;
  color: #aaa;
  font-weight: 600;
  white-space: nowrap;
  font-size: 0.75rem;
  text-transform: uppercase;
}
tbody tr {
  border-bottom: 1px solid #1e1e1e;
  cursor: pointer;
  transition: background 0.08s;
}
tbody tr:hover { background: var(--bg-hover); }
tbody tr.selected { background: var(--bg-selected); }
tbody tr.selected:hover { background: var(--bg-selected-hover); }
td {
  padding: 7px 10px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  vertical-align: middle;
}

/* Data styling */
td.bpm { color: var(--accent); font-weight: 700; font-size: 0.9rem; }
td.camelot { color: var(--accent-green); font-weight: 700; }
td.key { color: var(--accent-yellow); font-weight: 600; }
td.dance { color: #ff88aa; }

.play-btn {
  background: transparent;
  border: 1px solid #444;
  color: var(--accent);
  width: 22px;
  height: 22px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 0.6rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  line-height: 1;
}
.play-btn:hover { background: var(--accent); color: #000; border-color: var(--accent); }

/* Detail panel */
#detail-panel {
  width: 360px;
  background: var(--bg-panel);
  border-left: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  flex-shrink: 0;
}
#detail-header {
  padding: 14px;
  border-bottom: 1px solid var(--border);
  background: #181818;
  flex-shrink: 0;
}
#detail-header h2 { font-size: 1rem; margin-bottom: 4px; line-height: 1.3; font-weight: 600; }
#detail-artist { font-size: 0.8rem; color: var(--text-muted); margin-bottom: 8px; }
#detail-tags { display: flex; flex-wrap: wrap; gap: 5px; }

.tag {
  background: #252525;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.72rem;
  border: 1px solid #333;
  font-weight: 600;
}
.tag-bpm { color: var(--accent); }
.tag-key { color: var(--accent-yellow); }
.tag-camelot { color: var(--accent-green); }
.tag-dur { color: #ccc; }

#detail-content {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
}
.detail-section { margin-bottom: 18px; }
.detail-section h4 {
  font-size: 0.7rem;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
  border-bottom: 1px solid #2a2a2a;
  padding-bottom: 4px;
  letter-spacing: 0.5px;
  font-weight: 700;
}
.detail-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.8rem;
  padding: 4px 0;
  border-bottom: 1px solid #1a1a1a;
}
.detail-label { color: #999; }
.detail-value { color: var(--text-main); font-weight: 500; }
.detail-value.highlight { color: var(--accent); font-weight: 700; }

/* Viz tabs */
#viz-tabs { display: flex; gap: 2px; margin-bottom: 8px; }
.viz-tab {
  background: #222;
  border: none;
  color: #888;
  padding: 5px 10px;
  border-radius: 3px 3px 0 0;
  cursor: pointer;
  font-size: 0.72rem;
  text-transform: uppercase;
  font-weight: 600;
  transition: all 0.1s;
}
.viz-tab:hover { color: #ccc; background: #2a2a2a; }
.viz-tab.active {
  background: #333;
  color: var(--accent);
  border-bottom: 2px solid var(--accent);
}
#viz-image {
  width: 100%;
  border-radius: 4px;
  border: 1px solid #222;
  background: #000;
  display: none;
}
#viz-image.visible { display: block; }

/* Player bar */
#player-bar {
  height: 135px;
  background: #151515;
  border-top: 2px solid var(--accent);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
}
#player-controls {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 8px 16px;
  flex-shrink: 0;
}
#player-controls button {
  background: #2a2a2a;
  border: 1px solid #3a3a3a;
  color: var(--text-main);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
  flex-shrink: 0;
}
#player-controls button:hover { background: #333; border-color: #555; }
#player-controls button.primary {
  background: var(--accent);
  color: #000;
  border-color: var(--accent);
  font-size: 1.2rem;
}
#player-controls button.primary:hover { background: #33ddff; }

#player-info { flex: 1; min-width: 0; }
#player-track { font-size: 0.9rem; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#player-album { font-size: 0.75rem; color: var(--text-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
#player-tags { display: flex; gap: 8px; align-items: center; font-size: 0.75rem; flex-shrink: 0; }

#waveform-display {
  height: 44px;
  background: #0a0a0a;
  margin: 0 16px 6px;
  border-radius: 4px;
  overflow: hidden;
  position: relative;
  border: 1px solid #222;
}
#waveform-display img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  object-position: left;
  opacity: 0.5;
}
#waveform-display .playhead {
  position: absolute;
  top: 0;
  left: 0;
  width: 2px;
  height: 100%;
  background: var(--accent);
  pointer-events: none;
}

#progress-container {
  padding: 0 16px 10px;
  display: flex;
  align-items: center;
  gap: 10px;
  flex-shrink: 0;
}
#progress-bar {
  flex: 1;
  height: 5px;
  background: #2a2a2a;
  border-radius: 3px;
  cursor: pointer;
  position: relative;
}
#progress-fill {
  height: 100%;
  background: var(--accent);
  border-radius: 3px;
  width: 0%;
  pointer-events: none;
  transition: width 0.1s linear;
}
.time {
  font-size: 0.75rem;
  color: #888;
  font-variant-numeric: tabular-nums;
  width: 42px;
  text-align: center;
  font-family: monospace;
}

/* Scrollbar */
::-webkit-scrollbar { width: 7px; height: 7px; }
::-webkit-scrollbar-track { background: var(--bg-dark); }
::-webkit-scrollbar-thumb { background: #3a3a3a; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #4a4a4a; }

/* Toast notification */
#toast {
  position: fixed;
  top: 60px;
  right: 20px;
  background: #1a2e1a;
  border: 1px solid #2e8f2e;
  border-left: 4px solid #00ff88;
  color: #e0ffe0;
  padding: 14px 18px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 12px;
  box-shadow: 0 6px 24px rgba(0,0,0,0.5);
  z-index: 9999;
  font-size: 0.85rem;
  min-width: 280px;
  max-width: 400px;
  animation: toastSlide 0.4s ease-out;
}
#toast.hidden { display: none; }
#toast-icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #00ff88;
  color: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  font-weight: 700;
  flex-shrink: 0;
}
#toast-body { flex: 1; }
#toast-title { font-weight: 700; color: #fff; margin-bottom: 2px; }
#toast-msg { color: #aaa; font-size: 0.78rem; }
#toast-action {
  background: #00ff88;
  border: none;
  color: #000;
  padding: 5px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 700;
  font-size: 0.75rem;
  white-space: nowrap;
  flex-shrink: 0;
}
#toast-action:hover { background: #33ffaa; }
#toast-close {
  background: transparent;
  border: none;
  color: #888;
  font-size: 1.2rem;
  cursor: pointer;
  line-height: 1;
  padding: 0 2px;
  flex-shrink: 0;
}
#toast-close:hover { color: #fff; }

/* Highlight para album recien descargado */
.album-item.new {
  animation: newPulse 2s ease-in-out 3;
  border-left-color: #00ff88 !important;
  color: #00ff88 !important;
}
@keyframes toastSlide {
  from { transform: translateX(120%); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}
@keyframes newPulse {
  0%   { background: var(--bg-selected); }
  50%  { background: #1a3a2a; }
  100% { background: var(--bg-selected); }
}
