/* ============================================================
   Fantasy F1 2026 — Styles
   ============================================================ */

/* ---------- Reset & base ---------- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:           #0f1117;
  --surface:      #1a1d27;
  --surface-alt:  #22263a;
  --border:       #2e3349;
  --text:         #e8eaf0;
  --text-muted:   #8891aa;
  --accent:       #e8002d;   /* F1 red */
  --green:        #22c55e;
  --amber:        #f59e0b;
  --radius:       10px;
  --radius-sm:    6px;
  --shadow:       0 2px 12px rgba(0,0,0,.45);
  --font:         -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  --transition:   160ms ease;
}

html { font-size: 16px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: var(--font);
  line-height: 1.5;
  min-height: 100vh;
  padding-bottom: 3rem;
}

/* ---------- Header ---------- */
header {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: .875rem 1.25rem;
  position: sticky;
  top: 0;
  z-index: 10;
}

.header-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

h1 {
  font-size: 1.35rem;
  font-weight: 700;
  letter-spacing: -.02em;
}

h1 .season-year {
  color: var(--accent);
}

.admin-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  width: 2rem;
  height: 2rem;
  padding: 0;
  cursor: pointer;
  font-size: 1rem;
  line-height: 1;
  display: grid;
  place-items: center;
  transition: color var(--transition), border-color var(--transition);
}
.admin-btn:hover { color: var(--text); border-color: var(--text-muted); }

/* ---------- Main layout ---------- */
main {
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 0;
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.main-columns {
  display: grid;
  gap: 1.5rem;
  grid-template-columns: 1fr;
}

@media (min-width: 860px) {
  .main-columns {
    grid-template-columns: 360px 1fr;
    align-items: start;
  }
}

/* ---------- Section label ---------- */
.section-label {
  font-size: .72rem;
  font-weight: 700;
  letter-spacing: .1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: .75rem;
}

/* ---------- Event status panel ---------- */
#event-status {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
}

.event-rows {
  display: flex;
  flex-direction: column;
  gap: .5rem;
}

.event-row {
  display: grid;
  grid-template-columns: 1.5rem 1fr auto;
  align-items: center;
  gap: .75rem;
  padding: .6rem .75rem;
  border-radius: var(--radius-sm);
  background: var(--surface-alt);
  font-size: .9rem;
}

.event-row.past { opacity: .75; }

.event-icon { font-size: 1rem; text-align: center; }
.event-name { font-weight: 600; }
.event-detail { font-size: .8rem; color: var(--text-muted); text-align: right; }

.event-row.status-confirmed .event-icon { color: var(--green); }
.event-row.status-pending   .event-icon { color: var(--amber); }
.event-row.status-upcoming  .event-icon { color: var(--text-muted); }

.event-type-badge {
  font-size: .65rem;
  font-weight: 700;
  letter-spacing: .06em;
  text-transform: uppercase;
  background: var(--border);
  color: var(--text-muted);
  border-radius: 3px;
  padding: 1px 5px;
  margin-left: .4rem;
}

/* ---------- Leaderboard ---------- */
#leaderboard { }

.team-cards {
  display: flex;
  flex-direction: column;
  gap: .75rem;
}

.team-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  border-left: 4px solid var(--team-color, var(--border));
  padding: 1rem 1.1rem;
  display: grid;
  grid-template-columns: 2rem 1fr auto;
  align-items: center;
  gap: .75rem;
  transition: border-color var(--transition);
}

.team-rank {
  font-size: 1.2rem;
  font-weight: 800;
  color: var(--text-muted);
  text-align: center;
}

