/* ======================= MAIN SIDEBAR ======================= */

/* Per-tab title shown at the top of the sidebar in list views */
.sidebar-title-bar {
    padding: 12px 12px 0;
    text-align: center;
    flex-shrink: 0;
}

#sidebar-tab-title {
    font-size: 17px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: 0.01em;
}

.main-sidebar {
    width: var(--main-sidebar-width);
    background: var(--surface);
    border-right: 1px solid var(--border);
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.04); /* Subtle right shadow */
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
    z-index: 5;
}

.sidebar-header {
    padding: 12px;
    padding-bottom: 0 !important;
    display: flex;
    gap: 8px;
    border-bottom: none;
}

.search-box {
    flex: 1;
    min-width: 0;
    height: 38px;
    display: flex;
    align-items: center;
    gap: 8px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 8px 12px;
    transition: all 0.2s ease;
    overflow-x: hidden;
}

.search-box:focus-within {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--accent) 10%, transparent);
}

.search-box i {
    color: var(--text-tertiary);
    font-size: 14px;
}

.search-box input {
    flex: 1;
    border: none;
    outline: none;
    background: transparent;
    font-family: var(--font-sans);
    font-size: 14px;
    color: var(--text-primary);
}

.search-box input::placeholder {
    color: var(--text-tertiary);
}

.add-song-btn {
    background: var(--accent);
    color: white;
    flex-shrink: 0;
    border-radius: 12px;
    transform: scale(0.97);
}

/* Search bar clear button — shown only when input has text */
.search-clear-btn {
    display: none;
    width: 18px;
    height: 18px;
    border: none;
    background: transparent;
    color: var(--text-tertiary);
    border-radius: 4px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    flex-shrink: 0;
    padding: 0;
    line-height: 1;
    transition: color 0.15s ease;
    opacity: 0.7;
}

.search-clear-btn:hover {
    color: var(--text-primary);
    opacity: 0.9;
}

.search-box.has-text .search-clear-btn {
    display: flex;
}

.add-song-btn:hover {
    background: var(--accent-dark);
    color: white;
}


/* Song List */
.song-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
    padding-bottom: 80px;
    margin-top: 2px;
}

.song-list.no-margin {
    margin-top: 0;
}

.song-author {
    font-size: 12px;
    color: #a6acaf;;
    margin-top: 2px;
    line-height: 1.2;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    user-select: none;           /* ADD THIS */
    -webkit-user-select: none;   /* ADD THIS (Safari) */
}

body.dark-mode .song-author{
    color: #6a6a6a;
}

.song-item {
    /* Bleed edge-to-edge inside the 8px-padded .song-list container */
    margin-left: -8px;
    margin-right: -8px;
    padding: 6px 14px;
    border-radius: 0;
    cursor: pointer;
    transition: background 0.15s ease;
    margin-bottom: 0;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    user-select: none;
    -webkit-user-select: none;   /* ADD THIS (Safari) */
}

.song-item::after {
    content: '';
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--border-light);
    opacity: 0.75;
}

/* Hide the separator on the last song item. :last-of-type (div) is used so
   a trailing <p> hint element (shown on touch devices) doesn't break the match. */
.song-list > .song-item:last-of-type::after {
    display: none;
}

.song-item:hover {
    background: var(--surface-hover);
    border-radius: 6px;
}

.song-item.active {
    background: color-mix(in srgb, var(--accent) 14%, transparent);
    border-radius: 6px;
}

body.dark-mode .song-item.active {
    background: color-mix(in srgb, var(--accent) 8%, transparent);
}


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

.song-item .song-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    user-select: none;           /* ADD THIS */
    -webkit-user-select: none;   /* ADD THIS (Safari) */
}

body.dark-mode .song-item .song-title {
    font-weight: 500;
}


.song-menu-btn {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    border: none;
    background: transparent;
    color: var(--text-secondary);
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    opacity: 0;
    transition: all 0.2s ease;
}

.song-item:hover .song-menu-btn {
    opacity: 1;
}

.song-menu-btn:hover {
    background: var(--surface-hover);
    color: var(--accent);
}

.song-menu-btn:active {
    transform: scale(0.9);
}




/* ======================= COLLECTION TOGGLE ROWS ======================= */
.collection-toggle-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.15s ease;
    margin-bottom: 6px;
    border: 1.5px solid var(--border);
    background: var(--surface);
    overflow: hidden;
}

.collection-toggle-row > div {
    min-width: 0;
}

.collection-toggle-row:hover {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 5%, transparent);
}

