/* ======================================================
   2) INDEX-SIDAN (index-template.html)
   ====================================================== */

/* Info-box överst (”Topp xxxx” + ”Last update”) */
.leaderboard-info {
    width: 90%;
    margin: 1rem auto;
    padding: 0.5rem 1rem;
    background-color: rgba(0, 0, 0, 0.6);
    border-radius: 0.25rem;
    text-align: left;
}

#leaderboard-count {
    font-family: 'Inter', sans-serif;
    color: #ffc107;
    font-size: 1.5rem;
    margin: 0;
    padding: 0.5rem 0;
    text-shadow: 0.125rem 0.125rem 0.25rem rgba(0, 0, 0, 0.7);
}

#last-update {
    font-family: 'Inter', sans-serif;
    color: #ffc107;
    font-size: 0.9rem;
    margin: 0;
    display: block;
    text-shadow: 0.0625rem 0.0625rem 0.125rem rgba(0, 0, 0, 0.7);
}

/* Leaderboardtabell */
#leaderboard-table {
    font-family: 'Inter', sans-serif;
    width: 90%;
    margin: 1.25rem auto;
    border-collapse: collapse;
    background-color: rgba(0, 0, 0, 0.7);
    box-shadow: 0 0.25rem 0.625rem rgba(0, 0, 0, 0.8);
}

    #leaderboard-table th,
    #leaderboard-table td {
        padding: 0.75rem 0.9375rem;
        border: 1px solid rgba(255, 255, 255, 0.2);
        text-align: left;
    }


    #leaderboard-table th {
        font-family: 'Inter', sans-serif;
        background-color: rgba(255, 193, 7, 0.8);
        font-size: 1.1rem;
    }
        /* Centrera rankkolumn */
        #leaderboard-table th:first-child,
        #leaderboard-table td:first-child {
            text-align: center;
        }

    #leaderboard-table th {
        background-color: rgba(255, 193, 7, 0.8);
        font-size: 1.1rem;
    }

    #leaderboard-table tbody tr:nth-child(even) {
        background-color: rgba(0, 0, 0, 0.6);
    }

    #leaderboard-table tbody tr:hover {
        background-color: rgba(255, 193, 7, 0.2);
    }

    #leaderboard-table a {
        color: inherit;
        text-decoration: none;
        transition: background-color 0.3s;
        cursor: pointer;
        padding: 0.25rem;
        border-radius: 0.25rem;
    }

        #leaderboard-table a:hover {
            background-color: rgba(255, 193, 7, 0.3);
        }

/* Wrapper för horisontell scroll på små skärmar */
.table-responsive {
    width: 100%;
    overflow-x: auto;
}

@media (max-width: 767px) {
    .table-responsive {
        padding: 0 10px;
    }
}

/* Dropdowns (gamemode, region, säsong) */
.filters select {
    background-color: rgba(0, 0, 0, 0.8);
    color: #fff;
    border: 1px solid rgba(255, 193, 7, 0.8);
    padding: 0.5rem 0.625rem;
    margin: 0.625rem;
    margin-left: 1.25rem;
    border-radius: 0.25rem;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

@media (max-width: 767px) {
    .filters select {
        margin: 0.4375rem;
        padding: 0.4375rem 0.5625rem;
    }
}



/* Paginering */
#pagination {
    text-align: center;
}

    #pagination button {
        background-color: rgba(255, 193, 7, 0.8);
        color: #000;
        border: none;
        padding: 0.5rem 0.75rem;
        margin: 0.3125rem;
        border-radius: 0.25rem;
        cursor: pointer;
        font-family: 'Inter', sans-serif;
        transition: background-color 0.3s;
    }

        #pagination button:hover {
            background-color: rgba(255, 193, 7, 1);
        }

        #pagination button.active {
            background-color: rgba(255, 193, 7, 1);
            font-weight: bold;
        }

    #pagination span {
        padding: 0.5rem 0.75rem;
        margin: 0.3125rem;
        color: #fff;
    }

/* Loading overlay över tabellen */
#leaderboard-container {
    transition: opacity 0.3s ease;
}

#loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    z-index: 10;
}

    #loading-overlay .spinner {
        width: 40px;
        height: 40px;
        border: 4px solid #ccc;
        border-top-color: #333;
        border-radius: 50%;
        animation: spin 1s linear infinite;
        margin-bottom: 20px;
    }

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

