/**
 * Game Leaderboard Styles for AIML Games Framework
 *
 * Unified leaderboard styles that work across all game types:
 * - Individual games
 * - Game sets
 * - Overall leaderboards
 *
 * @package AIML_Games_Framework
 */

/* ============================================
 * Main Leaderboard Container
 * ============================================ */

.aiml-games-leaderboard {
    max-width: 100%;
    margin: 20px 0;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
}

.aiml-games-leaderboard h3 {
    margin-bottom: 10px;
    color: #333;
}

/* ============================================
 * Header Section
 * ============================================ */

.aiml-games-leaderboard-header {
    margin-bottom: 20px;
    text-align: center;
}

.aiml-games-leaderboard-title {
    font-size: 24px;
    font-weight: 600;
    color: #1e3a8a;
    margin: 0 0 8px 0;
}

.aiml-games-leaderboard-subtitle {
    font-size: 14px;
    color: #6b7280;
    margin: 0;
}

/* ============================================
 * Statistics Section
 * ============================================ */

.aiml-games-leaderboard-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 25px;
}

.aiml-games-leaderboard-stat-card {
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 15px;
    text-align: center;
}

.aiml-games-leaderboard-stat-value {
    display: block;
    font-size: 20px;
    font-weight: 700;
    color: #1e40af;
    margin-bottom: 4px;
}

