/* ==========================================================================
   PAGE RANK / RECORDS - CSS CORRIGÉ (Alignement Horizontal & Visibilité)
   ========================================================================== */

/* CORRECTION CLÉ : N'afficher la page QUE si elle possède la classe .active */
#records-page {
    background-color: #EEFBFF;
    min-height: 100vh;
    display: none; /* Masqué par défaut pour éviter la superposition avec Help */
    flex-direction: column;
}

#records-page.active {
    display: flex !important; /* Affiché uniquement lorsqu'il est actif */
}

/* En-tête du classement */
.records-header {
    background: linear-gradient(135deg, #5B58EB 0%, #BB63FF 100%);
    padding: 14px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 4px 20px rgba(91, 88, 235, 0.25);
}

.records-header .header-title {
    font-size: 19px;
    font-weight: 700;
    color: #ffffff;
}

.records-header .back-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    border-radius: 12px;
    padding: 6px 14px;
    font-size: 18px;
    color: #ffffff;
    cursor: pointer;
    backdrop-filter: blur(4px);
    transition: all 0.2s ease;
}

.records-header .back-btn:hover {
    background: rgba(255, 255, 255, 0.35);
    transform: translateX(-3px);
}

/* Bouton "Ma position" */
#btn-my-position {
    background: #FFFFFF;
    color: #5B58EB;
    font-weight: 700;
    font-size: 12px;
    padding: 7px 14px;
    border-radius: 20px;
    border: none;
    box-shadow: 0 3px 10px rgba(0, 0, 0, 0.12);
    cursor: pointer;
    text-transform: uppercase;
    transition: all 0.2s ease;
}

#btn-my-position:hover {
    transform: scale(1.05);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

#btn-my-position.hidden {
    display: none !important;
}

/* Conteneur principal */
.records-main {
    flex: 1;
    padding: 20px 16px 40px;
    max-width: 680px;
    width: 100%;
    margin: 0 auto;
}

.records-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

/* --------------------------------------------------------------------------
   ALIGNEMENT HORIZONTAL DES CARTES JOUEURS (ALIGNEMENT EN LIGNE SUR 1 LIGNE)
   -------------------------------------------------------------------------- */
.record-item,
.leaderboard-row {
    background: #ffffff;
    border-radius: 16px;
    padding: 12px 16px;
    display: flex !important;
    flex-direction: row !important; /* Force l'alignement horizontal sur 1 seule ligne */
    align-items: center !important;
    justify-content: flex-start !important;
    gap: 14px !important;
    box-shadow: 0 3px 10px rgba(91, 88, 235, 0.06);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    width: 100%;
    box-sizing: border-box;
}

.record-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 18px rgba(91, 88, 235, 0.12);
}

/* Mis en évidence pour l'utilisateur connecté */
.record-item.current-user, 
.record-item.my-rank {
    background: #F0F3FF;
    border: 2px solid #5B58EB;
}

/* 1. Numéro / Badge du Rang (À gauche) */
.record-rank {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 15px;
    flex-shrink: 0;
    background: #EDF2F7;
    color: #4A5568;
}

