/* ─── Variables ────────────────────────────────────────────────────────────── */
:root {
  --primary: #013369;
  --primary-light: #1a4a8a;
  --accent: #D50A0A;
  --accent-light: #ff2222;
  --bg: #F0F2F5;
  --card: #FFFFFF;
  --border: #E2E8F0;
  --text: #1A202C;
  --text-light: #64748B;
  --success: #16A34A;
  --warning: #D97706;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow: 0 4px 12px rgba(0,0,0,0.10);
  --shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
  --radius: 12px;
  --radius-sm: 8px;
  --transition: 0.18s ease;
}

/* ─── Reset ─────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-font-smoothing: antialiased; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
button { cursor: pointer; border: none; background: none; font: inherit; }
input, select, textarea { font: inherit; }
img { display: block; max-width: 100%; }
ul { list-style: none; }

/* ─── Layout ─────────────────────────────────────────────────────────────────── */
.container { max-width: 1100px; margin: 0 auto; padding: 0 20px; }
.page-content { padding: 24px 0 60px; }

/* ─── Header / Nav ────────────────────────────────────────────────────────── */
.header {
  background: var(--primary);
  color: white;
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
  position: sticky;
  top: 0;
  z-index: 100;
}
.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 60px;
}
.logo {
  font-size: 1.25rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.logo span { color: var(--accent); }
.nav {
  display: flex;
  align-items: center;
  gap: 4px;
}
.nav a {
  color: rgba(255,255,255,0.8);
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 500;
  transition: var(--transition);
}
.nav a:hover, .nav a.active {
  color: white;
  background: rgba(255,255,255,0.12);
}
.header-user {
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.875rem;
  color: rgba(255,255,255,0.8);
}
.btn-logout {
  color: rgba(255,255,255,0.7);
  font-size: 0.8rem;
  padding: 4px 10px;
  border: 1px solid rgba(255,255,255,0.25);
  border-radius: 6px;
  transition: var(--transition);
}
.btn-logout:hover { color: white; border-color: white; }

/* ─── Page Titles ─────────────────────────────────────────────────────────── */
.page-header {
  margin-bottom: 24px;
}
.page-header h1 {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--primary);
}
.page-header p {
  color: var(--text-light);
  margin-top: 4px;
  font-size: 0.95rem;
}
.week-badge {
  display: inline-flex;
  align-items: center;
  background: var(--primary);
  color: white;
  padding: 4px 14px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  text-transform: uppercase;
  margin-bottom: 12px;
}
.week-badge.locked { background: var(--accent); }

/* ─── Cards ────────────────────────────────────────────────────────────────── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border);
  overflow: hidden;
}
.card-header {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-header h2 {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
}
.card-body { padding: 20px; }

/* ─── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: var(--radius-sm);
  font-size: 0.9rem;
  font-weight: 600;
  transition: var(--transition);
  white-space: nowrap;
}
.btn-primary { background: var(--primary); color: white; }
.btn-primary:hover { background: var(--primary-light); }
.btn-accent { background: var(--accent); color: white; }
.btn-accent:hover { background: var(--accent-light); }
.btn-outline {
  border: 1.5px solid var(--border);
  color: var(--text);
  background: white;
}
.btn-outline:hover { border-color: var(--primary); color: var(--primary); }
.btn-sm { padding: 6px 14px; font-size: 0.8rem; }
.btn-danger { background: var(--accent); color: white; }
.btn-danger:hover { opacity: 0.85; }
.btn-success { background: var(--success); color: white; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ─── Forms ───────────────────────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--text-light);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.form-control {
  width: 100%;
  padding: 10px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 0.95rem;
  color: var(--text);
  background: white;
  transition: var(--transition);
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(1, 51, 105, 0.12);
}
.form-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.form-check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.9rem;
  cursor: pointer;
}
.form-check input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; }

/* ─── Login Page ──────────────────────────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--primary) 0%, #0a2a5e 100%);
  padding: 20px;
}
.login-card {
  background: white;
  border-radius: 16px;
  padding: 40px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
}
.login-logo {
  text-align: center;
  margin-bottom: 28px;
}
.login-logo h1 {
  font-size: 1.75rem;
  font-weight: 900;
  color: var(--primary);
  letter-spacing: -1px;
}
.login-logo h1 span { color: var(--accent); }
.login-logo p {
  color: var(--text-light);
  font-size: 0.9rem;
  margin-top: 4px;
}
.login-divider {
  width: 40px;
  height: 4px;
  background: var(--accent);
  border-radius: 2px;
  margin: 12px auto 24px;
}
.error-msg {
  background: #FEF2F2;
  border: 1px solid #FECACA;
  color: var(--accent);
  padding: 10px 14px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  margin-bottom: 16px;
  display: none;
}
.error-msg.show { display: block; }

/* ─── Picks Page ──────────────────────────────────────────────────────────── */
.picks-layout {
  display: grid;
  grid-template-columns: 1fr 380px;
  gap: 24px;
  align-items: start;
}
.section-label {
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 1px;
  color: var(--text-light);
  margin-bottom: 12px;
}

