/* ── Reset & base ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:          #111318;
  --surface:     #1e2130;
  --surface2:    #252a3d;
  --border:      #2e3450;
  --accent:      #5b8def;
  --accent-hover:#7aa4f7;
  --text:        #e4e6f0;
  --text-muted:  #7a80a0;
  --playing:     #5b8def;
  --player-h:    90px;
  --header-h:    60px;
  --radius:      8px;
}

html, body { height: 100%; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
}

/* ── Layout ──────────────────────────────────────────────── */
#app {
  display: flex;
  flex-direction: column;
  height: 100vh;
}

header {
  height: var(--header-h);
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 20px;
  flex-shrink: 0;
  z-index: 10;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo {
  font-size: 22px;
  color: var(--accent);
}

h1 {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.3px;
}

main {
  flex: 1;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ── Header right ────────────────────────────────────────── */
#header-right {
  display: flex;
  align-items: center;
}

.btn-icon {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 18px;
  cursor: pointer;
  padding: 6px 8px;
  border-radius: var(--radius);
  transition: color 0.15s, background 0.15s;
  line-height: 1;
}

.btn-icon:hover {
  color: var(--text);
  background: var(--surface2);
}

/* ── Folder setup ────────────────────────────────────────── */
.folder-input-row {
  display: flex;
  gap: 8px;
  width: 100%;
  max-width: 520px;
}

.folder-input-row input {
  flex: 1;
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-size: 13px;
  padding: 8px 12px;
  outline: none;
  height: auto;
}

.folder-input-row input:focus {
  border-color: var(--accent);
}

.setup-hint {
  font-size: 12px;
  color: var(--text-muted);
  max-width: 520px;
}

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  padding: 7px 16px;
  transition: background 0.15s, opacity 0.15s;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  background: var(--surface2);
  color: var(--text-muted);
  border: 1px solid var(--border);
}

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

.btn-large { padding: 12px 28px; font-size: 16px; }

/* ── Splash ──────────────────────────────────────────────── */
.splash {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  text-align: center;
  padding: 40px;
}

.splash-icon {
  font-size: 64px;
  color: var(--accent);
  margin-bottom: 8px;
}

.splash h2 { font-size: 24px; font-weight: 600; }

.splash p { color: var(--text-muted); max-width: 380px; }

.privacy-link { font-size: 12px; color: var(--text-muted); margin-top: 16px; }
.privacy-link:hover { color: var(--text); }

.splash-features {
  margin-top: 32px;
  max-width: 580px;
  width: 100%;
  text-align: left;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 24px 28px;
}

.splash-features h3 {
  font-size: 15px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 10px;
}

.splash-features > p {
  font-size: 13px;
  color: var(--text-muted);
  max-width: none;
  margin-bottom: 16px;
}

.feature-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.feature-list li {
  font-size: 13px;
  color: var(--text-muted);
  padding-left: 20px;
  position: relative;
}

.feature-list li::before {
  content: '▸';
  position: absolute;
  left: 0;
  color: var(--accent);
}

.feature-list li strong {
  color: var(--text);
}


/* ── File Browser ────────────────────────────────────────── */
#file-browser {
  flex: 1;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#browser-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 16px 8px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
  gap: 12px;
}

#breadcrumb {
  font-size: 13px;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 4px;
  flex: 1;
  min-width: 0;
}

#random-btn {
  flex-shrink: 0;
  font-size: 13px;
  padding: 5px 12px;
}

.bc-sep { color: var(--border); user-select: none; }

.bc-link {
  color: var(--accent);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
}

.bc-link:hover { background: var(--surface2); }

.bc-current {
  color: var(--text);
  font-weight: 500;
}

#file-list-container {
  flex: 1;
  overflow-y: auto;
  padding: 8px 0;
}

/* scrollbar */
#file-list-container::-webkit-scrollbar { width: 6px; }
#file-list-container::-webkit-scrollbar-track { background: transparent; }
#file-list-container::-webkit-scrollbar-thumb { background: var(--border); border-radius: 3px; }

#file-list {
  padding: 0 12px;
}

.file-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background 0.1s;
  user-select: none;
}

.file-item:hover { background: var(--surface2); }

.file-item.playing {
  background: rgba(91, 141, 239, 0.12);
  border-left: 3px solid var(--playing);
  padding-left: 9px;
}

.file-item.playing .file-name { color: var(--accent); }

.file-icon {
  font-size: 18px;
  flex-shrink: 0;
  width: 24px;
  text-align: center;
}

.file-name {
  flex: 1;
  font-size: 14px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.file-size {
  font-size: 12px;
  color: var(--text-muted);
  flex-shrink: 0;
}

.file-track-num {
  font-size: 12px;
  color: var(--text-muted);
  width: 32px;
  text-align: right;
  flex-shrink: 0;
}

/* Empty / error states */
.state-message {
  padding: 40px;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
}

/* ── Player ──────────────────────────────────────────────── */
#player {
  height: var(--player-h);
  background: var(--surface);
  border-top: 1px solid var(--border);
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 0 20px;
  flex-shrink: 0;
}

#track-info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
  width: 300px;
  flex-shrink: 0;
}

#track-art {
  width: 48px;
  height: 48px;
  flex-shrink: 0;
  border-radius: 4px;
  overflow: hidden;
  background: var(--surface2);
  display: flex;
  align-items: center;
  justify-content: center;
}

#track-icon {
  font-size: 20px;
  color: var(--accent);
}

#track-cover {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

#track-meta {
  min-width: 0;
}

