/* ==============================================================
   BASE CSS - COMMON STRUCTURE
   This file contains the layout and core styles shared across all themes.
   Themes only override variables and specific visual properties.
   ============================================================== */

* {
    box-sizing: border-box;
}

:root {
    /* DEFAULT VARIABLES (Fallback if not overridden) */
    --bg-color: #121212;
    --card-bg: #1e1e1e;
    --text-color: #e0e0e0;
    --text-muted: #a0a0a0;
    --primary-color: #00c3ff;
    --accent-color: #ff9500;
    --border-color: #333333;
    --success-color: #00e676;
    --danger-color: #ff1744;
    --font-main: 'Montserrat', 'Segoe UI', sans-serif;
    --font-heading: 'Russo One', 'Montserrat', sans-serif;
    --shadow-small: 0 4px 6px rgba(0, 0, 0, 0.3);
    --shadow-medium: 0 8px 16px rgba(0, 0, 0, 0.3);
}

body {
    font-family: var(--font-main);
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    margin: 0;
    padding: 0;
    padding-bottom: 40px;
    scroll-behavior: smooth;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

.container-sm {
    max-width: 800px;
}

.container-fluid {
    width: 100%;
    padding: 0 20px;
    max-width: 1800px;
    margin: 0 auto;
}

/* NAVIGATION */
.main-navbar {
    background-color: rgba(30, 30, 30, 0.85);
    /* Slightly transparent for glass effect */
    backdrop-filter: blur(12px);
    /* Glassmorphism */
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding: 10px 0;
    margin-bottom: 40px;
    position: sticky;
    top: 0;
    z-index: 1000;
    transition: background-color 0.3s;
}

.nav-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
    gap: 20px;
    flex-wrap: nowrap;
    /* Prevent ugly wrapping before breakpoint */
}

.nav-brand {
    font-family: var(--font-heading);
    font-size: 1.5em;
    text-decoration: none;
    background: linear-gradient(135deg, #fff 0%, var(--primary-color) 100%);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: 1px;
    white-space: nowrap;
}

.nav-menu {
    display: flex;
    gap: 5px;
    align-items: center;
    flex-wrap: wrap;
    /* Allow items to wrap on desktop if needed */
    justify-content: center;
}

/* Mobile-only nav title label inside the burger button (hidden on desktop) */
.nav-toggle-current-label {
    display: none;
}

.nav-controls {
    display: flex;
    align-items: center;
    gap: 5px;
    margin-left: auto;
    flex-shrink: 0;
    /* Keep controls visible */
}

/* Compact icon buttons for controls */
.nav-controls .nav-icon-btn,
.lang-dropdown .lang-btn {
    padding: 0;
    width: 34px;
    height: 34px;
    min-width: 34px;
    /* Fix for flex shrink */
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 0.9em;
    background: transparent;
    /* Ensure button background matches */
    line-height: 1;
    border: 1px solid transparent;
    /* Maintain border box sizing consistency */
}

.nav-controls .nav-icon-btn:hover,
.lang-dropdown .lang-btn:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.nav-controls .nav-icon-btn i,
.lang-dropdown .lang-btn span {
    font-size: 1.2em;
    /* Ensure icon is well sized */
}

.nav-link {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    padding: 8px 16px;
    border-radius: 50px;
    /* Pill shape */
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9em;
    border: 1px solid transparent;
    white-space: nowrap;
}

.nav-link:hover {
    color: white;
    background-color: rgba(255, 255, 255, 0.1);
    transform: translateY(-1px);
}

.nav-link.active {
    color: white;
    background-color: var(--primary-color);
    box-shadow: 0 4px 15px rgba(0, 195, 255, 0.3);
    font-weight: 600;
    border-color: rgba(255, 255, 255, 0.2);
}

/* Specific icons in nav */
.nav-link i {
    font-size: 1.1em;
}

/* RESPONSIVE PODIUMS */
@media (max-width: 600px) {
    .podium-display {
        height: auto !important;
        align-items: flex-end !important;
        transform: scale(0.9);
        /* Slight scale down */
        transform-origin: bottom center;
        margin-top: 10px !important;
    }

    .podium-step {
        width: 32% !important;
        /* Ensure they fit side by side */
        margin: 0 2px !important;
    }

    .podium-step img {
        width: 50px !important;
        height: 50px !important;
    }

    .podium-step.step-1 img {
        width: 70px !important;
        height: 70px !important;
    }

    .podium-step a {
        font-size: 0.8em !important;
    }

    .podium-step div[style*="font-size: 1.1em"],
    .podium-step div[style*="font-size: 0.9em"] {
        font-size: 0.8em !important;
    }
}

/* ENHANCED PODIUM CARDS */
.podium-card {
    position: relative;
    overflow: hidden;
    border-top: 4px solid transparent;
    /* Colored via inline style */
    transition: transform 0.3s, box-shadow 0.3s;
    background: var(--card-bg);
    border-radius: 12px;
    box-shadow: var(--shadow-medium);
    border: 1px solid var(--border-color);
    /* Fallback border */
    flex: 1 1 350px;
    min-width: 350px;
    display: flex;
    flex-direction: column;
}

.podium-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
}

.podium-header-banner {
    padding: 15px;
    background: linear-gradient(180deg, rgba(255, 255, 255, 0.05) 0%, transparent 100%);
    text-align: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.podium-watermark {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%) rotate(-15deg);
    font-size: 150px;
    opacity: 0.03;
    pointer-events: none;
    z-index: 0;
}

