/* ===================================== */
/*              TABLES                   */
/* ===================================== */

/* Базовая таблица */
.tracks-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

/* Заголовки */
.tracks-table thead tr {
    border-bottom: 1px solid rgba(255,255,255,0.05);
}

.tracks-table th {
    text-align: left;
    padding: 15px 16px;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-dim);
    text-transform: uppercase;
    letter-spacing: 1px;
    background: rgba(0,0,0,0.2);
}

/* Колонки - УНИФИЦИРОВАННЫЕ */
.col-index,
.track-index {
    width: 50px !important;
    min-width: 50px !important;
    max-width: 50px !important;
    text-align: center;
    font-weight: 600;
    color: var(--accent);
    font-family: monospace;
    font-size: 13px;
}

/* ВАЖНО: объединяем селекторы для ячейки с обложкой */
.col-cover,
.track-cover-cell,
td.col-cover,
td.track-cover-cell,
.artist-tracks-table td.col-cover,
.artist-tracks-table td.track-cover-cell,
.album-tracks-table td.col-cover,
.album-tracks-table td.track-cover-cell,
.playlist-tracks-table td.col-cover,
.playlist-tracks-table td.track-cover-cell,
.search-track-row td.col-cover,
.search-track-row td.track-cover-cell,
.home-table td.col-cover,
.home-table td.track-cover-cell {
    width: 50px !important;
    min-width: 50px !important;
    max-width: 50px !important;
    padding: 8px !important;
    box-sizing: border-box !important;
}

/* Фиксируем саму обложку */
.track-cover {
    width: 40px !important;
    height: 40px !important;
    min-width: 40px !important;
    max-width: 40px !important;
    border-radius: 6px;
    background-size: cover;
    background-position: center;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    flex-shrink: 0;
    margin: 0 auto !important;
}

/* Перебиваем для активной строки */
.track-row.active .col-cover,
.track-row.active .track-cover-cell,
.track-row.active td.col-cover,
.track-row.active td.track-cover-cell {
    width: 50px !important;
    min-width: 50px !important;
    max-width: 50px !important;
}

.track-row.active .track-cover {
    width: 40px !important;
    height: 40px !important;
}

/* Остальные колонки */
.col-title {
    min-width: 200px;
}

.col-plays {
    width: 100px;
    text-align: right;
}

.col-duration {
    width: 70px;
    text-align: right;
}

.col-menu {
    width: 40px;
    text-align: center;
}

/* Строки */
.tracks-table tbody tr {
    border-bottom: 1px solid rgba(255,255,255,0.02);
    cursor: pointer;
    transition: all 0.2s ease;
}

.tracks-table tbody tr:hover {
    background: rgba(255,215,0,0.05);
}

.tracks-table tbody tr.active {
    background: rgba(255,215,0,0.1);
    position: relative;
}

.tracks-table tbody tr.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--accent);
    box-shadow: 0 0 10px var(--accent);
}

.tracks-table tbody tr.selected {
    background: rgba(255,215,0,0.08);
}

/* Ячейки */
.tracks-table td {
    padding: 12px 16px;
    transition: all 0.2s ease;
}

/* Индекс - переопределяем для активной строки */
.track-row.active .col-index::before {
    content: "";
    margin-right: 0;
    animation: none;
}

.track-row.active .col-index {
    font-size: 14px;
    color: #FFD700;
}

