/* ═══════════════════════════════════════════════════════════
   Webradio Manager v2 — Library
   ═══════════════════════════════════════════════════════════ */

.library-filters {
    display: flex;
    gap: var(--space-sm);
    margin-bottom: var(--space-md);
    flex-wrap: wrap;
}

.library-filters .input {
    flex: 1;
    min-width: 150px;
}

.library-filters .select {
    width: auto;
}

.library-tabs {
    display: flex;
    gap: 4px;
    margin-left: auto;
}

.library-tabs .tab {
    padding: 6px 14px;
    border: 1px solid var(--border);
    background: var(--bg-secondary);
    color: var(--text-secondary);
    border-radius: var(--radius-sm);
    cursor: pointer;
    font-size: var(--font-size-sm);
    transition: all var(--transition-fast);
}

.library-tabs .tab:hover {
    background: var(--bg-hover);
    color: var(--text-primary);
}

.library-tabs .tab.active {
    background: var(--accent);
    color: #fff;
    border-color: var(--accent);
}

.library-tabs .tab.tab-disabled {
    opacity: 0.35;
    cursor: not-allowed;
    pointer-events: auto;
}

.library-tabs .tab.tab-disabled:hover {
    background: var(--bg-secondary);
    color: var(--text-secondary);
}

.search-status {
    padding: 8px 12px;
    margin-bottom: var(--space-sm);
    background: var(--bg-secondary);
    border-radius: var(--radius-sm);
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

.library-stats {
    display: flex;
    gap: var(--space-lg);
    margin-bottom: var(--space-md);
    padding: var(--space-sm) 0;
    border-bottom: 1px solid var(--border);
}

.stat-item {
    font-size: var(--font-size-sm);
    color: var(--text-secondary);
}

.stat-item strong {
    color: var(--text-primary);
    font-weight: 600;
}

.lib-select-all-label {
    display: flex;
    align-items: center;
    gap: var(--sp-xs);
    cursor: pointer;
    font-size: var(--fs-sm);
    color: var(--text-secondary);
}

.lib-select-all-label input[type="checkbox"] {
    accent-color: var(--accent);
}

.lib-checkbox {
    display: flex;
    align-items: center;
    flex-shrink: 0;
    cursor: pointer;
}

.lib-checkbox input[type="checkbox"] {
    width: 16px;
    height: 16px;
    accent-color: var(--accent);
    cursor: pointer;
}

.lib-action-bar {
    display: flex;
    align-items: center;
    gap: var(--sp-sm);
    padding: var(--sp-sm) var(--sp-md);
    background: var(--bg-tertiary);
    border: 1px solid var(--accent-dim);
    border-radius: var(--radius-md);
    margin-bottom: var(--sp-sm);
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--duration) var(--ease);
}

.lib-action-bar.visible {
    opacity: 1;
    pointer-events: all;
}

.lib-action-bar span {
    font-size: var(--fs-sm);
    color: var(--accent);
    font-weight: 600;
    margin-right: auto;
}

/* ─── Table Layout ─── */