/* Game Cards */
.games-list { display: flex; flex-direction: column; gap: 10px; }
.game-card {
  background: var(--card);
  border-radius: var(--radius);
  border: 1.5px solid var(--border);
  overflow: hidden;
  transition: var(--transition);
}
.game-card:hover { box-shadow: var(--shadow); }
.game-card.picked { border-color: var(--primary); }
.game-card.pick-correct { border-color: var(--success); border-left: 4px solid var(--success); }
.game-card.pick-wrong { border-color: var(--accent); border-left: 4px solid var(--accent); }
.result-badge {
  font-size: 0.68rem;
  font-weight: 700;
  padding: 2px 7px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
}
.result-badge.correct { background: #DCFCE7; color: #166534; }
.result-badge.wrong { background: #FEE2E2; color: var(--accent); }
.game-meta {
  padding: 6px 12px;
  background: #F8FAFC;
  border-bottom: 1px solid var(--border);
  font-size: 0.72rem;
  color: var(--text-light);
  font-weight: 500;
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.game-status-badge {
  padding: 2px 8px;
  border-radius: 4px;
  font-size: 0.7rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.game-status-badge.live { background: #FEF3C7; color: #92400E; }
.game-status-badge.final { background: #DCFCE7; color: #166534; }
.game-status-badge.scheduled { background: #EFF6FF; color: #1D4ED8; }
.game-teams {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  padding: 8px 12px;
  gap: 8px;
}
.team-btn {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 10px;
  border-radius: var(--radius-sm);
  border: 2px solid transparent;
  transition: var(--transition);
  cursor: pointer;
  background: none;
}
.team-btn:hover { background: #F0F4FF; border-color: var(--primary); }
.team-btn.selected { background: var(--primary); border-color: var(--primary); }
.team-btn.selected .team-name,
.team-btn.selected .team-short { color: white; }
/* Away team pushes content toward the @ sign */
.team-btn.away { flex-direction: row-reverse; justify-content: flex-start; padding-right: 24px; }
.team-btn.away .team-text { text-align: right; }
/* Home team nudged outward */
.team-btn:not(.away) { padding-left: 24px; }
.team-logo { width: 32px; height: 32px; object-fit: contain; flex-shrink: 0; }
.team-logo-placeholder {
  width: 32px;
  height: 32px;
  background: var(--bg);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.65rem;
  font-weight: 700;
  color: var(--text-light);
  flex-shrink: 0;
}
.team-text { display: flex; flex-direction: column; }
.team-short { font-size: 0.85rem; font-weight: 800; color: var(--primary); letter-spacing: 0.5px; }
.team-name { font-size: 0.7rem; color: var(--text-light); line-height: 1.2; }
.vs-text { font-size: 0.8rem; font-weight: 700; color: var(--text-light); text-align: center; white-space: nowrap; }
.game-score { font-size: 0.8rem; font-weight: 700; color: var(--text); text-align: center; }

/* Confidence Board */
.confidence-board { position: sticky; top: 80px; }
.confidence-board .card-header { background: var(--primary); color: white; border-color: transparent; }
.confidence-board .card-header h2 { color: white; }
.conf-count {
  background: rgba(255,255,255,0.2);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.75rem;
  font-weight: 700;
}
.confidence-list { display: flex; flex-direction: column; gap: 0; min-height: 60px; }
.confidence-empty { text-align: center; padding: 32px 20px; color: var(--text-light); font-size: 0.875rem; }
.confidence-empty p { margin-top: 8px; }
.conf-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 16px;
  border-bottom: 1px solid var(--border);
  cursor: grab;
  transition: background var(--transition);
  user-select: none;
}
.conf-item:last-child { border-bottom: none; }
.conf-item:hover { background: #F8FAFC; }
.conf-item.dragging { opacity: 0.4; background: #EFF6FF; }
.conf-item.drag-over { background: #DBEAFE; border-top: 2px solid var(--primary); }
.conf-points {
  min-width: 34px;
  height: 34px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.8rem;
  font-weight: 800;
  flex-shrink: 0;
}
.conf-team-logo { width: 28px; height: 28px; object-fit: contain; flex-shrink: 0; }
.conf-info { flex: 1; min-width: 0; }
.conf-team { font-size: 0.875rem; font-weight: 700; color: var(--text); }
.conf-game { font-size: 0.75rem; color: var(--text-light); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.conf-drag-handle { color: var(--border); font-size: 1.1rem; flex-shrink: 0; line-height: 1; }
.conf-remove {
  background: none;
  border: none;
  color: var(--text-light);
  font-size: 1rem;
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 4px;
  transition: var(--transition);
  line-height: 1;
}
.conf-remove:hover { color: var(--accent); background: #FEF2F2; }
.submit-section {
  padding: 16px;
  border-top: 1px solid var(--border);
  background: #F8FAFC;
}
.picks-progress { font-size: 0.8rem; color: var(--text-light); margin-bottom: 10px; text-align: center; }
.picks-progress strong { color: var(--primary); }
.locked-notice {
  text-align: center;
  padding: 16px;
  color: var(--accent);
  font-weight: 600;
  font-size: 0.875rem;
  background: #FEF2F2;
  border-top: 1px solid #FECACA;
}

/* ─── Leaderboard ─────────────────────────────────────────────────────────── */
.leaderboard-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.lb-table { width: 100%; border-collapse: collapse; }
.lb-table th {
  text-align: left;
  padding: 10px 16px;
  font-size: 0.75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-light);
  background: #F8FAFC;
  border-bottom: 1px solid var(--border);
}
.lb-table td { padding: 12px 16px; border-bottom: 1px solid var(--border); font-size: 0.9rem; }
.lb-table tr:last-child td { border-bottom: none; }
.lb-table tr:hover td { background: #F8FAFC; }
.lb-rank { font-weight: 800; color: var(--text-light); width: 40px; }
.lb-rank.gold { color: #D97706; }
.lb-rank.silver { color: #94A3B8; }
.lb-rank.bronze { color: #B45309; }
.lb-username { font-weight: 600; }
.lb-score { font-weight: 800; color: var(--primary); font-size: 1rem; }
.lb-weeks { color: var(--text-light); font-size: 0.825rem; }

.picks-detail-table { width: 100%; border-collapse: collapse; }
.picks-detail-table th {
  text-align: left;
  padding: 8px 12px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-light);
  background: #F8FAFC;
  border-bottom: 1px solid var(--border);
}
.picks-detail-table td { padding: 8px 12px; border-bottom: 1px solid var(--border); font-size: 0.83rem; }
.pick-correct { color: var(--success); font-weight: 700; }
.pick-wrong { color: var(--accent); font-weight: 700; text-decoration: line-through; }
.pick-pending { color: var(--text-light); }

/* ─── Admin Page ──────────────────────────────────────────────────────────── */
.admin-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.games-admin-list { display: flex; flex-direction: column; gap: 0; }
.admin-game-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.admin-game-row:last-child { border-bottom: none; }
.admin-game-row label {
  flex: 1;
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 10px;
}
.admin-game-row input[type="checkbox"] { width: 18px; height: 18px; cursor: pointer; accent-color: var(--primary); }
.admin-game-date { font-size: 0.75rem; color: var(--text-light); }

.users-list { display: flex; flex-direction: column; gap: 0; }
.user-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
}
.user-row:last-child { border-bottom: none; }
.user-avatar {
  width: 36px;
  height: 36px;
  background: var(--primary);
  color: white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.875rem;
  flex-shrink: 0;
}
.user-info { flex: 1; }
.user-name { font-weight: 600; font-size: 0.9rem; }
.user-role { font-size: 0.75rem; color: var(--text-light); }
.user-role.admin-badge { color: var(--accent); font-weight: 700; }

.stat-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  font-size: 0.9rem;
}
.stat-row:last-child { border-bottom: none; }
.stat-label { color: var(--text-light); }
.stat-value { font-weight: 700; color: var(--primary); }

/* ─── Toast ───────────────────────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
.toast {
  background: var(--text);
  color: white;
  padding: 12px 18px;
  border-radius: var(--radius-sm);
  font-size: 0.875rem;
  font-weight: 500;
  box-shadow: var(--shadow);
  animation: slideIn 0.2s ease;
  max-width: 320px;
}
.toast.success { background: var(--success); }
.toast.error { background: var(--accent); }
@keyframes slideIn { from { opacity: 0; transform: translateX(20px); } to { opacity: 1; transform: translateX(0); } }

/* ─── Loading ─────────────────────────────────────────────────────────────── */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 48px;
  color: var(--text-light);
  gap: 10px;
}
.spinner {
  width: 20px;
  height: 20px;
  border: 2px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ─── Misc ────────────────────────────────────────────────────────────────── */
.text-center { text-align: center; }
.text-muted { color: var(--text-light); font-size: 0.875rem; }
.mt-12 { margin-top: 12px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }
.flex { display: flex; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 0.72rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}
.badge-blue { background: #DBEAFE; color: var(--primary); }
.badge-red { background: #FEE2E2; color: var(--accent); }
.badge-green { background: #DCFCE7; color: #166534; }

/* ─── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 900px) {
  .picks-layout { grid-template-columns: 1fr; }
  .leaderboard-grid { grid-template-columns: 1fr; }
  .admin-grid { grid-template-columns: 1fr; }
  .confidence-board { position: static; }
}
@media (max-width: 600px) {
  .nav a { padding: 6px 10px; font-size: 0.8rem; }
  .login-card { padding: 28px 20px; }
  .form-row { grid-template-columns: 1fr; }
}
