/* VERSION: 2.0.0 */
/* SIDEBAR, PLAYLIST, TOOLS */

#playlist-sidebar {
    width: 350px;
    min-width: 260px;
    height: 100%;
    background: var(--bg-sidebar, var(--bg-surface-glass, rgba(14, 18, 28, 0.82)));
    backdrop-filter: blur(28px);
    -webkit-backdrop-filter: blur(28px);
    border-left: 1px solid var(--sidebar-border, var(--glass-border, rgba(255, 255, 255, 0.12)));
    box-shadow: -8px 0 32px rgba(0, 0, 0, 0.5), inset 1px 0 0 rgba(255, 255, 255, 0.08);
    display: flex;
    flex-direction: row; /* Horizontal layout: Left is main playlist, Right is vertical icon bar */
    transition: width 0.3s cubic-bezier(0.16, 1, 0.3, 1), transform 0.3s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.3s ease;
    overflow: hidden;
    flex-shrink: 0;
    z-index: 40; 
    position: relative;
    color: var(--text-main);
}

#playlist-sidebar.resizing {
    transition: none !important;
    user-select: none;
}

#playlist-sidebar.hidden {
    width: 0 !important;
    min-width: 0 !important;
    transform: translateX(100%);
    border-left: none;
    pointer-events: none;
}

/* Sidebar Resizer Handle */
#sidebar-resizer {
    position: absolute;
    left: -4px;
    top: 0;
    bottom: 0;
    width: 8px;
    cursor: ew-resize;
    z-index: 60;
    background: transparent;
    transition: background 0.2s, box-shadow 0.2s;
}
#sidebar-resizer:hover,
#sidebar-resizer.active {
    background: var(--accent, rgba(122, 162, 247, 0.6));
    box-shadow: 0 0 10px var(--accent-glow, rgba(122, 162, 247, 0.4));
}

/* Main Playlist Content Column */
.playlist-main-pane {
    flex: 1;
    min-width: 0;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.playlist-search-box {
    padding: 12px 14px 8px 14px;
    background: rgba(255, 255, 255, 0.02);
    border-bottom: 1px solid var(--glass-border, rgba(255, 255, 255, 0.08));
    flex-shrink: 0;
}

#playlist-search {
    width: 100%;
    background: var(--bg-well-recessed, rgba(4, 6, 10, 0.75));
    border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.10));
    padding: 9px 12px;
    border-radius: 8px;
    color: var(--text-main, #ffffff);
    font-size: 0.88rem;
    min-height: 38px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s, background 0.2s;
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5);
}
#playlist-search:focus {
    border-color: rgba(255, 255, 255, 0.35);
    background: rgba(6, 9, 15, 0.9);
    box-shadow: inset 0 2px 4px rgba(0, 0, 0, 0.5), 0 0 12px rgba(255, 255, 255, 0.12);
}
#playlist-search::placeholder {
    color: var(--text-dim, rgba(240, 246, 252, 0.45));
}

/* Vertical Action Sidebar Anchored to Right of Playlist */
.playlist-icon-sidebar {
    width: 48px;
    min-width: 48px;
    height: 100%;
    background: var(--bg-surface-glass-darker, var(--bg-well-recessed, var(--bg-sidebar, rgba(8, 12, 20, 0.88))));
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
    border-left: 1px solid var(--sidebar-border, var(--glass-border, rgba(255, 255, 255, 0.10)));
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 10px 0;
    gap: 6px;
    overflow-y: auto;
    overflow-x: hidden;
    flex-shrink: 0;
    scrollbar-width: none;
    z-index: 45;
}
.playlist-icon-sidebar::-webkit-scrollbar {
    display: none;
}

.icon-sidebar-divider {
    width: 24px;
    height: 1px;
    background: var(--sidebar-border, var(--glass-border, rgba(255, 255, 255, 0.12)));
    margin: 3px 0;
    flex-shrink: 0;
}

/* --- TOOLBAR BUTTON STYLES IN VERTICAL STRIP --- */
.playlist-icon-sidebar .icon-btn,
.playlist-tools .icon-btn {
    color: var(--icon-base, rgba(240, 246, 252, 0.72));
    background: var(--bg-hover, rgba(255, 255, 255, 0.04));
    opacity: 1;
    border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.08));
    border-radius: 8px;
    width: 36px; 
    height: 36px;
    min-width: 36px;
    min-height: 36px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    transform: none !important; 
    position: relative;
}

.playlist-icon-sidebar .icon-btn svg,
.playlist-tools .icon-btn svg {
    color: currentColor;
    stroke: currentColor;
    transition: color 0.18s ease;
}