/* Название */
.track-title-wrapper {
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.track-name {
    font-weight: 500;
    color: var(--text-main);
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.track-artist {
    font-size: 11px;
    color: var(--text-dim);
    display: inline-block;
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* Прослушивания */
.track-plays-wrapper {
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 6px;
    color: var(--text-dim);
}

.plays-icon {
    font-size: 10px;
    opacity: 0.6;
}

.plays-count {
    font-weight: 500;
}

tr:hover .plays-count {
    color: var(--text-main);
}

/* Длительность */
.track-duration {
    color: var(--text-dim);
    font-family: monospace;
    font-size: 13px;
    display: block;
    text-align: right;
}

tr:hover .track-duration {
    color: var(--text-main);
}

/* Пустое состояние */
.empty-table {
    text-align: center;
    padding: 60px 20px !important;
    color: var(--text-dim);
}

.empty-table .empty-icon {
    font-size: 48px;
    margin-bottom: 15px;
    opacity: 0.5;
}

.empty-table h3 {
    font-size: 18px;
    margin: 0 0 8px 0;
    color: #fff;
}

.empty-table p {
    font-size: 13px;
    margin: 0;
    opacity: 0.7;
}

/* Контекстное меню */
.table-context-menu {
    position: fixed;
    background: #282828;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    border: 1px solid rgba(255,255,255,0.1);
    z-index: 10000;
    min-width: 200px;
    overflow: hidden;
    animation: menuAppear 0.2s ease;
}

.context-menu-item {
    padding: 12px 16px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s ease;
    color: white;
    font-size: 14px;
}

.context-menu-item:hover {
    background: rgba(255,215,0,0.15);
    padding-left: 20px;
}

.menu-icon {
    font-size: 16px;
    width: 20px;
    text-align: center;
    color: var(--accent);
}

.context-menu-divider {
    height: 1px;
    background: rgba(255,255,255,0.1);
    margin: 4px 0;
}

@keyframes menuAppear {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Сортировка */
th.sortable {
    cursor: pointer;
    user-select: none;
}

th.sortable:hover {
    color: var(--accent);
}

th.sortable::after {
    content: '↕';
    margin-left: 5px;
    opacity: 0.5;
    font-size: 12px;
}

th.sortable.asc::after {
    content: '↑';
    opacity: 1;
}

th.sortable.desc::after {
    content: '↓';
    opacity: 1;
}

/* Анимации */
@keyframes fadeOut {
    to {
        opacity: 0;
        transform: translateX(-10px);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateX(10px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

.track-row.removing {
    animation: fadeOut 0.3s ease forwards;
}

.track-row.adding {
    animation: fadeIn 0.3s ease;
}

/* Адаптив */
@media (max-width: 768px) {
    .tracks-table {
        font-size: 12px;
    }

    .tracks-table th {
        padding: 10px 8px;
        font-size: 11px;
    }

    .tracks-table td {
        padding: 8px;
    }

    .col-index,
    .track-index {
        width: 40px !important;
        min-width: 40px !important;
        font-size: 11px;
    }

    .col-cover,
    .track-cover-cell,
    td.col-cover,
    td.track-cover-cell {
        width: 40px !important;
        min-width: 40px !important;
        max-width: 40px !important;
        padding: 4px !important;
    }

    .track-cover {
        width: 32px !important;
        height: 32px !important;
        min-width: 32px !important;
        max-width: 32px !important;
    }

    .col-title {
        min-width: 150px;
    }

    .track-name {
        font-size: 12px;
    }

    .track-artist {
        font-size: 10px;
    }

    .col-plays {
        width: 70px;
    }

    .plays-icon {
        font-size: 9px;
    }

    .plays-count {
        font-size: 11px;
    }

    .col-duration {
        width: 50px;
        font-size: 11px;
    }

    .col-menu {
        width: 35px;
    }
}

@media (max-width: 480px) {
    .col-plays {
        display: none;
    }

    .col-title {
        min-width: 120px;
    }

    .track-name {
        font-size: 11px;
    }

    .track-artist {
        font-size: 9px;
    }

    .col-duration {
        width: 45px;
        font-size: 10px;
    }
}


/* Фикс для колонки меню */
.tracks-table td:last-child,
.home-table td:last-child,
.artist-tracks-table td:last-child,
.album-tracks-table td:last-child,
.playlist-tracks-table td:last-child,
.history-tracks-table td:last-child,
.starred-tracks-table td:last-child,
.disliked-tracks-table td:last-child {
    width: 50px !important;
    min-width: 50px !important;
    max-width: 50px !important;
}


/* Контейнер таблицы - скролл если не влезает */
.table-container {
    overflow-x: auto;
    width: 100%;
    -webkit-overflow-scrolling: touch;
}

/* Таблица имеет минимальную ширину, но может скроллиться */
.home-table,
.tracks-table {
    min-width: 100%;
    width: 100%;
}

/* Когда таблица не влезает - появляется скролл */
@media (max-width: 1000px) {
    .home-table,
    .tracks-table {
        min-width: 500px;
    }
}
