/**
 * Global Species Hunters Leaderboard CSS
 *
 * Styles for the Species Hunters Global Leaderboard page
 * FishComp Design System: Primary #0267A1, Accent #00C3FF, Dark #013F63
 *
 * @package FishComp
 * @version 1.0
 * @created 2025-12-27
 */

/* ========================================
   CSS Custom Properties (FishComp Theme)
   ======================================== */
:root {
    --fc-primary: #0267A1;
    --fc-primary-dark: #013F63;
    --fc-accent: #00C3FF;
    --fc-accent-light: #E0F7FF;
    --fc-success: #28a745;
    --fc-warning: #ffc107;
    --fc-danger: #dc3545;
    --fc-gold: #FFD700;
    --fc-silver: #C0C0C0;
    --fc-bronze: #CD7F32;
    --fc-card-bg: #ffffff;
    --fc-card-border: #e0e0e0;
    --fc-text-muted: #5a6169;
    --fc-text-dark: #212529;
    --fc-shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.08);
    --fc-shadow-md: 0 4px 8px rgba(0, 0, 0, 0.12);
    --fc-transition: all 0.3s ease;
}

/* Dark mode overrides */
html.dark-mode {
    --fc-card-bg: #1a1a1a;
    --fc-card-border: #333;
    --fc-text-muted: #adb5bd;
    --fc-text-dark: #f5f5f5;
    --fc-accent-light: #0a2540;
}

/* ========================================
   Summary Cards
   ======================================== */
.summary-card {
    border-radius: 12px;
    border: 1px solid var(--fc-card-border);
    transition: var(--fc-transition);
}

.summary-card:hover {
    box-shadow: var(--fc-shadow-md);
    transform: translateY(-2px);
}

.summary-card .card-title {
    font-size: 0.85rem;
    font-weight: 600;
}

/* ========================================
   Your Rank Sticky Badge
   ======================================== */
.your-rank-sticky-global {
    position: sticky;
    top: 70px;
    z-index: 100;
    background: linear-gradient(135deg, var(--fc-primary) 0%, var(--fc-primary-dark) 100%);
    color: white;
    padding: 1rem 1.25rem;
    border-radius: 12px;
    margin-bottom: 1.5rem;
    box-shadow: var(--fc-shadow-md);
    animation: slideDownGlobal 0.5s ease-out;
}

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

.rank-badge-content {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}

.rank-info {
    display: flex;
    align-items: baseline;
    gap: 0.5rem;
}

.rank-label {
    font-size: 0.9rem;
    opacity: 0.9;
}

.rank-number-badge {
    font-size: 1.75rem;
    font-weight: 700;
}

.rank-stats {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    text-align: right;
}

.rank-stats small {
    display: block;
    font-size: 0.875rem;
}

.jump-to-rank-btn {
    padding: 0.5rem 1rem;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    color: white;
    cursor: pointer;
    transition: var(--fc-transition);
    text-decoration: none;
    font-size: 0.875rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
}

.jump-to-rank-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-1px);
}

/* ========================================
   Filter Controls
   ======================================== */
.global-leaderboard-filters {
    background: var(--fc-card-bg);
    border: 1px solid var(--fc-card-border);
    border-radius: 12px;
    padding: 1rem;
}

.filter-controls {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    align-items: center;
    justify-content: center;
}

.filter-group {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
}

.filter-group::-webkit-scrollbar {
    display: none;
}

.filter-btn {
    padding: 0.625rem 1.25rem;
    background: var(--fc-card-bg);
    border: 1px solid var(--fc-card-border);
    border-radius: 8px;
    cursor: pointer;
    transition: var(--fc-transition);
    font-size: 0.9rem;
    text-decoration: none;
    color: var(--fc-text-dark);
    display: inline-flex;
    align-items: center;
    white-space: nowrap;
}

.filter-btn:hover {
    border-color: var(--fc-primary);
    color: var(--fc-primary);
    text-decoration: none;
}