.playlist-icon-sidebar .icon-btn:hover,
.playlist-tools .icon-btn:hover {
    color: var(--icon-hover, #ffffff);
    background: var(--bg-hover, rgba(255, 255, 255, 0.12));
    border-color: var(--glass-border-bright, rgba(255, 255, 255, 0.25));
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3), var(--icon-glow);
}

.playlist-icon-sidebar .icon-btn.active,
.playlist-tools .icon-btn.active {
    color: #ffffff;
    background: var(--accent, #6366f1); 
    border-color: var(--accent, #6366f1);
    box-shadow: 0 0 10px var(--accent-glow, rgba(99, 102, 241, 0.4)), inset 0 1px 0 rgba(255, 255, 255, 0.3);
}

.playlist-icon-sidebar .icon-btn:active,
.playlist-tools .icon-btn:active {
    background: var(--accent, rgba(255, 255, 255, 0.18));
    transform: scale(0.96) !important;
}

.playlist-icon-sidebar .badge {
    background: var(--accent, rgba(99, 102, 241, 0.9));
    border: 1px solid var(--glass-border-bright, rgba(255, 255, 255, 0.3));
    color: #ffffff;
    box-shadow: 0 0 6px var(--accent-glow, rgba(99, 102, 241, 0.4));
}

/* VIRTUAL SCROLL CONTAINER */
#playlist-items,
.virtualized-playlist-container {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    position: relative;
    padding: 0;
}

/* Spacer for virtual scroll height */
.virtual-spacer {
    position: absolute;
    top: 0;
    left: 0;
    width: 1px;
    height: 100%;
    opacity: 0;
    pointer-events: none;
}

.playlist-item {
    position: absolute;
    left: 0;
    right: 0;
    width: 100%;
    height: 56px; 
    padding: 0 16px;
    font-size: 0.88rem;
    color: var(--text-muted, rgba(240, 246, 252, 0.82));
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    border-radius: 0;
    border: none;
    border-bottom: 1px solid var(--sidebar-border, var(--glass-border, rgba(255, 255, 255, 0.06)));
    transition: background 0.15s ease, color 0.15s ease;
    touch-action: pan-y;
    overflow: hidden; 
    box-sizing: border-box;
}

.playlist-item:hover {
    background: var(--bg-hover, rgba(255, 255, 255, 0.05));
    color: var(--text-main, #ffffff);
}
.playlist-item.active {
    background: color-mix(in srgb, var(--accent, #7aa2f7) 12%, transparent);
    color: var(--text-main, #ffffff);
    box-shadow: inset 3px 0 0 var(--accent, #7aa2f7);
    font-weight: 500;
}
.playlist-item.error { color: var(--error); text-decoration: line-through; opacity: 0.7; }
.playlist-item.dragging { opacity: 0.3; background: rgba(255, 255, 255, 0.05); }
.playlist-item.drag-over { border-top: 2px solid var(--accent, rgba(122, 162, 247, 0.8)); }

/* Mini EQ Overlay for Active Track */
.mini-eq-overlay {
    position: absolute;
    left: 16px; 
    width: 44px; 
    height: 32px;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    pointer-events: none;
    z-index: 5;
    border-radius: 4px;
}

.mini-eq-overlay svg { width: 22px; height: 18px; }

/* EQ Bar Animations */
.mini-eq-overlay .eq-bar { animation-play-state: paused; fill: #ffffff; }
.mini-eq-overlay.is-playing .eq-bar { animation-play-state: running; }
.eq-bar-4 { animation-duration: 0.5s; }
.eq-bar-5 { animation-duration: 0.7s; }

/* Touch Drag Visuals */
.playlist-item.touch-drag-source { opacity: 0.4; background: rgba(255, 255, 255, 0.08); }
.touch-drag-ghost {
    position: fixed; z-index: 9999; background: var(--bg-surface-elevated, rgba(16, 20, 30, 0.95)); border: 1px solid var(--glass-border); border-radius: 8px; padding: 10px; pointer-events: none; box-shadow: 0 8px 24px rgba(0,0,0,0.6); display: flex; align-items: center; gap: 10px; width: 280px; color: #fff; transform: translate(-50%, -100%); backdrop-filter: blur(16px);
}

.thumb-preview {
    width: 44px;
    height: 32px;
    background: rgba(0, 0, 0, 0.2);
    object-fit: cover;
    border-radius: 4px;
    flex-shrink: 0;
    border: 1px solid var(--glass-border, rgba(255, 255, 255, 0.1));
}
.item-info { flex: 1; overflow: hidden; display: flex; flex-direction: column; justify-content: center; }
.item-name { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; line-height: 1.25; font-weight: 500; }
.item-meta { font-size: 0.74rem; color: var(--text-dim, rgba(240, 246, 252, 0.45)); line-height: 1.25; margin-top: 2px; }

/* Playlist Footer - Height & Surface Matches Controls Bar Exactly */
.playlist-footer {
    height: var(--controls-height, 86px);
    min-height: var(--controls-height, 86px);
    flex-shrink: 0;
    box-sizing: border-box;
    border-top: 1px solid var(--sidebar-border, var(--glass-border, rgba(255, 255, 255, 0.12)));
    background: var(--bg-surface-glass, rgba(14, 18, 28, 0.88));
    backdrop-filter: blur(28px) saturate(190%);
    -webkit-backdrop-filter: blur(28px) saturate(190%);
    box-shadow: 0 -4px 24px rgba(0, 0, 0, 0.08);
    z-index: 45; 
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 16px;
    font-size: 0.78rem;
    color: var(--text-dim, rgba(240, 246, 252, 0.55));
    font-weight: 500;
    letter-spacing: 0.02em;
}

/* Mobile Sidebar Toggle */
#mobile-playlist-toggle {
    display: none; position: absolute; right: 15px; top: 50%; transform: translateY(-50%); width: 48px; height: 48px; border-radius: 50%; background: rgba(0,0,0,0.6); border: 1px solid rgba(255,255,255,0.2); color: #fff; z-index: 60; justify-content: center; align-items: center; cursor: pointer; backdrop-filter: blur(5px); transition: background 0.2s;
}
#mobile-playlist-toggle:active { background: var(--highlight); border-color: var(--highlight); }
#mobile-playlist-toggle svg { width: 28px; height: 28px; fill: currentColor; }

@media (max-width: 768px) {
    #mobile-playlist-toggle { display: flex; }
    #playlist-sidebar {
        position: absolute; right: 0; top: 0; height: 100%; width: 85%; max-width: 320px; box-shadow: -10px 0 30px rgba(0,0,0,0.8); border-left: 1px solid #333;
    }
    #playlist-sidebar.hidden { width: 85%; transform: translateX(100%); border-left: none; box-shadow: none; }
    #sidebar-resizer { display: none; }
}

/* ==========================================================================
   Smart Playlists Tabs (Item 16)
   ========================================================================== */
.smart-playlist-tabs {
    flex-shrink: 0;
    display: flex;
    align-items: center;
    gap: 4px;
    padding: 6px 10px;
    background: rgba(0, 0, 0, 0.25);
    border-bottom: 1px solid rgba(255, 255, 255, 0.08);
    overflow-x: auto;
    scrollbar-width: none;
}

.smart-playlist-tabs::-webkit-scrollbar {
    display: none;
}

.smart-tab-btn {
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.12);
    color: var(--text-dim, #94a3b8);
    border-radius: 4px;
    padding: 3px 8px;
    font-size: 0.68rem;
    font-weight: 700;
    cursor: pointer;
    white-space: nowrap;
    transition: all 0.15s ease;
}

.smart-tab-btn:hover {
    color: #fff;
    border-color: rgba(255, 255, 255, 0.3);
}

.smart-tab-btn.active {
    background: color-mix(in srgb, var(--accent, #7aa2f7) 20%, transparent);
    color: var(--accent, #7aa2f7);
    border-color: var(--accent, #7aa2f7);
}

/* Favorite Star Icon & Duplicate Badge */
.item-fav-btn {
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.25);
    cursor: pointer;
    padding: 2px 4px;
    font-size: 0.85rem;
    transition: color 0.15s ease, transform 0.15s ease;
}

.item-fav-btn:hover {
    color: #f59e0b;
    transform: scale(1.2);
}

.item-fav-btn.active {
    color: #f59e0b;
}

.duplicate-badge {
    background: rgba(239, 68, 68, 0.2);
    color: #ef4444;
    border: 1px solid rgba(239, 68, 68, 0.4);
    font-size: 0.6rem;
    font-weight: 700;
    padding: 1px 4px;
    border-radius: 3px;
    margin-left: 4px;
}

/* ==========================================================================
   Tag Editor Modal (Item 18)
   ========================================================================== */
.tag-field-row {
    display: flex;
    flex-direction: column;
    gap: 4px;
    margin-bottom: 12px;
}

.tag-field-row label {
    font-size: 0.76rem;
    font-weight: 700;
    color: var(--text-dim, #94a3b8);
    text-transform: uppercase;
}

.tag-input {
    background: rgba(0, 0, 0, 0.4);
    border: 1px solid var(--border-color, rgba(255, 255, 255, 0.2));
    border-radius: 6px;
    color: #fff;
    padding: 8px 10px;
    font-size: 0.85rem;
    outline: none;
    transition: border-color 0.2s ease;
}

.tag-input:focus {
    border-color: var(--accent, #7aa2f7);
}