/* ==========================================================================
   Leaderboard Page - Map & Scores Styles
   ========================================================================== */

.leaderboard-page {
    background: linear-gradient(180deg, #0a1628 0%, #0f1829 50%, #152238 100%);
    min-height: 100vh;
    padding: 0;
}

.leaderboard-container {
    max-width: 1600px;
    margin: 0 auto;
    padding: 1rem;
}

/* Header */
.leaderboard-header {
    text-align: center;
    margin-bottom: 2rem;
    padding: 2rem 1rem;
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.1), rgba(249, 115, 22, 0.1));
    border-radius: 16px;
    border: 1px solid rgba(251, 191, 36, 0.2);
}

.header-content {
    position: relative;
}

.back-btn {
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: #94a3b8;
    text-decoration: none;
    font-size: 0.9rem;
    transition: all 0.3s;
}

.back-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fbbf24;
}

.leaderboard-header h1 {
    font-size: 2.5rem;
    margin: 0 0 0.5rem;
    background: linear-gradient(135deg, #fbbf24, #f97316);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.header-subtitle {
    color: #64748b;
    font-size: 1rem;
    margin: 0;
}

/* Content Layout */
.content-wrapper {
    display: grid;
    grid-template-columns: 1fr 500px;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

/* Map Section */
.map-section {
    background: rgba(26, 39, 68, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 1.5rem;
    backdrop-filter: blur(10px);
}

.map-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.map-header h2 {
    font-size: 1.3rem;
    margin: 0;
    color: #f8fafc;
}

.map-controls {
    display: flex;
    gap: 0.5rem;
}

.btn {
    padding: 0.75rem 1.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
}

.btn-secondary {
    background: rgba(59, 130, 246, 0.2);
    color: #60a5fa;
    border: 1px solid rgba(59, 130, 246, 0.4);
}

.btn-secondary:hover {
    background: rgba(59, 130, 246, 0.3);
    border-color: #60a5fa;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.btn-secondary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.85rem;
}

.map-container {
    height: 600px;
    border-radius: 12px;
    overflow: hidden;
    border: 2px solid rgba(255, 255, 255, 0.1);
    margin-bottom: 1rem;
}

/* Dark theme for Leaflet map - subtle dark overlay */
.map-container .leaflet-tile {
    filter: brightness(0.7) saturate(0.8) contrast(1.1);
}

.map-container .leaflet-tile-pane {
    opacity: 0.85;
}

/* Mode Tabs */
.mode-tabs {
    display: flex;
    gap: 0.5rem;
    margin-bottom: 1rem;
    padding: 0.5rem;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 10px;
}

.mode-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding: 0.75rem 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: #94a3b8;
    cursor: pointer;
    transition: all 0.3s;
    font-size: 0.85rem;
}

.mode-tab:hover {
    background: rgba(255, 255, 255, 0.1);
    border-color: rgba(251, 191, 36, 0.3);
    color: #f8fafc;
}

.mode-tab.active {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.2), rgba(249, 115, 22, 0.2));
    border-color: #fbbf24;
    color: #fbbf24;
    transform: translateY(-2px);
}

.tab-icon {
    font-size: 1.5rem;
}

.tab-name {
    font-size: 0.75rem;
    font-weight: 600;
}

/* Local Rank Banner */
.local-rank-banner {
    margin-bottom: 1rem;
    padding: 1rem 1.5rem;
    border-radius: 12px;
    text-align: center;
    font-size: 1rem;
    font-weight: 600;
    animation: slideIn 0.5s ease;
}

.local-rank-banner.best {
    background: linear-gradient(135deg, rgba(16, 185, 129, 0.2), rgba(5, 150, 105, 0.2));
    border: 2px solid #10b981;
    color: #10b981;
}

.local-rank-banner.not-best {
    background: linear-gradient(135deg, rgba(251, 191, 36, 0.15), rgba(249, 115, 22, 0.15));
    border: 2px solid rgba(251, 191, 36, 0.5);
    color: #fbbf24;
}

