@import url('https://fonts.googleapis.com/css2?family=Titillium+Web:ital,wght@0,300;0,400;0,600;0,700;0,900;1,400&family=Inter:wght@300;400;500;600&display=swap');

/* ─── RESET & BASE ─── */
*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

:root {
  --f1-red:        #E8002D;
  --f1-red-dark:   #B0001F;
  --f1-bg:         #0D0D0F;
  --f1-surface:    #15151A;
  --f1-surface-2:  #1E1E25;
  --f1-surface-3:  #26262F;
  --f1-text:       #FFFFFF;
  --f1-text-muted: #8A8A9A;
  --f1-text-dim:   #55555F;
  --f1-border:     rgba(255,255,255,0.08);
  --f1-border-med: rgba(255,255,255,0.14);
  --f1-accent:     #FF5F5F;

  --font-display: 'Titillium Web', sans-serif;
  --font-body:    'Inter', sans-serif;

  --radius-sm:  4px;
  --radius-md:  8px;
  --radius-lg:  12px;

  --nav-height: 64px;
}

html, body {
  background-color: var(--f1-bg);
  color: var(--f1-text);
  font-family: var(--font-body);
  font-size: 15px;
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ─── NAV ─── */
header, nav, .navbar {
  position: sticky;
  top: 0;
  z-index: 100;
  height: var(--nav-height);
  background: rgba(13, 13, 15, 0.92);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--f1-border);
  display: flex;
  align-items: center;
  padding: 0 32px;
  gap: 48px;
}

/* Barre de vitesse rouge — signature du design */
header::before, nav::before, .navbar::before {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  width: 0;
  height: 2px;
  background: var(--f1-red);
  animation: revLine 1.2s cubic-bezier(.16,1,.3,1) 0.3s forwards;
}

@keyframes revLine {
  to { width: 100%; }
}

h1, .site-title {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 900;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--f1-text);
  text-decoration: none;
  text-align: center;
  padding-top: 1rem;
  flex-shrink: 0;
}

h1 span, .site-title span {
  color: var(--f1-red);
}

/* ─── NAV LINKS ─── */
nav ul, .navbar ul {
  list-style: none;
  display: flex;
  align-items: center;
  gap: 4px;
  margin: 0;
  padding: 0;
}

nav ul li a, .navbar ul li a,
nav a, .nav-link {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--f1-text-muted);
  text-decoration: none;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  transition: color 0.15s, background 0.15s;
  position: relative;
}

nav ul li a:hover, .navbar ul li a:hover,
nav a:hover, .nav-link:hover {
  color: var(--f1-text);
  background: var(--f1-surface-2);
}

nav ul li a.active, .navbar ul li a.active,
nav a.active, .nav-link.active {
  color: var(--f1-red);
}

nav ul li a.active::after, .navbar ul li a.active::after,
nav a.active::after, .nav-link.active::after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 16px;
  right: 16px;
  height: 2px;
  background: var(--f1-red);
  border-radius: 2px 2px 0 0;
}

/* ─── PAGE LAYOUT ─── */
.main-content, #page-content {
  max-width: 1400px;
  margin: 0 auto;
  padding: 32px 32px 64px;
}

/* ─── TYPOGRAPHIE ─── */
h2 {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--f1-text);
  margin-bottom: 8px;
}

h3 {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--f1-text);
  margin-bottom: 4px;
}

h4 {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--f1-text-muted);
  margin-bottom: 16px;
}

p {
  color: var(--f1-text-muted);
  font-size: 14px;
  line-height: 1.7;
}

/* ─── SECTION HEADER ─── */
.section-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-family: var(--font-display);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.14em;
  text-transform: uppercase;
  color: var(--f1-red);
  margin-bottom: 12px;
}

.section-label::before {
  content: '';
  width: 16px;
  height: 2px;
  background: var(--f1-red);
  border-radius: 1px;
}

/* ─── CARDS ─── */
.card {
  background: var(--f1-surface);
  border: 1px solid var(--f1-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  transition: border-color 0.2s;
}

.card:hover {
  border-color: var(--f1-border-med);
}

.card-accent {
  border-left: 3px solid var(--f1-red);
  border-radius: 0 var(--radius-lg) var(--radius-lg) 0;
}

/* ─── GRILLE STATS ─── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 12px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--f1-surface);
  border: 1px solid var(--f1-border);
  border-radius: var(--radius-md);
  padding: 20px 24px;
  position: relative;
  overflow: hidden;
  transition: border-color 0.2s, transform 0.15s;
}

.stat-card:hover {
  border-color: rgba(232, 0, 45, 0.3);
  transform: translateY(-2px);
}

.stat-card::after {
  content: '';
  position: absolute;
  top: 0; left: 0; right: 0;
  height: 2px;
  background: var(--f1-red);
  opacity: 0;
  transition: opacity 0.2s;
}

.stat-card:hover::after {
  opacity: 1;
}

.stat-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--f1-text-muted);
  margin-bottom: 8px;
}

.stat-value {
  font-family: var(--font-display);
  font-size: 32px;
  font-weight: 900;
  color: var(--f1-text);
  line-height: 1;
  letter-spacing: -0.01em;
}

.stat-value.red { color: var(--f1-red); }

.stat-delta {
  font-size: 12px;
  color: var(--f1-text-dim);
  margin-top: 6px;
}

/* ─── GRILLE CONTENU ─── */
.content-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.content-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 32px;
}

