/* ============================================================
   Music Player Bar
   Fixed bottom bar — designed to be reusable globally.
   When active: body gets .has-music-player and main content
   gets bottom padding to avoid overlap.
   ============================================================ */

#music-player-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 72px;
    background: #1a1a2e;
    border-top: 1px solid #333;
    display: none; /* shown by JS when music plays */
    align-items: center;
    gap: 16px;
    padding: 0 16px;
    z-index: 1060;
    box-shadow: 0 -2px 12px rgba(0,0,0,0.5);
}

body.has-music-player .main-content {
    padding-bottom: 80px;
}

/* Track info (left) */
.player-track-info {
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 200px;
    max-width: 260px;
    cursor: pointer;
    overflow: hidden;
}

.player-track-info:hover .player-title {
    color: #a78bfa;
}

#player-art {
    width: 46px;
    height: 46px;
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
}

.player-meta {
    overflow: hidden;
}

.player-title {
    display: block;
    color: #e2e8f0;
    font-size: 0.85rem;
    font-weight: 500;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.player-artist {
    display: block;
    color: #94a3b8;
    font-size: 0.75rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* Controls (center) */
.player-controls {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.player-btn {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 1.1rem;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 4px;
    line-height: 1;
    transition: color 0.15s, background 0.15s;
}

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

.player-btn.active {
    color: #a78bfa;
}

.player-btn-main {
    font-size: 1.4rem;
    color: #e2e8f0;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    background: rgba(255,255,255,0.06);
}

.player-btn-main:hover {
    background: rgba(255,255,255,0.14);
}

/* Progress (middle, expands to fill space) */
.player-progress {
    display: flex;
    align-items: center;
    gap: 8px;
    flex: 1;
    min-width: 0;
    font-size: 0.72rem;
    color: #64748b;
}

.player-seek {
    flex: 1;
    -webkit-appearance: none;
    appearance: none;
    height: 4px;
    border-radius: 2px;
    background: #334155;
    cursor: pointer;
    outline: none;
}

.player-seek::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #a78bfa;
    cursor: pointer;
}

.player-seek:hover {
    background: #475569;
}

/* Extra controls (right) */
.player-extra {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-shrink: 0;
}

.player-volume {
    -webkit-appearance: none;
    appearance: none;
    width: 80px;
    height: 4px;
    border-radius: 2px;
    background: #334155;
    cursor: pointer;
    outline: none;
}

.player-volume::-webkit-slider-thumb {
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    background: #64748b;
    cursor: pointer;
}

/* ============================================================
   Music Library Page
   ============================================================ */

/* Scan progress / error bars */
.scan-progress-bar {
    background: #1e293b;
    border: 1px solid #334155;
    border-radius: 6px;
    padding: 8px 12px;
    margin-bottom: 12px;
    font-size: 0.8rem;
    color: #cbd5e1;
}

.scan-error-bar {
    background: #2d1515;
    border: 1px solid #7f1d1d;
    border-radius: 6px;
    padding: 8px 12px;
    margin-bottom: 12px;
    font-size: 0.85rem;
    color: #fca5a5;
}

/* Tab nav */
.music-tabs {
    display: flex;
    gap: 4px;
    border-bottom: 1px solid #334155;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.music-tab {
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    color: #94a3b8;
    font-size: 0.875rem;
    padding: 8px 14px;
    cursor: pointer;
    white-space: nowrap;
    transition: color 0.15s, border-color 0.15s;
    margin-bottom: -1px;
}

.music-tab:hover { color: #e2e8f0; }

.music-tab.active {
    color: #a78bfa;
    border-bottom-color: #a78bfa;
    font-weight: 500;
}

/* Tab content */
.music-tab-content { display: none; }
.music-tab-content.active { display: block; }

/* Override Bootstrap text-muted for dark theme */
.music-tab-content .text-muted,
#music-player-bar .text-muted {
    color: #94a3b8 !important;
}

/* Section headers */
.music-section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin: 20px 0 10px;
}

.music-section-header:first-child { margin-top: 0; }

.music-section-header h4,
.music-section-header h5 {
    margin: 0;
    font-size: 1rem;
    font-weight: 600;
    color: #cbd5e1;
}

/* Card grid */
.music-card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 14px;
    margin-bottom: 8px;
}