.local-rank-detail {
    font-size: 0.85rem;
    color: #94a3b8;
    margin-top: 0.5rem;
    font-weight: normal;
}

@keyframes slideIn {
    from {
        opacity: 0;
        transform: translateY(-10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.map-legend {
    display: flex;
    gap: 1.5rem;
    justify-content: center;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.3);
    border-radius: 8px;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.85rem;
    color: #94a3b8;
}

.marker-dot {
    width: 24px;
    height: 24px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    border: 2px solid rgba(255, 255, 255, 0.3);
}

/* Scores Section */
.scores-section {
    background: rgba(26, 39, 68, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 16px;
    padding: 1.5rem;
    backdrop-filter: blur(10px);
    display: flex;
    flex-direction: column;
    max-height: calc(100vh - 250px);
}

.scores-header h2 {
    font-size: 1.3rem;
    margin: 0 0 1rem;
    color: #f8fafc;
}

.stats-summary {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0.75rem;
    margin-bottom: 1.5rem;
}

.stat-item {
    text-align: center;
    padding: 0.75rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.stat-value {
    display: block;
    font-size: 1.5rem;
    font-weight: 700;
    color: #fbbf24;
    font-family: monospace;
}

.stat-label {
    display: block;
    font-size: 0.75rem;
    color: #64748b;
    margin-top: 0.25rem;
}

/* Filters */
.filter-controls {
    display: flex;
    gap: 0.75rem;
    margin-bottom: 1rem;
}

.filter-select,
.filter-input {
    padding: 0.6rem 1rem;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 8px;
    color: #f8fafc;
    font-size: 0.85rem;
    font-family: inherit;
    transition: all 0.3s;
}

.filter-select {
    flex: 1;
}

.filter-input {
    flex: 1;
}

.filter-select:focus,
.filter-input:focus {
    outline: none;
    border-color: #fbbf24;
    background: rgba(255, 255, 255, 0.08);
}

.filter-select option {
    background: #1a2744;
    color: #f8fafc;
}

/* Scores List */
.scores-list {
    flex: 1;
    overflow-y: auto;
    padding-right: 0.5rem;
}

.scores-list::-webkit-scrollbar {
    width: 6px;
}

.scores-list::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.scores-list::-webkit-scrollbar-thumb {
    background: rgba(251, 191, 36, 0.3);
    border-radius: 3px;
}

.scores-list::-webkit-scrollbar-thumb:hover {
    background: rgba(251, 191, 36, 0.5);
}

.score-card {
    display: grid;
    grid-template-columns: 50px 1fr auto;
    gap: 1rem;
    align-items: center;
    padding: 1rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 10px;
    margin-bottom: 0.75rem;
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: all 0.3s;
    cursor: pointer;
}

.score-card:hover {
    background: rgba(255, 255, 255, 0.06);
    border-color: rgba(251, 191, 36, 0.3);
    transform: translateX(4px);
}

.score-card.gold {
    border-left: 3px solid #fbbf24;
    background: rgba(251, 191, 36, 0.08);
}

.score-card.silver {
    border-left: 3px solid #94a3b8;
    background: rgba(148, 163, 184, 0.05);
}

.score-card.bronze {
    border-left: 3px solid #cd7f32;
    background: rgba(205, 127, 50, 0.05);
}

.score-rank {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.rank-number {
    font-size: 1.2rem;
    font-weight: 700;
    color: #64748b;
}

.rank-medal {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

.score-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.player-name {
    font-size: 1rem;
    font-weight: 600;
    color: #f8fafc;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.location-badge {
    font-size: 0.75rem;
    padding: 0.15rem 0.5rem;
    background: rgba(59, 130, 246, 0.2);
    border-radius: 12px;
    color: #60a5fa;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}

.score-meta {
    font-size: 0.8rem;
    color: #64748b;
    display: flex;
    gap: 1rem;
}

.score-value {
    text-align: right;
}

.score-number {
    font-size: 1.3rem;
    font-weight: 700;
    color: #fbbf24;
    font-family: monospace;
    display: block;
}

.score-level {
    font-size: 0.75rem;
    color: #64748b;
}

/* Loading & Empty States */
.loading-spinner {
    text-align: center;
    padding: 3rem;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(251, 191, 36, 0.1);
    border-top-color: #fbbf24;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-spinner p {
    color: #64748b;
    font-size: 0.9rem;
}

.no-scores {
    text-align: center;
    padding: 3rem;
}

.no-scores p {
    color: #64748b;
    margin: 0.5rem 0;
}

.no-scores .text-muted {
    font-size: 0.85rem;
}

/* Footer */
.leaderboard-footer {
    text-align: center;
    padding: 2rem 1rem;
    color: #64748b;
    font-size: 0.85rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.leaderboard-footer p {
    margin: 0.5rem 0;
}

.leaderboard-footer a {
    color: #fbbf24;
    text-decoration: none;
    font-weight: 600;
    transition: color 0.3s;
}

.leaderboard-footer a:hover {
    color: #f97316;
}

.leaderboard-footer .separator {
    margin: 0 0.5rem;
    color: #475569;
}

.refresh-indicator {
    display: inline-block;
    color: #94a3b8;
    font-weight: 500;
}

.refreshing {
    color: #fbbf24;
    animation: spin 1s linear infinite;
}

.refresh-soon {
    color: #f97316;
    font-weight: 600;
    animation: pulse-glow 1s ease-in-out infinite;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

@keyframes pulse-glow {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.6;
    }
}

/* Custom Leaflet Popup */
.leaflet-popup-content-wrapper {
    background: linear-gradient(135deg, #1a2744, #0f1829);
    border: 1px solid rgba(251, 191, 36, 0.3);
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.leaflet-popup-content {
    margin: 1rem;
    color: #f8fafc;
    min-width: 200px;
}

.popup-player-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: #fbbf24;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.popup-score {
    font-size: 0.95rem;
    color: #94a3b8;
    margin-bottom: 0.25rem;
}

.popup-location {
    font-size: 0.8rem;
    color: #64748b;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.leaflet-popup-tip {
    background: linear-gradient(135deg, #1a2744, #0f1829);
}

/* Responsive */
@media (max-width: 1024px) {
    .content-wrapper {
        grid-template-columns: 1fr;
    }

    .scores-section {
        max-height: 600px;
    }
}

@media (max-width: 768px) {
    .leaderboard-header h1 {
        font-size: 1.8rem;
    }

    .back-btn {
        position: static;
        transform: none;
        display: inline-block;
        margin-bottom: 1rem;
    }

    .map-container {
        height: 350px;
    }

    .map-header {
        flex-direction: column;
        gap: 0.75rem;
        align-items: flex-start;
    }

    .map-controls {
        width: 100%;
    }

    .map-controls .btn {
        flex: 1;
    }

    .stats-summary {
        grid-template-columns: 1fr;
    }

    .filter-controls {
        flex-direction: column;
    }

    .score-card {
        grid-template-columns: 40px 1fr auto;
        gap: 0.75rem;
        padding: 0.75rem;
    }

    .rank-number {
        font-size: 1rem;
    }

    .rank-medal {
        font-size: 1.2rem;
    }

    .player-name {
        font-size: 0.9rem;
    }

    .score-number {
        font-size: 1.1rem;
    }

    .score-meta {
        flex-direction: column;
        gap: 0.25rem;
    }

    .map-legend {
        flex-direction: column;
        gap: 0.5rem;
    }

    .mode-tabs {
        gap: 0.25rem;
        padding: 0.25rem;
    }

    .mode-tab {
        padding: 0.5rem 0.25rem;
    }

    .tab-icon {
        font-size: 1.2rem;
    }

    .tab-name {
        font-size: 0.65rem;
    }
}

@media (max-width: 480px) {
    .leaderboard-container {
        padding: 0.5rem;
    }

    .leaderboard-header {
        padding: 1rem;
    }

    .map-section,
    .scores-section {
        padding: 1rem;
    }

    .map-container {
        height: 250px;
    }
}
