/* Leaderboard table */
.leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    table-layout: fixed;
}

.leaderboard-table th,
.leaderboard-table td {
    padding: 1rem 1rem;
    text-align: left;
    vertical-align: middle;
    white-space: nowrap;
    position: relative;
}

.leaderboard-table td {
    overflow: hidden;
    text-overflow: ellipsis;
}

.leaderboard-table td:nth-child(6) {
    overflow: visible;
}

.leaderboard-table td:nth-child(6):hover {
    z-index: 1000;
}

/* Desktop column widths */
.leaderboard-table th:nth-child(1),
.leaderboard-table td:nth-child(1) {
    width: 6%;
}

.leaderboard-table th:nth-child(2),
.leaderboard-table td:nth-child(2) {
    width: 46%;
    overflow: visible;
}

.leaderboard-table th:nth-child(3),
.leaderboard-table td:nth-child(3) {
    width: 12%;
}

.leaderboard-table th:nth-child(4),
.leaderboard-table td:nth-child(4) {
    width: 11%;
}

.leaderboard-table th:nth-child(5),
.leaderboard-table td:nth-child(5) {
    width: 13%;
}

.leaderboard-table th:nth-child(6),
.leaderboard-table td:nth-child(6) {
    width: 12%;
    text-align: right;
}

.leaderboard-table th {
    background-color: var(--bgtint);
    font-weight: 600;
    top: 0;
    cursor: pointer;
    user-select: none;
    transition: background-color 0.2s;
    z-index: 10;
}

/* Sorting indicators */
.leaderboard-table th.sortable::after {
    content: '';
    display: inline-block;
    width: 1.5rem;
    height: 1.5rem;
    margin-left: 0.5rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M8 2L11 6H5L8 2Z' fill='%23666' stroke='%23666' stroke-width='0.5'/%3E%3Cpath d='M8 14L5 10H11L8 14Z' fill='%23666' stroke='%23666' stroke-width='0.5'/%3E%3C/svg%3E");
    background-size: contain;
    background-repeat: no-repeat;
    opacity: 0.6;
    vertical-align: text-top;
}

.leaderboard-table th.sortable.sort-asc::after {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M8 4L11 10H5L8 4Z' fill='%23333' stroke='%23333' stroke-width='0.5'/%3E%3C/svg%3E");
    opacity: 1;
}

.leaderboard-table th.sortable.sort-desc::after {
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M8 12L5 6H11L8 12Z' fill='%23333' stroke='%23333' stroke-width='0.5'/%3E%3C/svg%3E");
    opacity: 1;
}

/* Mini heatmap */
.mini-heatmap {
    display: grid;
    grid-template-columns: repeat(6, 0.65rem);
    grid-template-rows: repeat(5, 0.65rem);
    margin: auto;
    width: fit-content;
    border: 1px solid #000000;
    border-radius: 2px;
}

.mini-heatmap-cell {
    position: relative;
}

.mini-heatmap-cell[data-tooltip]:hover::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 0.2rem 0.3rem;
    border-radius: 0.3rem;
    font-size: 0.8rem;
    font-weight: 600;
    white-space: nowrap;
    z-index: 1001;
    pointer-events: none;
}

.mini-heatmap-cell[data-tooltip]:hover::before {
    content: '';
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%) translateY(100%);
    border: 0.4rem solid transparent;
    border-top-color: rgba(0, 0, 0, 0.9);
    z-index: 1001;
}

/* Model cell styling */
.model-cell-wrapper {
    display: flex;
    align-items: center;
}

.model-name-container {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-width: 0;
}

.model-name-row {
    display: flex;
    align-items: center;
}

.company-icon {
    width: 1.5rem;
    height: 1.5rem;
    margin-right: 0.5rem;
    flex-shrink: 0;
}

.icon-placeholder {
    width: 1.5rem;
    height: 1.5rem;
    margin-right: 0.5rem;
    flex-shrink: 0;
}

/* New tag styling */
.new-tag {
    display: inline-block;
    margin-left: 0.5rem;
    padding: 0.15rem 0.4rem;
    background-color: #10b981;
    color: white;
    font-size: 0.65rem;
    font-weight: 700;
    border-radius: 0.25rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    vertical-align: middle;
}

