/* ========== СТИЛИ ДЛЯ ТАБЛИЦЫ ЛИДЕРОВ ========== */

/* Анимации для таблицы лидеров */
@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulseGold {
    0%, 100% {
        text-shadow: 0 0 10px rgba(255, 215, 0, 0.5);
    }
    50% {
        text-shadow: 0 0 20px rgba(255, 215, 0, 0.8);
    }
}

@keyframes leaderboardShine {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

@keyframes bounce {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Эффект для топ-3 мест */
.leaderboard-place-1 {
    animation: pulseGold 2s infinite;
}

.leaderboard-place-2 {
    color: #C0C0C0 !important;
    text-shadow: 0 2px 4px rgba(192, 192, 192, 0.3);
}

.leaderboard-place-3 {
    color: #CD7F32 !important;
    text-shadow: 0 2px 4px rgba(205, 127, 50, 0.3);
}

/* Эффект при скролле */
.leaderboard-row {
    animation: fadeInUp 0.5s ease-out;
    animation-fill-mode: both;
}

/* Задержки для анимации строк */
.leaderboard-row:nth-child(1) { animation-delay: 0.1s; }
.leaderboard-row:nth-child(2) { animation-delay: 0.2s; }
.leaderboard-row:nth-child(3) { animation-delay: 0.3s; }
.leaderboard-row:nth-child(4) { animation-delay: 0.4s; }
.leaderboard-row:nth-child(5) { animation-delay: 0.5s; }
.leaderboard-row:nth-child(6) { animation-delay: 0.6s; }
.leaderboard-row:nth-child(7) { animation-delay: 0.7s; }
.leaderboard-row:nth-child(8) { animation-delay: 0.8s; }
.leaderboard-row:nth-child(9) { animation-delay: 0.9s; }
.leaderboard-row:nth-child(10) { animation-delay: 1.0s; }

/* Основные стили для таблицы лидеров */
.leaderboard-container {
    display: flex;
    flex-direction: column;
    height: 100vh;
    width: 100%;
    background: white;
    position: relative;
    overflow: hidden;
}

.leaderboard-header {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    background-size: 400% 400%;
    animation: gradientFlow 8s ease infinite;
    color: white;
    padding: 25px 20px;
    text-align: center;
    position: relative;
    overflow: hidden;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

@keyframes gradientFlow {
    0% {
        background-position: 0% 50%;
    }
    50% {
        background-position: 100% 50%;
    }
    100% {
        background-position: 0% 50%;
    }
}

.leaderboard-header::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 100%;
    background: linear-gradient(90deg, transparent 0%, rgba(255, 255, 255, 0.15) 50%, transparent 100%);
    animation: leaderboardShine 3s infinite linear;
    border-radius: 10px;
    z-index: 1;
}

.leaderboard-header h1 {
    font-size: 28px;
    font-weight: 800;
    margin: 0 0 10px 0;
    text-shadow: 0 2px 10px rgba(0,0,0,0.3);
    position: relative;
    z-index: 2;
}

.leaderboard-header div {
    font-size: 14px;
    opacity: 0.9;
    position: relative;
    z-index: 2;
}

.leaderboard-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    background: #f8f9fa;
    position: relative;
}

/* Стилизация скроллбара */
.leaderboard-content::-webkit-scrollbar {
    width: 6px;
}

.leaderboard-content::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.05);
    border-radius: 3px;
}

.leaderboard-content::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 3px;
}