.filter-btn.active {
    background: var(--fc-primary);
    color: white;
    border-color: var(--fc-primary);
}

/* ========================================
   Achievement Badge Legend
   ======================================== */
.badge-legend {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    background: var(--fc-card-bg);
    border: 1px solid var(--fc-card-border);
    border-radius: 10px;
    font-size: 0.85rem;
}

.badge-legend-title {
    font-weight: 600;
    color: var(--fc-text-muted);
}

/* ========================================
   Achievement Badges
   ======================================== */
.achievement-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    padding: 0.25rem 0.6rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-beginner {
    background: linear-gradient(135deg, #E8F5E9 0%, #C8E6C9 100%);
    color: #2E7D32;
}

.badge-explorer {
    background: linear-gradient(135deg, #E3F2FD 0%, #BBDEFB 100%);
    color: #1565C0;
}

.badge-hunter {
    background: linear-gradient(135deg, #FFF3E0 0%, #FFE0B2 100%);
    color: #E65100;
}

.badge-expert {
    background: linear-gradient(135deg, #F3E5F5 0%, #E1BEE7 100%);
    color: #7B1FA2;
}

.badge-master {
    background: linear-gradient(135deg, #FFF8E1 0%, #FFE082 100%);
    color: #F57F17;
    box-shadow: 0 0 8px rgba(255, 215, 0, 0.4);
}

/* Dark mode badge adjustments */
html.dark-mode .badge-beginner {
    background: linear-gradient(135deg, #1B5E20 0%, #2E7D32 100%);
    color: #A5D6A7;
}

html.dark-mode .badge-explorer {
    background: linear-gradient(135deg, #0D47A1 0%, #1565C0 100%);
    color: #90CAF9;
}

html.dark-mode .badge-hunter {
    background: linear-gradient(135deg, #BF360C 0%, #E65100 100%);
    color: #FFCC80;
}

html.dark-mode .badge-expert {
    background: linear-gradient(135deg, #4A148C 0%, #7B1FA2 100%);
    color: #CE93D8;
}

html.dark-mode .badge-master {
    background: linear-gradient(135deg, #FF8F00 0%, #FFB300 100%);
    color: #000;
}

/* ========================================
   Leaderboard Container & Entries
   ======================================== */
.global-leaderboard-container {
    max-width: 1200px;
    margin: 0 auto;
}

.global-leaderboard-entry {
    display: flex;
    align-items: center;
    padding: 1rem 1.25rem;
    margin-bottom: 0.75rem;
    background: var(--fc-card-bg);
    border: 1px solid var(--fc-card-border);
    border-radius: 12px;
    transition: var(--fc-transition);
    position: relative;
}

.global-leaderboard-entry:hover {
    box-shadow: var(--fc-shadow-md);
    transform: translateY(-2px);
}

/* Top 3 Special Styling */
.global-leaderboard-entry[data-rank="1"] {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.12) 0%, rgba(255, 165, 0, 0.08) 100%);
    border: 2px solid var(--fc-gold);
}

.global-leaderboard-entry[data-rank="2"] {
    background: linear-gradient(135deg, rgba(192, 192, 192, 0.12) 0%, rgba(168, 168, 168, 0.08) 100%);
    border: 2px solid var(--fc-silver);
}

.global-leaderboard-entry[data-rank="3"] {
    background: linear-gradient(135deg, rgba(205, 127, 50, 0.12) 0%, rgba(184, 115, 51, 0.08) 100%);
    border: 2px solid var(--fc-bronze);
}

/* Current User Highlighting */
.global-leaderboard-entry.current-user {
    border: 2px solid var(--fc-primary);
    background: var(--fc-accent-light);
    box-shadow: 0 2px 12px rgba(2, 103, 161, 0.2);
}

/* Highlight Flash Animation */
.global-leaderboard-entry.highlight-flash {
    animation: flashHighlight 2s ease-out;
}

@keyframes flashHighlight {
    0%, 100% {
        background: var(--fc-card-bg);
    }
    25%, 75% {
        background: rgba(0, 195, 255, 0.25);
    }
    50% {
        background: rgba(0, 195, 255, 0.4);
    }
}

/* ========================================
   Leaderboard Entry Columns
   ======================================== */

/* Rank Column */
.rank-column {
    flex: 0 0 70px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.25rem;
    padding-right: 0.75rem;
    border-right: 2px solid var(--fc-card-border);
}

.rank-number {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--fc-text-dark);
}

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

/* Participant Column */
.participant-column {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 1rem;
    min-width: 0;
    padding: 0 1rem;
}

.participant-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    object-fit: cover;
    background: var(--fc-accent-light);
    flex-shrink: 0;
    border: 2px solid var(--fc-card-border);
}

.participant-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
    min-width: 0;
}

.participant-name {
    font-weight: 600;
    font-size: 1rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    color: var(--fc-text-dark);
}

/* Species Count Column */
.species-column {
    flex: 0 0 100px;
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding: 0 0.5rem;
}

.species-count {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--fc-primary);
    line-height: 1;
}

.species-label {
    font-size: 0.75rem;
    color: var(--fc-text-muted);
    text-transform: uppercase;
    font-weight: 500;
}

/* Catches Column */
.catches-column {
    flex: 0 0 100px;
    text-align: center;
    color: var(--fc-text-muted);
    font-size: 0.9rem;
}

/* Last Catch Column */
.last-catch-column {
    flex: 0 0 140px;
    text-align: center;
    font-size: 0.85rem;
}

/* Actions Column */
.actions-column {
    flex: 0 0 auto;
    padding-left: 0.5rem;
}

.view-species-btn {
    border-radius: 8px;
    font-size: 0.85rem;
    padding: 0.4rem 0.75rem;
    transition: var(--fc-transition);
}

.view-species-btn:hover {
    background: var(--fc-primary);
    color: white;
    border-color: var(--fc-primary);
}

/* ========================================
   Species Gallery Modal
   ======================================== */
.species-gallery-card {
    background: var(--fc-card-bg);
    border: 1px solid var(--fc-card-border);
    border-radius: 10px;
    overflow: hidden;
    transition: var(--fc-transition);
    height: 100%;
    position: relative;
}

.species-gallery-card:hover {
    box-shadow: var(--fc-shadow-md);
    transform: translateY(-3px);
}

.species-gallery-img {
    width: 100%;
    height: 100px;
    object-fit: cover;
    background: var(--fc-accent-light);
}

.species-gallery-info {
    padding: 0.75rem;
}

.species-gallery-name {
    display: block;
    font-size: 0.9rem;
    color: var(--fc-text-dark);
    margin-bottom: 0.25rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.species-gallery-scientific {
    display: block;
    font-size: 0.75rem;
    color: var(--fc-text-muted);
    font-style: italic;
    margin-bottom: 0.5rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.species-gallery-stats {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    color: var(--fc-text-muted);
}

.species-gallery-stats span {
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

/* Personal catch styling */
.species-gallery-card.personal-catch {
    border: 2px solid var(--fc-primary);
    box-shadow: 0 4px 12px rgba(2, 103, 161, 0.2);
}

.species-gallery-card.personal-catch .species-gallery-img {
    object-fit: cover;
}

.personal-catch-badge {
    position: absolute;
    top: 8px;
    right: 8px;
    background: linear-gradient(135deg, var(--fc-primary), #1a365d);
    color: white;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 4px;
    z-index: 2;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.personal-catch-badge i {
    font-size: 0.6rem;
}

/* Measurement stats */
.species-measurements {
    display: flex;
    gap: 0.5rem;
    margin: 0.25rem 0;
    flex-wrap: wrap;
}

.species-measurement {
    background: var(--fc-primary);
    color: white;
    font-size: 0.65rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 8px;
    display: inline-flex;
    align-items: center;
    gap: 3px;
}

.species-measurement i {
    font-size: 0.55rem;
}

/* Dark mode personal catch */
html.dark-mode .species-gallery-card.personal-catch {
    border-color: var(--fc-primary);
    box-shadow: 0 4px 12px rgba(2, 103, 161, 0.3);
}

html.dark-mode .personal-catch-badge {
    background: linear-gradient(135deg, var(--fc-primary), #2d4a6f);
}

html.dark-mode .species-measurement {
    background: var(--fc-primary);
}

/* Modal improvements */
#speciesGalleryModal .modal-content {
    border-radius: 16px;
}

#speciesGalleryModal .modal-header {
    border-bottom: 1px solid var(--fc-card-border);
}

#speciesGalleryModal .modal-footer {
    border-top: 1px solid var(--fc-card-border);
}

/* ========================================
   Pagination Styles
   ======================================== */
.pagination .page-link {
    border-radius: 8px;
    margin: 0 0.15rem;
    color: var(--fc-primary);
    border-color: var(--fc-card-border);
    transition: var(--fc-transition);
}

.pagination .page-link:hover {
    background: var(--fc-accent-light);
    color: var(--fc-primary);
    border-color: var(--fc-primary);
}

.pagination .page-item.active .page-link {
    background: var(--fc-primary);
    border-color: var(--fc-primary);
    color: white;
}

.pagination .page-item.disabled .page-link {
    color: var(--fc-text-muted);
}

/* ========================================
   Mobile Responsive Styles
   ======================================== */
@media (max-width: 767px) {
    /* Sticky badge on mobile */
    .your-rank-sticky-global {
        top: 60px;
        padding: 0.75rem 1rem;
        margin-bottom: 1rem;
    }

    .rank-badge-content {
        flex-direction: column;
        text-align: center;
        gap: 0.75rem;
    }

    .rank-info {
        justify-content: center;
    }

    .rank-stats {
        text-align: center;
        flex-direction: row;
        gap: 1rem;
    }

    .jump-to-rank-btn {
        width: 100%;
        justify-content: center;
    }

    /* Leaderboard entry mobile */
    .global-leaderboard-entry {
        flex-wrap: wrap;
        padding: 0.75rem;
    }

    .rank-column {
        flex: 0 0 55px;
        padding-right: 0.5rem;
    }

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

    .participant-column {
        flex: 1;
        padding: 0 0.5rem;
        gap: 0.5rem;
    }

    .participant-avatar {
        width: 40px;
        height: 40px;
    }

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

    .species-column {
        flex: 0 0 auto;
        padding: 0 0.5rem;
    }

    .species-count {
        font-size: 1.25rem;
    }

    .species-label {
        font-size: 0.65rem;
    }

    .actions-column {
        flex-basis: 100%;
        margin-top: 0.75rem;
        padding-left: 0;
    }

    .view-species-btn {
        width: 100%;
        text-align: center;
    }

    /* Filter buttons mobile */
    .filter-group {
        width: 100%;
        justify-content: center;
    }

    .filter-btn {
        padding: 0.5rem 0.75rem;
        font-size: 0.8rem;
    }

    /* Badge legend mobile */
    .badge-legend {
        justify-content: center;
        font-size: 0.75rem;
    }

    .badge-legend-title {
        width: 100%;
        text-align: center;
        margin-bottom: 0.25rem;
    }

    /* Summary cards on mobile */
    .summary-card .card-body {
        padding: 0.75rem;
    }

    .summary-card .card-title {
        font-size: 0.75rem;
    }

    .summary-card .card-text {
        font-size: 1.25rem !important;
    }
}

/* Tablet adjustments */
@media (min-width: 768px) and (max-width: 991px) {
    .rank-column {
        flex: 0 0 60px;
    }

    .participant-avatar {
        width: 42px;
        height: 42px;
    }

    .species-count {
        font-size: 1.5rem;
    }

    .catches-column {
        flex: 0 0 80px;
        font-size: 0.85rem;
    }
}

/* ========================================
   Dark Mode Additional Overrides
   ======================================== */
html.dark-mode .global-leaderboard-filters,
html.dark-mode .badge-legend,
html.dark-mode .global-leaderboard-entry,
html.dark-mode .species-gallery-card,
html.dark-mode .summary-card {
    background: var(--fc-card-bg);
    border-color: var(--fc-card-border);
}

html.dark-mode .filter-btn {
    background: var(--fc-card-bg);
    color: var(--fc-text-dark);
    border-color: var(--fc-card-border);
}

html.dark-mode .filter-btn:hover {
    color: var(--fc-accent);
    border-color: var(--fc-accent);
}

html.dark-mode .filter-btn.active {
    background: var(--fc-primary);
    color: white;
}

html.dark-mode .rank-column {
    border-right-color: var(--fc-card-border);
}

html.dark-mode .participant-avatar {
    border-color: var(--fc-card-border);
}

html.dark-mode .species-count {
    color: var(--fc-accent);
}

html.dark-mode .view-species-btn {
    color: var(--fc-accent);
    border-color: var(--fc-accent);
}

html.dark-mode .view-species-btn:hover {
    background: var(--fc-accent);
    color: #000;
}

html.dark-mode .pagination .page-link {
    background: var(--fc-card-bg);
    color: var(--fc-accent);
    border-color: var(--fc-card-border);
}

html.dark-mode .pagination .page-link:hover {
    background: var(--fc-accent-light);
    color: var(--fc-accent);
}

html.dark-mode .pagination .page-item.active .page-link {
    background: var(--fc-primary);
    border-color: var(--fc-primary);
    color: white;
}

/* Dark mode top 3 styling */
html.dark-mode .global-leaderboard-entry[data-rank="1"] {
    background: linear-gradient(135deg, rgba(255, 215, 0, 0.15) 0%, rgba(255, 165, 0, 0.1) 100%);
}

html.dark-mode .global-leaderboard-entry[data-rank="2"] {
    background: linear-gradient(135deg, rgba(192, 192, 192, 0.15) 0%, rgba(168, 168, 168, 0.1) 100%);
}

html.dark-mode .global-leaderboard-entry[data-rank="3"] {
    background: linear-gradient(135deg, rgba(205, 127, 50, 0.15) 0%, rgba(184, 115, 51, 0.1) 100%);
}

html.dark-mode .global-leaderboard-entry.current-user {
    background: rgba(0, 195, 255, 0.1);
}

html.dark-mode .global-leaderboard-entry.highlight-flash {
    animation: flashHighlightDark 2s ease-out;
}

@keyframes flashHighlightDark {
    0%, 100% {
        background: var(--fc-card-bg);
    }
    25%, 75% {
        background: rgba(0, 195, 255, 0.2);
    }
    50% {
        background: rgba(0, 195, 255, 0.35);
    }
}

/* ========================================
   Accessibility Improvements
   ======================================== */

/* Focus indicators */
.filter-btn:focus,
.view-species-btn:focus,
.jump-to-rank-btn:focus,
.pagination .page-link:focus {
    outline: 2px solid var(--fc-accent);
    outline-offset: 2px;
}

/* Reduced motion preference */
@media (prefers-reduced-motion: reduce) {
    .global-leaderboard-entry,
    .species-gallery-card,
    .summary-card,
    .filter-btn,
    .view-species-btn,
    .your-rank-sticky-global {
        transition: none;
    }

    .global-leaderboard-entry:hover,
    .species-gallery-card:hover,
    .summary-card:hover {
        transform: none;
    }

    .global-leaderboard-entry.highlight-flash {
        animation: none;
        background: rgba(0, 195, 255, 0.3);
    }

    .your-rank-sticky-global {
        animation: none;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .global-leaderboard-entry,
    .species-gallery-card,
    .filter-btn,
    .badge-legend {
        border-width: 2px;
    }

    .achievement-badge {
        border: 1px solid currentColor;
    }
}