.collection-toggle-row.in-collection {
    border-color: var(--accent);
    background: color-mix(in srgb, var(--accent) 10%, transparent);
}

.collection-toggle-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    user-select: none;           /* ADD THIS */
    -webkit-user-select: none;   /* ADD THIS (Safari) */
}

.collection-toggle-count {
    font-size: 12px;
    color: var(--text-tertiary);
    user-select: none;           /* ADD THIS */
    -webkit-user-select: none;   /* ADD THIS (Safari) */
}

.collection-toggle-check {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 1.5px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 11px;
    color: white;
    background: transparent;
    transition: all 0.15s ease;
}

.in-collection .collection-toggle-check {
    background: var(--accent);
    border-color: var(--accent);
}



/* Visual feedback while long-press is building up */
.song-item.long-pressing {
    background: color-mix(in srgb, var(--accent) 12%, transparent) !important;
    transition: background 0.1s;
}

/* Desktop: mouse held down, waiting for hold timer to unlock drag */
.song-item.mouse-holding {
    cursor: grab !important;
    background: color-mix(in srgb, var(--accent) 10%, transparent) !important;
    transition: background 0.15s;
}

/* Desktop: drag unlocked and active */
.song-item.drag-ready {
    cursor: grabbing !important;
}


/* Lyrics search results — shown below normal results with a subtle section divider */

.lyrics-search-label {
    margin: 0;
    padding: 18px 0 4px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-tertiary);
    letter-spacing: 0.04em;
    text-align: center;
    user-select: none;           /* ADD THIS */
    -webkit-user-select: none;   /* ADD THIS (Safari) */
}

.song-item.hide-separator::after {
    display: none;
}

/* Lyrics-matched songs are dimmed to distinguish them from normal results */
.song-item.lyrics-match {
    opacity: 0.5;
}

.song-item.lyrics-match:hover {
    opacity: 0.85;
}

/* When a lyrics result is the active/selected song, keep it visually dimmer */
.song-item.lyrics-match.active {
    opacity: 0.7;
}

/* Context menu popup (long-press on all-songs tab) */
.song-ctx-backdrop {
    position: fixed;
    inset: 0;
    z-index: 1000;
}

.song-ctx-menu {
    position: fixed;
    z-index: 1001;
    background: var(--surface-elevated);
    border: 1px solid var(--border);
    border-radius: 10px;
    box-shadow: var(--shadow-lg);
    animation: ctx-pop 0.12s ease-out;
    padding: 4px;
    min-width: 190px;
    user-select: none;           /* ADD THIS */
    -webkit-user-select: none;   /* ADD THIS (Safari) */
}

@keyframes ctx-pop {
    from { opacity: 0; transform: scale(0.92); }
    to   { opacity: 1; transform: scale(1); }
}

.song-ctx-item {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 7px 10px;
    font-size: 14px;
    color: var(--text-primary);
    background: none;
    border: none;
    border-radius: 7px;
    cursor: pointer;
    text-align: left;
    font-family: inherit;
    transition: background 0.12s ease;
    user-select: none;           /* ADD THIS */
    -webkit-user-select: none;   /* ADD THIS (Safari) */
}

.song-ctx-item:hover {
    background: var(--surface-hover);
}

.song-ctx-item:active {
    background: var(--surface-hover);
}

/* Divider between items — shares .ctx-divider from header.css */

.song-ctx-item i {
    width: 16px;
    text-align: center;
    color: var(--text-secondary);
    font-size: 13px;
    flex-shrink: 0;
}

.song-ctx-item--danger {
    color: #dc3545;
}

.song-ctx-item--danger i {
    color: #dc3545;
}

