/* Sort-Related Styles */

.sortable,
.sortable-header {
    cursor: pointer;
    user-select: none;
    position: relative;
    transition: background-color .2s ease-in-out;
}

.sortable > div {
    display: flex;
    align-items: center;
    white-space: nowrap;
}

.sort-icon {
    display: inline-block;
    margin-left: 8px;
    opacity: .6;
    transition: opacity .2s, color .2s, transform .3s;
    position: relative;
    width: 8px;
    height: 13px;
    flex-shrink: 0;
    vertical-align: middle;
}

.sort-icon::before,
.sort-icon::after {
    content: "";
    display: block;
    width: 0;
    height: 0;
    border-left: 4px solid transparent;
    border-right: 4px solid transparent;
    transition: border-color 0.2s ease-in-out;
}

.sort-icon::before {
    border-bottom: 5px solid #ccc;
    margin-bottom: 3px;
}

.sort-icon::after {
    border-top: 5px solid #ccc;
}

.sortable-header:hover .sort-icon::before {
    border-bottom-color: #999;
}

.sortable-header:hover .sort-icon::after {
    border-top-color: #999;
}

.benchmark-table th .sort-icon {
    width: 5px;
    height: 13px;
    background-size: contain;
    background-repeat: no-repeat;
}

.sortable-header .sort-icon {
    width: 1em;
    text-align: center;
    font-size: .9em;
    color: var(--text-secondary);
}

.benchmark-table th.sorted-asc,
.benchmark-table th.sorted-desc {
    background-color: #e6f2ff;
    color: #2c5282;
}

.benchmark-table th.sorted-asc .sort-icon,
.benchmark-table th.sorted-desc .sort-icon {
    opacity: 1;
}

.benchmark-table th.sorted-asc .sort-icon {
    transform: rotate(180deg);
}

.sortable-header.sorted-asc .sort-icon,
.sortable-header.sorted-desc .sort-icon {
    opacity: 1;
    color: var(--color-danger);
}

.sortable-header.sorted-asc .sort-icon::after {
    border-top-color: #007bff;
}

.sortable-header.sorted-desc .sort-icon::before {
    border-bottom-color: #007bff;
}

.desktop-data-row .sorted-active,
.highlighted-column,
.list-header .sorted-active,
.sorted-column {
    background-color: rgba(26, 35, 126, .1);
}

/* Duplicated and more specific sort-related styles from the end of the original CSS */
.sortable-header {
    cursor: pointer;
    position: relative;
    user-select: none;
    transition: all 0.3s ease;
    display: flex !important;
    align-items: center;
    justify-content: center;
    height: 100%;
    padding: 12px 8px;
    white-space: nowrap;
}

.sortable-header:hover {
    background-color: rgba(0, 123, 255, 0.15);
    transform: translateY(-1px);
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.2);
}

.sortable-header.active {
    background-color: rgba(0, 123, 255, 0.12);
    border-top: 1px solid rgba(0, 123, 255, 0.3);
    border-left: 1px solid rgba(0, 123, 255, 0.3);
    border-right: 1px solid rgba(0, 123, 255, 0.3);
}

.sort-icon {
    margin-left: 5px;
    font-size: 0.8em;
    opacity: 0.5;
    transition: all 0.3s ease;
    display: inline-block;
    color: #666;
    /* Re-defined properties from earlier sort-icon */
    position: relative;
    width: 9px;
    height: 13px;
}

.sort-icon.active {
    opacity: 1;
    color: #007bff;
    transform: scale(1.1);
}

.sortable-header:hover .sort-icon {
    opacity: 0.8;
    color: #007bff;
}

.list-item.sorted-column-score > .col:nth-child(3),
.list-item.sorted-column-date > .col:nth-child(4),
.list-item.sorted-column-params > .col:nth-child(5) {
    background-color: rgba(0, 123, 255, 0.05) !important;
    transition: all 0.3s ease;
    position: relative;
}

.list-item.sorted-column-score > .col:nth-child(3)::before,
.list-item.sorted-column-date > .col:nth-child(4)::before,
.list-item.sorted-column-params > .col:nth-child(5)::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    border-radius: 0 3px 3px 0;
}

.mobile-card.sorted-column-score,
.mobile-card.sorted-column-date,
.mobile-card.sorted-column-params {
    background-color: rgba(0, 123, 255, 0.05) !important;
    box-shadow: 0 2px 8px rgba(0, 123, 255, 0.1);
    transition: all 0.3s ease;
}

.list-item.sorted-column-score:hover > .col:nth-child(3),
.list-item.sorted-column-date:hover > .col:nth-child(4),
.list-item.sorted-column-params:hover > .col:nth-child(5) {
    background-color: rgba(0, 123, 255, 0.08) !important;
    transform: translateX(2px);
}

.mobile-card.sorted-column-score:hover,
.mobile-card.sorted-column-date:hover,
.mobile-card.sorted-column-params:hover {
    background-color: rgba(0, 123, 255, 0.08) !important;
    border-left-width: 6px !important;
    transform: translateX(2px);
}

@keyframes sortPulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.sort-icon.active.pulse {
    animation: sortPulse 0.5s ease-in-out;
}

.benchmark-header-cell.sortable-header.active {
    background-color: rgba(0, 123, 255, 0.12) !important;
    color: #007bff;
    font-weight: 600;
}

.list-container.sorting-score .list-item .col:nth-child(3),
.list-container.sorting-date .list-item .col:nth-child(4),
.list-container.sorting-params .list-item .col:nth-child(5) {
    background: linear-gradient(90deg,
    rgba(0, 123, 255, 0.03) 0%,
    rgba(0, 123, 255, 0.05) 50%,
    rgba(0, 123, 255, 0.03) 100%);
    border-left: 1px solid rgba(0, 123, 255, 0.3);
    border-right: 1px solid rgba(0, 123, 255, 0.3);
}

.list-container .list-item .col.sorting-active {
    background: linear-gradient(90deg, rgba(0, 123, 255, 0.03) 0%, rgba(0, 123, 255, 0.05) 50%, rgba(0, 123, 255, 0.03) 100%);
    border-left: 1px solid rgba(0, 123, 255, 0.3);
    border-right: 1px solid rgba(0, 123, 255, 0.3);
}

.list-container.sorting-score .mobile-card,
.list-container.sorting-date .mobile-card,
.list-container.sorting-params .mobile-card {
    background: linear-gradient(135deg,
    rgba(0, 123, 255, 0.03) 0%,
    rgba(0, 123, 255, 0.05) 100%);
}

.sort-icon::before {
    top: 0;
    border-bottom: 6px solid #ccc;
}
.sort-icon::after {
    bottom: 0;
    border-top: 6px solid #ccc;
}

.sort-icon.asc::before {
    border-bottom-color: #007bff;
}
.sort-icon.desc::after {
    border-top-color: #007bff;
}