/* Model details styling */
.model-details {
    font-size: 0.75rem;
    color: var(--textlight);
    margin-top: 0.25rem;
    font-weight: 400;
}

/* Responsive Design - Table */
@media screen and (max-width: 1024px) {
    .leaderboard-table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    .leaderboard-table thead,
    .leaderboard-table tbody,
    .leaderboard-table tr {
        display: table;
        width: 100%;
        table-layout: fixed;
    }

    .leaderboard-table thead {
        width: 100%;
    }

    .leaderboard-table th,
    .leaderboard-table td {
        white-space: nowrap;
    }

    /* Hide Company and Solved columns on tablet and below */
    .leaderboard-table th:nth-child(3),
    .leaderboard-table td:nth-child(3),
    .leaderboard-table th:nth-child(5),
    .leaderboard-table td:nth-child(5) {
        display: none;
    }

    /* Adjust column widths for 4-column layout */
    .leaderboard-table th:nth-child(1),
    .leaderboard-table td:nth-child(1) {
        width: 8%;
    }

    .leaderboard-table th:nth-child(2),
    .leaderboard-table td:nth-child(2) {
        width: 60%;
    }

    .leaderboard-table th:nth-child(4),
    .leaderboard-table td:nth-child(4) {
        width: 13%;
    }

    .leaderboard-table th:nth-child(6),
    .leaderboard-table td:nth-child(6) {
        width: 19%;
        text-align: right;
    }
}

@media screen and (max-width: 850px) {
    .leaderboard-table th,
    .leaderboard-table td {
        padding: 0.7rem 0.5rem;
        font-size: 0.85rem;
    }

    .company-icon {
        width: 1.2rem;
        height: 1.2rem;
        margin-right: 0.3rem;
    }

    .mini-heatmap {
        grid-template-columns: repeat(6, 0.5rem);
        grid-template-rows: repeat(5, 0.5rem);
    }

    .new-tag {
        font-size: 0.55rem;
        padding: 0.1rem 0.3rem;
        margin-left: 0.3rem;
    }

    .rank-cell {
        font-size: 1rem !important;
    }

    /* Tighter column widths for smaller tablets */
    .leaderboard-table th:nth-child(1),
    .leaderboard-table td:nth-child(1) {
        width: 8%;
    }

    .leaderboard-table th:nth-child(2),
    .leaderboard-table td:nth-child(2) {
        width: 62%;
    }

    .leaderboard-table th:nth-child(4),
    .leaderboard-table td:nth-child(4) {
        width: 13%;
    }

    .leaderboard-table th:nth-child(6),
    .leaderboard-table td:nth-child(6) {
        width: 17%;
        text-align: right;
        padding-right: 0.5rem;
    }
}

@media screen and (max-width: 480px) {
    .leaderboard-table th,
    .leaderboard-table td {
        padding: 0.5rem 0.3rem;
        font-size: 0.75rem;
    }

    .company-icon {
        width: 1rem;
        height: 1rem;
        margin-right: 0.25rem;
    }

    .mini-heatmap {
        grid-template-columns: repeat(6, 0.4rem);
        grid-template-rows: repeat(5, 0.4rem);
    }

    .new-tag {
        display: none;
    }

    .rank-cell {
        font-size: 0.9rem !important;
    }

    .leaderboard-table th.sortable::after {
        width: 1.2rem;
        height: 1.2rem;
        margin-left: 0.3rem;
    }

    /* Even tighter for phones */
    .leaderboard-table th:nth-child(1),
    .leaderboard-table td:nth-child(1) {
        width: 9%;
        padding-left: 0.2rem;
        padding-right: 0.2rem;
    }

    .leaderboard-table th:nth-child(2),
    .leaderboard-table td:nth-child(2) {
        width: 58%;
        padding-left: 0.3rem;
        padding-right: 0.3rem;
    }

    .leaderboard-table th:nth-child(4),
    .leaderboard-table td:nth-child(4) {
        width: 16%;
        padding-left: 0.2rem;
        padding-right: 0.2rem;
    }

    .leaderboard-table th:nth-child(6),
    .leaderboard-table td:nth-child(6) {
        width: 17%;
        text-align: right;
        padding-right: 0.3rem;
    }
}
