/* Virtual F1 — Global Styles */
:root {
  --bg: #0a0a0a;
  --bg2: #111111;
  --card: #1a1a1a;
  --card-hover: #222222;
  --border: #2a2a2a;
  --accent: #e10600;
  --accent-hover: #ff1a17;
  --text: #ffffff;
  --text-muted: #888888;
  --text-dim: #444444;
  --green: #00c853;
  --amber: #ffab00;
  --mono: 'Courier New', Courier, monospace;
}

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

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  min-height: 100vh;
}

/* ---- NAV ---- */
nav {
  background: #000;
  border-bottom: 2px solid var(--accent);
  padding: 0 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 56px;
  position: sticky;
  top: 0;
  z-index: 100;
}

.nav-brand {
  font-weight: 900;
  font-size: 1.2rem;
  color: var(--accent);
  text-decoration: none;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.nav-links {
  display: flex;
  gap: 1.5rem;
  align-items: center;
  list-style: none;
}

.nav-links a {
  color: var(--text-muted);
  text-decoration: none;
  font-size: 0.9rem;
  font-weight: 500;
  transition: color 0.15s;
}

.nav-links a:hover, .nav-links a.active { color: var(--text); }

/* ---- LAYOUT ---- */
.container { max-width: 1200px; margin: 0 auto; padding: 2rem 1.5rem; }
.page-title { font-size: 1.8rem; font-weight: 800; margin-bottom: 1.5rem; }
.page-title span { color: var(--accent); }

/* ---- CARD ---- */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.5rem;
  position: relative;
  overflow: hidden;
}

.card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    45deg,
    transparent,
    transparent 10px,
    rgba(255,255,255,0.012) 10px,
    rgba(255,255,255,0.012) 20px
  );
  pointer-events: none;
}

/* ---- BUTTONS ---- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  padding: 0.6rem 1.2rem;
  border-radius: 6px;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background 0.15s, transform 0.1s;
  text-decoration: none;
}

.btn:active { transform: scale(0.97); }

.btn-primary { background: var(--accent); color: #fff; }
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary { background: var(--border); color: var(--text); }
.btn-secondary:hover { background: var(--card-hover); }

.btn-danger { background: #8b0000; color: #fff; }
.btn-danger:hover { background: #b00000; }

.btn-sm { padding: 0.35rem 0.75rem; font-size: 0.8rem; }

/* ---- FORMS ---- */
.form-group { margin-bottom: 1rem; }
.form-label { display: block; font-size: 0.85rem; color: var(--text-muted); margin-bottom: 0.4rem; }

.form-input {
  width: 100%;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.6rem 0.9rem;
  color: var(--text);
  font-size: 0.95rem;
  outline: none;
  transition: border-color 0.15s;
}

.form-input:focus { border-color: var(--accent); }

/* ---- TABS ---- */
.tabs {
  display: flex;
  border-bottom: 1px solid var(--border);
  margin-bottom: 1.5rem;
  gap: 0;
}

.tab-btn {
  padding: 0.75rem 1.25rem;
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color 0.15s, border-color 0.15s;
}

.tab-btn:hover { color: var(--text); }
.tab-btn.active { color: var(--text); border-bottom-color: var(--accent); }

.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---- RACE GRID ---- */
.race-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
}

.race-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 1.25rem;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;
  position: relative;
  overflow: hidden;
}

.race-card:hover { border-color: var(--accent); background: var(--card-hover); }

.race-card::before {
  content: '';
  position: absolute;
  inset: 0;
  background: repeating-linear-gradient(
    45deg, transparent, transparent 10px,
    rgba(255,255,255,0.012) 10px, rgba(255,255,255,0.012) 20px
  );
  pointer-events: none;
}

.race-round {
  font-size: 0.75rem;
  color: var(--accent);
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  margin-bottom: 0.3rem;
}

.race-name {
  font-size: 1.05rem;
  font-weight: 700;
  margin-bottom: 0.25rem;
}

.race-circuit {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.75rem;
}