.podium-content-wrapper {
    position: relative;
    z-index: 1;
    padding: 20px;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

/* RESPONSIVE NAVIGATION */
.nav-toggle-btn {
    display: none;
    background: transparent;
    border: none;
    color: var(--text-color);
    font-size: 1.4em;
    cursor: pointer;
    padding: 5px 10px;
    margin-right: 15px;
    /* Espace après le burger */
    transition: transform 0.2s;
}

.nav-toggle-btn:hover {
    color: var(--primary-color);
    transform: scale(1.1);
}

@media (max-width: 1150px) {
    .nav-toggle-btn {
        order: 2;
        /* Burger après le logo (logo masqué sur mobile) */
        margin-left: 0;
    }

    .nav-container {
        /* Flex pour tout aligner */
        display: flex;
        flex-wrap: wrap;
        align-items: center;
        padding: 5px 8px;
        /* Réduction espacement global */
    }

    /* Brand hidden on mobile — burger + current page title take its place */
    .nav-brand {
        display: none;
    }

    /* Burger button on mobile: now also displays the current page label
       inline, so the whole button is one unified menu trigger */
    .nav-toggle-btn {
        display: flex;
        align-items: center;
        gap: 10px;
        padding: 6px 12px;
        margin-right: auto;
        /* pushes nav-controls to the right edge */
        border-radius: 8px;
        max-width: calc(100vw - 130px);
        /* leaves room for the right-side controls */
        min-width: 0;
        transition: background-color 0.15s ease;
    }

    .nav-toggle-btn:hover,
    .nav-toggle-btn:active {
        background: rgba(255, 255, 255, 0.06);
        transform: none;
        /* override the default scale */
    }

    .nav-toggle-btn > i.fa-bars,
    .nav-toggle-btn > i.fa-xmark {
        flex-shrink: 0;
        font-size: 1.2em;
    }

    .nav-toggle-current-label {
        display: flex;
        align-items: center;
        gap: 8px;
        min-width: 0;
        color: var(--text-color);
        font-family: var(--font-heading);
        font-size: 0.85em;
        text-transform: uppercase;
        letter-spacing: 1px;
        overflow: hidden;
    }

    .nav-toggle-current-icon {
        color: var(--primary-color);
        font-size: 0.9em;
        flex-shrink: 0;
    }

    .nav-toggle-current-text {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        min-width: 0;
    }

    /* Controls stay on the right */
    .nav-controls {
        display: flex;
        align-items: center;
        order: 3;
    }

    /* === MOBILE NAV: simple dropdown below the navbar === */
    /* No drawer, no overlay, no scroll lock — just the menu list flowing under the bar */
    .nav-menu {
        display: none;
        flex-direction: column;
        align-items: stretch;
        position: absolute;
        top: 100%;
        left: 0;
        right: 0;
        margin: 0;
        padding: 4px 0;
        background: rgba(30, 30, 30, 0.96);
        backdrop-filter: blur(14px);
        -webkit-backdrop-filter: blur(14px);
        border: none;
        border-bottom: 1px solid rgba(255, 255, 255, 0.06);
        box-shadow: none;
        gap: 0;
        z-index: 999;
        overflow: visible;
        transform: none;
        transition: none;
        animation: none;
    }

    .nav-menu.active {
        display: flex;
    }

    /* No body scroll lock — the menu is a simple dropdown, page can scroll behind it */

    /* Nav links inside the drawer — discrete, no heavy accent on active */
    .nav-link {
        width: 100%;
        white-space: nowrap;
        justify-content: flex-start;
        padding: 12px 16px;
        border-radius: 0;
        margin: 0;
        background: transparent;
        color: var(--text-muted);
        font-size: 0.95em;
        flex-shrink: 0;
        min-height: 46px;
        gap: 14px;
        border: none;
        transition: background-color 0.15s ease, color 0.15s ease;
    }

    .nav-link i {
        width: 20px;
        text-align: center;
        font-size: 0.95em;
        opacity: 0.7;
        color: inherit;
    }

    .nav-link:hover {
        background-color: rgba(255, 255, 255, 0.04);
        color: var(--text-color);
        transform: none;
    }

    .nav-link.active {
        background-color: rgba(0, 195, 255, 0.12);
        color: var(--primary-color);
        font-weight: 600;
        box-shadow: inset 3px 0 0 var(--primary-color);
    }

    .nav-link.active i {
        opacity: 1;
        color: var(--primary-color);
    }

    .nav-link.active:hover {
        background-color: rgba(0, 195, 255, 0.18);
        color: var(--primary-color);
    }

    .nav-link:active {
        background-color: rgba(255, 255, 255, 0.06);
    }

    /* Adjust dropdowns for mobile */
    .lang-dropdown .lang-btn {
        padding: 5px;
    }

    .main-navbar {
        padding: 5px 0;
    }

    @keyframes fadeIn {
        from {
            opacity: 0;
            transform: translateY(-5px);
        }

        to {
            opacity: 1;
            transform: translateY(0);
        }
    }
}

/* TROPHIES / BADGES */
.trophy-container {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    margin-top: 20px;
    width: 100%;
}

.trophy-item {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 8px 15px;
    border-radius: 50px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 0.9em;
    transition: all 0.2s;
    cursor: pointer;
}

.trophy-item:hover {
    transform: translateY(-2px);
    background: rgba(255, 255, 255, 0.1);
    border-color: var(--primary-color);
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.3);
}

