/**
 * Leaderboard Styles
 * Version: 1.0.0
 */

/* ============================================
   Leaderboard Container
   ============================================ */
.leaderboard-container {
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--sand-100, #faf8f4);
}

/* ============================================
   Filter Controls
   ============================================ */
.leaderboard-filters {
    display: flex;
    gap: 12px;
    padding: 16px 20px;
    background: white;
    border-bottom: 1px solid var(--sand-200, #f5f0e8);
    align-items: center;
    flex-wrap: wrap;
}

.leaderboard-region-select {
    flex: 1;
    min-width: 140px;
    max-width: 200px;
    padding: 10px 14px;
    border: 2px solid var(--sand-200, #f5f0e8);
    border-radius: var(--radius-sm, 8px);
    font-size: 0.95rem;
    font-family: inherit;
    background: var(--sand-100, #faf8f4);
    color: var(--text-primary, #1a1a1a);
    cursor: pointer;
    transition: all 0.2s;
}

.leaderboard-region-select:focus {
    outline: none;
    border-color: var(--forest-500, #3d7a52);
    background: white;
}

.leaderboard-type-toggle {
    display: flex;
    gap: 0;
    border-radius: var(--radius-sm, 8px);
    overflow: hidden;
    border: 2px solid var(--sand-200, #f5f0e8);
}

.type-toggle-btn {
    padding: 10px 16px;
    background: var(--sand-100, #faf8f4);
    border: none;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary, #555);
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.type-toggle-btn:first-child {
    border-right: 1px solid var(--sand-200, #f5f0e8);
}

.type-toggle-btn:hover {
    background: var(--forest-50, #f4faf6);
}

.type-toggle-btn.active {
    background: var(--forest-600, #2d5a3d);
    color: white;
}

/* ============================================
   Leaderboard Content Area
   ============================================ */
.leaderboard-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px 20px;
}

/* ============================================
   Leaderboard List
   ============================================ */
.leaderboard-list {
    display: flex;
    flex-direction: column;
    gap: 1px;
    background: var(--sand-200, #f5f0e8);
    border-radius: var(--radius-lg, 16px);
    overflow: hidden;
    box-shadow: var(--card-shadow, 0 1px 3px rgba(0,0,0,0.08), 0 4px 12px rgba(0,0,0,0.05));
}

.leaderboard-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 16px;
    background: white;
    cursor: pointer;
    transition: background 0.15s;
}

.leaderboard-item:hover {
    background: var(--forest-50, #f4faf6);
}

.leaderboard-item:active {
    background: var(--forest-100, #e8f5ed);
}

/* ============================================
   Rank Styling
   ============================================ */
.leaderboard-rank {
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-family: 'Fraunces', Georgia, serif;
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-muted, #666);
    background: var(--sand-100, #faf8f4);
    border-radius: 50%;
    flex-shrink: 0;
}

/* Gold - Rank 1 */
.leaderboard-item.rank-1 .leaderboard-rank {
    background: linear-gradient(135deg, var(--gold-400, #f4c430), var(--gold-500, #daa520));
    color: var(--forest-900, #0d2818);
    box-shadow: 0 2px 8px rgba(218, 165, 32, 0.4);
}

.leaderboard-item.rank-1 {
    background: linear-gradient(135deg, rgba(244, 196, 48, 0.08), rgba(218, 165, 32, 0.04));
}

/* Silver - Rank 2 */
.leaderboard-item.rank-2 .leaderboard-rank {
    background: linear-gradient(135deg, #e8e8e8, #c0c0c0);
    color: var(--forest-900, #0d2818);
    box-shadow: 0 2px 8px rgba(192, 192, 192, 0.4);
}

.leaderboard-item.rank-2 {
    background: linear-gradient(135deg, rgba(192, 192, 192, 0.08), rgba(192, 192, 192, 0.04));
}

/* Bronze - Rank 3 */
.leaderboard-item.rank-3 .leaderboard-rank {
    background: linear-gradient(135deg, #d4a574, #cd7f32);
    color: white;
    box-shadow: 0 2px 8px rgba(205, 127, 50, 0.4);
}

.leaderboard-item.rank-3 {
    background: linear-gradient(135deg, rgba(205, 127, 50, 0.08), rgba(205, 127, 50, 0.04));
}

/* ============================================
   User Info
   ============================================ */
.leaderboard-user {
    flex: 1;
    min-width: 0;
}

.leaderboard-name {
    font-weight: 600;
    color: var(--forest-800, #1a3a2a);
    font-size: 0.95rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

/* ============================================
   Species Count
   ============================================ */
.leaderboard-count {
    font-family: 'Fraunces', Georgia, serif;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--forest-600, #2d5a3d);
    min-width: 40px;
    text-align: right;
}

.leaderboard-arrow {
    color: var(--text-muted, #666);
    opacity: 0.5;
    transition: opacity 0.15s, transform 0.15s;
}

.leaderboard-item:hover .leaderboard-arrow {
    opacity: 1;
    transform: translateX(2px);
}

/* ============================================
   Loading State
   ============================================ */
.leaderboard-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    gap: 12px;
    color: var(--text-muted, #666);
}

.leaderboard-loading-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--sand-200, #f5f0e8);
    border-top-color: var(--forest-500, #3d7a52);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* ============================================
   Empty State
   ============================================ */
.leaderboard-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    gap: 12px;
}

.leaderboard-empty-icon {
    font-size: 3rem;
    margin-bottom: 8px;
}

.leaderboard-empty h3 {
    font-size: 1.2rem;
    color: var(--text-primary, #1a1a1a);
    font-weight: 600;
    margin: 0;
}

.leaderboard-empty p {
    color: var(--text-muted, #666);
    font-size: 0.95rem;
    max-width: 280px;
    margin: 0;
}

/* ============================================
   Error State
   ============================================ */
.leaderboard-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    text-align: center;
    gap: 12px;
}

.leaderboard-error-icon {
    font-size: 3rem;
    margin-bottom: 8px;
}

.leaderboard-error h3 {
    font-size: 1.2rem;
    color: var(--text-primary, #1a1a1a);
    font-weight: 600;
    margin: 0;
}

.leaderboard-error p {
    color: var(--text-muted, #666);
    font-size: 0.95rem;
    max-width: 280px;
    margin: 0;
}

.leaderboard-retry-btn {
    margin-top: 12px;
    padding: 10px 24px;
    background: var(--forest-500, #3d7a52);
    color: white;
    border: none;
    border-radius: var(--radius-sm, 8px);
    font-size: 0.95rem;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.2s;
}

.leaderboard-retry-btn:hover {
    background: var(--forest-600, #2d5a3d);
}

/* ============================================
   User Sightings Modal
   ============================================ */
.user-sightings-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 10000;
    justify-content: center;
    align-items: flex-start;
    padding: 20px;
    overflow-y: auto;
}

.user-sightings-overlay.active {
    display: flex;
}

.user-sightings-modal {
    background: white;
    border-radius: var(--radius-lg, 16px);
    max-width: 600px;
    width: 100%;
    max-height: calc(100vh - 40px);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: modalSlideUp 0.3s ease;
    margin: auto 0;
}

@keyframes modalSlideUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

.user-sightings-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    border-bottom: 1px solid var(--sand-200, #f5f0e8);
    background: var(--forest-50, #f4faf6);
}

.user-sightings-header h2 {
    font-family: 'Fraunces', Georgia, serif;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--forest-800, #1a3a2a);
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
    padding-right: 12px;
}

.user-sightings-close {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: rgba(0, 0, 0, 0.08);
    border: none;
    color: var(--text-secondary, #555);
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
    flex-shrink: 0;
    transition: background 0.2s;
}

.user-sightings-close:hover {
    background: rgba(0, 0, 0, 0.15);
}

.user-sightings-body {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
}

/* Loading state in modal */
.user-sightings-loading {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    gap: 12px;
    color: var(--text-muted, #666);
}

/* Empty state in modal */
.user-sightings-empty {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    color: var(--text-muted, #666);
}

/* Error state in modal */
.user-sightings-error {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 40px 20px;
    text-align: center;
    color: var(--coral-500, #e76f51);
}

/* Fallback list styling (when SightingCard not available) */
.user-sightings-list {
    display: flex;
    flex-direction: column;
    gap: 1px;
    background: var(--sand-200, #f5f0e8);
    border-radius: var(--radius-md, 12px);
    overflow: hidden;
}

.user-sighting-item {
    padding: 12px 14px;
    background: white;
}

.user-sighting-species {
    font-weight: 600;
    color: var(--forest-700, #234d38);
    font-size: 0.95rem;
}

.user-sighting-meta {
    font-size: 0.85rem;
    color: var(--text-muted, #666);
    margin-top: 2px;
}

/* ============================================
   Responsive Styles
   ============================================ */
@media (max-width: 540px) {
    .leaderboard-filters {
        flex-direction: column;
        gap: 10px;
        padding: 12px 16px;
    }

    .leaderboard-region-select {
        max-width: none;
        width: 100%;
    }

    .leaderboard-type-toggle {
        width: 100%;
    }

    .type-toggle-btn {
        flex: 1;
        padding: 10px 12px;
        font-size: 0.85rem;
    }

    .leaderboard-content {
        padding: 12px 16px;
    }

    .leaderboard-item {
        padding: 12px 14px;
    }

    .leaderboard-rank {
        width: 28px;
        height: 28px;
        font-size: 0.9rem;
    }

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

    .leaderboard-count {
        font-size: 1rem;
    }

    .user-sightings-modal {
        max-height: calc(100vh - 20px);
        margin: 10px 0 0 0;
        border-radius: var(--radius-lg, 16px) var(--radius-lg, 16px) 0 0;
    }

    .user-sightings-header h2 {
        font-size: 1rem;
    }
}
