/* Inputs & Search */
.search-wrapper {
    width: 35%;
    min-width: 200px;
    height: 100%;
    position: relative;
    background: var(--input-bg);
    border-radius: var(--input-radius);
    border: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
}

.search-input {
    width: 100%;
    height: 100%;
    padding: 0 15px 0 40px;
    border: none;
    background: transparent;
    color: var(--text-primary);
    font-size: 0.95rem;
    outline: none;
}

.search-icon-left {
    position: absolute;
    left: 15px;
    opacity: 0.5;
    pointer-events: none;
}

/* Buttons */
.source-wrapper {
    position: relative;
    height: 100%;
}

.source-btn,
.search-btn {
    height: 100%;
    padding: 0 15px;
    border-radius: var(--input-radius);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    border: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    white-space: nowrap;
    transition: all 0.6s var(--ease-out);
}

.source-btn {
    background: var(--input-bg);
    color: var(--text-primary);
}

.search-btn {
    background: var(--c-active-bg);
    color: #fff;
    border: none;
    padding: 0 20px;
}

.action-btn {
    padding: 6px 16px;
    border-radius: 8px;
    border: 1px solid var(--glass-border);
    background: rgba(255, 255, 255, 0.05);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.3s var(--ease-out);
}

.action-btn:hover {
    background: var(--c-active-bg);
    color: #fff;
}

.btn-danger {
    color: #ff5555;
}

.btn-danger:hover {
    background: #ff5555;
    color: #fff;
}

.btn-icon {
    font-size: 1rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: 0.2s;
    background: none;
    border: none;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon:hover {
    color: var(--text-primary);
    transform: scale(1.1);
}

/* Capsule Switch */
.capsule-switch {
    background: var(--input-bg);
    border-radius: 30px;
    padding: 4px;
    display: flex;
    width: 40%;
    margin: 0 auto 25px auto;
    border: 1px solid var(--glass-border);
    position: relative;
    z-index: 5;
}

.switch-btn {
    flex: 1;
    padding: 6px 0;
    text-align: center;
    border-radius: 25px;
    cursor: pointer;
    font-weight: 600;
    color: var(--text-secondary);
    transition: all 0.6s var(--ease-out);
}

.switch-btn.active {
    background: var(--c-active-bg);
    color: #fff;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.2);
}

/* Tags */
.hot-tags-row {
    flex: 1;
    display: flex;
    gap: 8px;
    overflow-x: auto;
    align-items: center;
    scrollbar-width: none;
    height: 100%;
    margin-left: 10px;
}

.hot-tag {
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.85rem;
    white-space: nowrap;
    background: var(--input-bg);
    border: 1px solid var(--glass-border);
    cursor: pointer;
    color: var(--text-secondary);
    transition: all 0.6s var(--ease-out);
}

.hot-tag:hover {
    background: var(--c-active-bg);
    color: #fff;
}

/* Tiles & Grid */
.tile-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 12px;
    margin-bottom: 20px;
}

@media (max-width: 1600px) {
    .tile-grid {
        grid-template-columns: repeat(6, 1fr);
    }
}

@media (max-width: 1200px) {
    .tile-grid {
        grid-template-columns: repeat(4, 1fr);
    }
}

.tile {
    aspect-ratio: 1;
    border-radius: 12px;
    position: relative;
    overflow: hidden;
    cursor: pointer;
    background: #000;
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.4s ease;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.tile::before {
    content: '';
    position: absolute;
    inset: 0;
    background: var(--img) center/cover;
    filter: brightness(0.85) saturate(0.9);
    transition: transform 0.6s cubic-bezier(0.25, 0.46, 0.45, 0.94), filter 0.4s ease;
}

.tile:hover {
    transform: translateY(-8px) scale(1.02);
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.6);
    z-index: 10;
    border-color: rgba(255, 255, 255, 0.3);
}

.tile:hover::before {
    transform: scale(1.2);
    filter: brightness(1.1) saturate(1.2);
}