.trophy-icon {
    font-size: 1.2em;
}

.trophy-info {
    display: flex;
    flex-direction: column;
    line-height: 1.1;
    text-align: left;
}

.trophy-title {
    font-weight: bold;
    font-size: 0.9em;
    color: #fff;
}

.trophy-val {
    font-size: 0.75em;
    color: var(--text-muted);
}

.mini-badge {
    font-size: 1.1em;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    cursor: pointer;
    flex-shrink: 0;
    margin-left: 3px;
    opacity: 0.9;
}

.mini-badge:hover {
    transform: scale(1.3);
    opacity: 1;
    text-shadow: 0 0 10px currentColor;
    /* Glow effect using icon color */
    z-index: 10;
}

/* RANK & RACES COUNT STYLES */
.pos-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 4px 12px;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.95em;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-color);
    min-width: 30px;
}

.pos-badge.pos-1 {
    border-color: #FFD700;
    color: #FFD700;
    background: rgba(255, 215, 0, 0.15);
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
    border-width: 1px;
}

.pos-badge.pos-1 i {
    color: #FFD700;
}

.pos-badge.pos-2 {
    border-color: #C0C0C0;
    color: #C0C0C0;
    background: rgba(192, 192, 192, 0.15);
    box-shadow: 0 0 5px rgba(192, 192, 192, 0.2);
}

.pos-badge.pos-2 i {
    color: #C0C0C0;
}

.pos-badge.pos-3 {
    border-color: #CD7F32;
    color: #CD7F32;
    background: rgba(205, 127, 50, 0.15);
    box-shadow: 0 0 5px rgba(205, 127, 50, 0.2);
}

.pos-badge.pos-3 i {
    color: #CD7F32;
}

/* Ensure hover on clickable badge doesn't break style */
a.pos-badge:hover {
    filter: brightness(1.2);
    transform: translateY(-1px);
    transition: all 0.2s;
    text-decoration: none;
}

.rank-circle {
    width: 28px;
    height: 28px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-muted);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
    font-size: 0.9em;
}

.rank-circle.rank-1 {
    border-color: #FFD700;
    color: #FFD700;
    background: rgba(255, 215, 0, 0.1);
    box-shadow: 0 0 10px rgba(255, 215, 0, 0.3);
    font-size: 1.1em;
    border-width: 2px;
}

.rank-circle.rank-2 {
    border-color: #C0C0C0;
    color: #C0C0C0;
    background: rgba(192, 192, 192, 0.1);
    box-shadow: 0 0 5px rgba(192, 192, 192, 0.2);
}

.rank-circle.rank-3 {
    border-color: #CD7F32;
    color: #CD7F32;
    background: rgba(205, 127, 50, 0.1);
    box-shadow: 0 0 5px rgba(205, 127, 50, 0.2);
}

/* ROW HIGHLIGHTS FOR TOP 3 */
.row-rank-1 {
    background: linear-gradient(90deg, rgba(255, 215, 0, 0.08) 0%, transparent 100%);
}

.row-rank-1 td:first-child {
    border-left: 3px solid #FFD700;
}

.row-rank-2 {
    background: linear-gradient(90deg, rgba(192, 192, 192, 0.05) 0%, transparent 100%);
}

.row-rank-2 td:first-child {
    border-left: 3px solid #C0C0C0;
}

.row-rank-3 {
    background: linear-gradient(90deg, rgba(205, 127, 50, 0.05) 0%, transparent 100%);
}

.row-rank-3 td:first-child {
    border-left: 3px solid #CD7F32;
}

.races-count-badge {
    display: inline-block;
    font-weight: 600;
    color: var(--text-color);
    background: transparent;
    border: 1px solid rgba(255, 255, 255, 0.15);
    padding: 2px 10px;
    border-radius: 12px;
    font-size: 0.85em;
    min-width: 30px;
    text-align: center;
}

/* TYPOGRAPHY */
h1 {
    text-align: center;
    color: var(--primary-color);
    margin-bottom: 40px;
    font-family: var(--font-heading);
    font-size: 3em;
    text-transform: uppercase;
    letter-spacing: 2px;
}

h2 {
    font-family: var(--font-heading);
    color: var(--text-color);
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 10px;
    display: inline-block;
    margin-top: 40px;
}

/* CARDS */
.race-card,
.history-card,
.chart-container,
.performer-card,
.stat-card {
    background-color: var(--card-bg);
    border-radius: 12px;
    box-shadow: var(--shadow-medium);
    margin-bottom: 30px;
    overflow: hidden;
    transition: transform 0.3s, box-shadow 0.3s;
    border: 1px solid var(--border-color);
}

.chart-container {
    position: relative;
    height: 400px;
    /* Default height */
    padding: 15px;
}

@media (max-width: 768px) {
    .chart-container {
        height: 300px;
        /* Smaller height on mobile */
    }
}

.race-card:hover,
.performer-card:hover,
.stat-card:hover {
    transform: translateY(-4px);
    border-color: var(--primary-color);
}

/* GRIDS */
.top-performers-grid,
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 15px;
    margin-bottom: 40px;
}

/* TABLES */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    /* Smooth scroll on iOS */
    margin-bottom: 20px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px;
    /* Force min width to trigger scroll */
}

