/* --- style.css --- */
/* F1 Goblin - Feuille de style principale */

/* --- 1. CONFIGURATION GÉNÉRALE (VARIABLES & RESET) --- */
:root {
    --f1-red: #ff1801;
    --bg-dark: #15151e;
    --bg-card: #1f1f2b;
    --text-white: #ffffff;
    --text-gray: #b0b0b8;
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Titillium Web', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--bg-dark);
    color: var(--text-white);
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* --- 2. SIDEBAR (NAVIGATION GAUCHE) --- */
.sidebar {
    width: 250px;
    background-color: #000000;
    display: flex;
    flex-direction: column;
    padding: 20px;
    margin-right: 40px;
    border-right: 2px solid var(--f1-red);
    flex-shrink: 0;
    z-index: 3000;
}


.logo-container {
    text-align: center;
    margin-bottom: 40px;
}

.logo-container img {
    max-width: 120px;
    height: auto;
    transition: transform 0.3s ease;
}

.logo-container img:hover {
    transform: scale(1.05);
}

.nav-links {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.nav-links h3 {
    color: var(--text-gray);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 15px;
    padding-left: 10px;
}

.nav-links a {
    display: block;
    color: var(--text-white);
    text-decoration: none;
    padding: 12px;
    border-radius: 8px;
    transition: background 0.3s;
    font-weight: 600;
}

.nav-links a:hover {
    background-color: rgba(255, 255, 255, 0.1);
}

.nav-links a.active {
    background-color: var(--f1-red);
    font-weight: bold;
    box-shadow: 0 4px 15px rgba(255, 24, 1, 0.3);
}

 /* --- 3. CONTENU PRINCIPAL --- */
.main-content {
    flex: 1;
    position: relative;
    padding: 0;
    overflow: auto;
}


/* Header du Dashboard */
.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 20px;
    margin-bottom: 30px;
}

.dashboard-header h1 {
    font-size: 1.5rem;
    font-weight: 900;
    letter-spacing: 2px;
    margin: 0;
    background: linear-gradient(90deg, #fff, #888);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    text-transform: uppercase;
}

/* Bouton Save (Capture d'écran) */
.save-btn {
    background: rgba(255, 255, 255, 0.1);
    padding: 8px 15px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.9rem;
    font-weight: bold;
    color: #b0b0b8;
    border: 1px solid transparent;
    transition: all 0.3s;
    margin-right: auto;
    margin-left: 20px;
}

.save-btn:hover {
    background: var(--f1-red);
    color: white;
    border-color: var(--f1-red);
    box-shadow: 0 0 10px rgba(255, 24, 1, 0.4);
}

.save-btn:active {
    transform: scale(0.95);
}

/* --- 4. SÉLECTEUR DE SAISON (DROPDOWN) --- */
.year-selector-container {
    display: flex;
    align-items: center;
    gap: 10px;
}

.custom-dropdown {
    position: relative;
    font-family: 'Segoe UI', sans-serif;
    min-width: 100px;
    user-select: none;
    z-index: 50;
}

.dropdown-trigger {
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.2);
    padding: 8px 15px;
    border-radius: 8px;
    color: white;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Style commun des listes déroulantes (Année + Pilotes) */
.dropdown-options {
    display: none;
    position: absolute;
    top: 110%;
    left: 0;
    width: 100%;
    max-height: 300px;
    overflow-y: auto;
    background: #1e1e2f;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 8px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.9);
    z-index: 9999;
}

.dropdown-options.open {
    display: block;
    animation: fadeIn 0.2s ease-out;
}

/* Items de liste */
.dropdown-item {
    padding: 12px 15px;
    cursor: pointer;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    color: #ccc;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background 0.2s;
}

.dropdown-item:last-child {
    border-bottom: none;
}

.dropdown-item:hover {
    background: var(--f1-red);
    color: white;
}

/* Scrollbar Custom */
.dropdown-options::-webkit-scrollbar {
    width: 6px;
}

.dropdown-options::-webkit-scrollbar-track {
    background: #15151e;
}

.dropdown-options::-webkit-scrollbar-thumb {
    background: #444;
    border-radius: 4px;
}

/* Animation d'ouverture */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(-5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- 5. INTERFACE DUEL (CARTES PILOTES) --- */
.duel-interface {
    background-color: var(--bg-card);
    border-radius: 16px;
    padding: 30px;
    margin: 20px auto;
    max-width: 900px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: box-shadow 0.8s ease, border-color 0.8s ease;
}

.duel-visuals {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding: 0 20px;
    position: relative;
}

/* Carte Pilote */
.driver-card-visual {
    position: relative;
    width: 250px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Dropdown pilote (positionné sur l'avatar) */
.driver-card-visual .dropdown-options {
    top: 20px;
    left: 50%;
    transform: translateX(-50%);
    width: 220px;
    background: rgba(30, 30, 47, 0.98);
    backdrop-filter: blur(5px);
}

/* Avatar interactif */
.clickable-area {
    cursor: pointer;
    width: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    transition: transform 0.2s;
}

.clickable-area:hover {
    transform: translateY(-5px);
}

.avatar-container {
    width: 120px;
    height: 120px;
    margin: 0 auto 15px auto;
    border-radius: 50%;
    border: 4px solid #444;
    padding: 3px;
    position: relative;
    background: #1a1a25;
    box-shadow: 0 10px 20px rgba(0, 0, 0, 0.4);
}

.avatar-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top center;
    border-radius: 50%;
    background-color: #2c2c3e;
}

/* "Change" au survol */
.avatar-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    display: flex;
    justify-content: center;
    align-items: center;
    font-weight: bold;
    font-size: 0.9rem;
    opacity: 0;
    transition: opacity 0.3s;
    border-radius: 50%;
    z-index: 10;
}

.clickable-area:hover .avatar-overlay {
    opacity: 1;
}

.team-badge {
    position: absolute;
    bottom: 0;
    right: 0;
    width: 30px;
    height: 30px;
    background-color: #fff;
    border-radius: 50%;
    border: 3px solid #151f2e;
    z-index: 5;
}

.team-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.driver-info h2 {
    font-size: 1.2rem;
    margin: 0;
    font-weight: 700;
    color: #fff;
}

.driver-info p {
    font-size: 0.9rem;
    margin: 5px 0 10px 0;
    color: #b0b0b8;
    text-transform: uppercase;
}

.driver-rating {
    display: inline-block;
    padding: 5px 15px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 20px;
    font-weight: bold;
    font-size: 1.1rem;
}

/* --- 6. BOUTON VS --- */
.vs-separator {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-top: 50px;
    width: 100%;
    height: 60px;
}

.vs-line {
    flex: 1;
    height: 1px;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.2), transparent);
}

.vs-pill {
    position: relative;
    height: 44px;
    width: 44px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 30px;
    display: flex;
    justify-content: center;
    align-items: center;
    cursor: pointer;
    overflow: hidden;
    transition: all 0.4s cubic-bezier(0.25, 1, 0.5, 1);
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.3);
    user-select: none;
}