#loading-overlay p {
    color: #ffd80e;
    font-family: 'Inter', sans-serif;
    font-size: 1.2rem;
    font-weight: bold;
    text-align: center;
    background: rgba(0, 0, 0, 0.6);
    padding: 6px 14px;
    border-radius: 8px;
    box-shadow: 0 0 12px rgba(255, 215, 0, 0.6);
}

@keyframes blink-border {
    0%,100% {
        border-color: red;
    }

    50% {
        border-color: transparent;
    }
}

@media (max-width: 767px) and (orientation: portrait) {
    #leaderboard-table {
        width: 100%;
    }

        #leaderboard-table th, #leaderboard-table td {
            padding: 0.25rem 0.375rem;
            font-size: 0.7rem;
        }
}

/* Döljer ratingkolumn för vissa spellägen */
.hide-rating {
    display: none !important;
}
/* --- Klickhint för spelarnamn --- */
#leaderboard-table td a::after {
    content: " ↗";
    font-size: 0.8rem;
    color: rgba(255, 193, 7, 0.6);
    opacity: 0;
    transition: opacity 0.3s;
}

#leaderboard-table td a:hover::after {
    opacity: 1;
}

#leaderboard-table td a:hover {
    text-decoration: underline;
    color: #ffc107;
}

/* Gör hela raden klickbar-känsla */
#leaderboard-table tbody tr {
    cursor: pointer;
    transition: background-color 0.2s ease;
}

    #leaderboard-table tbody tr:hover {
        background-color: rgba(255, 193, 7, 0.2);
    }

/* --- Klick-hint ovanför leaderboard-tabellen --- */
#click-hint {
    display: inline-block;
    text-align: center;
    background: rgba(0, 0, 0, 0.55);
    padding: 8px 16px;
    margin: 0.5rem auto 1rem auto;
    border-radius: 8px;
    color: #ffc107;
    font-family: 'Inter', sans-serif;
    font-size: 1rem;
    font-weight: 500;
    text-shadow: 0 0 6px rgba(0, 0, 0, 0.9);
    backdrop-filter: blur(2px);
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.4);
    width: fit-content;
    opacity: 0.95;
    transition: transform 0.2s ease, opacity 0.3s ease;
}

    #click-hint:hover {
        opacity: 1;
        transform: scale(1.03);
    }


/* Premium-ikon i headern på index */
#premium-icon {
    font-size: 1.3rem;
    margin-left: 6px;
    text-decoration: none;
    color: gold;
    opacity: 0.9;
    transition: transform 0.2s ease, opacity 0.2s ease;
}

    #premium-icon:hover {
        transform: scale(1.2);
        opacity: 1;
    }


/* --- Avancerad sökning-panel --- */
.advanced-panel {
    width: 90%;
    margin: 1rem auto;
    padding: 1rem 1.25rem;
    background-color: rgba(0, 0, 0, 0.7);
    border: 1px solid rgba(255, 193, 7, 0.6);
    border-radius: 0.5rem;
    box-shadow: 0 0.25rem 0.5rem rgba(0, 0, 0, 0.8);
    font-family: 'Inter', sans-serif;
    color: #ffc107;
}

.adv-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 0.75rem;
}

    .adv-row label,
    .adv-row span {
        font-family: 'Inter', sans-serif;
        color: #ffc107;
    }

    /* Radio-knappar (matchar checkbox-stil) */
    .adv-row input[type="radio"] {
        appearance: none;
        width: 16px;
        height: 16px;
        border: 2px solid rgba(255, 193, 7, 0.7);
        border-radius: 50%;
        background-color: rgba(25, 25, 25, 0.9);
        cursor: pointer;
        transition: all 0.2s ease-in-out;
        position: relative;
    }

        .adv-row input[type="radio"]:checked::after {
            content: "";
            position: absolute;
            top: 50%;
            left: 50%;
            width: 8px;
            height: 8px;
            background-color: #ffc107;
            border-radius: 50%;
            transform: translate(-50%, -50%);
        }

