/* ─────────────────────────────────────────────────────────────
   F1 RACE ANALYTICS – PREMIUM DESIGN SYSTEM
   Dark Carbon Mode, Neon Accents, Glassmorphism
───────────────────────────────────────────────────────────── */

:root {
  --bg-primary: #0b0e14;
  --bg-card: rgba(18, 24, 38, 0.75);
  --bg-card-hover: rgba(28, 36, 56, 0.85);
  --border-color: rgba(255, 255, 255, 0.08);
  --border-glow: rgba(225, 6, 0, 0.3);
  
  --f1-red: #e10600;
  --f1-red-glow: rgba(225, 6, 0, 0.5);
  --text-primary: #f8fafc;
  --text-secondary: #94a3b8;
  --text-muted: #64748b;
  
  --compound-soft: #ef4444;
  --compound-medium: #eab308;
  --compound-hard: #f8fafc;
  --compound-inter: #10b981;
  --compound-wet: #3b82f6;

  --accent-cyan: #06b6d4;
  --accent-purple: #a855f7;
  
  --font-main: 'Outfit', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --font-mono: 'JetBrains Mono', 'Fira Code', monospace;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  background-color: var(--bg-primary);
  background-image: 
    radial-gradient(circle at 15% 15%, rgba(225, 6, 0, 0.08) 0%, transparent 40%),
    radial-gradient(circle at 85% 85%, rgba(6, 182, 212, 0.05) 0%, transparent 40%),
    linear-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1px),
    linear-gradient(90deg, rgba(255, 255, 255, 0.02) 1px, transparent 1px);
  background-size: 100% 100%, 100% 100%, 32px 32px, 32px 32px;
  color: var(--text-primary);
  font-family: var(--font-main);
  min-height: 100vh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* Container */
.container {
  max-width: 1400px;
  margin: 0 auto;
  padding: 24px;
}

/* Header */
header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 20px 28px;
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  margin-bottom: 24px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.4);
}

.brand {
  display: flex;
  align-items: center;
  gap: 16px;
}

.f1-badge {
  background: linear-gradient(135deg, #e10600, #b30000);
  color: #fff;
  font-weight: 900;
  font-size: 20px;
  padding: 6px 14px;
  border-radius: 8px;
  letter-spacing: 1px;
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.4);
  box-shadow: 0 0 20px var(--border-glow);
}

.brand-text h1 {
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: #fff;
}

.brand-text p {
  font-size: 13px;
  color: var(--text-secondary);
}

.header-badges {
  display: flex;
  gap: 12px;
  align-items: center;
}

.race-picker {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 700;
}

.race-picker select {
  max-width: 240px;
  padding: 8px 30px 8px 12px;
  color: #fff;
  background: #172233;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font: inherit;
}

.badge-pill {
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-color);
  padding: 6px 14px;
  border-radius: 9999px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.badge-dot {
  width: 8px;
  height: 8px;
  background: #22c55e;
  border-radius: 50%;
  box-shadow: 0 0 10px #22c55e;
  animation: pulse 2s infinite;
}

@keyframes pulse {
  0%, 100% { opacity: 1; transform: scale(1); }
  50% { opacity: 0.5; transform: scale(0.9); }
}

/* Metric Cards */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

.metric-card {
  background: var(--bg-card);
  backdrop-filter: blur(12px);
  border: 1px solid var(--border-color);
  border-radius: 14px;
  padding: 20px;
  transition: transform 0.2s ease, border-color 0.2s ease;
  position: relative;
  overflow: hidden;
}

.metric-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 4px;
  height: 100%;
  background: var(--f1-red);
  opacity: 0;
  transition: opacity 0.2s ease;
}

.metric-card:hover {
  transform: translateY(-2px);
  border-color: rgba(255, 255, 255, 0.15);
}

.metric-card:hover::before {
  opacity: 1;
}

.metric-title {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  font-weight: 700;
  margin-bottom: 8px;
}

.metric-value {
  font-size: 26px;
  font-weight: 800;
  color: #fff;
  letter-spacing: -0.5px;
}

.metric-sub {
  font-size: 12px;
  color: var(--text-secondary);
  margin-top: 4px;
}

/* Navigation Tabs */
.tabs-nav {
  display: flex;
  gap: 8px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 24px;
  overflow-x: auto;
  padding-bottom: 4px;
}