.tile-badge {
    position: absolute;
    top: 4px;
    right: 4px;
    font-size: 0.6rem;
    background: rgba(255, 50, 50, 0.85);
    padding: 2px 6px;
    border-radius: 4px;
    color: #fff;
    z-index: 2;
    border: none;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
}

.tile-count-badge {
    position: absolute;
    bottom: 6px;
    left: 6px;
    font-size: 0.7rem;
    background: rgba(0, 0, 0, 0.6);
    padding: 2px 6px;
    border-radius: 4px;
    color: #eee;
    z-index: 3;
    backdrop-filter: blur(4px);
}

.tile-text {
    position: absolute;
    bottom: 6px;
    left: 6px;
    right: 6px;
    font-weight: 700;
    font-size: 0.8rem;
    color: #fff;
    z-index: 2;
    text-shadow: 0 2px 6px rgba(0, 0, 0, 0.9);
    line-height: 1.2;
    pointer-events: none;
}

/* Lists */
.list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}

.list-header-row {
    display: grid;
    /* Fixed: Align Artist (4th col) to center. Col 1+2 = 90px. Col 3 = 50% - 90px. */
    grid-template-columns: 40px 50px calc(50% - 90px) 1fr 1fr 120px;
    padding: 0 15px 8px 15px;
    color: var(--text-secondary);
    font-size: 0.85rem;
    font-weight: 600;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 8px;
    align-items: center;
}

.list-header-row span:last-child {
    text-align: right;
    padding-right: 10px;
}

.song-item {
    display: grid;
    /* Fixed: Align Artist to center. Matches header. */
    grid-template-columns: 40px 50px calc(50% - 90px) 1fr 1fr 120px;
    border-radius: 10px;
    align-items: center;
    color: var(--text-secondary);
    cursor: pointer;
    border: 1px solid rgba(255, 255, 255, 0.03);
    transition: all 0.2s cubic-bezier(0.25, 0.46, 0.45, 0.94);
    position: relative;
    overflow: hidden;
}

.song-item.selectable {
    /* Fixed: Align Artist to center. Col 1+2 = 130px. Col 3 = 50% - 130px. Checkbox logic handles 80px col 1. */
    grid-template-columns: 80px 50px calc(50% - 130px) 1fr 1fr 120px;
}

.song-item.selectable .select-cell {
    display: flex;
    align-items: center;
    padding-left: 45px;
    /* Force checkbox to start after the Play Icon (which is at left:20px) */
    height: 100%;
}

.song-item:hover {
    background: var(--item-hover-bg) !important;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    color: var(--text-primary);
    box-shadow: 4px 4px 0 var(--c-fx-border);
    transform: translate(-2px, -2px);
    border: 1px solid var(--c-fx-border);
    z-index: 10;
}

.song-item.active {
    background: var(--c-active-bg) !important;
    color: #fff !important;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    border-bottom: none;
    transform: scale(1);
}

.song-item.active * {
    color: #fff !important;
}

.song-item::before {
    content: '\f04b';
    font-family: "Font Awesome 6 Free";
    font-weight: 900;
    position: absolute;
    left: 20px;
    top: 50%;
    transform: translate(-80px, -50%);
    color: var(--c-hover-text);
    font-size: 1rem;
    transition: 0.3s cubic-bezier(0.5, -0.5, 0.2, 1.5);
    opacity: 0;
    pointer-events: none;
}

.song-item:hover::before {
    transform: translate(-50%, -50%);
    opacity: 1;
}

.song-index-num {
    transition: 0.3s;
    display: inline-block;
    width: 100%;
    text-align: center;
}

.song-item:hover .song-index-num {
    transform: translateX(-50px);
    opacity: 0;
}

.list-thumb {
    width: 40px;
    height: 40px;
    border-radius: 6px;
    object-fit: cover;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
    opacity: 0;
    transition: opacity 0.4s ease-in, transform 0.4s var(--ease-bounce);
}

.list-thumb.loaded {
    opacity: 1;
}