/* ── Drag-to-delete zone (shown at bottom of sidebar while dragging a collection song) ── */
.drag-delete-zone {
    position: fixed;
    z-index: 199;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
    color: #dc3545;
    border: 2px dashed color-mix(in srgb, #dc3545 45%, transparent);
    border-radius: 8px;
    background: color-mix(in srgb, #dc3545 5%, var(--surface));
    opacity: 0;
    transform: translateY(6px);
    transition: opacity 0.2s ease, transform 0.2s ease, background 0.15s ease, border-color 0.15s ease;
    pointer-events: none;
    box-sizing: border-box;
}

.drag-delete-zone.drag-active {
    opacity: 1;
    transform: translateY(0);
}

.drag-delete-zone.drag-over {
    background: color-mix(in srgb, #dc3545 16%, var(--surface));
    border-color: #dc3545;
    border-style: solid;
}

.drag-delete-zone i {
    font-size: 13px;
}

/* ── Sidebar tab bar (hidden by default; shown on tablet portrait only) ── */
.sidebar-tab-bar {
    display: none;
}

.collections-list-header {
    position: sticky;
    top: -8px;
    z-index: 2;
    margin: -8px -8px 0 -8px;
    padding: 7px 10px;
    background: var(--surface);
    border-bottom: 1px solid var(--border-light);
    box-shadow: 0 2px 6px color-mix(in srgb, var(--border) 25%, transparent);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* Mobile: .song-list has padding-top: 4px (not 8px), so correct the sticky offset */
@media (max-width: 550px) {
    .collections-list-header {
        top: -4px;
        margin-top: -4px;
    }
}

.collections-list-label {
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    user-select: none;           /* ADD THIS */
    -webkit-user-select: none;   /* ADD THIS (Safari) */
}

/* ======================= COLLECTION LIST ITEMS ======================= */
/* Wider padding to visually distinguish collections from songs */
.collection-item {
    padding: 11px 18px;
    user-select: none;           /* ADD THIS */
    -webkit-user-select: none;   /* ADD THIS (Safari) */
}

.collection-item.active {
    background: color-mix(in srgb, var(--accent) 13%, transparent);
}

body.dark-mode .collection-item.active {
    background: color-mix(in srgb, var(--accent) 7%, transparent);
}

/* .new-collection-inline-btn styles live in collection-header.css
   alongside .collection-add-song-btn so both buttons stay in sync */

/* ======================= ADD SONG TO COLLECTION OVERLAY ======================= */
.add-song-to-col-overlay {
    position: fixed;
    inset: 0;
    z-index: 300;
    background: rgba(0, 0, 0, 0.45);
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    user-select: none;           /* ADD THIS */
    -webkit-user-select: none;   /* ADD THIS (Safari) */
}

.add-song-to-col-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* Default: centered modal (desktop + tablet) */
.add-song-to-col-modal {
    background: var(--surface);
    border-radius: 16px;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.18);
    width: min(480px, 88vw);
    height: 72dvh;
    min-height: 380px;
    max-height: 72dvh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transform: scale(0.96);
    transition: transform 0.2s ease;
}

.add-song-to-col-overlay.active .add-song-to-col-modal {
    transform: scale(1);
}

.add-song-to-col-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 16px 12px 20px;
    border-bottom: 1px solid var(--border-light);
    flex-shrink: 0;
}

.add-song-to-col-header h2 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text-primary);
}

.add-song-to-col-search-row {
    padding: 12px 16px;
    flex-shrink: 0;
}

.add-song-to-col-list {
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 0 8px 12px;
    flex: 1;
}

.add-song-to-col-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.12s ease;
}

.add-song-to-col-row:hover {
    background: var(--surface-hover);
}

.add-song-to-col-row.in-collection {
    background: color-mix(in srgb, var(--accent) 8%, transparent);
}

.add-song-to-col-info {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.add-song-to-col-name {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-primary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.add-song-to-col-author {
    font-size: 12px;
    color: var(--text-tertiary);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.add-song-to-col-check {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    border: 1.5px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    font-size: 11px;
    color: white;
    background: transparent;
    transition: all 0.15s ease;
}

.in-collection .add-song-to-col-check {
    background: var(--accent);
    border-color: var(--accent);
}


/* ======================= FAVORITES COLLECTION ======================= */
.collection-favorites-star {
    color: #f5c518 !important;
    font-size: 11px;
    margin-right: 2px;
}

.favorites-toggle-row {
    background: color-mix(in srgb, #f5c518 8%, transparent) !important;
    border-color: color-mix(in srgb, #f5c518 40%, transparent) !important;
}

.favorites-toggle-row:hover {
    background: color-mix(in srgb, #f5c518 14%, transparent) !important;
    border-color: color-mix(in srgb, #f5c518 55%, transparent) !important;
}

.favorites-toggle-row.in-collection {
    background: color-mix(in srgb, #f5c518 18%, transparent) !important;
    border-color: #f5c518 !important;
}

.favorites-toggle-row .collection-toggle-check {
    border-color: color-mix(in srgb, #f5c518 60%, transparent) !important;
}

.favorites-toggle-row.in-collection .collection-toggle-check {
    background: #f5c518 !important;
    border-color: #f5c518 !important;
}

.favorites-toggle-divider {
    height: 1px;
    background: var(--border-light);
    margin: 8px 2px;
}