th,
td {
    padding: 12px;
    /* Slightly reduced padding */
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

th {
    font-weight: 700;
    color: var(--primary-color);
    text-transform: uppercase;
    font-size: 0.85em;
    white-space: nowrap;
    /* Prevent headers from wrapping too much */
}

/* STYLES FOR UNRANKED PLAYERS */
tr.is-unranked {
    opacity: 0.6;
}

tr.is-unranked:hover {
    opacity: 1;
}

.unranked-separator td {
    border-bottom: 1px solid var(--border-color);
    border-top: 1px solid var(--border-color);
}

/* ==============================================================
   UTILITIES
   ============================================================== */

/* COLORS */
.text-primary {
    color: var(--primary-color) !important;
}

.text-accent {
    color: var(--accent-color) !important;
}

.text-success {
    color: var(--success-color) !important;
}

.text-danger {
    color: var(--danger-color) !important;
}

.text-muted {
    color: var(--text-muted) !important;
}

.text-white {
    color: white !important;
}

.bg-danger-soft {
    background-color: rgba(255, 23, 68, 0.1);
}

.bg-success-soft {
    background-color: rgba(0, 230, 118, 0.1);
}

.bg-accent-soft {
    background-color: rgba(255, 149, 0, 0.1);
}

/* LAYOUT & SPACING */
.d-flex {
    display: flex;
}

.flex-column {
    flex-direction: column;
}

.align-center {
    align-items: center;
}

.justify-center {
    justify-content: center;
}

.justify-between {
    justify-content: space-between;
}

.justify-end {
    justify-content: flex-end;
}

.gap-5 {
    gap: 5px;
}

.gap-10 {
    gap: 10px;
}

.gap-15 {
    gap: 15px;
}

.gap-20 {
    gap: 20px;
}

.m-0 {
    margin: 0;
}

.mt-0 {
    margin-top: 0;
}

.mb-0 {
    margin-bottom: 0;
}

.mt-10 {
    margin-top: 10px;
}

.mb-10 {
    margin-bottom: 10px;
}

.mt-20 {
    margin-top: 20px;
}

.mb-20 {
    margin-bottom: 20px;
}

.p-10 {
    padding: 10px;
}

.p-15 {
    padding: 15px;
}

.p-20 {
    padding: 20px;
}

.p-30 {
    padding: 30px;
}

.w-100 {
    width: 100%;
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.cursor-pointer {
    cursor: pointer;
}

/* PAGE HEADER (Standardized) */
.page-header {
    margin-bottom: 30px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 15px;
}

.profile-header {
    /* Legacy alias, merged into similar style if needed, but keeping separate for specific gradient backgrounds if defined elsewhere */
    margin-bottom: 30px;
}

.page-title,
.profile-name {
    margin: 0;
    font-family: var(--font-heading);
    text-transform: uppercase;
    font-size: 2em;
    color: var(--text-color);
    letter-spacing: 1px;
}

.page-title i,
.profile-name i {
    color: var(--primary-color);
    margin-right: 10px;
}

/* FLOATING NAVIGATION (from competitor.php) */
.nav-floating {
    position: fixed;
    top: 50%;
    transform: translateY(-50%);
    width: 140px;
    height: 160px;
    background: rgba(0, 0, 0, 0.6);
    color: rgba(255, 255, 255, 0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    font-size: 2em;
    text-decoration: none;
    border-radius: 12px;
    transition: all 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275);
    z-index: 100;
    backdrop-filter: blur(5px);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.nav-floating:hover {
    background: var(--primary-color);
    color: #000;
    width: 90px;
    box-shadow: 0 0 20px var(--primary-color);
    border-color: transparent;
}

.nav-prev {
    left: 0;
    border-radius: 0 12px 12px 0;
    border-left: none;
    padding-left: 5px;
}

.nav-next {
    right: 0;
    border-radius: 12px 0 0 12px;
    border-right: none;
    padding-right: 5px;
}

.nav-info {
    font-size: 0.4em;
    display: flex;
    flex-direction: column;
    align-items: center;
    opacity: 1;
    transform: none;
    margin-top: 10px;
    font-weight: bold;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
    text-align: center;
    width: 100%;
}

.nav-details {
    margin-top: 8px;
    font-size: 0.9em;
    font-weight: normal;
    white-space: normal;
    line-height: 1.3;
    padding: 0 5px;
}

/* Mobile Responsive for Floating Nav */
@media (max-width: 768px) {
    .nav-floating {
        width: 40px;
        height: 80px;
        font-size: 1.5em;
        top: auto;
        bottom: 20px;
        transform: none;
        background: rgba(0, 0, 0, 0.8);
    }

    .nav-prev {
        left: 0;
        width: 100px;
        height: 100px;
    }

    .nav-next {
        right: 0;
        width: 100px;
        height: 100px;
    }

    .nav-info {
        font-size: 0.3em;
    }

    .nav-details {
        display: none;
    }
}

/* UTILS */
.error-message {
    background-color: rgba(255, 23, 68, 0.1);
    color: var(--danger-color);
    padding: 15px;
    border-radius: 8px;
    border: 1px solid var(--danger-color);
    margin-bottom: 20px;
    text-align: center;
}

.notice {
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 20px;
    border: 1px solid;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.95em;
}

.notice-warning {
    background-color: rgba(255, 149, 0, 0.1);
    color: var(--accent-color);
    border-color: var(--accent-color);
}

.notice-danger {
    background-color: rgba(255, 23, 68, 0.1);
    color: var(--danger-color);
    border-color: var(--danger-color);
}

.notice i {
    margin-right: 10px;
    font-size: 1.2em;
}

/* TIMELINE (Horizontal) */
.timeline-section {
    position: relative;
    padding: 20px 0;
    margin: 40px 0;
    overflow-x: auto;
    -ms-overflow-style: none;
    scrollbar-width: none;
}

.timeline-section::-webkit-scrollbar {
    display: none;
}

.timeline-container {
    display: flex;
    align-items: flex-start;
    padding: 0 40px;
    min-width: max-content;
    position: relative;
}

.timeline-line {
    position: absolute;
    top: 50px;
    left: 0;
    width: 100%;
    height: 4px;
    background: var(--border-color);
    /* Default */
    z-index: 1;
}

.timeline-item {
    position: relative;
    width: 220px;
    margin-right: 40px;
    z-index: 2;
    transition: transform 0.3s;
}

.timeline-marker {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    margin: 40px auto 20px;
    position: relative;
    z-index: 2;
    background: var(--bg-color);
    border: 3px solid var(--primary-color);
}

.timeline-date {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.8em;
    font-weight: bold;
    text-align: center;
    background: var(--card-bg);
    border: 1px solid var(--border-color);
}

.timeline-content {
    background: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    padding: 15px;
    text-align: center;
    display: block;
    color: inherit;
    text-decoration: none;
}

/* RESPONSIVE */
@media (max-width: 768px) {
    .nav-container {
        flex-wrap: nowrap;
        gap: 5px;
        padding: 5px 8px;
    }

    .nav-brand {
        font-size: 1.1em;
    }

    .nav-toggle-btn {
        margin-left: 5px;
        margin-right: auto;
        padding: 5px 8px;
    }

    .nav-menu {
        flex-wrap: nowrap;
        justify-content: flex-start;
    }
}

/* LANGUAGE & THEME DROPDOWN */
.lang-dropdown {
    position: relative;
    display: inline-block;
    margin-left: 15px;
}

.lang-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    transition: color 0.2s;
    font-family: var(--font-main);
    font-size: 1rem;
}

.lang-btn:hover {
    color: var(--primary-color);
}

.lang-content {
    display: none;
    position: absolute;
    right: 0;
    top: 100%;
    background-color: var(--card-bg);
    min-width: 160px;
    box-shadow: var(--shadow-medium);
    z-index: 2000;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    overflow: hidden;
}


.lang-item {
    color: var(--text-color);
    padding: 12px 16px;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background-color 0.2s;
}

.lang-item:hover {
    background-color: rgba(255, 255, 255, 0.05);
}

.lang-item.active {
    color: var(--primary-color);
    font-weight: bold;
    background-color: rgba(0, 195, 255, 0.1);
}

/* RACE LIST STYLES (from races.php) */
.race-list {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.race-list-item {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    justify-content: flex-start;
    background-color: var(--card-bg);
    background-image: linear-gradient(145deg, var(--card-bg), #252525);
    border: 1px solid var(--border-color);
    border-left: 4px solid transparent;
    /* Prépare la bordure gauche */
    border-radius: 12px;
    padding: 25px;
    text-decoration: none;
    color: var(--text-color);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    box-shadow: var(--shadow-small);
    position: relative;
    overflow: hidden;
    animation: fadeInUp 0.5s ease-out forwards;
    opacity: 0;
    /* Pour l'animation */
}

/* Stagger animation for items */
.race-list-item:nth-child(1) {
    animation-delay: 0.1s;
}

.race-list-item:nth-child(2) {
    animation-delay: 0.2s;
}

.race-list-item:nth-child(3) {
    animation-delay: 0.3s;
}

.race-list-item:nth-child(4) {
    animation-delay: 0.4s;
}

.race-list-item:nth-child(5) {
    animation-delay: 0.5s;
}

.race-list-item:nth-child(n+6) {
    animation-delay: 0.6s;
}

.race-list-item:hover {
    transform: translateY(-5px);
    border-left-color: var(--primary-color);
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.4);
    border-top-color: rgba(255, 255, 255, 0.1);
}

/* Effet de lueur au survol */
.race-list-item::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(to right, transparent 0%, rgba(255, 255, 255, 0.03) 50%, transparent 100%);
    transform: skewX(-20deg) translateX(-150%);
    transition: transform 0.5s;
    pointer-events: none;
}

.race-list-item:hover::after {
    transform: skewX(-20deg) translateX(150%);
}

.race-item-logo {
    height: 120px;
    width: auto;
    border-radius: 8px;
    object-fit: cover;
    flex-shrink: 0;
    box-shadow: 0 4px 10px rgba(0,0,0,0.4);
}

.race-item-logo-placeholder {
    width: 120px;
    height: 120px;
    border-radius: 8px;
    border: 2px dashed rgba(255,255,255,0.1);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0,0,0,0.2);
}

.race-item-body {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    position: relative;
    z-index: 1;
}

.race-item-main {
    flex: 1;
    min-width: 0;
    z-index: 1;
}

.race-item-title {
    font-family: var(--font-heading);
    font-size: 1.4em;
    color: white;
    margin-bottom: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: color 0.3s;
    text-align: left;
}

.race-list-item:hover .race-item-title {
    color: var(--primary-color);
    text-shadow: 0 0 10px rgba(0, 195, 255, 0.4);
}

.race-item-meta {
    font-size: 0.95em;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    gap: 2px;
    align-items: flex-start;
}

.race-item-meta i {
    color: var(--primary-color);
    opacity: 0.8;
}

.race-item-stats {
    background: rgba(255, 149, 0, 0.1);
    padding: 10px 20px;
    border-radius: 30px;
    font-weight: 700;
    color: var(--accent-color);
    border: 1px solid rgba(255, 149, 0, 0.3);
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 1;
    transition: all 0.3s;
}

.race-list-item:hover .race-item-stats {
    background: rgba(255, 149, 0, 0.2);
    border-color: var(--accent-color);
    box-shadow: 0 0 10px rgba(255, 149, 0, 0.2);
    transform: scale(1.05);
}

.race-item-stats i {
    font-size: 1.1em;
}

@media (max-width: 768px) {
    .race-list-item {
        flex-direction: column;
        align-items: stretch;
        gap: 6px;
    }

    .race-item-main {
        flex: 1;
        min-width: 0;
        overflow: hidden;
    }

    .race-item-title {
        white-space: normal;
        overflow: visible;
        text-overflow: unset;
        word-break: break-word;
    }

    .race-item-stats {
        flex-shrink: 0;
        margin-right: 0 !important;
    }
}

/* PODIUM STYLES (from index.php) */
.podium-container {
    display: flex;
    justify-content: center;
    align-items: flex-end;
    gap: 15px;
    margin: 40px 0 60px 0;
    min-height: 250px;
}

.podium-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    width: 200px;
    transition: transform 0.3s;
    position: relative;
    box-shadow: var(--shadow-medium);
}