.vs-text {
    font-size: 1.1rem;
    font-weight: 900;
    font-style: italic;
    color: #fff;
    flex-shrink: 0;
    z-index: 2;
}

.vs-hidden-text {
    font-size: 0.8rem;
    font-weight: 700;
    color: #fff;
    text-transform: uppercase;
    letter-spacing: 1px;
    opacity: 0;
    white-space: nowrap;
    margin-left: 0px;
    transform: translateX(20px);
    transition: all 0.3s ease;
}

/* Animation Pilule au survol */
.vs-pill:hover {
    width: 160px;
    background: var(--f1-red);
    border-color: var(--f1-red);
    box-shadow: 0 0 20px rgba(255, 24, 1, 0.4);
    gap: 10px;
}

.vs-pill:hover .vs-hidden-text {
    opacity: 1;
    transform: translateX(0);
    margin-left: 5px;
}

.vs-pill:active {
    transform: scale(0.95);
}

/* --- 7. GRAPHIQUE BARRES --- */
#chart-duel-full {
    display: flex;
    justify-content: center;
    min-height: 400px;
}

.chart-label {
    font-size: 13px;
    fill: var(--text-gray);
    font-weight: 600;
}

.chart-value {
    font-size: 18px;
    font-weight: bold;
}

rect {
    transition: opacity 0.2s;
}

rect:hover {
    opacity: 0.9;
}

/* Tooltip D3 */
.d3-tooltip {
    position: absolute;
    text-align: center;
    padding: 8px 12px;
    font-size: 14px;
    background: rgba(20, 20, 30, 0.95);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: 6px;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s;
    z-index: 10000;
}