.tab-btn {
  background: transparent;
  border: none;
  color: var(--text-secondary);
  padding: 10px 20px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  border-radius: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: all 0.2s ease;
  white-space: nowrap;
}

.tab-btn:hover {
  color: #fff;
  background: rgba(255, 255, 255, 0.04);
}

.tab-btn.active {
  color: #fff;
  background: rgba(225, 6, 0, 0.15);
  border: 1px solid rgba(225, 6, 0, 0.4);
  box-shadow: 0 0 15px rgba(225, 6, 0, 0.2);
}

/* Content Views */
.view-content {
  display: none;
  animation: fadeIn 0.3s ease forwards;
}

.view-content.active {
  display: block;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Glass Card */
.glass-panel {
  background: var(--bg-card);
  backdrop-filter: blur(16px);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 24px;
  box-shadow: 0 12px 36px rgba(0, 0, 0, 0.35);
  margin-bottom: 24px;
}

.panel-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.panel-title {
  font-size: 18px;
  font-weight: 800;
  letter-spacing: -0.3px;
  color: #fff;
}

.panel-desc {
  font-size: 13px;
  color: var(--text-secondary);
}

/* Table Styles */
.table-responsive {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  text-align: left;
}

th {
  padding: 12px 16px;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  font-weight: 700;
}

td {
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.04);
  color: var(--text-primary);
}

tr:hover td {
  background: rgba(255, 255, 255, 0.02);
}

.team-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
}

.team-stripe {
  width: 4px;
  height: 16px;
  border-radius: 2px;
}

.compound-badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 11px;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.compound-badge.soft {
  background: rgba(239, 68, 68, 0.2);
  color: #ef4444;
  border: 1px solid rgba(239, 68, 68, 0.4);
}

.compound-badge.medium {
  background: rgba(234, 179, 8, 0.2);
  color: #eab308;
  border: 1px solid rgba(234, 179, 8, 0.4);
}

.compound-badge.hard {
  background: rgba(248, 250, 252, 0.2);
  color: #f8fafc;
  border: 1px solid rgba(248, 250, 252, 0.4);
}

/* Stint Gantt Timeline */
.timeline-container {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 16px;
}

.driver-timeline-row {
  display: flex;
  align-items: center;
  gap: 16px;
}

.timeline-driver-name {
  width: 150px;
  font-size: 13px;
  font-weight: 700;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.timeline-track {
  flex: 1;
  height: 24px;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 6px;
  display: flex;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.stint-segment {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 10px;
  font-weight: 800;
  color: #000;
  transition: opacity 0.2s ease;
  cursor: pointer;
  position: relative;
}

.stint-segment:hover {
  opacity: 0.85;
}

.stint-segment.soft { background: #ef4444; }
.stint-segment.medium { background: #eab308; }
.stint-segment.hard { background: #f8fafc; color: #000; }

/* Filter / Select controls */
.controls-bar {
  display: flex;
  gap: 12px;
  align-items: center;
}

select, input {
  background: rgba(18, 24, 38, 0.9);
  border: 1px solid var(--border-color);
  color: #fff;
  padding: 8px 14px;
  border-radius: 8px;
  font-family: inherit;
  font-size: 13px;
  outline: none;
}

select:focus, input:focus {
  border-color: var(--f1-red);
}

/* Architecture visual */
.arch-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
  gap: 16px;
}

.arch-node {
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  padding: 18px;
  position: relative;
}

.arch-node h3 {
  font-size: 15px;
  font-weight: 800;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.arch-node ul {
  list-style: none;
  font-size: 13px;
  color: var(--text-secondary);
}

.arch-node li {
  margin-bottom: 6px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.arch-node li::before {
  content: '▸';
  color: var(--f1-red);
}

/* Responsive */
@media (max-width: 768px) {
  header {
    flex-direction: column;
    align-items: flex-start;
    gap: 16px;
  }
  .header-badges {
    width: 100%;
    flex-wrap: wrap;
  }
  .race-picker {
    flex: 1;
  }
  .race-picker select {
    flex: 1;
    min-width: 0;
  }
  .driver-timeline-row {
    flex-direction: column;
    align-items: flex-start;
  }
  .timeline-driver-name {
    width: 100%;
  }
  .timeline-track {
    width: 100%;
  }
}