.podium-item:hover {
    transform: translateY(-10px);
    border-color: var(--primary-color);
}

/* 1st Place */
.podium-item.rank-1 {
    height: 280px;
    order: 2;
    background: linear-gradient(to bottom, rgba(255, 215, 0, 0.1), var(--card-bg));
    border-color: #ffd700;
    z-index: 2;
}

.podium-item.rank-1 .podium-rank-badge {
    color: #ffd700;
    font-size: 2.5em;
    text-shadow: 0 0 15px rgba(255, 215, 0, 0.5);
}

/* 2nd Place */
.podium-item.rank-2 {
    height: 240px;
    order: 1;
    border-color: #c0c0c0;
}

.podium-item.rank-2 .podium-rank-badge {
    color: #c0c0c0;
    font-size: 2em;
}

/* 3rd Place */
.podium-item.rank-3 {
    height: 210px;
    order: 3;
    border-color: #cd7f32;
}

.podium-item.rank-3 .podium-rank-badge {
    color: #cd7f32;
    font-size: 2em;
}

.podium-rank-badge {
    margin-bottom: 15px;
    font-family: var(--font-heading);
}

.podium-name {
    font-weight: 700;
    font-size: 1.1em;
    margin-bottom: 5px;
    color: var(--text-color);
}

.podium-nick {
    color: var(--primary-color);
    font-size: 0.9em;
    margin-bottom: 15px;
}