/* --- Avancerad filterrad (Region, Game mode, Season) --- */
.adv-filters-row {
    display: flex;
    flex-wrap: nowrap; /* ❗ håll allt på en rad */
    align-items: center;
    gap: 0.75rem;
    overflow-x: auto; /* ✅ tillåt scroll om skärmen är för smal */
}

    /* Etiketterna */
    .adv-filters-row label {
        white-space: nowrap;
        font-family: 'Inter', sans-serif;
        color: #ffc107;
    }

    /* Alla selects */
    .adv-filters-row select {
        background-color: rgba(0, 0, 0, 0.8);
        color: #fff;
        border: 1px solid rgba(255, 193, 7, 0.8);
        padding: 0.4rem 0.6rem;
        border-radius: 0.25rem;
        font-family: 'Inter', sans-serif;
        cursor: pointer;
        max-height: 2.2rem;
    }

/* Individuella bredder för balans */
.adv-select-region {
    width: 90px;
    min-width: 70px;
}

.adv-select-gamemode {
    width: 150px;
    max-width: 180px;
}

.adv-select-season {
    width: 100px;
    min-width: 80px;
}

/* Mindre skärmar */
@media (max-width: 800px) {
    .adv-filters-row {
        flex-wrap: wrap; /* bryt snyggt på mobil */
        justify-content: flex-start;
    }

        .adv-filters-row select {
            flex: 1 1 100%;
            width: 100%;
            max-width: none;
        }
}

/* ================================
   FAVORITE STAR (Leaderboard)
   ================================ */

.favorite-star {
    font-size: 20px; /* större och mer klickvänlig */
    cursor: pointer;
    margin-left: 8px; /* lite mer spacing från spelarnamn */
    color: gold;
    opacity: 0.55; /* synlig även ofylld */
    text-shadow: 0 0 3px rgba(255, 215, 0, 0.6); /* svag glow-effekt */
    transition: opacity 0.2s ease, transform 0.15s ease;
}

    .favorite-star.filled {
        opacity: 1;
        text-shadow: 0 0 6px rgba(255, 215, 0, 0.9); /* starkare glow när fylld */
    }

    .favorite-star:hover {
        opacity: 0.9;
        transform: scale(1.25); /* tydlig "tryck på mig"-effekt */
    }

/* ================================
   FAVORITE MODAL (Login / Premium)
   ================================ */

.favorite-modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
}

    .favorite-modal.hidden {
        display: none;
    }

/* Backdrop – mörk bakgrund */
.favorite-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(3px);
}

/* Modalbox – själva rutan */
.favorite-modal-box {
    position: relative;
    background: #1e1e1e; /* matchar HSLeaderboard dark mode */
    padding: 24px 28px;
    border-radius: 10px;
    width: 90%;
    max-width: 380px;
    z-index: 3100;
    box-shadow: 0 0 12px rgba(0, 0, 0, 0.4);
    border: 1px solid rgba(255, 215, 0, 0.25); /* svag guld-kant */
    animation: favoriteModalFadeIn 0.18s ease-out;
}

    /* Titel */
    .favorite-modal-box h2 {
        margin-top: 0;
        margin-bottom: 12px;
        font-size: 20px;
        color: #ffc107;
        text-shadow: 0 0 4px rgba(255, 215, 0, 0.5);
    }

    /* Text */
    .favorite-modal-box p {
        font-size: 15px;
        line-height: 1.4;
        margin-bottom: 20px;
        color: #ffc107;
    }

/* Knapp-container */
.favorite-modal-buttons {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

/* Modal-knappar */
.favorite-modal-btn {
    padding: 8px 14px;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.15s ease;
    font-weight: 600;
}

/* Primär knapp */
#favorite-modal-btn-primary {
    background: #ffca28; /* guldig */
    color: #000;
}

    #favorite-modal-btn-primary:hover {
        background: #ffd95a;
        transform: scale(1.05);
    }

/* Sekundär knapp */
#favorite-modal-btn-secondary {
    background: #444;
    color: #fff;
}

    #favorite-modal-btn-secondary:hover {
        background: #555;
        transform: scale(1.05);
    }