/* Podiums (1er, 2e, 3e) */
.record-rank.gold, .record-rank.rank-1 {
    background: linear-gradient(135deg, #FFD700, #FF9900);
    color: #ffffff;
}

.record-rank.silver, .record-rank.rank-2 {
    background: linear-gradient(135deg, #CBD5E0, #A0AEC0);
    color: #ffffff;
}

.record-rank.bronze, .record-rank.rank-3 {
    background: linear-gradient(135deg, #ED8936, #C05621);
    color: #ffffff;
}

/* 2. Photo d'avatar */
.record-avatar, 
.record-item img {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
    border: 2px solid #E2E8F0;
    background-color: #F7FAFC;
}

/* 3. Zone du Nom et détails (S'étire au milieu) */
.record-info {
    flex: 1 !important;
    display: flex !important;
    flex-direction: column !important;
    justify-content: center;
    min-width: 0; /* Évite les dépassements de texte */
}

.record-name, 
.record-info span:first-child {
    font-weight: 700;
    color: #2D3748;
    font-size: 15px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* 4. Score (Poussé tout à fait à droite) */
.record-score {
    font-weight: 800;
    color: #5B58EB;
    font-size: 16px;
    white-space: nowrap;
    margin-left: auto !important; /* Aligne le score à l'extrême droite */
    background: #EEFBFF;
    padding: 6px 12px;
    border-radius: 20px;
}

/* Statistiques, podium et navigation de rang */
.leaderboard-summary {
    display: grid;
    grid-template-columns: repeat(3, minmax(0, 1fr));
    gap: 10px;
    margin-bottom: 18px;
}

.leaderboard-summary > div {
    min-height: 88px;
    border-radius: 18px;
    background: linear-gradient(145deg, #ffffff, #f4f6ff);
    border: 1px solid rgba(91, 88, 235, 0.08);
    box-shadow: 0 8px 24px rgba(91, 88, 235, 0.08);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.leaderboard-summary span { font-size: 20px; }
.leaderboard-summary strong { color: #302e9c; font-size: 18px; margin-top: 3px; }
.leaderboard-summary small { color: #718096; font-size: 11px; margin-top: 3px; }

.leaderboard-podium {
    min-height: 240px;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    align-items: end;
    gap: 10px;
    margin-bottom: 18px;
}

.podium-card {
    position: relative;
    min-height: 210px;
    padding: 28px 10px 12px;
    border-radius: 22px 22px 12px 12px;
    background: linear-gradient(180deg, #ffffff 0%, #f8f9ff 100%);
    border: 1px solid rgba(91, 88, 235, 0.1);
    box-shadow: 0 10px 24px rgba(91, 88, 235, 0.1);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-start;
}

.podium-card.rank-1 {
    min-height: 240px;
    background: linear-gradient(180deg, #fffaf0, #ffffff 75%);
    border-color: rgba(245, 158, 11, 0.35);
}

.podium-card.rank-2 { margin-bottom: 0; }
.podium-card.rank-3 { margin-bottom: 0; }
.podium-card.current-user { border: 2px solid #5B58EB; }

.podium-card .podium-medal {
    position: absolute;
    top: -14px;
    font-size: 30px;
}

.podium-card img {
    width: 68px;
    height: 68px;
    border-radius: 50%;
    object-fit: cover;
    border: 4px solid #e2e8f0;
    margin-bottom: 8px;
}

.podium-card.rank-1 img { border-color: #fbbf24; width: 76px; height: 76px; }
.podium-card.rank-2 img { border-color: #94a3b8; }
.podium-card.rank-3 img { border-color: #d97706; }
.podium-card strong {
    max-width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: #2D3748;
    font-size: 13px;
}
.podium-score { color: #5B58EB; font-weight: 800; font-size: 12px; margin-top: 5px; }
.podium-step {
    width: calc(100% + 20px);
    margin-top: auto;
    height: 38px;
    display: grid;
    place-items: center;
    border-radius: 0 0 12px 12px;
    background: linear-gradient(135deg, #5B58EB, #8b5cf6);
    color: white;
    font-weight: 900;
}
.podium-card.rank-1 .podium-step { height: 48px; }

.leaderboard-divider {
    display: flex;
    align-items: center;
    gap: 10px;
    margin: 4px 0 2px;
    color: #64748b;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}
.leaderboard-divider span { height: 1px; flex: 1; background: #dfe4f2; }
.you-badge {
    display: inline-block;
    margin-left: 6px;
    padding: 2px 6px;
    border-radius: 8px;
    background: #5B58EB;
    color: white;
    font-size: 9px;
}

@media (min-width: 701px) {
    .featured-categories { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}

@media (max-width: 700px) {
    .leaderboard-summary { gap: 6px; }
    .leaderboard-summary > div { min-height: 76px; border-radius: 14px; }
    .leaderboard-summary strong { font-size: 14px; }
    .leaderboard-podium { gap: 5px; min-height: 220px; }
    .podium-card { min-height: 194px; padding-inline: 6px; }
    .podium-card.rank-1 { min-height: 220px; }
    .podium-card img { width: 58px; height: 58px; }
    .podium-card.rank-1 img { width: 66px; height: 66px; }
    .record-rank { width: 32px; height: 32px; font-size: 12px; }
    .record-avatar, .record-item img { width: 40px; height: 40px; }
    .record-score { font-size: 13px; padding: 5px 8px; }
}