.leaderboard-content::-webkit-scrollbar-thumb:hover {
    background: linear-gradient(135deg, #5a6fd8 0%, #6a4190 100%);
}

/* Таблица лидеров - ИСПРАВЛЕННЫЕ ГРИДЫ */
.leaderboard-table {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Заголовок таблицы - увеличиваем колонку с именем */
.leaderboard-table-header {
    display: grid;
    grid-template-columns: 60px minmax(150px, 1fr) 80px;
    gap: 15px;
    padding: 15px 20px;
    background: white;
    border-radius: 12px;
    font-weight: 600;
    color: #667eea;
    font-size: 14px;
    margin-bottom: 5px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}

/* Строка таблицы - увеличиваем колонку с именем */
.leaderboard-row {
    display: grid;
    grid-template-columns: 60px minmax(150px, 1fr) 80px;
    gap: 15px;
    padding: 18px 20px;
    background: white;
    border-radius: 12px;
    align-items: center;
    transition: all 0.3s ease;
    cursor: pointer;
    border: 1px solid #e0e0e0;
    animation: fadeInUp 0.3s ease-out;
}

.leaderboard-row:hover {
    background: #f8f9fa;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

.leaderboard-row.current-user {
    background: linear-gradient(135deg, #667eea10 0%, #764ba210 100%);
    border-color: #667eea;
    box-shadow: 0 2px 8px rgba(102, 126, 234, 0.1);
}

/* Стили для имени - убираем ограничение white-space */
.leaderboard-name-cell {
    font-weight: 500;
    color: #333;
    overflow: visible;
    white-space: normal;
    word-break: break-word;
    line-height: 1.3;
}

/* Для текущего пользователя */
.leaderboard-row.current-user .leaderboard-name-cell {
    color: #667eea;
    font-weight: 600;
}

.leaderboard-place {
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    color: #666;
}

.leaderboard-points {
    font-weight: 700;
    color: #667eea;
    text-align: right;
    font-size: 18px;
    white-space: nowrap;
}

/* Стили для медалей */
.medal-gold {
    font-size: 24px;
    animation: pulseGold 2s infinite;
}

.medal-silver {
    font-size: 24px;
    color: #C0C0C0;
}

.medal-bronze {
    font-size: 24px;
    color: #CD7F32;
}

/* ========== ДОПОЛНИТЕЛЬНЫЕ СТИЛИ ДЛЯ ГОСТЕЙ ========== */

/* Сообщение для гостей в таблице лидеров */
.guest-leaderboard-message {
    animation: fadeInUp 0.5s ease-out;
}

.guest-leaderboard-message button {
    transition: all 0.3s ease;
}

.guest-leaderboard-message button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.guest-leaderboard-message button:active {
    transform: translateY(0);
}

/* Карточка текущего пользователя */
.user-info-card {
    margin-top: 20px;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    border-radius: 16px;
    color: white;
    text-align: center;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

.user-info-title {
    font-size: 14px;
    opacity: 0.9;
    margin-bottom: 5px;
}

.user-info-place {
    font-size: 28px;
    font-weight: 800;
    margin-bottom: 10px;
}

.user-info-points {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 5px;
}

.user-info-message {
    font-size: 12px;
    opacity: 0.8;
    margin-top: 10px;
}

/* Сообщение о пустой таблице */
.empty-leaderboard {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    text-align: center;
    color: #666;
    padding: 40px 20px;
}

.empty-leaderboard-icon {
    font-size: 48px;
    margin-bottom: 20px;
    animation: bounce 2s infinite;
}

.empty-leaderboard-title {
    font-size: 20px;
    font-weight: 600;
    margin-bottom: 10px;
    color: #333;
}

.empty-leaderboard-message {
    font-size: 16px;
    margin-bottom: 30px;
    max-width: 300px;
}

/* Кнопка начать тренировку */
.start-training-btn {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    border: none;
    border-radius: 12px;
    padding: 14px 30px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(102, 126, 234, 0.2);
}

.start-training-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(102, 126, 234, 0.3);
}

.start-training-btn:active {
    transform: translateY(0);
}

/* Кнопка назад */
#backFromLeaderboardBtn {
    position: absolute;
    top: 12px;
    left: 12px;
    background: rgba(255, 255, 255, 0.25);
    border: 1.5px solid rgba(255, 255, 255, 0.4);
    border-radius: 10px;
    padding: 8px 12px;
    font-size: 14px;
    font-weight: 600;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    z-index: 10;
    backdrop-filter: blur(8px);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
}

#backFromLeaderboardBtn:hover {
    background: rgba(255, 255, 255, 0.35);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
    border-color: rgba(255, 255, 255, 0.6);
}

#backFromLeaderboardBtn:active {
    transform: translateY(0);
}

/* ========== АДАПТИВНОСТЬ ========== */
@media (max-width: 500px) {
    .leaderboard-header {
        padding: 20px 15px;
        min-height: 100px;
    }

    .leaderboard-header h1 {
        font-size: 24px;
    }

    .leaderboard-header div {
        font-size: 12px;
    }

    #backFromLeaderboardBtn {
        top: 8px;
        left: 8px;
        padding: 6px 10px;
        font-size: 12px;
        gap: 4px;
    }

    .leaderboard-content {
        padding: 15px;
    }

    /* На мобильных делаем колонку с именем шире, а баллы уже */
    .leaderboard-table-header,
    .leaderboard-row {
        grid-template-columns: 50px minmax(120px, 1fr) 70px;
        gap: 10px;
        padding: 12px 15px;
        font-size: 13px;
    }

    .leaderboard-row {
        padding: 15px;
    }

    .leaderboard-place {
        font-size: 16px;
    }

    .leaderboard-points {
        font-size: 15px;
    }

    .medal-gold,
    .medal-silver,
    .medal-bronze {
        font-size: 20px;
    }

    .user-info-card {
        padding: 15px;
        border-radius: 14px;
    }

    .user-info-place {
        font-size: 24px;
    }

    .user-info-points {
        font-size: 16px;
    }

    .empty-leaderboard-icon {
        font-size: 42px;
    }

    .empty-leaderboard-title {
        font-size: 18px;
    }

    .empty-leaderboard-message {
        font-size: 14px;
        max-width: 280px;
    }

    .start-training-btn {
        padding: 12px 25px;
        font-size: 15px;
    }

    /* Стили для гостей на мобильных */
    .guest-leaderboard-message {
        padding: 25px 20px !important;
    }

    .guest-leaderboard-message div[style*="font-size: 56px"] {
        font-size: 48px !important;
    }

    .guest-leaderboard-message div[style*="font-size: 20px"] {
        font-size: 18px !important;
    }

    .guest-leaderboard-message div[style*="font-size: 15px"] {
        font-size: 14px !important;
    }

    .guest-leaderboard-message button {
        padding: 12px 24px !important;
        font-size: 14px !important;
    }
}