/* Album/Artist card */
.music-card {
    background: #1e293b;
    border-radius: 8px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.15s, box-shadow 0.15s, background 0.15s;
    border: 1px solid #334155;
}

.music-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.4);
    background: #243044;
}

.music-card-art {
    width: 100%;
    aspect-ratio: 1;
    background: #0f172a;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
}

.music-card-art img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.music-card-art-placeholder {
    font-size: 2.5rem;
    color: #334155;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

/* Circle art for artists */
.music-card-art-circle {
    border-radius: 50%;
    width: 80%;
    aspect-ratio: 1;
    margin: 10% auto 0;
}

.music-card-info {
    padding: 8px 10px 10px;
}

.music-card-title {
    font-size: 0.82rem;
    font-weight: 500;
    color: #e2e8f0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.music-card-subtitle {
    font-size: 0.75rem;
    color: #94a3b8;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-top: 2px;
}

.music-card-meta {
    font-size: 0.7rem;
    color: #64748b;
    margin-top: 2px;
}

.music-card-count {
    font-size: 0.7rem;
    color: #64748b;
    margin-top: 2px;
}

.music-card-actions {
    margin-top: 4px;
}

/* Small track card */
.music-card-sm .music-card-art {
    aspect-ratio: 1;
}

/* ============================================================
   Tracks Table
   ============================================================ */

.tracks-genre-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.tracks-genre-toggle {
    font-size: 0.78rem;
    padding: 3px 10px;
}

.tracks-genre-toggle.open {
    background: rgba(167,139,250,0.12);
    border-color: #a78bfa;
    color: #a78bfa;
}

.tracks-genre-filter {
    margin-bottom: 12px;
    padding: 10px 12px;
    background: #1a1a2e;
    border: 1px solid #334155;
    border-radius: 6px;
}

.music-tracks-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.music-tracks-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

.music-tracks-table thead th {
    color: #94a3b8;
    font-weight: 500;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 6px 8px;
    border-bottom: 1px solid #334155;
    white-space: nowrap;
    background: #1a1a2a;
}

.music-track-row {
    cursor: pointer;
    border-bottom: 1px solid #252535;
    transition: background 0.1s;
}

.music-track-row:hover {
    background: #232336;
}

.music-track-row td {
    padding: 7px 8px;
    vertical-align: middle;
    color: #cbd5e1;
}

.track-num { color: #64748b; width: 32px; text-align: right; }
.track-art { width: 40px; }
.track-art-placeholder { color: #475569; font-size: 1rem; }
.track-title { color: #e2e8f0; max-width: 240px; }
.track-artist { color: #94a3b8; max-width: 160px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track-album  { color: #64748b; max-width: 160px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.track-duration { color: #64748b; text-align: right; white-space: nowrap; width: 52px; }
.track-actions { width: 32px; text-align: center; }

/* ============================================================
   Genres
   ============================================================ */

.music-genres-list {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    padding: 4px 0;
    flex: 1;
}

.music-genre-chip {
    font-size: 0.82rem;
    padding: 5px 14px;
    border-radius: 20px;
    border-color: #334155;
    color: #94a3b8;
    transition: all 0.15s;
}

.music-genre-chip:hover {
    background: #a78bfa;
    border-color: #a78bfa;
    color: white;
}

.music-genre-chip.active {
    background: #7c3aed;
    border-color: #7c3aed;
    color: white;
}

/* ============================================================
   Folder Browser (Settings Modal)
   ============================================================ */

.folder-browser {
    border: 1px solid #334155;
    border-radius: 6px;
    overflow: hidden;
    background: #0f172a;
}

.folder-browser-path {
    background: #1e293b;
    color: #94a3b8;
    font-size: 0.78rem;
    font-family: monospace;
    padding: 6px 10px;
    border-bottom: 1px solid #334155;
    word-break: break-all;
}

.folder-browser-list {
    max-height: 220px;
    overflow-y: auto;
    padding: 4px 0;
}

.folder-item {
    padding: 6px 12px;
    cursor: pointer;
    font-size: 0.83rem;
    color: #94a3b8;
    transition: background 0.1s;
    user-select: none;
}

.folder-item:hover {
    background: #1e293b;
    color: #e2e8f0;
}

.folder-item-back {
    color: #64748b;
    border-bottom: 1px solid #1e293b;
    margin-bottom: 2px;
}

/* ============================================================
   Loading / Empty states
   ============================================================ */

.music-loading {
    color: #64748b;
    font-size: 0.85rem;
    padding: 20px;
    text-align: center;
}

/* ============================================================
   Select Mode (All Tracks)
   ============================================================ */

.tracks-select-toolbar {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 8px 10px;
    background: #1e293b;
    border: 1px solid #a78bfa;
    border-radius: 6px;
    margin-bottom: 8px;
}

.track-select { width: 32px; text-align: center; }

.music-track-row.selected-row {
    background: rgba(167,139,250,0.12);
}

/* Playlist picker sits above other modals */
#pickPlaylistModal { z-index: 1075; }
#pickPlaylistModal + .modal-backdrop { z-index: 1074; }

/* Currently playing track row */
.music-track-row.now-playing td {
    color: #fbbf24 !important;
}
.music-track-row.now-playing .track-num::before {
    content: '▶ ';
    font-size: 0.65rem;
}

/* ── Stats Tab ────────────────────────────────────────────────────────────── */

.music-stats-kpis {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.music-stats-kpi {
    flex: 1;
    min-width: 140px;
    background: #1e1e2e;
    border-radius: 10px;
    padding: 1.2rem 1.5rem;
    text-align: center;
    border: 1px solid #2a2a3e;
}

.music-stats-kpi-value {
    font-size: 2.2rem;
    font-weight: 700;
    color: #a78bfa;
    line-height: 1;
}

.music-stats-kpi-label {
    font-size: 0.8rem;
    color: #888;
    margin-top: 0.4rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.music-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 1rem;
    margin-bottom: 1rem;
}

.music-stats-card {
    background: #1e1e2e;
    border-radius: 10px;
    padding: 1rem 1.2rem;
    border: 1px solid #2a2a3e;
}

.music-stats-card h5 {
    margin-bottom: 0.2rem;
    font-size: 0.95rem;
    color: #ccc;
}

.music-stats-period-label {
    font-size: 0.75rem;
    color: #666;
    margin-bottom: 0.8rem;
}

.music-stats-list {
    margin: 0;
    padding-left: 1.4rem;
    font-size: 0.87rem;
}

.music-stats-list li {
    padding: 0.3rem 0;
    border-bottom: 1px solid #2a2a3e;
    color: #ccc;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.music-stats-list li:last-child { border-bottom: none; }

.music-stats-list .stat-rank {
    min-width: 1.4rem;
    color: #666;
    font-size: 0.78rem;
    margin-right: 0.4rem;
}

.music-stats-list .stat-name {
    flex: 1;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-right: 0.5rem;
}

.music-stats-list .stat-count {
    font-size: 0.78rem;
    color: #a78bfa;
    white-space: nowrap;
    background: rgba(167,139,250,0.12);
    padding: 1px 6px;
    border-radius: 10px;
}

.music-stats-heatmap-card {
    margin-top: 0;
}

.music-stats-heatmap {
    overflow-x: auto;
    padding-top: 0.5rem;
}

.heatmap-table {
    border-collapse: separate;
    border-spacing: 3px;
    font-size: 0.7rem;
}

.heatmap-table th {
    color: #666;
    text-align: center;
    padding: 0 2px;
    font-weight: normal;
    white-space: nowrap;
}

.heatmap-table td.heatmap-day-label {
    color: #666;
    padding-right: 6px;
    white-space: nowrap;
}

.heatmap-cell {
    width: 22px;
    height: 22px;
    border-radius: 3px;
    background: #2a2a3e;
    cursor: default;
    position: relative;
}

.heatmap-cell:hover::after {
    content: attr(title);
    position: absolute;
    bottom: 26px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: #fff;
    font-size: 0.7rem;
    padding: 2px 6px;
    border-radius: 4px;
    white-space: nowrap;
    z-index: 10;
    pointer-events: none;
}