.library-list {
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.lib-table {
    width: 100%;
    border-collapse: collapse;
    table-layout: fixed;
}

.lib-table col.col-check { width: 32px; }
.lib-table col.col-cover { width: 44px; }
.lib-table col.col-dur  { width: 48px; }
.lib-table col.col-src  { width: 66px; }
.lib-table col.col-act  { width: 144px; }

.lib-table thead th {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 5px 6px;
    border-bottom: 2px solid var(--border);
    cursor: pointer;
    user-select: none;
    white-space: nowrap;
    background: var(--bg-primary);
    position: sticky;
    top: 0;
    z-index: 1;
    transition: color var(--transition-fast);
}

.lib-table thead th:hover {
    color: var(--accent);
}

.lib-table thead th.th-active {
    color: var(--accent);
}

.lib-table thead th.th-check    { text-align: center; cursor: default; }
.lib-table thead th.th-cover   { text-align: center; cursor: default; }
.lib-table thead th.th-track_name { text-align: left; }
.lib-table thead th.th-artist   { text-align: left; }
.lib-table thead th.th-duration { text-align: right; }
.lib-table thead th.th-source   { text-align: center; }
.lib-table thead th.th-actions  { text-align: right; cursor: default; }

.lib-table tbody tr {
    cursor: pointer;
    transition: background var(--transition-fast);
}

.lib-table tbody tr:hover {
    background: var(--bg-hover);
}

.lib-table tbody tr.selected {
    background: rgba(0, 212, 255, 0.06);
}

.lib-table tbody td {
    padding: 4px 6px;
    font-size: var(--font-size-sm);
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.td-check    { text-align: center; }
.td-cover-col { text-align: center; padding: 2px 4px !important; }
.td-cover-col .cover-thumb { display: block; width: 32px; height: 32px; object-fit: cover; border-radius: 3px; margin: 0 auto; }
.td-cover-col .td-cover-placeholder { width: 32px; height: 32px; margin: 0 auto; background: var(--bg-tertiary); border-radius: 3px; display:flex;align-items:center;justify-content:center;font-size:14px;font-weight:700;color:var(--text-muted); }
.td-track_name { font-weight: 500; color: var(--text-primary); }
.td-artist   { color: var(--text-secondary); font-size: var(--font-size-xs); }
.td-duration { font-family: var(--font-mono); font-size: 11px; color: var(--text-tertiary); text-align: right; }
.td-source   { text-align: center; }
.td-actions  { text-align: right; opacity: 0; transition: opacity var(--transition-fast); }

.lib-table tbody tr:hover td.td-actions { opacity: 1; }

/* Genre/year tag inside title cell */
.lc-genre-tag {
    font-size: 10px;
    font-weight: 400;
    color: var(--accent);
    background: var(--accent-dim);
    padding: 0 5px;
    border-radius: 3px;
    margin-left: 6px;
    flex-shrink: 0;
    display: inline;
}

/* Source badges */
.src-badge {
    display: inline-block;
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px 2px;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    vertical-align: middle;
    line-height: 1.3;
}

.src-local { background: rgba(0, 212, 255, 0.15); color: #00d4ff; }
.src-deezer { background: rgba(255, 0, 128, 0.15); color: #ff0080; }
.src-spotify { background: rgba(30, 215, 96, 0.15); color: #1ed760; }
.src-youtube { background: rgba(255, 0, 0, 0.15); color: #ff0000; }
.src-import { background: rgba(255, 170, 0, 0.15); color: #ffaa00; }
.src-unknown { background: rgba(128, 128, 128, 0.15); color: #888; }

/* ─── External search results (Deezer/YouTube/Spotify) ─── */
.library-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 10px;
    background: var(--bg-secondary);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    margin-bottom: 2px;
    transition: all var(--transition-fast);
}
.library-item:hover {
    background: var(--bg-hover);
    border-color: var(--border);
}
.lib-track-info {
    flex: 1;
    min-width: 0;
}
.lib-track-title {
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.lib-track-meta {
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}
.lib-track-duration {
    font-family: var(--font-mono);
    font-size: 11px;
    color: var(--text-tertiary);
    flex-shrink: 0;
    width: 44px;
    text-align: right;
}
.lib-track-genre {
    font-size: 10px;
    font-weight: 600;
    padding: 1px 6px 2px;
    border-radius: var(--radius-sm);
    text-transform: uppercase;
    letter-spacing: 0.3px;
    flex-shrink: 0;
}
.lib-actions {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity var(--transition-fast);
}
.library-item:hover .lib-actions {
    opacity: 1;
}

/* Action buttons */
.btn-icon {
    background: none;
    border: none;
    color: var(--text-tertiary);
    padding: 2px 5px;
    cursor: pointer;
    font-size: 13px;
    border-radius: 3px;
    transition: all var(--transition-fast);
    line-height: 1;
}

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

.btn-icon.btn-danger:hover {
    color: #ff4444;
}

/* Scan button loading state */
.btn-scanning {
    position: relative;
    pointer-events: none;
}

.btn-scanning::after {
    content: '';
    width: 14px;
    height: 14px;
    border: 2px solid transparent;
    border-top-color: currentColor;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
    margin-left: 6px;
}

/* ─── File Browser ─────────────────── */
.file-browser {
    display: flex;
    flex-direction: column;
    gap: 4px;
    flex: 1;
    overflow-y: auto;
    min-height: 0;
}

.file-browser-toolbar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: var(--bg-secondary);
    border-radius: var(--radius-md);
    margin-bottom: 4px;
}

.file-browser-path {
    flex: 1;
    font-family: var(--font-mono);
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-browser-entries {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.fb-entry {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background: var(--bg-secondary);
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    cursor: default;
    transition: all var(--transition-fast);
}

.fb-entry:hover {
    background: var(--bg-hover);
    border-color: var(--border);
}

.fb-entry .fb-icon {
    width: 18px;
    text-align: center;
    flex-shrink: 0;
    font-size: var(--font-size-sm);
}

.fb-entry .fb-name {
    flex: 1;
    font-size: var(--font-size-sm);
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.fb-entry .fb-size {
    font-family: var(--font-mono);
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
    flex-shrink: 0;
}

.fb-entry .fb-actions {
    display: flex;
    gap: 2px;
    flex-shrink: 0;
    opacity: 0;
    transition: opacity var(--transition-fast);
}

.fb-entry:hover .fb-actions {
    opacity: 1;
}

.fb-entry.fb-dir {
    cursor: pointer;
}

/* ─── Library Player Bar ─── */

.lib-player-bar {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 8px 12px;
    background: var(--bg-tertiary);
    border: 1px solid var(--accent-dim);
    border-radius: var(--radius-md);
    margin-bottom: var(--space-sm);
}

.lib-player-info {
    flex: 1;
    min-width: 0;
}

.lib-player-title {
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--text-primary);
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.lib-player-artist {
    font-size: var(--font-size-xs);
    color: var(--text-tertiary);
}

.lib-player-controls {
    display: flex;
    gap: 4px;
}

.lib-player-out {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
}

.lib-player-out select {
    max-width: 160px;
}

/* ── Edit modal cover ── */
.te-layout {
    display: flex;
    gap: 16px;
    align-items: flex-start;
}
.te-cover-col {
    flex: 0 0 auto;
}
.te-cover-img {
    width: 120px;
    height: 120px;
    object-fit: cover;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.3);
}
.te-fields-col {
    flex: 1;
    min-width: 0;
}
.te-fields-col .form-row {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 8px;
}
.te-fields-col .form-row label {
    font-size: var(--font-size-xs);
    color: var(--text-secondary);
    font-weight: 500;
}
.te-fields-col .form-row .input {
    width: 100%;
}
