/* /web/static/css/leaderboard.css */

/* =========================================================
   LAYOUT & CONTAINERS
========================================================= */

/* Main wrapper to hold the leaderboard and the rank card side-by-side on desktop */
.main-layout {
    display: flex;
    flex-direction: column; /* Stacked by default (Mobile) */
    gap: 20px;
    max-width: 1400px;
    margin: 20px auto;
    padding: 0 15px;
}

/* Expansion for the large leaderboard container */
.container-large {
    max-width: 1200px !important;
    width: 95% !important;
}

/* Desktop View: Side-by-side logic */
@media (min-width: 1200px) {
    .main-layout {
        flex-direction: row;
        align-items: flex-start;
        gap: 30px; /* Mehr Abstand zwischen Tabelle und Panel */
    }

    .container-large {
        flex: 1;
        order: 1;
    }

    .personal-card-section {
        width: 550px; /* Hier wurde die Breite erhöht */
        flex-shrink: 0;
        order: 2;
        position: sticky;
        top: 20px;
    }
}

/* =========================================================
   LEADERBOARD TABLE STYLING
========================================================= */

table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0 10px; /* Space between rows */
    margin-top: 25px;
}

th {
    background-color: transparent;
    color: var(--accent-pink);
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: 15px;
    text-align: left;
    border-bottom: 2px solid #313244;
}

td {
    padding: 18px;
    background-color: #1e1e2e;
    color: var(--text-main);
    transition: background 0.2s;
}

/* Row Corner Smoothing */
tr td:first-child { border-radius: 12px 0 0 12px; border-left: 4px solid transparent; }
tr td:last-child { border-radius: 0 12px 12px 0; }

tr:hover td {
    background-color: #2a2a3d;
    color: var(--white);
}

/* Rank Highlighting (Top 3) */
.rank-1 td { border-left-color: #f9e2af; } /* Gold */
.rank-1 .rank-text { color: #f9e2af; font-size: 1.3em; text-shadow: 0 0 8px rgba(249, 226, 175, 0.4); }

.rank-2 td { border-left-color: #bac2de; } /* Silver */
.rank-3 td { border-left-color: #fab387; } /* Bronze */

/* User Identity Cell */
.user-cell {
    display: flex;
    align-items: center;
    gap: 15px;
    font-weight: 600;
}

.user-cell img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid var(--accent-pink);
    box-shadow: 0 0 10px rgba(244, 167, 187, 0.2);
}

/* =========================================================
   PERSONAL RANK CARD SECTION
========================================================= */

.personal-card-section {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.rank-card-preview {
    width: 100%;
    height: auto;
    aspect-ratio: 4 / 1;
    border-radius: 10px;
    border: 2px solid var(--accent-pink);
    object-fit: cover;
    margin: 15px 0;
    display: block;
}

/* Loading/Status Messages inside the card box */
.loading {
    color: var(--accent-blue);
    font-style: italic;
    padding: 20px;
}

/* =========================================================
   MODAL & IMAGE CROPPER
========================================================= */

.modal {
    display: flex;
    align-items: center;
    justify-content: center;
    position: fixed;
    top: 0; left: 0;
    width: 100vw; height: 100vh;
    background: rgba(0, 0, 0, 0.9);
    z-index: 9999;
}

.modal-content {
    background: var(--bg-panel);
    padding: 25px;
    border-radius: 15px;
    border: 1px solid var(--accent-pink);
    max-width: 95%;
    width: 500px;
}

.modal-btns {
    display: flex;
    gap: 15px;
    margin-top: 25px;
    justify-content: center;
}

/* Specific button overrides for the modal */
#saveCroppedBtn { background-color: #3ba55c; color: white; border: none; flex: 1; padding: 12px; border-radius: 8px; font-weight: bold; cursor: pointer; }
#cancelCropBtn { background-color: #ed4245; color: white; border: none; flex: 1; padding: 12px; border-radius: 8px; font-weight: bold; cursor: pointer; }

/* Adjusting the Croppie instance boundary */
.cr-boundary {
    border-radius: 10px;
    border: 1px solid #45475a;
    background-color: var(--bg-input);
}


/* =========================================================
   FLOATING TOAST NOTIFICATION (VORDERGRUND FIX)
========================================================= */
#messageBox {
    position: fixed !important;
    bottom: 25px !important;
    right: 25px !important;
    left: auto !important; /* Verhindert Strecken auf Mobile */
    top: auto !important;
    
    z-index: 999999 !important; /* Absoluter Vordergrund über allen Tabellen & Modals */
    
    width: calc(100% - 50px);
    max-width: 420px;
    padding: 16px 20px;
    border-radius: 10px;
    font-weight: 600;
    font-family: sans-serif;
    font-size: 0.95rem;
    line-height: 1.4;
    
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(8px); /* Schicker Milchglas-Effekt über der Tabelle */
    -webkit-backdrop-filter: blur(8px);
    
    animation: slideInToast 0.35s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    transition: opacity 0.2s ease;
}

/* Animation für ein smoothes Hereinfliegen von unten rechts */
@keyframes slideInToast {
    from {
        transform: translateY(50px) scale(0.95);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

/* Smartphone-Optimierung: Zentriert den Toast ganz unten auf kleinen Bildschirmen */
@media (max-width: 480px) {
    #messageBox {
        bottom: 15px !important;
        right: 15px !important;
        left: 15px !important;
        width: auto;
        max-width: none;
    }
}

/* =========================================================
   MOBILE ADJUSTMENTS (LEADERBOARD SPECIFIC)
========================================================= */

/* Macht die Tabellen-Bereiche horizontal scrollbar! (Super wichtig für Handys) */
#levelBoard, #songgameBoard, #countingBoard {
    overflow-x: auto;
    width: 100%;
    -webkit-overflow-scrolling: touch; /* Flüssiges Scrollen auf iOS */
    padding-bottom: 10px; /* Platz für den Scrollbalken */
}

@media (max-width: 768px) {
    .main-layout {
        padding: 0 10px;
    }

    h1 {
        font-size: 1.5rem;
        margin-bottom: 15px;
    }

    th, td {
        padding: 12px 10px;
        font-size: 0.85rem;
        white-space: nowrap; /* Verhindert hässliche Zeilenumbrüche in der Tabelle */
    }

    .user-cell img {
        width: 32px;
        height: 32px;
        border-width: 1px;
    }

    .rank-card-preview {
        aspect-ratio: auto;
        height: 120px; /* Etwas kompakter auf dem Handy */
    }

    .upload-controls {
        width: 100%;
    }

    #triggerUploadBtn {
        width: 100%;
        padding: 12px;
        font-size: 1rem;
    }
}