/* F1 Fantasy Dashboard — matches enzom.duckdns.org site aesthetic */

:root {
  --bg: #0c1015;
  --surface: #131921;
  --card: #1b2433;
  --border: #273347;

  --gold: #d4a843;
  --gold-glow: rgba(212, 168, 67, 0.14);
  --gold-line: rgba(212, 168, 67, 0.35);

  --red: #e05252;
  --red-bg: rgba(224, 82, 82, 0.12);
  --green: #4caf7d;
  --green-bg: rgba(76, 175, 125, 0.12);
  --blue: #5b8def;
  --blue-bg: rgba(91, 141, 239, 0.12);
  --amber: #e0a030;

  --text: #e4eaf3;
  --muted: #7a90a8;

  --shadow: 0 18px 60px rgba(0, 0, 0, 0.45);
  --r: 8px;
  --rl: 14px;
}

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

html { font-size: 16px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: 'Outfit', system-ui, -apple-system, Segoe UI, Roboto, Arial, sans-serif;
  min-height: 100dvh;
  overflow-x: hidden;
  padding: 22px;
}

/* Atmospheric background grid */
body::before {
  content: '';
  position: fixed;
  inset: 0;
  background:
    radial-gradient(ellipse 80% 50% at 50% -10%, rgba(212, 168, 67, 0.06) 0%, transparent 70%),
    repeating-linear-gradient(0deg, transparent, transparent 59px, rgba(255, 255, 255, 0.018) 59px, rgba(255, 255, 255, 0.018) 60px),
    repeating-linear-gradient(90deg, transparent, transparent 59px, rgba(255, 255, 255, 0.018) 59px, rgba(255, 255, 255, 0.018) 60px);
  pointer-events: none;
  z-index: 0;
}

a { color: var(--gold); text-decoration: none; }
a:hover { text-decoration: underline; }

.wrap {
  max-width: 1060px;
  margin: 0 auto;
  position: relative;
  z-index: 1;
}

/* Header */
.header {
  display: flex;
  gap: 14px;
  align-items: flex-start;
  justify-content: space-between;
  flex-wrap: wrap;
  margin-bottom: 14px;
}

.brand {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

h1 {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--gold);
}

h1 a { color: var(--gold); text-decoration: none; }

.sub { color: var(--muted); font-size: 14px; }

.header-pills {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.pill {
  padding: 6px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  font-size: 12px;
  white-space: nowrap;
}

.rule {
  height: 1px;
  background: linear-gradient(90deg, transparent 0%, var(--gold-line) 30%, var(--gold-line) 70%, transparent 100%);
  margin: 10px 0 16px;
}

/* Cards */
.card {
  background: rgba(19, 25, 33, 0.72);
  border: 1px solid var(--border);
  border-radius: 18px;
  box-shadow: var(--shadow);
  overflow: hidden;
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
}

.section-block {
  padding: 20px;
  margin-bottom: 16px;
}

.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
  flex-wrap: wrap;
  gap: 8px;
}

.section-header h2 {
  font-size: 17px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.tag {
  padding: 4px 10px;
  border-radius: 999px;
  border: 1px solid var(--border);
  background: rgba(255, 255, 255, 0.03);
  color: var(--muted);
  font-size: 12px;
}

/* Loading & Error */
.loading-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}

.spinner {
  width: 36px;
  height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--gold);
  border-radius: 50%;
  margin: 0 auto 16px;
  animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

.error-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}

.error-icon { font-size: 48px; margin-bottom: 16px; }
.error-state h3 { color: var(--text); margin-bottom: 8px; }
.error-state .hint { margin-top: 12px; font-size: 13px; }
.error-state code {
  background: var(--card);
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 12px;
  color: var(--gold);
}

/* Team Grid — Driver Cards */
.team-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
  gap: 10px;
  margin-bottom: 14px;
}

.driver-card {
  border: 1px solid var(--border);
  border-radius: var(--rl);
  background: rgba(255, 255, 255, 0.03);
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  transition: transform 0.12s ease, border-color 0.12s ease, background 0.12s ease;
}

.driver-card:hover {
  transform: translateY(-1px);
  border-color: rgba(212, 168, 67, 0.45);
  background: rgba(212, 168, 67, 0.06);
}

.driver-card.boosted {
  border-color: var(--gold);
  background: var(--gold-glow);
}

.driver-name {
  font-weight: 600;
  font-size: 14px;
  letter-spacing: -0.01em;
}