@media (max-width: 380px) {
    .leaderboard-table-header,
    .leaderboard-row {
        grid-template-columns: 45px minmax(100px, 1fr) 65px;
        gap: 8px;
        padding: 10px 12px;
        font-size: 12px;
    }

    .leaderboard-row {
        padding: 12px 10px;
    }

    .leaderboard-place {
        font-size: 14px;
    }

    .leaderboard-points {
        font-size: 13px;
    }

    .medal-gold,
    .medal-silver,
    .medal-bronze {
        font-size: 18px;
    }

    /* Стили для гостей на очень маленьких экранах */
    .guest-leaderboard-message {
        padding: 20px 15px !important;
    }

    .guest-leaderboard-message div[style*="font-size: 48px"] {
        font-size: 42px !important;
    }

    .guest-leaderboard-message div[style*="font-size: 18px"] {
        font-size: 16px !important;
    }

    .guest-leaderboard-message div[style*="font-size: 14px"] {
        font-size: 13px !important;
    }

    .guest-leaderboard-message button {
        padding: 10px 20px !important;
        font-size: 13px !important;
    }
}

@media (max-height: 600px) {
    .leaderboard-header {
        padding: 15px;
        min-height: 80px;
    }

    .leaderboard-header h1 {
        font-size: 20px;
        margin-bottom: 5px;
    }

    .leaderboard-header div {
        font-size: 11px;
    }

    .leaderboard-content {
        padding: 10px;
    }

    .leaderboard-row {
        padding: 12px 15px;
    }

    .guest-leaderboard-message {
        padding: 20px !important;
        margin-top: 10px;
    }

    .guest-leaderboard-message div[style*="font-size: 56px"] {
        font-size: 42px !important;
        margin-bottom: 10px !important;
    }

    .guest-leaderboard-message div[style*="font-size: 20px"] {
        font-size: 16px !important;
        margin-bottom: 8px !important;
    }

    .guest-leaderboard-message button {
        padding: 10px 20px !important;
        font-size: 13px !important;
    }
}