/* --- 8. GRAPHIQUE TIMELINE --- */
.timeline-container {
    margin-top: 40px;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    width: 100%;
}

.timeline-container h3 {
    text-align: center;
    font-size: 1.1rem;
    color: var(--text-gray);
    text-transform: uppercase;
    letter-spacing: 2px;
    margin-bottom: 20px;
}

#chart-timeline {
    width: 100%;
    height: 350px;
}

.line {
    fill: none;
    stroke-width: 3px;
    stroke-linecap: round;
    filter: drop-shadow(0 0 5px rgba(0, 0, 0, 0.5));
}

.dot {
    stroke: #1f1f2b;
    stroke-width: 2px;
    transition: r 0.2s, filter 0.2s;
    cursor: pointer;
}

.dot:hover {
    r: 6;
    filter: brightness(1.3);
}

/* Personnalisation Axes Timeline */
.axis-x text {
    display: none;
}

/* Cache les chiffres car -> drapeaux */
.axis-y text {
    fill: #8a8a9b;
    font-size: 11px;
    font-family: 'Segoe UI', sans-serif;
}

.grid line {
    stroke: rgba(255, 255, 255, 0.1);
    stroke-dasharray: 4;
}

.grid path {
    display: none;
}

/* --- 9. RESPONSIVE --- */
@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .viz-1 {
        grid-column: span 1;
        height: 400px;
    }

    .duel-visuals {
        flex-direction: column;
        gap: 30px;
    }

    .sidebar {
        width: 60px;
        padding: 10px;
    }

    .nav-links span {
        display: none;
    }
}

/* --- 4. LA GRILLE DES 5 DIVS (DASHBOARD) --- */
.dashboard-grid {
    display: grid;
    /* 3 colonnes de largeur égale */
    grid-template-columns: repeat(3, 1fr);
    /* 2 lignes de 300px de haut */
    grid-template-rows: repeat(2, 300px);
    gap: 20px;
}

/* Style commun pour toutes les cartes */
.card {
    background-color: var(--bg-card);
    border-radius: 12px;
    padding: 20px;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.5);
    display: flex;
    flex-direction: column;
    position: relative;
    overflow: hidden;
}

.card-header {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 15px;
    color: var(--text-gray);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
    padding-bottom: 10px;
    display: flex;
    justify-content: space-between;
}

/* Zone vide pour placer tes futurs graphiques */
.viz-placeholder {
    flex: 1;
    background: repeating-linear-gradient(45deg,
            rgba(255, 255, 255, 0.03),
            rgba(255, 255, 255, 0.03) 10px,
            rgba(255, 255, 255, 0.05) 10px,
            rgba(255, 255, 255, 0.05) 20px);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: rgba(255, 255, 255, 0.2);
    font-style: italic;
}

/* --- 5. CONFIGURATION SPÉCIFIQUE DES DIVS --- */

/* DIV 1 : La carte principale (Track Map) - Prend 2 colonnes de large et 2 lignes de haut */
.viz-1 {
    grid-column: span 2;
    grid-row: span 2;
    border-top: 4px solid var(--f1-red);
}

/* Les autres divs occupent l'espace restant */
.viz-2 {
    border-top: 4px solid #3498db;
}

/* Bleu */
.viz-3 {
    border-top: 4px solid #f1c40f;
}

/* Jaune */
.viz-4 {
    border-top: 4px solid #2ecc71;
}

/* Vert */
.viz-5 {
    border-top: 4px solid #9b59b6;
}

/* Violet */

/* --- RESPONSIVE (Adaptation Mobile) --- */
@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
        /* Une seule colonne sur mobile */
        grid-template-rows: auto;
    }

    .viz-1 {
        grid-column: span 1;
        height: 400px;
    }

    .sidebar {
        width: 60px;
        padding: 10px;
    }

    .nav-links span,
    .nav-links h3,
    .nav-links a {
        text-align: center;
        font-size: 0.7rem;
        padding: 5px;
    }

    .logo-container img {
        max-width: 40px;
    }
}

/* --- Ajout pour D3.js --- */
.viz-container {
    width: 100%;
    height: 100%;
    min-height: 200px;
    /* Sécurité */
    position: relative;
}

/* Pour que les SVG D3 soient responsifs */
svg {
    width: 100%;
    height: 100%;
    overflow: visible;
}