/* =========================================
   RESC STANDINGS STYLES (Simracing Theme)
   ========================================= */

body {
    background-color: #0B101E !important; 
}

#resc_standings_content {
    padding: 120px 4rem 4rem 4rem; 
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 2rem;
    flex: 1 0 auto;
    min-height: 0;
}

/* --- Header & Controls --- */
.standings_header {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    border-bottom: 1px solid rgba(42, 86, 255, 0.2);
    padding-bottom: 1.5rem;
}

.standings_title_wrap {
    display: flex;
    flex-direction: column;
    gap: 0.3rem;
}

.season_subtitle {
    font-family: var(--font-heading);
    font-size: 0.95rem;
    color: var(--accent-sim);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

/* --- Empty State (No Active Season) --- */
.no_season_card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 4rem 2rem;
    background-color: #151C2D;
    border: 1px solid rgba(42, 86, 255, 0.2);
    border-radius: 12px;
    max-width: 700px;
    margin: 2rem auto;
    gap: 1.2rem;
    box-shadow: 0 10px 30px rgba(0,0,0,0.4);
}

.no_season_icon {
    font-size: 3.5rem;
    line-height: 1;
}

.no_season_title {
    font-family: var(--font-heading);
    font-size: 2rem;
    color: var(--text-main);
    text-transform: uppercase;
}

.no_season_desc {
    color: var(--text-muted);
    font-size: 1rem;
    line-height: 1.6;
    max-width: 550px;
}

.no_season_actions {
    display: flex;
    gap: 1rem;
    margin-top: 0.5rem;
}

.page-title {
    font-family: var(--font-heading);
    font-size: 2.5rem;
    text-transform: uppercase;
}

.accent-blue { color: var(--accent-sim); }