.podium-elo {
    font-family: var(--font-heading);
    font-size: 1.8em;
    color: var(--text-color);
}

.podium-label {
    font-size: 0.8em;
    color: var(--text-muted);
    text-transform: uppercase;
}

/* ==============================================================
   ADMIN DASHBOARD (Harmonized)
   Shared across all pages containing admin/config tools.
   ============================================================== */
.admin-tabs-container {
    background: rgba(45, 45, 45, 0.4);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    margin-bottom: 25px;
}

.admin-tab-header {
    opacity: 0.7;
    transition: all 0.2s;
    user-select: none;
    border-bottom: 3px solid transparent;
}

.admin-tab-header:hover {
    opacity: 1;
    background: rgba(255, 255, 255, 0.05);
}

.admin-tab-header.active {
    opacity: 1;
}

/* Tab Colors */
.admin-tab-header.text-primary.active {
    border-bottom-color: var(--primary-color);
}

.admin-tab-header.text-danger.active {
    border-bottom-color: var(--danger-color);
}

.admin-tab-header.text-success.active {
    border-bottom-color: var(--success-color);
}

.admin-tab-header.text-accent.active {
    border-bottom-color: var(--accent-color);
}

.admin-tab-header.active:not(.text-primary):not(.text-danger):not(.text-success):not(.text-accent) {
    border-bottom-color: #fff;
}

.admin-tab-content {
    transition: all 0.3s ease;
}

.admin-info-badge {
    background: rgba(255, 149, 0, 0.15);
    color: var(--accent-color);
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 0.85em;
    border: 1px solid rgba(255, 149, 0, 0.3);
    display: inline-flex;
    align-items: center;
    gap: 5px;
}

/* LEGACY ALIASES (Keep temporarily if needed, but discouraged) */
.admin-panel {
    padding: 15px;
}

/* ==============================================================
   MOBILE RESPONSIVE (Global)
   Applied to all pages for smartphone optimization.
   ============================================================== */

/* Utility: hide on mobile */
@media (max-width: 768px) {
    .hide-mobile {
        display: none !important;
    }
}

