/* ============================================================
   Madison All-City Interclub Tennis Championships
   Prototype Stylesheet
   ============================================================ */

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

:root {
  --bg: #f4f6f8;
  --surface: #ffffff;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --primary: #15803d;     /* tennis green */
  --primary-dark: #14532d;
  --accent: #ca8a04;      /* gold for #1 */
  --danger: #dc2626;
  --warn: #ea580c;
  --info: #2563eb;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-lg: 0 10px 25px rgba(0,0,0,0.1);
  --radius: 10px;
}

body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.45;
  -webkit-font-smoothing: antialiased;
}

/* ---------- Top Bar ---------- */
.topbar {
  background: var(--primary-dark);
  color: white;
  padding: 12px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  position: sticky;
  top: 0;
  z-index: 50;
  box-shadow: var(--shadow);
}
.topbar h1 {
  font-size: 16px;
  font-weight: 600;
  line-height: 1.2;
}
.topbar h1 .sub {
  display: block;
  font-size: 11px;
  font-weight: 400;
  opacity: 0.8;
  margin-top: 2px;
}
.nav-links { display: flex; gap: 8px; flex-shrink: 0; }
.nav-links a {
  color: white;
  text-decoration: none;
  font-size: 13px;
  padding: 6px 12px;
  border-radius: 6px;
  background: rgba(255,255,255,0.1);
  transition: background 0.15s;
}
.nav-links a:hover { background: rgba(255,255,255,0.2); }
.nav-links a.active { background: var(--accent); }

/* ---------- Layout ---------- */
.container { max-width: 1200px; margin: 0 auto; padding: 16px; }
.page-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
}
.page-sub {
  color: var(--text-muted);
  font-size: 14px;
  margin-bottom: 20px;
}