.content-grid-3 {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 20px;
  margin-bottom: 32px;
}

/* ─── TABLES ─── */
.table-wrapper {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--f1-border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

thead th {
  background: var(--f1-surface-2);
  font-family: var(--font-display);
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--f1-text-muted);
  padding: 12px 16px;
  text-align: left;
  border-bottom: 1px solid var(--f1-border);
  white-space: nowrap;
}

tbody tr {
  border-bottom: 1px solid var(--f1-border);
  transition: background 0.12s;
}

tbody tr:last-child {
  border-bottom: none;
}

tbody tr:hover {
  background: var(--f1-surface-2);
}

tbody td {
  padding: 12px 16px;
  color: var(--f1-text);
  vertical-align: middle;
}

/* Position podium */
td.pos-1 { color: var(--f1-red); font-weight: 700; }
td.pos-2 { color: #C0C0C0; font-weight: 600; }
td.pos-3 { color: #CD7F32; font-weight: 600; }

/* ─── BADGES ─── */
.badge {
  display: inline-block;
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  padding: 3px 8px;
  border-radius: var(--radius-sm);
}

.badge-red   { background: rgba(232,0,45,0.15);  color: var(--f1-red); }
.badge-gray  { background: var(--f1-surface-3);   color: var(--f1-text-muted); }
.badge-white { background: rgba(255,255,255,0.08); color: var(--f1-text); }

/* ─── DROPDOWNS & SELECTS ─── */
select, .Select-control, .dash-dropdown .e  lt-dropdown .Select-control {
  background: var(--f1-surface-2) !important;
  border: 1px solid var(--f1-border-med) !important;
  border-radius: var(--radius-sm) !important;
  color: var(--f1-text) !important;
  font-family: var(--font-body) !important;
  font-size: 13px !important;
  padding: 8px 12px !important;
  cursor: pointer;
  outline: none;
  transition: border-color 0.15s;
}

select:hover, .Select-control:hover, .dash-dropdown .elt-dropdown .Select-control:hover {
  border-color: rgba(232,0,45,0.4) !important;
}

select:focus, .Select-control.is-focused, .dash-dropdown .elt-dropdown .Select-control.is-focused {
  border-color: var(--f1-red) !important;
  box-shadow: 0 0 0 3px rgba(232,0,45,0.1) !important;
}

/* Menu dropdown Dash */
.Select-menu-outer, .VirtualizedSelectFocusedOption {
  background: var(--f1-surface-2) !important;
  border: 1px solid var(--f1-border-med) !important;
  border-radius: var(--radius-sm) !important;
}

.Select-option {
  background: transparent !important;
  color: var(--f1-text-muted) !important;
  font-size: 13px !important;
}

.Select-option:hover, .Select-option.is-focused {
  background: var(--f1-surface-3) !important;
  color: var(--f1-text) !important;
}

.Select-option.is-selected {
  background: rgba(232,0,45,0.12) !important;
  color: var(--f1-red) !important;
}

/* ─── INPUTS ─── */
input[type="text"], input[type="number"], input[type="search"] {
  background: var(--f1-surface-2);
  border: 1px solid var(--f1-border-med);
  border-radius: var(--radius-sm);
  color: var(--f1-text);
  font-family: var(--font-body);
  font-size: 13px;
  padding: 8px 12px;
  outline: none;
  transition: border-color 0.15s;
  width: 100%;
}

input:focus {
  border-color: var(--f1-red);
  box-shadow: 0 0 0 3px rgba(232,0,45,0.1);
}

/* ─── BOUTONS ─── */
button, .btn {
  font-family: var(--font-display);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  padding: 9px 20px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--f1-border-med);
  background: transparent;
  color: var(--f1-text-muted);
  background: var(--f1-surface-2); !important;
  cursor: pointer;
  transition: all 0.15s;
}

button:hover, .btn:hover {
  background: var(--f1-surface-2);
  color: var(--f1-text);
  border-color: var(--f1-border-med);
}

button.btn-primary, .btn-primary {
  background: var(--f1-red);
  border-color: var(--f1-red);
  color: #fff;
}

button.btn-primary:hover, .btn-primary:hover {
  background: var(--f1-red-dark);
  border-color: var(--f1-red-dark);
}

/* ─── GRAPHIQUES PLOTLY ─── */
.js-plotly-plot,
.dash-graph,
.plot-container {
  background: transparent !important;
}

.js-plotly-plot .plotly .bg {
  fill: transparent !important;
}

/* ─── TABS ─── */
.tab, .tab--selected,
.rc-tabs-tab {
  font-family: var(--font-display) !important;
  font-size: 12px !important;
  font-weight: 700 !important;
  letter-spacing: 0.1em !important;
  text-transform: uppercase !important;
  color: var(--f1-text-muted) !important;
  background: transparent !important;
  border: none !important;
  border-bottom: 2px solid transparent !important;
  padding: 10px 20px !important;
  cursor: pointer;
  transition: all 0.15s !important;
}

.tab--selected,
.rc-tabs-tab-active {
  color: var(--f1-text) !important;
  border-bottom-color: var(--f1-red) !important;
}

/* ─── SLIDER ─── */
.rc-slider-rail {
  background: var(--f1-surface-3) !important;
}

.rc-slider-track {
  background: var(--f1-red) !important;
}

.rc-slider-handle {
  border-color: var(--f1-red) !important;
  background: var(--f1-bg) !important;
  box-shadow: 0 0 0 3px rgba(232,0,45,0.2) !important;
}

.rc-slider-handle:hover {
  border-color: var(--f1-red-dark) !important;
}

/* ─── PILOTE / ÉQUIPE CARD ─── */
.driver-card {
  background: var(--f1-surface);
  border: 1px solid var(--f1-border);
  border-radius: var(--radius-lg);
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 16px;
  transition: border-color 0.2s, transform 0.15s;
  cursor: pointer;
}

.driver-card:hover {
  border-color: rgba(232,0,45,0.3);
  transform: translateY(-2px);
}

.driver-number {
  font-family: var(--font-display);
  font-size: 40px;
  font-weight: 900;
  color: var(--f1-red);
  line-height: 1;
  min-width: 52px;
  letter-spacing: -0.02em;
}

.driver-info .driver-name {
  font-family: var(--font-display);
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  color: var(--f1-text);
}

.driver-info .driver-team {
  font-size: 12px;
  color: var(--f1-text-muted);
  margin-top: 2px;
}

/* ─── TEAM COLOR STRIPE ─── */
.team-stripe {
  width: 4px;
  height: 100%;
  border-radius: 2px;
  flex-shrink: 0;
}

/* ─── SEPARATEUR ─── */
.divider {
  border: none;
  border-top: 1px solid var(--f1-border);
  margin: 32px 0;
}

/* ─── LOADING ─── */
._dash-loading-callback {
  background: rgba(13,13,15,0.7) !important;
}

._dash-loading-callback::after {
  border-color: var(--f1-red) transparent transparent transparent !important;
}

/* ─── SCROLLBAR ─── */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}