.song-item:hover .list-thumb {
    transform: translateX(10px) rotate(5deg);
    filter: brightness(1.1);
}

.song-item>span:nth-child(3),
.song-item>span:nth-child(4),
.song-item>span:nth-child(5) {
    transition: transform 0.4s var(--ease-bounce);
}

.song-item:hover>span:nth-child(3),
.song-item:hover>span:nth-child(4),
.song-item:hover>span:nth-child(5) {
    transform: translateX(15px);
}

.song-item:hover>span:nth-child(3) {
    color: var(--c-hover-text);
    text-shadow: 0 0 5px rgba(0, 0, 0, 0.5);
}

.list-heart {
    font-size: 0.9rem;
    opacity: 0;
    transition: 0.2s;
}

.song-item:hover .list-heart,
.song-item.active .list-heart,
.list-heart.is-loved {
    opacity: 1;
}

.list-heart.is-loved {
    color: #ff5555;
}

.text-link {
    cursor: pointer;
    position: relative;
    z-index: 10;
    color: var(--text-secondary);
    text-decoration: none;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.3);
    transition: all 0.2s;
}

.song-item.active .text-link {
    color: #fff !important;
    border-bottom-color: rgba(255, 255, 255, 0.5);
}

.text-link:hover {
    color: var(--c-hover-text) !important;
    border-bottom: 1px solid var(--c-hover-text);
    opacity: 1;
}

.song-item.active .text-link:hover {
    color: #fff !important;
    border-bottom-color: #fff;
}

@media (max-width: 1000px) {
    .song-item {
        grid-template-columns: 40px 1fr 50px;
    }

    .song-item>div:nth-child(2),
    .song-item>div:nth-child(4),
    .song-item>div:nth-child(5) {
        display: none;
    }

    .list-header-row {
        grid-template-columns: 40px 1fr 50px;
    }

    .list-header-row>span:nth-child(2),
    .list-header-row>span:nth-child(4),
    .list-header-row>span:nth-child(5) {
        display: none;
    }
}

/* Pagination */
.pagination {
    display: flex;
    justify-content: center;
    gap: 15px;
    margin-top: 15px;
    padding-bottom: 10px;
    align-items: center;
}

/* Modals & Popups */
.popup {
    position: absolute;
    background: var(--modal-bg);
    color: var(--text-primary);
    border: 1px solid var(--glass-border);
    border-radius: 12px;
    padding: 8px;
    display: none;
    flex-direction: column;
    z-index: 9999;
    box-shadow: 0 10px 50px rgba(0, 0, 0, 0.6);
}

.popup.show {
    display: flex;
    animation: popUp 0.2s;
}

.pop-item {
    padding: 10px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    gap: 10px;
    align-items: center;
    font-size: 0.9rem;
    color: var(--text-secondary);
    transition: 0.2s;
}

.pop-item:hover {
    background: rgba(128, 128, 128, 0.15);
    color: var(--text-primary);
}

.pop-item.active {
    background: var(--c-active-bg);
    color: #fff;
    font-weight: 700;
}

.modal-mask {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 10000;
    display: none;
    justify-content: center;
    align-items: center;
    backdrop-filter: blur(10px);
}

.modal {
    background: var(--modal-bg);
    color: var(--text-primary);
    width: 420px;
    padding: 30px;
    border-radius: 24px;
    box-shadow: 0 25px 80px rgba(0, 0, 0, 0.7);
    border: 1px solid var(--glass-border);
}

.modal-input {
    width: 100%;
    padding: 16px;
    border-radius: 12px;
    background: var(--input-bg);
    border: 1px solid var(--glass-border);
    color: var(--text-primary);
    outline: none;
    margin-bottom: 30px;
    font-size: 1rem;
}

.modal-btns {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
}

.btn-modal {
    padding: 10px 28px;
    border-radius: 12px;
    border: none;
    font-weight: 600;
    cursor: pointer;
}

.btn-confirm {
    background: var(--c-active-bg);
    color: #fff;
}