.aiml-games-leaderboard-stat-label {
    display: block;
    font-size: 12px;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ============================================
 * Leaderboard Table
 * ============================================ */

.aiml-games-leaderboard-table-container {
    overflow-x: auto;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    margin-bottom: 20px;
}

.aiml-games-leaderboard-table {
    width: 100%;
    border-collapse: collapse;
    background: white;
}

.aiml-games-leaderboard-table th {
    background: #f1f5f9;
    color: #374151;
    font-weight: 600;
    padding: 12px 8px;
    text-align: left;
    border-bottom: 1px solid #e2e8f0;
    font-size: 13px;
}

.aiml-games-leaderboard-table td {
    padding: 10px 8px;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

.aiml-games-leaderboard-row:hover {
    background: #f8fafc;
}

/* ============================================
 * Rank Styling
 * ============================================ */

.aiml-games-leaderboard-rank {
    font-weight: 600;
    text-align: center;
    width: 60px;
}

.aiml-games-leaderboard-rank-1 {
    color: #d97706;
    font-size: 16px;
}

.aiml-games-leaderboard-rank-2 {
    color: #6b7280;
    font-size: 15px;
}

.aiml-games-leaderboard-rank-3 {
    color: #92400e;
    font-size: 14px;
}

.aiml-games-leaderboard-medal {
    margin-right: 4px;
}

/* ============================================
 * Player Column
 * ============================================ */

.aiml-games-leaderboard-player {
    font-weight: 500;
    min-width: 120px;
}

.aiml-games-leaderboard-you-indicator {
    font-size: 11px;
    color: #059669;
    font-weight: 600;
    margin-left: 4px;
}

/* ============================================
 * Score Column
 * ============================================ */

.aiml-games-leaderboard-score {
    font-weight: 600;
    color: #1e40af;
    text-align: right;
    min-width: 80px;
}

/* ============================================
 * Time Column
 * ============================================ */

.aiml-games-leaderboard-time {
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 12px;
    color: #6b7280;
    text-align: right;
    min-width: 70px;
}

/* ============================================
 * Plays Column
 * ============================================ */

.aiml-games-leaderboard-plays {
    text-align: center;
    color: #6b7280;
    font-size: 13px;
    min-width: 60px;
}

/* ============================================
 * Current User Highlight
 * ============================================ */

.aiml-games-current-user-highlight {
    background: #fef3c7 !important;
}

.aiml-games-current-user-highlight td {
    border-color: #fde68a !important;
}

/* Pulse animation for current user row */
.aiml-games-current-user-highlight.aiml-games-current-user-pulse {
    animation: aimlGamesUserPulse 1.5s ease-in-out;
}

@keyframes aimlGamesUserPulse {
    0% {
        box-shadow: 0 0 0 0 rgba(251, 191, 36, 0.7);
        transform: scale(1);
    }
    50% {
        box-shadow: 0 0 0 10px rgba(251, 191, 36, 0.3);
        transform: scale(1.01);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(251, 191, 36, 0);
        transform: scale(1);
    }
}

/* ============================================
 * Pending Score Highlight
 * ============================================ */

.aiml-games-leaderboard-pending-score {
    background: #fff3cd !important;
    animation: aiml-games-pulse-pending 1.5s ease-in-out infinite;
}

.aiml-games-leaderboard-pending-score td {
    font-weight: 600;
}

@keyframes aiml-games-pulse-pending {
    0%, 100% { background-color: #fff3cd; }
    50% { background-color: #ffe69c; }
}

/* ============================================
 * Empty State
 * ============================================ */

.aiml-games-leaderboard-empty {
    text-align: center;
    padding: 60px 20px;
    background: #f8fafc;
    border: 2px dashed #cbd5e1;
    border-radius: 12px;
    margin: 20px 0;
}

.aiml-games-leaderboard-empty-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 16px;
    opacity: 0.6;
}

.aiml-games-leaderboard-empty-message {
    font-size: 18px;
    font-weight: 500;
    color: #374151;
    margin-bottom: 8px;
}

.aiml-games-leaderboard-empty-suggestion {
    font-size: 14px;
    color: #6b7280;
}

.aiml-games-empty-row td {
    color: #666;
    font-style: italic;
}

/* ============================================
 * User Position Section
 * ============================================ */

.aiml-games-leaderboard-user-position {
    background: #fef7ff;
    border: 1px solid #e9d5ff;
    border-radius: 8px;
    padding: 20px;
    margin-top: 20px;
}

.aiml-games-leaderboard-user-position-title {
    font-size: 18px;
    font-weight: 600;
    color: #7c3aed;
    margin: 0 0 15px 0;
}

.aiml-games-leaderboard-user-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: 15px;
}

.aiml-games-leaderboard-user-stat {
    text-align: center;
}

.aiml-games-leaderboard-user-stat-value {
    display: block;
    font-size: 18px;
    font-weight: 700;
    color: #7c3aed;
    margin-bottom: 4px;
}

.aiml-games-leaderboard-user-stat-label {
    display: block;
    font-size: 11px;
    color: #6b46c1;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* ============================================
 * Your Score Section (Pending/Unsaved)
 * ============================================ */

.aiml-games-your-score {
    background-color: #fff3cd !important;
    padding: 15px;
    border-radius: 5px;
    margin-top: 15px;
}

.aiml-games-your-score h4 {
    margin-bottom: 10px;
    color: #555;
}

/* ============================================
 * Loading State
 * ============================================ */

.aiml-games-leaderboard-loading {
    text-align: center;
    padding: 20px;
    color: #666;
}

.aiml-games-leaderboard-loading .aiml-games-loading {
    margin-right: 10px;
}

.aiml-games-leaderboard.is-loading {
    opacity: 0.6;
    pointer-events: none;
    transition: opacity 160ms ease;
}

/* ============================================
 * Responsive Design
 * ============================================ */

@media (max-width: 768px) {
    .aiml-games-leaderboard table {
        font-size: 0.9em;
    }

    .aiml-games-leaderboard-table th,
    .aiml-games-leaderboard-table td {
        padding: 8px 4px;
        font-size: 12px;
    }

    .aiml-games-leaderboard-stats {
        grid-template-columns: repeat(2, 1fr);
    }

    .aiml-games-leaderboard-user-stats {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 480px) {
    .aiml-games-leaderboard table {
        font-size: 0.8em;
    }

    .aiml-games-leaderboard-table th,
    .aiml-games-leaderboard-table td {
        padding: 6px 3px;
    }

    .aiml-games-leaderboard-title {
        font-size: 20px;
    }

    .aiml-games-leaderboard-stat-value {
        font-size: 18px;
    }

    .aiml-games-leaderboard-user-stat-value {
        font-size: 16px;
    }
}