::-webkit-scrollbar-track {
  background: var(--f1-surface);
}

::-webkit-scrollbar-thumb {
  background: var(--f1-surface-3);
  border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--f1-text-dim);
}

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

@media (max-width: 768px) {
  header, nav, .navbar {
    padding: 0 16px;
    gap: 16px;
  }

  .main-content, #page-content {
    padding: 20px 16px 48px;
  }

  .content-grid-2,
  .content-grid-3 {
    grid-template-columns: 1fr;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
  }

  h2 { font-size: 22px; }
}

@media (max-width: 480px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  nav ul { gap: 0; }

  nav ul li a, .nav-link {
    padding: 6px 10px;
    font-size: 11px;
  }
}

/* ─── ANIMATION ENTRÉE ─── */
@keyframes fadeUp {
  from { opacity: 0; transform: translateY(16px); }
  to   { opacity: 1; transform: translateY(0); }
}

.card, .stat-card, .driver-card {
  animation: fadeUp 0.4s ease both;
}

/* Décalage en cascade pour les grilles */
.stats-grid > *:nth-child(1) { animation-delay: 0.05s; }
.stats-grid > *:nth-child(2) { animation-delay: 0.10s; }
.stats-grid > *:nth-child(3) { animation-delay: 0.15s; }
.stats-grid > *:nth-child(4) { animation-delay: 0.20s; }

.content-grid > *:nth-child(1),
.content-grid-2 > *:nth-child(1),
.content-grid-3 > *:nth-child(1) { animation-delay: 0.10s; }

.content-grid > *:nth-child(2),
.content-grid-2 > *:nth-child(2),
.content-grid-3 > *:nth-child(2) { animation-delay: 0.18s; }

.content-grid > *:nth-child(3),
.content-grid-3 > *:nth-child(3) { animation-delay: 0.26s; }

/* ─── PLOTLY DARK THEME OVERRIDE ─── */
.gtitle, .xtitle, .ytitle, text.xtick, text.ytick {
  fill: var(--f1-text-muted) !important;
  font-family: var(--font-body) !important;
}

.gridlayer line {
  stroke: var(--f1-border) !important;
}

.zerolinelayer line {
  stroke: var(--f1-border-med) !important;
}

.dash-card {
  background: #1f1f1f;
  text-align: center;
  padding: 1rem 0;
}

.dash-options-list-option-text {
  color: var(--f1-text)
}

#track-dropdown, #driver-dropdown, #time-per-lap-track {
    background: var(--f1-surface-2); !important;
}

.dash-dropdown-content {
    background: var(--f1-surface-2); !important;
}