#track-name {
  font-size: 13px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#track-folder {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

#player-center {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  min-width: 0;
}

#player-controls {
  display: flex;
  align-items: center;
  gap: 16px;
}

.ctrl-btn {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-muted);
  font-size: 14px;
  padding: 4px 6px;
  border-radius: 50%;
  transition: color 0.15s, background 0.15s;
  line-height: 1;
}

.ctrl-btn:hover {
  color: var(--text);
  background: var(--surface2);
}

.ctrl-btn-main {
  width: 36px;
  height: 36px;
  background: var(--accent);
  color: #fff;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  padding: 0;
}

.ctrl-btn-main:hover { background: var(--accent-hover); color: #fff; }

#progress-row {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  max-width: 600px;
}

#progress-row span {
  font-size: 11px;
  color: var(--text-muted);
  min-width: 36px;
  text-align: center;
}

#progress-track {
  position: relative;
  flex: 1;
  height: 4px;
  background: var(--border);
  border-radius: 2px;
}

#progress-fill {
  position: absolute;
  left: 0; top: 0; bottom: 0;
  background: var(--accent);
  border-radius: 2px;
  pointer-events: none;
  width: 0%;
}

#progress-bar {
  position: absolute;
  left: 0; top: 50%;
  transform: translateY(-50%);
  width: 100%;
  opacity: 0;
  cursor: pointer;
  height: 100%;
}

/* ── Right cluster (volume + shuffle) ────────────────────── */
#player-right {
  display: flex;
  align-items: center;
  gap: 16px;
  flex-shrink: 0;
}

/* ── Volume ──────────────────────────────────────────────── */
#volume-section {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 130px;
}

#volume-icon { font-size: 16px; }

/* ── Range input shared ──────────────────────────────────── */
input[type="range"] {
  -webkit-appearance: none;
  appearance: none;
  background: transparent;
  height: 4px;
}

input[type="range"]::-webkit-slider-runnable-track {
  background: var(--border);
  height: 4px;
  border-radius: 2px;
}

input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 12px;
  height: 12px;
  background: var(--text);
  border-radius: 50%;
  margin-top: -4px;
  cursor: pointer;
}

input[type="range"]::-moz-range-track {
  background: var(--border);
  height: 4px;
  border-radius: 2px;
}

input[type="range"]::-moz-range-thumb {
  width: 12px;
  height: 12px;
  background: var(--text);
  border: none;
  border-radius: 50%;
  cursor: pointer;
}

#volume-bar { flex: 1; min-width: 0; }

/* ── Loading overlay ─────────────────────────────────────── */
#loading-overlay {
  position: fixed;
  inset: 0;
  background: rgba(17, 19, 24, 0.75);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  z-index: 100;
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

#loading-text { font-size: 14px; color: var(--text-muted); }

/* ── Utilities ───────────────────────────────────────────── */
.hidden { display: none !important; }

/* ── Info button ─────────────────────────────────────────────── */
#info-btn {
  font-size: 16px;
  flex-shrink: 0;
  opacity: 0.5;
  padding: 4px 6px;
}
#info-btn:hover { opacity: 1; }

/* ── Details modal ───────────────────────────────────────────── */
#details-modal {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 200;
}

#details-panel {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  width: min(520px, 92vw);
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

#details-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 14px;
  flex-shrink: 0;
}

#details-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  padding: 0 2px;
}
#details-close:hover { color: var(--text); }

#details-body {
  overflow-y: auto;
  padding: 12px 16px 16px;
}

.details-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

.details-table td {
  padding: 5px 8px;
  vertical-align: top;
  border-bottom: 1px solid rgba(255,255,255,0.04);
}

.details-table td:first-child {
  color: var(--text-muted);
  white-space: nowrap;
  width: 40%;
  font-size: 12px;
}

.details-table tr.dt-section td {
  padding-top: 14px;
  padding-bottom: 4px;
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.6px;
  text-transform: uppercase;
  color: var(--accent);
  border-bottom: 1px solid var(--border);
}

.details-table tr.dt-sub td {
  font-size: 11px;
  color: var(--text-muted);
  padding-top: 8px;
  padding-bottom: 2px;
  font-style: italic;
}

.details-table tr.dt-rg td { color: var(--text); }
.details-table tr.dt-rg td:first-child { color: var(--accent); }

.dt-warn {
  color: #e8a64a !important;
  font-style: italic;
}

/* ── Shuffle toggle ──────────────────────────────────────────── */
#shuffle-label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 13px;
  color: var(--text-muted);
  flex-shrink: 0;
  user-select: none;
  white-space: nowrap;
}

#shuffle-label:hover { color: var(--text); }

#shuffle-label input[type="checkbox"] {
  appearance: none;
  -webkit-appearance: none;
  width: 32px;
  height: 18px;
  background: var(--border);
  border-radius: 9px;
  position: relative;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
}

#shuffle-label input[type="checkbox"]::after {
  content: '';
  position: absolute;
  width: 12px;
  height: 12px;
  background: var(--text-muted);
  border-radius: 50%;
  top: 3px;
  left: 3px;
  transition: transform 0.2s, background 0.2s;
}

#shuffle-label input[type="checkbox"]:checked {
  background: var(--accent);
}

#shuffle-label input[type="checkbox"]:checked::after {
  transform: translateX(14px);
  background: #fff;
}

#shuffle-label.active { color: var(--accent); }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 600px) {
  #track-info { width: 160px; }
  #track-folder { display: none; }
  #player-right { display: none; }
  #player { gap: 12px; padding: 0 12px; }
}
