/* ========================================================================
   1. CONFIGURACIÓ GENERAL I TIPOGRAFIA
   ======================================================================== */
@font-face {
    font-family: 'Formula1-Regular';
    src: url('../fonts/Formula1-Regular_web_0.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

body {
    background-color: #0b0b0b;
    /* Bandera de quadres amb el gris "blanc" molt apagat (#121212) */
    background-image: linear-gradient(45deg, #121212 25%, transparent 25%), linear-gradient(-45deg, #121212 25%, transparent 25%), linear-gradient(45deg, transparent 75%, #121212 75%), linear-gradient(-45deg, transparent 75%, #121212 75%);
    background-size: 40px 40px;
    background-position: 0 0, 0 20px, 20px -20px, -20px 0px;
    color: white;
    font-family: 'Formula1-Regular', Arial, sans-serif !important;
    margin-bottom: 60px;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}
/* ========================================================================
   2. NAVEGACIÓ PRINCIPAL (NAVBAR)
   ======================================================================== */
.navbar-f1 {
    background-color: #000 !important;
    border-bottom: 3px solid #e10600;
    padding: 0.5rem 1.5rem;
    position: relative;
    z-index: 2000;
}

    .navbar-f1 .navbar-brand img {
        max-height: 45px;
    }

    .navbar-f1 .nav-link {
        color: #fff !important;
        font-family: 'Formula1-Regular', sans-serif !important;
        font-size: 0.8rem !important;
        text-transform: uppercase !important;
        letter-spacing: 2px !important;
        padding: 1rem 1.2rem !important;
        transition: all 0.3s ease;
    }

        .navbar-f1 .nav-link:hover {
            color: #b84cff !important;
            text-shadow: 0 0 10px rgba(184, 76, 255, 0.5);
        }

    .navbar-f1 .dropdown-menu {
        background-color: #15151e;
        border: 1px solid #333;
        border-top: 3px solid #e10600;
    }

    .navbar-f1 .dropdown-item {
        font-family: 'Formula1-Regular', sans-serif !important;
        color: #ccc !important;
        font-size: 0.75rem !important;
        text-transform: uppercase;
        padding: 10px 20px;
    }

        .navbar-f1 .dropdown-item:hover {
            background-color: #e10600 !important;
            color: white !important;
        }

/* ========================================================================
   3. HOME: RACE CARD & WEATHER
   ======================================================================== */
.f1-home-container {
    max-width: 800px;
    margin: 40px auto;
}

.f1-race-card {
    background-color: #15151e;
    border-radius: 15px;
    overflow: hidden;
    border-bottom: 5px solid #e10600;
    box-shadow: 0 10px 30px rgba(0,0,0,0.5);
    margin-bottom: 30px;
}

.f1-card-header {
    background-color: #e10600;
    padding: 10px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.f1-card-body {
    padding: 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
}

.f1-track-display {
    font-size: 2.5rem;
    margin-bottom: 15px;
    text-transform: uppercase;
    color: goldenrod
}

.f1-weather-widget {
    background: rgba(255, 255, 255, 0.05);
    padding: 15px 25px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    gap: 15px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.f1-temp {
    font-size: 1.8rem;
    color: #0cf;
    font-weight: bold;
    text-shadow: 0 0 10px rgba(0, 204, 255, 0.4);
}

/* ========================================================================
   4. PESTANYES DE SESSIÓ (AMB FIX DE CLICS)
   ======================================================================== */
.f1-tabs {
    display: flex;
    justify-content: flex-start;
    background-color: #0b0b0b;
    border-bottom: 1px solid #333;
    margin: 0; /* Hem tret el margin de 20px perquè no faci salts estranys en fixar-se */
    padding: 0 20px;
    /* PROPIETATS PER FIXAR L'ELEMENT */
    position: -webkit-sticky; /* Suport per a Safari */
    position: sticky;
    top: 0; /* Si NO tens navbar fixa, posa 0. Si la tens, posa l'alçada de la navbar */
    z-index: 1050; /* Per sobre de les taules */
    /* Opcional: una petita ombra quan fem scroll perquè es separi visualment del contingut */
    box-shadow: 0 2px 10px rgba(0,0,0,0.5);
}

.f1-tab {
    display: flex;
    align-items: center;
    padding: 18px 25px;
    cursor: pointer !important;
    color: #999;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    transition: all 0.3s ease;
    pointer-events: auto !important;
}

    .f1-tab:hover {
        color: #fff;
        background-color: rgba(255, 255, 255, 0.05);
    }

    .f1-tab.active {
        color: #fff;
        font-weight: bold;
        border-bottom: 4px solid #e10600;
    }

.f1-tab-content {
    display: none;
    padding-top: 20px;
}

    .f1-tab-content.active {
        display: block !important;
    }

/* ========================================================================
   5. TAULES DE TELEMETRIA I ESTATS DE VOLTA
   ======================================================================== */
.f1-table, .f1DescTable {
    width: 100%;
    border-collapse: collapse;
    margin: 20px auto;
    background-color: transparent;
}

    .f1-table th {
        color: #e10600;
        text-align: center;
        padding: 15px;
        font-size: 0.75rem;
        letter-spacing: 1px;
        text-transform: uppercase;
        border-bottom: 2px solid #333;
    }

    .f1-table td {
        padding: 12px 10px;
        border-bottom: 1px solid #222;
        text-align: center;
        color: #eee;
        font-size: 0.85rem;
    }

    .f1-table tr:nth-child(even) {
        background-color: rgba(255,255,255,0.02);
    }

/* --- ESTATS ESPECIALS DE LES FILES --- */
.f1-fastlap {
    color: #b84cff !important;
    font-weight: bold;
    text-shadow: 0 0 8px rgba(184, 76, 255, 0.6);
}

.f1-Personalfastlap {
    color: #00ff00 !important;
    font-weight: bold;
}

/* VOLTA BRUTA / INVALIDADA (CORREGIT) */
.f1-table tr.f1-InvalidLap td {
    background-color: rgba(69, 21, 21, 0.4) !important; /* Vermell fosc de fons */
    color: #ff4444 !important; /* Text vermell brillant */
    border-bottom: 1px solid #600 !important;
}

/* ========================================================================
   6. ODOMETER (VISITES)
   ======================================================================== */
.f1-counters {
    display: flex;
    gap: 20px;
    justify-content: center;
    margin-top: 20px;
}

.f1-counter {
    background: #15151e;
    padding: 20px;
    border-radius: 12px;
    text-align: center;
    flex: 1;
    min-width: 180px;
}

    .f1-counter .label {
        font-size: 0.7rem;
        color: #e10600;
        text-transform: uppercase;
        letter-spacing: 1px;
        margin-bottom: 15px;
    }

.odometer {
    display: inline-flex;
    gap: 4px;
    background: #000;
    padding: 8px;
    border-radius: 6px;
}

.digit {
    width: 24px;
    height: 36px;
    background: #1a1a1a;
    color: #0cf;
    font-family: 'Consolas', monospace;
    font-size: 20px;
    line-height: 36px;
    text-align: center;
    border-radius: 4px;
    border: 1px solid #333;
}

    .digit.animate {
        animation: f1Flip 0.3s ease-out;
    }

@keyframes f1Flip {
    0% {
        transform: rotateX(-90deg);
        opacity: 0;
    }

    100% {
        transform: rotateX(0deg);
        opacity: 1;
    }
}

/* ========================================================================
   7. FOOTER
   ======================================================================== */
.f1-footer {
    background-color: #000;
    padding: 30px 0;
    margin-top: 50px;
    font-size: 0.65rem;
    color: #444;
    text-align: center;
    border-top: 1px solid #333;
    letter-spacing: 1px;
}

/* ========================================================================
   9. LOADING SPINNER (ESTIL F1)
   ======================================================================== */
/* ========================================================================
   SPINNER (Compatible amb el teu ID gridSpinner)
   ======================================================================== */
.spinner {
    display: none; /* Ocult per defecte, el JS el mostrarà */
    width: 22px; /* Mida petita per anar al costat del select */
    height: 22px;
    border: 3px solid rgba(225, 6, 0, 0.1); /* Vermell F1 suau de fons */
    border-top: 3px solid #e10600; /* Vermell F1 intens a la punta */
    border-right: 3px solid #e10600; /* Fem que la punta sigui més llarga */
    border-radius: 50%;
    animation: f1-spin 0.8s cubic-bezier(0.4, 0, 0.2, 1) infinite;
    margin-left: 10px; /* Separació del desplegable */
    vertical-align: middle;
    display: inline-block; /* Perquè es quedi a la mateixa línia */
    box-shadow: 0 0 8px rgba(225, 6, 0, 0.2);
}

@keyframes f1-spin {
    to {
        transform: rotate(360deg);
    }
}

/* ========================================================================
10. CAR LOGO
======================================================================== */

/* Logo del cotxe a la graella */
.car-logo-grid {
    width: 40px; /* Amplada fixa */
    height: 25px; /* Alçada fixa */
    object-fit: contain; /* Això fa que el logo no es deformi encara que la imatge sigui gran */
    margin-right: 12px;
    vertical-align: middle;
    background-color: White; /* Un fons tènue per si el logo és blanc */
    padding: 2px;
    border-radius: 4px;
}

.driver-logo-grid {
    width: 40px; /* Amplada fixa */
    height: 25px; /* Alçada fixa */
    object-fit: contain; /* Això fa que el logo no es deformi encara que la imatge sigui gran */
    margin-right: 12px;
    vertical-align: middle;
    background-color: transparent; /* Un fons tènue per si el logo és blanc */
    padding: 2px;
    border-radius: 4px;
}

/*.driver-logo-laps {
    width: 100px;*/ /* Amplada fixa */
    /*height: 75px;*/ /* Alçada fixa */
    /*object-fit: contain;*/ /* Això fa que el logo no es deformi encara que la imatge sigui gran */
    /*margin-right: 12px;
    vertical-align: middle;
    background-color: transparent;*/ /* Un fons tènue per si el logo és blanc */
    /*padding: 2px;
    border-radius: 4px;
}*/

.driver-logo-laps {
    width: 100px;
    height: 75px;
    object-fit: contain;
    margin-bottom: 10px; /* Espai amb la taula */
    vertical-align: middle;
    background-color: #1a1a1a; /* Fons fosc per destacar el brillant */
    padding: 4px;
    border-radius: 4px;
    /* Vora inicial i efecte de resplendor */
    border: 2px solid #e10600;
    box-shadow: 0 0 5px #e10600;
    /* Animació */
    animation: f1-glow 2s infinite alternate;
    transition: transform 0.3s ease;
}

    /* Efecte zoom quan passes el ratolí */
    .driver-logo-laps:hover {
        transform: scale(1.1);
        box-shadow: 0 0 20px #e10600;
        cursor: pointer;
    }

/* Definició de l'animació de moviment de llum */
@keyframes f1-glow {
    0% {
        box-shadow: 0 0 5px rgba(225, 6, 0, 0.5);
        border-color: rgba(225, 6, 0, 0.5);
    }

    100% {
        box-shadow: 0 0 20px rgba(225, 6, 0, 1), 0 0 40px rgba(225, 6, 0, 0.2);
        border-color: rgba(255, 255, 255, 0.8); /* Centelleig blanc a la vora */
    }
}

/* Contenidor de la cel·la per alinear logo + text */
.cell-car {
    display: flex;
    align-items: center;
    justify-content: flex-start;
    min-width: 150px;
    padding-left: 10px;
}

/* ========================================================================
11. Calendar Cards
======================================================================== */


/* Contenidor Principal */
.f1-calendar-container {
    display: flex;
    flex-direction: column;
    gap: 25px;
    padding: 20px;
    max-width: 1000px;
    margin: 0 auto;
}

/* Targeta Base */
.f1-race-card-layout {
    display: flex;
    background-color: #15151e;
    border-radius: 0 15px 15px 0;
    overflow: hidden;
    border-left: 5px solid #e10600; /* La línia vermella de F1 */
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    min-height: 180px;
}

.f1-race-card-layout:hover {
    transform: translateX(10px);
    box-shadow: 0 5px 20px rgba(225, 6, 0, 0.2);
}

/* Columna Imatge */
.f1-card-track-image {
    width: 250px;
    background-color: #1a1a1a;
    display: flex;
    align-items: center;
    justify-content: center;
    position: relative;
    padding: 15px;
    border-right: 1px solid #333;
}

.f1-card-track-image img {
    max-width: 100%;
    max-height: 120px;
    filter: brightness(0.8) invert(1); /* Per fer que els traçats negres es vegin blancs */
    object-fit: contain;
}

.f1-order-badge {
    position: absolute;
    top: 0;
    left: 0;
    background: #e10600;
    color: white;
    padding: 2px 10px;
    font-size: 0.7rem;
    font-weight: bold;
    font-family: 'Formula1-Regular', sans-serif;
}

/* Columna Informació */
.f1-card-info {
    flex: 1;
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.f1-track-name {
    font-family: 'Formula1-Regular', sans-serif;
    color: #fff;
    margin: 10px 0;
    text-transform: uppercase;
    font-size: 1.4rem;
}

.f1-card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.f1-tag-category {
    background: #333;
    color: #fff;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 0.65rem;
    letter-spacing: 1px;
}

.f1-tag-weather {
    color: #0cf;
    font-size: 0.75rem;
}

.f1-event-details {
    display: flex;
    gap: 20px;
    margin-bottom: 15px;
    color: #bbb;
    font-size: 0.85rem;
}

/* Grid de petites dades inferiors */
.f1-card-stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    border-top: 1px solid #333;
    padding-top: 15px;
}

.stat-box {
    display: flex;
    flex-direction: column;
}

.stat-label {
    font-size: 0.6rem;
    color: #e10600;
    text-transform: uppercase;
}

.stat-value {
    font-size: 0.8rem;
    color: #fff;
    font-weight: bold;
}

.f1-no-data {
    text-align: center;
    padding: 50px;
    color: #666;
    border: 2px dashed #333;
}

/* ========================================================================
12. Sponsors
======================================================================== */


/* Contenidor de patrocinadors sota el clima */
.f1-sponsors-container {
    margin-top: 20px;
    padding-top: 15px;
    border-top: 1px dashed rgba(255, 255, 255, 0.1); /* Línia divisòria subtil */
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
}

.f1-sponsor-label {
    font-size: 0.6rem;
    color: #666;
    letter-spacing: 2px;
    text-transform: uppercase;
    font-weight: bold;
}

.f1-sponsor-logos {
    display: flex;
    gap: 60px;
    justify-content: center;
    align-items: center;
    /* Filtre per fer que els logos es vegin blancs/grisos i no distreguin 
       fins que passes el ratolí per sobre */
/*    filter: grayscale(1) brightness(1.5);
    opacity: 0.7;*/
    transition: all 0.3s ease;
}

    .f1-sponsor-logos:hover {
        filter: grayscale(0) brightness(1);
        opacity: 1;
    }

.f1-partner-logo {
    max-height: 80px; /* Mida controlada */
    width: auto;
    object-fit: contain;
}

/* ========================================================================
13. Calendar
======================================================================== */


/* Estilos para el colapsable */
.f1-past-races-details {
    margin-bottom: 2rem;
    border: 1px solid red;
    border-radius: 8px;
    overflow: hidden;
}

.f1-past-races-summary {
    background-color: red;
    padding: 15px 20px;
    cursor: pointer;
    font-weight: bold;
    list-style: none; /* Quita flecha nativa */
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: white; /* Rojo F1 */
}

    .f1-past-races-summary::-webkit-details-marker {
        display: none;
    }

.f1-past-content {
    padding: 15px;
    background-color: dimgrey;
    /* Opcional: bajar un poco la opacidad para marcar que ya pasaron */
    opacity: 0.85;
}

.f1-past-races-details[open] .arrow {
    transform: rotate(180deg);
}

.arrow {
    transition: transform 0.3s ease;
}

/* ========================================================================
14. Podium
======================================================================== */


.podium-section {
    font-family: 'Formula1-Regular', Arial, sans-serif !important;
    text-transform: uppercase;
    padding: 60px 0;
    color: white;
}

.podium-container {
    display: flex;
    align-items: flex-end;
    justify-content: center;
    height: 550px;
    gap: 20px;
    margin: 100px auto 40px auto;
    max-width: 1000px;
}

/* Estructura Base del Cajón */
.podium-step {
    width: 280px;
    text-align: center;
    position: relative;
    border-radius: 8px 8px 0 0;
    border-bottom: 5px solid #e10600;
    box-shadow: 0 15px 45px rgba(0,0,0,0.9);
    padding: 20px 10px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Alturas y Colores Metálicos */
.step-1 {
    height: 480px;
    background: linear-gradient(135deg, #bf953f 0%, #fcf6ba 50%, #b38728 100%);
    color: #000;
    order: 2;
    z-index: 10;
}

.step-2 {
    height: 400px;
    background: linear-gradient(135deg, #70706F 0%, #EFEFEF 50%, #4a4a4a 100%);
    color: #000;
    order: 1;
}

.step-3 {
    height: 360px;
    background: linear-gradient(135deg, #804a00 0%, #b08d57 50%, #5e3500 100%);
    color: #000;
    order: 3;
}

/* Contenedor Foto y Corona */
.pilot-frame {
    position: relative;
    margin-top: -110px; /* Espacio para que no choque con la corona */
    margin-bottom: 20px;
    width: 150px;
    height: 150px;
}

.pilot-photo {
    width: 150px;
    height: 150px;
    border-radius: 50%;
    border: 6px solid #e10600;
    background-color: #15151e;
    box-shadow: 0 0 25px rgba(0,0,0,0.6);
    /* Ajuste para bajar la cara dentro del círculo */
    object-fit: cover;
    object-position: 50% 15%;
}

.crown-icon {
    position: absolute;
    top: -45px;
    left: 50%;
    transform: translateX(-50%);
    font-size: 3rem;
    z-index: 20;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.5));
}

/* Textos del podio */
.podium-name {
    font-size: 1.3rem;
    font-weight: bold;
    margin: 10px 0 5px 0;
    min-height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.podium-points {
    font-size: 0.9rem;
    background: rgba(0,0,0,0.2);
    padding: 6px 15px;
    border-radius: 20px;
    font-weight: bold;
    margin-bottom: 20px;
}

.step-number-big {
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 7rem;
    font-weight: 900;
    opacity: 0.15;
}

/* Sección de Hitos (Poles y Hotlaps) */
.f1-stats-footer {
    display: flex;
    justify-content: center;
    gap: 40px;
    margin-top: 80px;
    flex-wrap: wrap;
}

.f1-stat-card {
    background-color: #15151e;
    border-left: 6px solid #e10600;
    padding: 25px 35px;
    min-width: 380px;
    display: flex;
    align-items: center;
    gap: 25px;
    border-radius: 0 12px 12px 0;
    box-shadow: 0 10px 20px rgba(0,0,0,0.4);
}

.stat-text h4 {
    color: #e10600;
    font-size: 0.8rem;
    margin: 0;
    letter-spacing: 2px;
}

.stat-text p {
    color: white;
    font-size: 1.2rem;
    margin: 8px 0 0 0;
}