.team-rank.rank-1 { color: #ffd700; }
.team-rank.rank-2 { color: #c0c0c0; }
.team-rank.rank-3 { color: #cd7f32; }

.team-info { min-width: 0; }
.team-name {
  font-weight: 700;
  font-size: 1rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.team-drivers {
  font-size: .8rem;
  color: var(--text-muted);
  margin-top: .15rem;
}

.team-points {
  text-align: right;
}
.points-value {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -.03em;
  line-height: 1;
  color: var(--text);
}
.points-label {
  font-size: .7rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
}

.adjustment-note {
  font-size: .72rem;
  color: var(--text-muted);
  margin-top: .1rem;
}

/* ---------- Chart ---------- */
#chart-container {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.1rem 1.25rem;
}

.chart-wrap {
  position: relative;
  height: 320px;
}

@media (min-width: 860px) {
  .chart-wrap { height: 400px; }
}

/* ---------- Error banner ---------- */
.error-banner {
  background: rgba(232, 0, 45, .12);
  border: 1px solid rgba(232, 0, 45, .4);
  border-radius: var(--radius-sm);
  color: #ff6b88;
  padding: .75rem 1rem;
  font-size: .9rem;
}

/* ---------- Skeletons ---------- */
.skeleton {
  background: linear-gradient(90deg, var(--surface) 25%, var(--surface-alt) 50%, var(--surface) 75%);
  background-size: 200% 100%;
  animation: shimmer 1.4s infinite;
  border-radius: var(--radius);
}

.event-row.skeleton { height: 2.75rem; border: none; }
.team-card.skeleton  { height: 5rem; border: none; }

@keyframes shimmer {
  from { background-position: 200% 0; }
  to   { background-position: -200% 0; }
}

/* ---------- Admin dialog ---------- */
dialog {
  position: fixed;
  inset: 0;
  margin: auto;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--surface);
  color: var(--text);
  padding: 0;
  max-width: 640px;
  width: calc(100vw - 2rem);
  max-height: calc(100vh - 4rem);
  overflow-y: auto;
  box-shadow: var(--shadow);
}

dialog::backdrop {
  background: rgba(0,0,0,.6);
  backdrop-filter: blur(2px);
}

.dialog-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  background: var(--surface);
  z-index: 1;
}

.dialog-header h2 { font-size: 1rem; font-weight: 700; }

.close-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  font-size: 1rem;
  padding: .25rem;
  border-radius: var(--radius-sm);
  transition: color var(--transition);
}
.close-btn:hover { color: var(--text); }

/* ---------- Admin sections ---------- */
.admin-section {
  padding: 1.25rem;
}

.admin-hint {
  color: var(--text-muted);
  font-size: .9rem;
  margin-bottom: 1rem;
}

.input-row {
  display: flex;
  gap: .5rem;
}

input[type="password"],
input[type="text"],
input[type="number"] {
  background: var(--bg);
  border: 1px solid var(--border);
  color: var(--text);
  border-radius: var(--radius-sm);
  padding: .5rem .75rem;
  font-size: .9rem;
  font-family: var(--font);
  outline: none;
  transition: border-color var(--transition);
  width: 100%;
}
input:focus { border-color: var(--text-muted); }

button {
  background: var(--accent);
  border: none;
  color: #fff;
  border-radius: var(--radius-sm);
  padding: .5rem 1rem;
  font-size: .9rem;
  font-family: var(--font);
  font-weight: 600;
  cursor: pointer;
  white-space: nowrap;
  transition: opacity var(--transition);
}
button:hover { opacity: .85; }
button:disabled { opacity: .45; cursor: default; }

.secondary-btn {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  color: var(--text);
}

.field-error {
  color: #ff6b88;
  font-size: .8rem;
  margin-top: .5rem;
}

/* ---------- Team editor ---------- */
.team-editor-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1rem;
}

.team-editor-card {
  background: var(--surface-alt);
  border: 1px solid var(--border);
  border-left: 4px solid var(--team-color, var(--border));
  border-radius: var(--radius-sm);
  padding: 1rem;
}

.team-editor-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: .5rem .75rem;
  margin-bottom: .5rem;
}

.team-editor-row.full { grid-template-columns: 1fr; }

.field-label {
  font-size: .72rem;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: .2rem;
}

.team-editor-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: .5rem;
}

.remove-team-btn {
  background: none;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: .25rem .6rem;
  font-size: .8rem;
}
.remove-team-btn:hover { color: #ff6b88; border-color: #ff6b88; }

.editor-actions {
  display: flex;
  gap: .5rem;
  justify-content: flex-end;
  padding-top: .75rem;
  border-top: 1px solid var(--border);
}

.save-status {
  margin-top: .75rem;
  font-size: .85rem;
  text-align: right;
}
.save-status.ok  { color: var(--green); }
.save-status.err { color: #ff6b88; }