.driver-price {
  color: var(--muted);
  font-size: 13px;
}

.boost-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 8px;
  border-radius: 999px;
  background: rgba(212, 168, 67, 0.18);
  color: var(--gold);
  font-size: 11px;
  font-weight: 600;
  align-self: flex-start;
}

/* Constructor Row */
.constructors-row {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.constructor-badge {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: var(--rl);
  background: rgba(255, 255, 255, 0.03);
  font-weight: 500;
  font-size: 14px;
  flex: 1;
  min-width: 140px;
}

.constructor-badge .c-icon {
  width: 28px;
  height: 28px;
  border-radius: 8px;
  background: var(--blue-bg);
  display: grid;
  place-items: center;
  font-size: 14px;
  flex-shrink: 0;
}

.constructor-price {
  color: var(--muted);
  font-size: 12px;
  margin-left: auto;
}

/* Budget Gauge */
.budget-section {
  border-top: 1px solid var(--border);
  padding-top: 14px;
}

.budget-label {
  display: flex;
  justify-content: space-between;
  font-size: 13px;
  margin-bottom: 6px;
}

.budget-label span:first-child { color: var(--muted); }
.budget-label span:last-child { font-weight: 600; }

.budget-bar {
  height: 8px;
  background: rgba(255, 255, 255, 0.06);
  border-radius: 999px;
  overflow: hidden;
  margin-bottom: 6px;
}

.budget-fill {
  height: 100%;
  border-radius: 999px;
  background: linear-gradient(90deg, var(--gold), #e8c76a);
  transition: width 0.6s ease;
}

.budget-detail {
  font-size: 12px;
  color: var(--muted);
}

/* Diff Section */
.diff-noop {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px;
  background: var(--green-bg);
  border: 1px solid rgba(76, 175, 125, 0.3);
  border-radius: var(--rl);
  font-weight: 500;
  color: var(--green);
}

.noop-icon { font-size: 20px; }

.diff-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 14px;
}

.diff-col h4 {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 8px;
}

.diff-remove-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--red-bg);
  color: var(--red);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 4px;
}

.diff-add-badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 999px;
  background: var(--green-bg);
  color: var(--green);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 4px;
}

.boost-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px;
  background: rgba(255, 255, 255, 0.02);
  border: 1px solid var(--border);
  border-radius: var(--r);
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.boost-label {
  font-weight: 600;
  font-size: 13px;
  margin-right: 4px;
}

.arrow {
  color: var(--muted);
  font-size: 16px;
}

.policy-row {
  padding: 12px;
  border-radius: var(--r);
  font-size: 13px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.policy-ok {
  background: var(--green-bg);
  border: 1px solid rgba(76, 175, 125, 0.3);
  color: var(--green);
}

.policy-warn {
  background: rgba(224, 160, 48, 0.12);
  border: 1px solid rgba(224, 160, 48, 0.3);
  color: var(--amber);
}

/* Optimal Team Tables */
.optimal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-bottom: 14px;
}

.table-label {
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--muted);
  margin-bottom: 8px;
}

.table-wrap {
  overflow-x: auto;
}

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

.data-table th {
  text-align: left;
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
  color: var(--muted);
  font-weight: 500;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.data-table td {
  padding: 8px 10px;
  border-bottom: 1px solid rgba(39, 51, 71, 0.5);
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table .boosted-row {
  background: var(--gold-glow);
}

.role-badge {
  display: inline-block;
  padding: 1px 8px;
  border-radius: 999px;
  background: var(--gold-glow);
  color: var(--gold);
  font-size: 11px;
  font-weight: 600;
}

.optimal-summary {
  border-top: 1px solid var(--border);
  padding-top: 12px;
  display: flex;
  gap: 24px;
  flex-wrap: wrap;
}

.opt-stat {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.opt-stat .label {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  color: var(--muted);
}

.opt-stat .value {
  font-size: 18px;
  font-weight: 700;
  color: var(--gold);
}

/* Chart */
.chart-container {
  height: 260px;
  position: relative;
}

/* Footer */
.footer {
  border-top: 1px solid var(--border);
  padding: 12px 0;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  color: var(--muted);
  font-size: 13px;
}

/* Responsive */
@media (max-width: 640px) {
  body { padding: 14px; }

  .team-grid {
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 8px;
  }

  .diff-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

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

  .header {
    flex-direction: column;
    gap: 10px;
  }

  .chart-container {
    height: 200px;
  }

  .section-block {
    padding: 14px;
  }
}

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