/* Fade-in animation */
@keyframes favoriteModalFadeIn {
    from {
        opacity: 0;
        transform: translateY(-8px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}


/* === INDEX LAYOUT WRAPPER (VÄG A) ===========================================
   Mål: En enda index-lokal "ägare" av horisontell layout på desktop.
   - Stabil content-kolumn (centrerad)
   - CTA kan aldrig påverka sidans bredd (endast höjd)
   - Alla index-block blir width:100% relativt kolumnen
   Scope: Endast index via body.index-page
============================================================================= */

/* Wrapper som äger horisontell layout (mobil: flytande, desktop: fast kolumn) */
body.index-page .index-layout {
    box-sizing: border-box;
    margin-left: auto;
    margin-right: auto;
    width: 100%;
    padding-left: 20px;
    padding-right: 20px;
}

/* Desktop: fast kolumnbredd (med säker max så det aldrig overflowar smalare fönster) */
@media (min-width: 768px) {
    body.index-page .index-layout {
        width: 800px;
        max-width: calc(100% - 40px);
        padding-left: 0;
        padding-right: 0;
    }
}

/* Alla direkta block i kolumnen ska följa kolumnen (inte sätta egen bredd) */
body.index-page .index-layout > * {
    box-sizing: border-box;
    width: 100%;
}
/* Viktigt: gör att width:100% + padding INTE kan sticka ut (index-only) */
body.index-page .index-layout *,
body.index-page .index-layout *::before,
body.index-page .index-layout *::after {
    box-sizing: border-box;
}
/* Neutralisera index-blockens egna bredd-/centreringsansvar (endast index) */
body.index-page .leaderboard-info,
body.index-page #leaderboard-table,
body.index-page .filters,
body.index-page .search-container,
body.index-page #click-hint,
body.index-page .table-responsive,
body.index-page .pagination-container {
    width: 100%;
    max-width: none;
    margin-left: 0;
    margin-right: 0;
}

/* Neutralisera den "Gemensam vänsterjustering..."-regeln för index */
body.index-page main > .filters,
body.index-page main > .search-container,
body.index-page main > .leaderboard-info,
body.index-page main > #click-hint {
    width: 100%;
    max-width: none;
    margin-left: 0;
    margin-right: 0;
}
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* ======================================================
   Popular leaderboard links (index only)
   ====================================================== */

body.index-page .popular-leaderboards {
    margin: 0.35rem 0 0.85rem 0;
    padding: 0.75rem 0.9rem;
    background: rgba(0, 0, 0, 0.42);
    border: 1px solid rgba(255, 193, 7, 0.22);
    border-radius: 0.5rem;
    box-shadow: 0 0.2rem 0.6rem rgba(0, 0, 0, 0.22);
}

    body.index-page .popular-leaderboards h2 {
        margin: 0 0 0.55rem 0;
        font-family: 'Inter', sans-serif;
        font-size: 0.95rem;
        font-weight: 600;
        color: rgba(255, 193, 7, 0.92);
        text-shadow: 0 0 4px rgba(0, 0, 0, 0.65);
    }

    body.index-page .popular-leaderboards ul {
        list-style: none;
        margin: 0;
        padding: 0;
        display: flex;
        flex-wrap: wrap;
        gap: 0.45rem;
    }

    body.index-page .popular-leaderboards li {
        margin: 0;
        padding: 0;
    }

    body.index-page .popular-leaderboards a {
        display: inline-block;
        padding: 0.4rem 0.65rem;
        border-radius: 999px;
        background: rgba(255, 193, 7, 0.1);
        border: 1px solid rgba(255, 193, 7, 0.18);
        color: #f3f3f3;
        text-decoration: none;
        font-size: 0.9rem;
        line-height: 1.2;
        transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
    }

        body.index-page .popular-leaderboards a:hover {
            background: rgba(255, 193, 7, 0.18);
            border-color: rgba(255, 193, 7, 0.35);
            transform: translateY(-1px);
        }

@media (max-width: 600px) {
    body.index-page .popular-leaderboards {
        margin-top: 0.25rem;
        padding: 0.7rem 0.75rem;
    }

        body.index-page .popular-leaderboards h2 {
            font-size: 0.9rem;
            margin-bottom: 0.5rem;
        }

        body.index-page .popular-leaderboards ul {
            display: grid;
            grid-template-columns: 1fr 1fr;
            gap: 0.4rem;
        }

        body.index-page .popular-leaderboards a {
            display: block;
            text-align: center;
            font-size: 0.82rem;
            padding: 0.42rem 0.45rem;
        }
}