.standings_controls {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.select_wrapper { position: relative; }

.custom_select {
    appearance: none;
    background-color: #151C2D; 
    color: var(--text-main);
    border: 1px solid rgba(42, 86, 255, 0.3);
    padding: 0.6rem 2.5rem 0.6rem 1rem;
    border-radius: 6px;
    font-family: var(--font-heading);
    font-size: 0.9rem;
    cursor: pointer;
    transition: border-color 0.3s;
}

.custom_select:focus { outline: none; border-color: var(--accent-sim); }
.select_wrapper::after { content: '▼'; position: absolute; right: 1rem; top: 50%; transform: translateY(-50%); font-size: 0.7rem; pointer-events: none; color: var(--text-muted); }

.standings_view { animation: fadeIn 0.4s ease; }
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Separators for Category Grouping --- */
.category_separator {
    width: 100%;
    padding: 1.5rem 0 0.5rem 0;
    margin-top: 1rem;
    border-bottom: 2px solid var(--accent-sim);
    color: var(--text-main);
    font-family: var(--font-heading);
    font-size: 1.5rem;
    text-transform: uppercase;
    letter-spacing: 1px;
}
.category_separator:first-child { margin-top: 0; }

.category_separator_row {
    background: #101626 !important;
    color: var(--text-main);
    font-family: var(--font-heading);
    font-size: 1.2rem;
    text-align: left !important;
    padding: 1rem 1.5rem !important;
    position: sticky;
    left: 0;
    z-index: 4;
    letter-spacing: 1px;
    border-top: 1px solid rgba(42, 86, 255, 0.3);
    border-bottom: 1px solid rgba(42, 86, 255, 0.3);
}

/* --- View 1: Season Standings --- */
.season_list_header {
    display: flex;
    align-items: center;
    padding: 0.5rem 1rem;
    color: var(--text-muted);
    font-weight: bold;
    font-size: 0.85rem;
    text-transform: uppercase;
    border-bottom: 1px solid rgba(255,255,255,0.05);
    margin-bottom: 1rem;
}

.season_row {
    display: flex;
    align-items: center;
    background-color: #151C2D;
    border: 1px solid rgba(42, 86, 255, 0.1);
    border-radius: 8px;
    margin-bottom: 0.5rem;
    padding: 1rem;
    cursor: pointer;
    transition: transform 0.2s ease, background-color 0.2s ease, border-color 0.2s;
}

.season_row:hover {
    background-color: #1a233a;
    border-color: rgba(42, 86, 255, 0.4);
    transform: translateX(5px);
}

.col_pos { width: 60px; font-family: var(--font-heading); font-size: 1.2rem; text-align: center; }
.col_car { width: 150px; display: flex; justify-content: center; }
.col_car_img_wrapper { width: 120px; height: 35px; } 
.col_driver { flex: 2; font-size: 1.1rem; font-weight: bold; padding-left: 1rem; }
.col_driver_dsq { flex: 2; font-size: 1.1rem; font-weight: bold; padding-left: 1rem; color:#d80000}
.col_cat { flex: 1; font-size: 0.9rem; color: var(--accent-sim); font-weight: bold; text-transform: uppercase; }
.col_stats { flex: 2; display: flex; gap: 1rem; color: var(--text-muted); font-size: 0.85rem; }
.col_points { width: 100px; text-align: right; font-family: var(--font-heading); font-size: 1.2rem; color: var(--text-main); }

.pos-1 { border-left: 4px solid #FFD700; background: linear-gradient(90deg, rgba(255, 215, 0, 0.08) 0%, #151C2D 20%); }
.pos-2 { border-left: 4px solid #C0C0C0; background: linear-gradient(90deg, rgba(192, 192, 192, 0.05) 0%, #151C2D 20%); }
.pos-3 { border-left: 4px solid #CD7F32; background: linear-gradient(90deg, rgba(205, 127, 50, 0.05) 0%, #151C2D 20%); }

.pos-1 .col_pos, .pos-1 .col_points { color: #FFD700; }
.pos-2 .col_pos, .pos-2 .col_points { color: #C0C0C0; }
.pos-3 .col_pos, .pos-3 .col_points { color: #CD7F32; }

/* --- Slide Navigation Controls --- */
.slide_controls {
    display: flex;
    gap: 0.4rem;
    align-items: center;
}

.btn_slide_nav {
    background-color: #151C2D;
    border: 1px solid rgba(42, 86, 255, 0.35);
    color: var(--text-main);
    border-radius: 6px;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.2s ease;
    padding: 0;
}

.btn_slide_nav:hover {
    background-color: #2a56ff;
    border-color: #2a56ff;
    color: #fff;
    box-shadow: 0 0 12px rgba(42, 86, 255, 0.5);
    transform: translateY(-1px);
}

.btn_slide_nav:active {
    transform: translateY(1px);
}

/* --- View 2: Race by Race Table --- */
.race_table_wrapper {
    width: 100%;
    overflow-x: auto; 
    overflow-y: hidden;
    background-color: #151C2D;
    border-radius: 8px;
    border: 1px solid rgba(42, 86, 255, 0.2);
    scrollbar-width: thin;
    scrollbar-color: #2a56ff rgba(15, 22, 38, 0.9);
    cursor: grab;
    -webkit-overflow-scrolling: touch;
}

.race_table_wrapper.grabbing {
    cursor: grabbing !important;
    user-select: none;
}

.race_table_wrapper::-webkit-scrollbar {
    height: 9px;
}

.race_table_wrapper::-webkit-scrollbar-track {
    background: #0f1626;
    border-radius: 4px;
}

.race_table_wrapper::-webkit-scrollbar-thumb {
    background: rgba(42, 86, 255, 0.6);
    border-radius: 4px;
    border: 1px solid rgba(42, 86, 255, 0.3);
}

.race_table_wrapper::-webkit-scrollbar-thumb:hover {
    background: #2a56ff;
}

.race_table { 
    width: max-content; 
    min-width: 100%; 
    border-collapse: separate; 
    border-spacing: 0; 
    white-space: nowrap; 
}

.race_table th, .race_table td { 
    padding: 0.85rem 0.5rem; 
    text-align: center; 
    border-bottom: 1px solid rgba(255, 255, 255, 0.05); 
}

.race_table th { 
    font-size: 0.85rem; 
    color: var(--text-muted); 
    text-transform: uppercase; 
    font-weight: bold; 
    background-color: rgba(0, 0, 0, 0.25); 
}

.race_table tbody tr { 
    cursor: pointer; 
    transition: background-color 0.2s; 
}

.race_table tbody tr:hover { 
    background-color: rgba(42, 86, 255, 0.05); 
}

.race_table td { 
    font-size: 0.95rem; 
    vertical-align: middle; 
}

/* Category separator row spanning across table */
tr.category_separator_tr {
    cursor: default !important;
}

tr.category_separator_tr:hover {
    background-color: transparent !important;
}

tr.category_separator_tr td.category_separator_fixed {
    position: sticky;
    left: 0;
    width: 370px;
    min-width: 370px;
    max-width: 370px;
    box-sizing: border-box;
    background-color: #101626 !important;
    z-index: 5;
    border-top: 1px solid rgba(42, 86, 255, 0.3);
    border-bottom: 1px solid rgba(42, 86, 255, 0.3);
    border-right: 3px solid #2a56ff;
    padding: 0.8rem 1.2rem;
    text-align: left !important;
    font-weight: 700;
    font-size: 1rem;
    color: #fff;
    white-space: nowrap;
}

tr.category_separator_tr td.category_separator_fill {
    background-color: #101626 !important;
    border-top: 1px solid rgba(42, 86, 255, 0.3);
    border-bottom: 1px solid rgba(42, 86, 255, 0.3);
    padding: 0;
}

/* Fixed Column 1: Pos (0px -> 50px) */
.race_table th:nth-child(1), .race_table tbody tr:not(.category_separator_tr) td:nth-child(1) { 
    position: sticky; 
    left: 0; 
    width: 50px; 
    min-width: 50px; 
    max-width: 50px; 
    box-sizing: border-box;
    background-color: #151C2D; 
    z-index: 2; 
    border-right: 1px solid rgba(255, 255, 255, 0.05); 
    text-align: center;
}

/* Fixed Column 2: Pilote (50px -> 290px) */
.race_table th:nth-child(2), .race_table tbody tr:not(.category_separator_tr) td:nth-child(2) { 
    position: sticky; 
    left: 50px; 
    width: 240px; 
    min-width: 240px; 
    max-width: 240px; 
    box-sizing: border-box;
    background-color: #151C2D; 
    z-index: 2; 
    border-right: 1px solid rgba(255, 255, 255, 0.05); 
    text-align: left; 
    font-weight: bold; 
    padding: 0.85rem 0.8rem;
}

/* Fixed Column 3: Total Points (290px -> 370px) - BOUNDARY of sliding section */
.race_table th:nth-child(3), .race_table tbody tr:not(.category_separator_tr) td:nth-child(3) { 
    position: sticky; 
    left: 290px; 
    width: 80px; 
    min-width: 80px; 
    max-width: 80px; 
    box-sizing: border-box;
    background-color: #151C2D; 
    z-index: 2; 
    border-right: 3px solid #2a56ff; 
    text-align: center; 
    font-weight: bold; 
    font-size: 1.15rem;
}

/* Fixed Headers (Higher z-index so content scrolls under them) */
.race_table th:nth-child(1), 
.race_table th:nth-child(2), 
.race_table th:nth-child(3) { 
    z-index: 6; 
    background-color: #121827; 
}

/* Synchronized row hover on fixed cells */
.race_table tbody tr:not(.category_separator_tr):hover td:nth-child(1), 
.race_table tbody tr:not(.category_separator_tr):hover td:nth-child(2), 
.race_table tbody tr:not(.category_separator_tr):hover td:nth-child(3) { 
    background-color: #1c253c; 
}

/* Race Columns (Columns 4 and beyond: SLIDING SECTION) */
.race_table th.race_col_header,
.race_table td.race_col_cell {
    min-width: 210px;
    width: 210px;
    box-sizing: border-box;
    border-right: 1px solid rgba(255, 255, 255, 0.03);
    text-align: center;
}

.matrix_driver_cell { 
    display: flex; 
    align-items: center; 
    gap: 12px; 
    min-width: 0;
    width: 100%;
}

.matrix_car_img { 
    width: 55px; 
    height: 18px; 
    flex-shrink: 0;
}

.matrix_driver_info {
    min-width: 0;
    overflow: hidden;
}

.matrix_driver_name {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    font-size: 0.95rem;
    font-weight: bold;
}

.matrix_driver_cat {
    display: block;
    font-size: 0.72rem;
    color: var(--accent-sim);
    font-weight: 600;
    text-transform: uppercase;
}

.race_result_cell { 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    justify-content: center;
    gap: 4px; 
    min-width: 80px;
}

.cell_pts_line {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 5px;
    line-height: 1.1;
}

.race_pts { 
    font-family: var(--font-heading); 
    font-weight: bold; 
    font-size: 1.15rem; 
    color: var(--text-main); 
}

.race_pts.zero { 
    color: var(--text-muted); 
    opacity: 0.5; 
}

.cell_details_line {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-size: 0.75rem;
    color: var(--text-muted);
    line-height: 1;
}

.cell-sub-q { color: var(--text-muted); font-size: 0.75rem; }
.cell-sub-r { color: #60a5fa; font-weight: 600; font-size: 0.75rem; }
.cell-sub-sep { color: rgba(255, 255, 255, 0.25); font-size: 0.65rem; }

/* MT badge in purple */
.badge-mt { 
    font-size: 0.65rem; 
    background: #9333ea; 
    color: #fff; 
    padding: 1px 5px; 
    border-radius: 4px; 
    font-weight: bold; 
    box-shadow: 0 0 6px rgba(147, 51, 234, 0.4);
    letter-spacing: 0.5px;
}

/* DNF & DNS in race text red */
.status-dnf {
    color: #ef4444;
    font-weight: 800;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
}

.status-dns {
    color: #ef4444;
    font-weight: 800;
    font-size: 0.8rem;
    letter-spacing: 0.5px;
}

/* DSQ with red background */
.badge-dsq {
    display: inline-block;
    background: #dc2626;
    color: #ffffff;
    padding: 2px 7px;
    border-radius: 4px;
    font-weight: 800;
    font-size: 0.78rem;
    text-shadow: 0 1px 2px rgba(0,0,0,0.5);
    box-shadow: 0 0 8px rgba(220, 38, 38, 0.45);
    letter-spacing: 0.5px;
}

/* Full DNS badge */
.badge-full-dns {
    display: inline-block;
    background: rgba(255, 255, 255, 0.05);
    color: #9ca3af;
    border: 1px dashed rgba(255, 255, 255, 0.25);
    padding: 3px 6px;
    border-radius: 4px;
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.cell-pending {
    color: var(--text-muted);
    opacity: 0.35;
    font-size: 1.2rem;
    font-family: var(--font-heading);
}

/* --- Modal Base --- */
.custom_modal { 
    position: fixed; 
    top: 0; 
    left: 0; 
    width: 100%; 
    height: 100%; 
    z-index: 2000; 
    display: flex; 
    justify-content: center; 
    align-items: center; 
}
.modal_backdrop { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-color: rgba(5, 5, 5, 0.85); backdrop-filter: blur(8px); }
.modal_content { position: relative; width: calc(100% - 20px); max-width: 800px; z-index: 2001; }

/* Modal Close Cross */
.btn-close-icon {
    position: absolute;
    top: 1.2rem;
    right: 1.2rem;
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    z-index: 2005;
    transition: color 0.3s, transform 0.3s;
    padding: 0;
    display: flex;
}
.btn-close-icon:hover {
    color: #d80000;
    transform: scale(1.1);
}

/* --- F1 Compact Profile Styles --- */
.comp-resc-container {
    position: relative;
    background-color: #151C2D;
    border: 1px solid rgba(42, 86, 255, 0.3);
    border-radius: 12px;
    padding: 2.5rem 2rem 2rem 2rem;
    box-shadow: 0 15px 40px rgba(0,0,0,0.6);
}

.f1-hero-header { display: flex; justify-content: space-between; align-items: center; border-bottom: 2px solid var(--accent-sim); padding-bottom: 1rem; margin-bottom: 1.5rem; }
.f1-pilot-info { display: flex; align-items: baseline; gap: 1rem; }
.f1-car-number { font-family: var(--font-heading); font-size: 2.5rem; color: var(--text-muted); }
.f1-pilot-name { font-family: var(--font-heading); font-size: 1.8rem; color: var(--text-main); text-transform: uppercase; }
.f1-dropdown { font-weight: bold; color: var(--accent-sim); font-size: 1rem; }

.f1-car-display { display: flex; align-items: center; gap: 2rem; background: rgba(0,0,0,0.2); border-radius: 8px; padding: 1.5rem; margin-bottom: 2rem; }
.resc-car-image-wrapper { width: 250px; height: 75px; }
.f1-team-badge { flex: 1; }
.f1-team-name { font-size: 1.2rem; font-weight: bold; margin-bottom: 0.3rem; }
.f1-car-model { color: var(--text-muted); font-size: 0.9rem; }

.f1-stats-container { display: flex; flex-direction: column; gap: 1.5rem; }
.f1-main-stats { display: flex; gap: 1rem; }
.f1-secondary-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(100px, 1fr)); gap: 1rem; }

/* Uniform Blue Stat Boxes */
.f1-stat-box { 
    background-color: rgba(42, 86, 255, 0.06) !important; 
    border: 1px solid rgba(42, 86, 255, 0.25) !important; 
    border-radius: 6px; 
    padding: 1rem; 
    display: flex; 
    flex-direction: column; 
    align-items: center; 
    text-align: center; 
    transition: all 0.2s ease;
}
.f1-stat-box:hover {
    border-color: rgba(42, 86, 255, 0.5) !important;
    background-color: rgba(42, 86, 255, 0.12) !important;
}

.highlight-pos, .highlight-pts, .highlight-pena, .highlight-pena-dsq, .box-dnf { 
    border-color: rgba(42, 86, 255, 0.25) !important; 
    background-color: rgba(42, 86, 255, 0.06) !important; 
}

.f1-stat-title { font-size: 0.8rem; color: var(--text-muted); text-transform: uppercase; margin-bottom: 0.5rem; }
.f1-stat-value { font-family: var(--font-heading); font-size: 1.5rem; color: var(--text-main); }

/* --- Profile Action Link --- */
.f1-profile-action {
    margin-top: 1.5rem;
    text-align: center;
    border-top: 1px solid rgba(42, 86, 255, 0.2);
    padding-top: 1.5rem;
}

.btn-profile-link {
    display: inline-block;
    padding: 0.8rem 2rem;
    background-color: transparent;
    border: 1px solid rgba(42, 86, 255, 0.5);
    border-radius: 6px;
    color: var(--text-main);
    font-family: var(--font-heading);
    font-size: 0.85rem;
    text-transform: uppercase;
    text-decoration: none !important; /* Force la suppression du soulignement */
    letter-spacing: 1px;
    transition: all 0.3s ease;
}

.btn-profile-link:hover {
    background-color: var(--accent-sim);
    color: #fff;
    border-color: var(--accent-sim);
    box-shadow: 0 0 15px rgba(42, 86, 255, 0.4);
    transform: translateY(-2px);
}
/* --- Mobile Responsiveness (Radical Overflow Fix) --- */
@media (max-width: 899px) {
    #resc_standings_content { 
        padding: 8.5rem 1rem 2rem 1rem; 
        margin-top: 1.5rem;
    }
    .page-title {
        font-size: 1.8rem;
    }
    .standings_header { flex-direction: column; align-items: flex-start; gap: 1.5rem; }
    .standings_controls { width: 100%; flex-direction: column; align-items: stretch; }
    #btn_toggle_view { display: none; }
    
    .season_list_header { display: none; }
    
    .season_row { flex-direction: column; align-items: flex-start; padding: 1.5rem; position: relative; }
    .col_pos { position: absolute; top: 1rem; right: 1rem; width: auto; font-size: 1.5rem; }
    .col_car { width: 100%; justify-content: flex-start; margin-bottom: 1rem; }
    .col_car_img_wrapper { width: 150px; height: 45px; }
    .col_driver { padding-left: 0; margin-bottom: 0.2rem; font-size: 1.3rem; }
    .col_cat { margin-bottom: 1rem; }
    .col_stats { width: 100%; flex-direction: column; gap: 0.5rem; border-top: 1px solid rgba(255,255,255,0.05); padding-top: 1rem; margin-bottom: 1rem; }
    .col_points { width: 100%; text-align: left; font-size: 1.8rem; }

    /* --- Modal Mobile Adjustments (Ultra Strict Containment) --- */
    .comp-resc-container { 
        padding: 1.5rem 0.8rem 1rem 0.8rem !important; 
        box-sizing: border-box;
        width: 100%;
    }
    
    .btn-close-icon {
        top: 0.8rem;
        right: 0.8rem;
    }
    
    .f1-hero-header { 
        flex-direction: column; 
        align-items: flex-start; 
        gap: 0.5rem; 
        width: 100%;
    }
    
    /* Superposition forcée du numéro et du nom pour éviter l'élargissement */
    .f1-pilot-info { 
        display: flex;
        flex-direction: column; 
        align-items: flex-start;
        gap: 0.2rem; 
        width: 100%;
    }
    
    .f1-car-number { font-size: 1.8rem; line-height: 1; }
    
    /* Force le texte à aller à la ligne s'il est trop long */
    .f1-pilot-name { 
        font-size: 1.3rem; 
        line-height: 1.1;
        width: 100%;
        word-wrap: break-word;
        overflow-wrap: break-word;
        white-space: normal;
    }
    
    .f1-season-picker { align-self: flex-start; margin-top: 0.2rem; }
    .f1-dropdown { font-size: 0.85rem; }

    .f1-car-display { 
        flex-direction: column; 
        align-items: center; 
        text-align: center;
        gap: 0.8rem; 
        padding: 0.8rem; 
        width: 100%;
        box-sizing: border-box;
    }
    
    .resc-car-image-wrapper { width: 100%; height: auto; display: flex; justify-content: center; }
    .resc-car-img { max-width: 100%; height: auto; }
    
    .f1-team-name { font-size: 1.1rem; word-wrap: break-word; }
    .f1-car-model { font-size: 0.8rem; word-wrap: break-word; }
    
    /* Stats Grids - minmax(0, 1fr) empêche le grid de dépasser son conteneur */
    .f1-stats-container { gap: 0.5rem; width: 100%; }
    
    .f1-main-stats, .f1-secondary-stats {
        display: grid;
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 0.5rem;
        width: 100%;
    }
    
    .f1-stat-box {
        padding: 0.6rem 0.2rem; 
        min-width: 0; /* Vital : autorise le contenu à rétrécir */
        word-wrap: break-word;
    }
    
    .f1-stat-title {
        font-size: 0.6rem; 
        line-height: 1.2;
        margin-bottom: 0.3rem;
        white-space: normal; /* "MEILLEURS TOURS" se coupera en deux lignes */
    }
    
    .f1-stat-value {
        font-size: 1.1rem;
    }

    .f1-profile-action {
        padding-top: 1rem;
        margin-top: 1rem;
    }
    
    /* Le bouton prend 100% de la largeur dispo sans déborder */
    .btn-profile-link {
        display: block;
        width: 100%;
        box-sizing: border-box;
        padding: 0.6rem 1rem;
        font-size: 0.75rem;
    }
}