.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}
@media (max-width: 800px) {
  .grid-2 { grid-template-columns: 1fr; }
}

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  margin-bottom: 16px;
  overflow: hidden;
}
.card-header {
  padding: 12px 16px;
  background: var(--primary);
  color: white;
  font-weight: 600;
  font-size: 15px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-header.alt { background: #334155; }
.card-body { padding: 12px 16px; }

/* ---------- Court Board ---------- */
.court-row {
  display: grid;
  grid-template-columns: 44px 1fr;
  gap: 10px;
  padding: 10px;
  border-bottom: 1px solid var(--border);
  align-items: center;
  font-size: 14px;
}
.court-row:last-child { border-bottom: none; }
.court-num {
  background: var(--primary);
  color: white;
  font-weight: 700;
  text-align: center;
  border-radius: 6px;
  padding: 8px 0;
  font-size: 14px;
}
.court-num.empty { background: #94a3b8; }
.match-text { line-height: 1.4; }
.team {
  display: block;
  padding: 2px 0;
}
.team .club-tag {
  display: inline-block;
  font-weight: 700;
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 4px;
  color: white;
  margin-right: 6px;
  vertical-align: middle;
  min-width: 38px;
  text-align: center;
}
.vs-divider {
  text-align: center;
  color: var(--text-muted);
  font-size: 11px;
  font-weight: 600;
  margin: 2px 0;
}

/* ---------- Leaderboard Table ---------- */
.table-wrap { overflow-x: auto; }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}
th, td {
  padding: 10px 12px;
  text-align: left;
  border-bottom: 1px solid var(--border);
}
th {
  background: #f8fafc;
  font-weight: 600;
  font-size: 12px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}
td.num, th.num { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:hover { background: #f8fafc; }

.place {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: #e2e8f0;
  color: var(--text);
  font-weight: 700;
  font-size: 13px;
}
.place-1 { background: #fbbf24; color: white; }
.place-2 { background: #cbd5e1; color: white; }
.place-3 { background: #d97706; color: white; }

/* ---------- Recent Results ---------- */
.result-row {
  padding: 10px 12px;
  border-bottom: 1px solid var(--border);
  font-size: 14px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}
.result-row:last-child { border-bottom: none; }
.result-text { flex: 1; }
.result-text .winner { font-weight: 600; }
.result-score {
  font-weight: 700;
  background: #f1f5f9;
  padding: 4px 10px;
  border-radius: 6px;
  font-variant-numeric: tabular-nums;
  flex-shrink: 0;
}
.result-time {
  font-size: 11px;
  color: var(--text-muted);
  display: block;
  margin-top: 2px;
}

/* ---------- Badges ---------- */
.badge {
  display: inline-block;
  font-size: 11px;
  font-weight: 600;
  padding: 3px 8px;
  border-radius: 999px;
  white-space: nowrap;
}
.badge-ready    { background: #dcfce7; color: #166534; }
.badge-court    { background: #dbeafe; color: #1e40af; }
.badge-na       { background: #fee2e2; color: #991b1b; }
.badge-approved { background: #dcfce7; color: #166534; }
.badge-pending  { background: #fef3c7; color: #92400e; }
.badge-suggested { background: #f1f5f9; color: var(--text-muted); }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
  padding: 8px 14px;
  border: 1px solid var(--border);
  background: white;
  color: var(--text);
  border-radius: 6px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
  font-family: inherit;
  min-height: 36px;
}
.btn:hover { background: #f8fafc; }
.btn-primary { background: var(--primary); color: white; border-color: var(--primary); }
.btn-primary:hover { background: var(--primary-dark); }
.btn-danger { background: white; color: var(--danger); border-color: #fecaca; }
.btn-danger:hover { background: #fef2f2; }
.btn-warn { background: white; color: var(--warn); border-color: #fed7aa; }
.btn-warn:hover { background: #fff7ed; }
.btn-info { background: white; color: var(--info); border-color: #bfdbfe; }
.btn-info:hover { background: #eff6ff; }
.btn-sm { padding: 5px 10px; font-size: 12px; min-height: 30px; }
.btn-block { width: 100%; }
.btn-group { display: flex; flex-wrap: wrap; gap: 6px; }

/* ---------- Admin Queue / Match Card ---------- */
.match-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 10px;
}
.match-card.approved { border-left: 4px solid var(--primary); }
.match-card.pending  { border-left: 4px solid #fbbf24; }
.match-card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 8px;
  font-size: 13px;
}
.match-id { color: var(--text-muted); font-weight: 600; }
.team-row {
  font-size: 14px;
  padding: 4px 0;
}
.team-rating-line {
  font-size: 12px;
  color: var(--text-muted);
  margin: 2px 0 6px 0;
  padding-left: 4px;
}
.vs-row {
  text-align: center;
  color: var(--text-muted);
  font-weight: 600;
  font-size: 11px;
  margin: 2px 0;
}
.reasons {
  font-size: 12px;
  color: var(--text-muted);
  background: #f8fafc;
  padding: 6px 10px;
  border-radius: 6px;
  margin: 8px 0;
}
.reasons strong { color: var(--text); }

/* ---------- Tabs ---------- */
.tabs {
  display: flex;
  gap: 4px;
  border-bottom: 2px solid var(--border);
  margin-bottom: 16px;
  overflow-x: auto;
}
.tab {
  padding: 10px 16px;
  background: none;
  border: none;
  font-size: 14px;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  white-space: nowrap;
  font-family: inherit;
}
.tab.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ---------- Roster table specifics ---------- */
.rating-cell {
  font-weight: 700;
  color: var(--primary-dark);
  font-variant-numeric: tabular-nums;
}
.record-cell { font-variant-numeric: tabular-nums; }

/* ---------- Modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 16px;
}
.modal-backdrop.open { display: flex; }
.modal {
  background: white;
  border-radius: var(--radius);
  width: 100%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}
.modal-header {
  padding: 16px;
  border-bottom: 1px solid var(--border);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
.modal-header h3 { font-size: 16px; }
.modal-close {
  background: none;
  border: none;
  font-size: 22px;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
}
.modal-body { padding: 16px; }
.modal-footer {
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 8px;
}

.form-group { margin-bottom: 14px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text);
}
.form-control {
  width: 100%;
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 14px;
  font-family: inherit;
}
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(21,128,61,0.15);
}
.score-display {
  background: #f8fafc;
  padding: 10px;
  border-radius: 6px;
  margin-bottom: 12px;
  font-size: 13px;
}
.score-display .label { color: var(--text-muted); font-size: 11px; font-weight: 600; text-transform: uppercase; margin-bottom: 4px; }

.winner-pick {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}
.winner-btn {
  padding: 14px 10px;
  border: 2px solid var(--border);
  background: white;
  border-radius: 8px;
  cursor: pointer;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  text-align: center;
  transition: all 0.15s;
}
.winner-btn:hover { border-color: var(--primary); }
.winner-btn.selected {
  border-color: var(--primary);
  background: #f0fdf4;
  color: var(--primary-dark);
}

/* ---------- Filters ---------- */
.filter-row {
  display: flex;
  gap: 8px;
  margin-bottom: 12px;
  flex-wrap: wrap;
}
.filter-row select, .filter-row input {
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: 13px;
  background: white;
  font-family: inherit;
}

/* ---------- Footer / Toast ---------- */
.toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background: var(--text);
  color: white;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 14px;
  box-shadow: var(--shadow-lg);
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
  z-index: 200;
}
.toast.show { opacity: 1; }

/* ---------- Demo banner ---------- */
.demo-banner {
  background: #fef3c7;
  color: #92400e;
  padding: 8px 16px;
  font-size: 12px;
  text-align: center;
  border-bottom: 1px solid #fde68a;
}

/* ---------- Section subhead ---------- */
.section-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin: 18px 0 10px 0;
}
.section-head h2 {
  font-size: 17px;
  font-weight: 700;
}

/* ---------- Mobile tweaks ---------- */
@media (max-width: 600px) {
  .topbar h1 { font-size: 14px; }
  .topbar h1 .sub { font-size: 10px; }
  .nav-links a { padding: 5px 8px; font-size: 12px; }
  .container { padding: 12px; }
  .page-title { font-size: 19px; }
  .court-row { font-size: 13px; }
  th, td { padding: 8px 8px; font-size: 13px; }
  .btn { padding: 7px 10px; font-size: 12px; }
}