.race-status {
  display: inline-block;
  padding: 0.25rem 0.6rem;
  border-radius: 4px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.status-upcoming    { background: #1a2a3a; color: #4a9fd4; }
.status-open        { background: #1a3a1a; color: #4ad44a; }
.status-locked      { background: #2a2a1a; color: #d4c44a; }
.status-predicted   { background: #0f2a2a; color: #4ad4b8; }
.status-results     { background: #2a1a2a; color: #c44ad4; }
.status-sprint      { font-size: 0.65rem; background: #3a1a00; color: var(--accent); margin-left: 0.4rem; }

/* ---- DRAG RANKER ---- */
.ranker-container {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  max-width: 480px;
}

.ranker-slot {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 0.5rem 0.75rem;
  cursor: grab;
  user-select: none;
  transition: border-color 0.15s, background 0.15s;
  touch-action: none;
}

.ranker-slot:active { cursor: grabbing; }
.ranker-slot.dragging { opacity: 0.4; border-style: dashed; }
.ranker-slot.drag-over { border-color: var(--accent); background: #2a0a0a; }

.slot-position {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--accent);
  font-weight: 700;
  min-width: 28px;
  text-align: center;
}

.slot-driver {
  flex: 1;
  font-size: 0.95rem;
  font-weight: 500;
}

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

.slot-handle {
  color: var(--text-dim);
  font-size: 1rem;
}

.ranker-pool {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
}

.ranker-pool-title {
  font-size: 0.8rem;
  color: var(--text-muted);
  margin-bottom: 0.5rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.pool-drivers {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

.pool-driver {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 4px;
  padding: 0.3rem 0.6rem;
  font-size: 0.8rem;
  cursor: pointer;
  transition: border-color 0.15s;
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

.pool-driver:hover { border-color: var(--accent); }

/* ---- LEADERBOARD ---- */
.lb-table {
  width: 100%;
  border-collapse: collapse;
}

.lb-table th, .lb-table td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

.lb-table th {
  color: var(--text-muted);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}

.lb-table td { font-size: 0.95rem; }

.lb-table .rank {
  font-family: var(--mono);
  color: var(--accent);
  font-weight: 700;
}

.lb-table .points {
  font-family: var(--mono);
  font-weight: 700;
}

.lb-table .me { background: rgba(225, 6, 0, 0.08); }

.lb-table tr:hover { background: var(--card-hover); }

/* ---- COUNTDOWN ---- */
.countdown {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--amber);
}

.countdown.locked { color: var(--text-dim); }

/* ---- SCORE CHIPS ---- */
.chip {
  display: inline-block;
  padding: 0.15rem 0.45rem;
  border-radius: 3px;
  font-size: 0.75rem;
  font-weight: 700;
  font-family: var(--mono);
}

.chip-exact  { background: rgba(0, 200, 83, 0.15); color: var(--green); }
.chip-partial { background: rgba(255, 171, 0, 0.15); color: var(--amber); }
.chip-miss   { background: rgba(100, 100, 100, 0.1); color: var(--text-dim); }

/* ---- AUTH PAGE ---- */
.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: radial-gradient(ellipse at center, #1a0000 0%, #0a0a0a 70%);
}

.auth-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 2.5rem;
  width: 100%;
  max-width: 400px;
}

.auth-logo {
  text-align: center;
  margin-bottom: 1.5rem;
}

.auth-logo-text {
  font-size: 2rem;
  font-weight: 900;
  color: var(--accent);
  letter-spacing: 0.05em;
  text-transform: uppercase;
}

.auth-logo-sub {
  font-size: 0.8rem;
  color: var(--text-muted);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

/* ---- ALERTS ---- */
.alert {
  padding: 0.75rem 1rem;
  border-radius: 6px;
  font-size: 0.9rem;
  margin-bottom: 1rem;
}

.alert-error { background: rgba(225, 6, 0, 0.1); border: 1px solid rgba(225, 6, 0, 0.3); color: #ff6b6b; }
.alert-success { background: rgba(0, 200, 83, 0.1); border: 1px solid rgba(0, 200, 83, 0.3); color: var(--green); }

/* ---- MODAL ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  display: none;
}

.modal-overlay.open { display: flex; }

.modal {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 2rem;
  max-width: 480px;
  width: 100%;
}

.modal-title { font-size: 1.1rem; font-weight: 700; margin-bottom: 1rem; }
.modal-actions { display: flex; gap: 0.75rem; justify-content: flex-end; margin-top: 1.5rem; }

/* ---- ADMIN ---- */
.admin-user-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
}

.admin-user-table th, .admin-user-table td {
  padding: 0.6rem 0.85rem;
  border-bottom: 1px solid var(--border);
  text-align: left;
}

.admin-user-table th {
  color: var(--text-muted);
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.admin-search {
  margin-bottom: 1rem;
}

/* ---- SESSION LOCK TIME ---- */
.session-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.4rem 0;
  font-size: 0.85rem;
  border-bottom: 1px solid var(--border);
}

.session-row:last-child { border-bottom: none; }

.session-label {
  color: var(--text-muted);
  text-transform: capitalize;
  min-width: 120px;
}

.session-time { font-family: var(--mono); font-size: 0.8rem; }

/* ---- PREDICT PAGE ---- */
.predict-header {
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.predict-race-name { font-size: 1.4rem; font-weight: 800; margin-bottom: 0.25rem; }
.predict-circuit { color: var(--text-muted); font-size: 0.9rem; }

/* ---- RESULTS PAGE ---- */
.result-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}

.result-pos {
  font-family: var(--mono);
  font-size: 0.85rem;
  color: var(--accent);
  font-weight: 700;
  min-width: 32px;
  text-align: center;
}

.result-driver { flex: 1; font-weight: 500; }
.result-points { font-family: var(--mono); font-weight: 700; }

/* ---- RESPONSIVE ---- */
@media (max-width: 640px) {
  .race-grid { grid-template-columns: 1fr; }
  .container { padding: 1rem; }
  nav { padding: 0 1rem; }
  .nav-links { gap: 1rem; }
  .ranker-container { max-width: 100%; }
}

/* ---- SPINNER ---- */
.spinner {
  display: inline-block;
  width: 20px; height: 20px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

/* ---- SELECT ---- */
select.form-input {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23888' stroke-width='1.5' fill='none'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 0.9rem center;
  padding-right: 2.5rem;
}