@media (max-width: 768px) {

    /* --- TYPOGRAPHY --- */
    h1 {
        font-size: 1.6em;
        margin-bottom: 20px;
        letter-spacing: 0.5px;
    }

    h2 {
        font-size: 1.1em;
        margin-top: 20px;
    }

    /* --- CONTAINERS (tighter side padding so cards reach closer to edges) --- */
    .container {
        padding: 0 6px;
    }

    .container-fluid {
        padding: 0 4px;
    }

    /* --- TABLES (Critical for readability) --- */
    table {
        min-width: 420px;
        font-size: 0.85em;
    }

    th,
    td {
        padding: 8px 6px;
    }

    th {
        font-size: 0.75em;
    }

    .table-responsive {
        border-radius: 6px;
        margin-bottom: 15px;
    }

    /* Smaller position badges in tables */
    .pos-badge {
        padding: 3px 8px;
        font-size: 0.85em;
        min-width: 24px;
    }

    .rank-circle {
        width: 24px;
        height: 24px;
        font-size: 0.8em;
    }

    /* Competitor names more compact */
    .competitor-name {
        font-size: 0.9em;
    }

    .competitor-nick {
        display: none;
    }

    /* ELO change badges */
    .elo-change {
        font-size: 0.85em;
    }

    .races-count-badge {
        font-size: 0.75em;
        padding: 1px 6px;
    }

    /* --- CARDS: tighter outer margins on mobile --- */
    .race-card,
    .history-card,
    .chart-container,
    .performer-card,
    .stat-card,
    .podium-card {
        margin-bottom: 10px;
        margin-left: 0;
        margin-right: 0;
        border-radius: 8px;
    }

    /* Race list items: edge-to-edge cards too */
    .race-list-item {
        margin-left: 0;
        margin-right: 0;
    }

    .chart-container {
        height: 250px;
        padding: 10px;
    }

    /* Disable hover lift on mobile (prevents sticky hover on touch) */
    .race-card:hover,
    .performer-card:hover,
    .stat-card:hover {
        transform: none;
    }

    /* --- PODIUM CARDS (from render_podium_card) --- */
    .race-card[style*="flex: 1 1 350px"] {
        min-width: 100% !important;
        flex-basis: 100% !important;
    }

    /* --- PODIUM CONTAINER (index.php) --- */
    .podium-container {
        gap: 8px;
        margin: 20px 0 30px 0;
        min-height: 180px;
    }

    .podium-item {
        width: 110px;
        padding: 12px 8px;
    }

    .podium-item.rank-1 {
        height: 200px;
    }

    .podium-item.rank-2 {
        height: 170px;
    }

    .podium-item.rank-3 {
        height: 150px;
    }

    .podium-name {
        font-size: 0.85em;
    }

    .podium-elo {
        font-size: 1.3em;
    }

    /* --- TROPHIES / BADGES --- */
    .trophy-container {
        gap: 6px;
        margin-top: 10px;
    }

    .trophy-item {
        padding: 6px 10px;
        font-size: 0.8em;
        gap: 6px;
    }

    .trophy-icon {
        font-size: 1em;
    }

    .trophy-title {
        font-size: 0.8em;
    }

    .trophy-val {
        font-size: 0.7em;
    }

    .mini-badge {
        font-size: 0.9em;
    }

    /* --- RACE LIST (races.php) --- */
    .race-list-item {
        padding: 10px 12px;
        border-radius: 8px;
        gap: 6px;
    }

    .race-item-body {
        gap: 8px;
    }

    .race-item-logo,
    .race-item-logo-placeholder {
        height: 80px;
        width: auto;
        min-width: 80px;
    }

    .race-item-title {
        font-size: 0.95em;
        margin-bottom: 2px;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .race-item-meta {
        font-size: 0.78em;
        gap: 3px;
    }

    .race-item-stats {
        padding: 3px 8px;
        font-size: 0.72em;
        border-radius: 20px;
        gap: 4px;
    }

    .race-item-stats i {
        font-size: 0.9em;
    }

    .race-participants-label {
        display: none;
    }

    /* --- TOP PERFORMERS GRID --- */
    .top-performers-grid,
    .stats-grid {
        grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
        gap: 10px;
    }

    /* --- PAGE HEADER --- */
    .page-header {
        margin-bottom: 15px;
        padding-bottom: 10px;
    }

    .page-title,
    .profile-name {
        font-size: 1.4em;
    }

    /* --- FLOATING NAV (competitor prev/next) --- */
    .nav-floating {
        width: 36px;
        height: 70px;
        font-size: 1.2em;
    }

    .nav-prev {
        width: 36px;
        height: 70px;
    }

    .nav-next {
        width: 36px;
        height: 70px;
    }

    .nav-info {
        font-size: 0.25em;
    }

    /* --- ADMIN TABS (more compact) --- */
    .admin-tabs-container {
        border-radius: 8px;
        margin-bottom: 15px;
    }

    .admin-tab-header {
        font-size: 0.85em;
    }

    .admin-tab-header strong {
        display: none;
    }

    /* --- TIMELINE (horizontal scroll already works, just tighter) --- */
    .timeline-item {
        width: 160px;
        margin-right: 20px;
    }

    .timeline-content {
        padding: 10px;
        font-size: 0.85em;
    }

    /* --- MISC UTILITIES --- */
    .p-20 {
        padding: 12px;
    }

    .p-30 {
        padding: 15px;
    }

    .mb-20 {
        margin-bottom: 12px;
    }

    .gap-20 {
        gap: 12px;
    }

    /* Segmented control (leaderboard tabs) */
    .segmented-control {
        flex-wrap: wrap;
        width: 100%;
    }

    .segmented-control label {
        font-size: 0.85em;
        padding: 6px 12px;
    }

    /* View tabs (Officiel / Tous) - leaderboard.php */
    .view-tabs-container .segmented-control {
        width: 100%;
        display: flex;
    }

    .view-tabs-container .view-tab {
        flex: 1;
        justify-content: center;
        padding: 8px 12px !important;
        font-size: 0.85em !important;
        gap: 6px !important;
    }

    /* --- SECTION HEADERS WITH ACTION (index.php) --- */
    /* h2 + bouton "Toutes les courses →" / "Comparer →" */
    .section-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        gap: 8px;
    }

    .section-header h2 {
        font-size: 1.05em !important;
    }

    .section-header-action {
        padding: 4px 12px !important;
        font-size: 0.8em !important;
        align-self: flex-start;
    }

    /* --- DEV WARNING BANNER (index.php) --- */
    .dev-warning-banner {
        padding: 12px !important;
        margin-bottom: 18px !important;
        gap: 10px !important;
    }

    .dev-warning-banner .dev-warning-icon {
        font-size: 1.2em !important;
    }

    .dev-warning-banner h3 {
        font-size: 1em !important;
        margin-bottom: 6px !important;
    }

    .dev-warning-banner > div:last-child > div {
        font-size: 0.85em !important;
        line-height: 1.4 !important;
    }

    /* --- STATS BAR (leaderboard.php) - Grid 2x2 --- */
    .stats-bar {
        display: grid !important;
        grid-template-columns: repeat(2, 1fr) !important;
        gap: 8px !important;
        font-size: 0.9em !important;
    }

    .stats-bar .stats-tile {
        padding: 8px 10px !important;
        gap: 6px !important;
        flex-wrap: wrap;
        min-width: 0;
    }

    .stats-bar .stats-label {
        font-size: 0.65em !important;
        letter-spacing: 0.3px !important;
        flex: 1;
        min-width: 0;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .stats-bar .stats-value {
        font-size: 1em !important;
        margin-left: auto;
    }

    /* --- LEADERBOARD TABLE: Hide accessory columns under 600px --- */
    /* (kept Rang / Nom / ELO; Fiabilité / Courses / Badges hidden) */

    /* --- COMPETITOR PROFILE (competitor.php) --- */
    /* Profile picture: smaller on mobile */
    .profile-pic-container {
        width: 110px !important;
        height: 110px !important;
    }

    .profile-pic-container i {
        font-size: 3em !important;
    }

    /* "Gérer mon compte" button: stop overlapping centered title */
    .manage-account-wrapper {
        position: static !important;
        text-align: center;
        margin-top: 10px;
        margin-bottom: 10px;
    }

    .manage-account-btn {
        display: inline-block;
    }

    /* Big stat cards (Classement / ELO / Fiabilité): less giant numbers */
    .score-cards-grid {
        grid-template-columns: repeat(auto-fit, minmax(105px, 1fr)) !important;
        gap: 8px !important;
    }

    .score-cards-grid > div {
        padding: 12px 8px !important;
    }

    .score-cards-grid > div > div:first-child {
        font-size: 0.7rem !important;
        letter-spacing: 0.5px !important;
    }

    .score-cards-grid > div > div:nth-child(2) {
        font-size: 1.8rem !important;
        margin: 2px 0 !important;
    }

    /* Social icons: slightly tighter */
    .social-icon-btn {
        font-size: 1.5em !important;
    }
}

/* Leaderboard accessory columns + history table accessory columns: hide under 600px */
@media (max-width: 600px) {
    #leaderboardTable .col-races,
    #leaderboardTable .col-badges {
        display: none !important;
    }

    /* Tighter column spacing on the leaderboard for mobile */
    #leaderboardTable th,
    #leaderboardTable td {
        padding-left: 4px !important;
        padding-right: 4px !important;
    }

    /* First / last cells: a touch more breathing room on the edges */
    #leaderboardTable th:first-child,
    #leaderboardTable td:first-child {
        padding-left: 6px !important;
    }

    #leaderboardTable th:last-child,
    #leaderboardTable td:last-child {
        padding-right: 6px !important;
    }

    /* Internal gap inside Rang / Nom / ELO cells */
    #leaderboardTable td .d-flex.gap-10 {
        gap: 4px !important;
    }

    /* Reliability column on mobile: keep the "Fiabilité" header text visible,
       and show only the battery icon in the cells (no XX% text) */
    #leaderboardTable th.col-reliability {
        padding-left: 4px !important;
        padding-right: 4px !important;
    }

    #leaderboardTable td.col-reliability {
        padding-left: 4px !important;
        padding-right: 4px !important;
    }

    #leaderboardTable td.col-reliability span {
        display: none !important;
    }

    #leaderboardTable td.col-reliability .d-flex {
        gap: 0 !important;
    }

    /* Allow the table to shrink without forcing horizontal scroll */
    #leaderboardTable {
        min-width: 0 !important;
    }

    #leaderboardTable .table-responsive,
    .table-responsive:has(#leaderboardTable) {
        overflow-x: visible !important;
    }

    /* Competitor history table: hide Time and Reliability change columns */
    .history-table .col-time,
    .history-table .col-reliability-change {
        display: none !important;
    }

    .history-table {
        min-width: 0 !important;
    }
}

/* Extra small screens (iPhone SE, 375px) */
@media (max-width: 480px) {
    h1 {
        font-size: 1.3em;
        margin-bottom: 15px;
    }

    table {
        min-width: 360px;
        font-size: 0.8em;
    }

    th,
    td {
        padding: 6px 4px;
    }

    .race-item-title {
        font-size: 1em;
    }

    .podium-item {
        width: 95px;
        padding: 10px 5px;
    }

    .nav-floating {
        display: none;
    }

    .page-title,
    .profile-name {
        font-size: 1.2em;
    }
}