/* ============================================================
   Vermont Baseball League — styles.css
   ============================================================ */

/* ── Variables ── */
:root {
  --navy:       #1a2e4a;
  --navy-dark:  #0f1e30;
  --navy-light: #243c5a;
  --blue:       #2c7be5;
  --blue-hover: #1a68d4;
  --gold:       #f59e0b;
  --gold-dark:  #d97706;
  --silver:     #94a3b8;
  --bronze:     #b45309;
  --bg:         #f1f5f9;
  --card:       #ffffff;
  --text:       #1e293b;
  --text-light: #475569;
  --muted:      #94a3b8;
  --border:     #e2e8f0;
  --green:      #16a34a;
  --green-bg:   #f0fdf4;
  --red:        #dc2626;
  --red-bg:     #fef2f2;
  --shadow:     0 1px 3px rgba(0,0,0,.10), 0 1px 2px rgba(0,0,0,.06);
  --shadow-md:  0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.05);
  --radius:     8px;
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', sans-serif; font-size: 16px; }
body { background: var(--bg); color: var(--text); min-height: 100vh; }
button { font-family: inherit; }
a { color: var(--blue); }

/* ── Navigation ── */
.nav {
  background: var(--navy-dark);
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.35);
}
.nav-inner {
  max-width: 1200px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  padding: 0 20px;
  height: 62px;
  gap: 8px;
}
.nav-brand {
  color: #fff;
  font-weight: 700;
  font-size: 1.05rem;
  flex: 1;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
}
.nav-brand .brand-icon { color: var(--gold); font-size: 1.2em; }
.nav-tabs { display: flex; gap: 2px; }
.nav-tab {
  color: rgba(255,255,255,.65);
  background: none;
  border: none;
  padding: 8px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-size: .875rem;
  font-weight: 500;
  transition: background .15s, color .15s;
  display: flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
}
.nav-tab:hover  { background: rgba(255,255,255,.10); color: #fff; }
.nav-tab.active { background: var(--blue); color: #fff; }

/* ── Main Layout ── */
.main { max-width: 1200px; margin: 0 auto; padding: 24px 20px; }
.page { display: none; }
.page.active { display: block; }
.spacer { height: 20px; }
.spacer-sm { height: 12px; }

/* ── Cards ── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 20px 24px;
  border: 1px solid var(--border);
}
.card-title {
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-light);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-bottom: 6px;
}
.card-value {
  font-size: 1.8rem;
  font-weight: 800;
  color: var(--text);
  line-height: 1;
  font-variant-numeric: tabular-nums;
}
.card-sub {
  font-size: .8rem;
  color: var(--muted);
  margin-top: 6px;
  line-height: 1.4;
}

/* ── Stat Card Grid ── */
.stats-cards {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 16px;
  margin-bottom: 24px;
}

/* ── Section Header ── */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.section-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
}

/* ── Year Selector Bar ── */
.year-bar {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.year-arrow {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  color: var(--text-light);
  font-size: 1rem;
  transition: background .15s, color .15s, border-color .15s;
}
.year-arrow:hover:not(:disabled) { background: var(--navy); color: #fff; border-color: var(--navy); }
.year-arrow:disabled { opacity: .35; cursor: not-allowed; }
.year-select {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 1rem;
  font-weight: 700;
  color: var(--text);
  cursor: pointer;
  appearance: auto;
}

/* ── Season Hero Banner ── */
.season-hero {
  background: linear-gradient(135deg, var(--navy-dark) 0%, var(--navy-light) 100%);
  border-radius: var(--radius);
  padding: 22px 28px;
  margin-bottom: 18px;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.season-hero-left .hero-year  { font-size: 2.4rem; font-weight: 900; color: var(--gold); line-height: 1; }
.season-hero-left .hero-league { font-size: .8rem; color: rgba(255,255,255,.55); margin-top: 4px; letter-spacing: .04em; text-transform: uppercase; }
.season-hero-mid { text-align: center; }
.season-hero-right { text-align: right; }
.hero-label { font-size: .75rem; color: rgba(255,255,255,.55); text-transform: uppercase; letter-spacing: .08em; }
.hero-team  { font-size: 1.25rem; font-weight: 700; margin-top: 4px; }
.hero-pts   { font-size: .9rem; color: var(--gold); margin-top: 3px; }

/* ── Tables ── */
.table-wrap { overflow-x: auto; border-radius: var(--radius); }
table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}
thead th {
  background: var(--navy);
  color: rgba(255,255,255,.88);
  font-weight: 600;
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: 10px 14px;
  white-space: nowrap;
  text-align: left;
}
thead th.r { text-align: right; }
thead th.sortable { cursor: pointer; user-select: none; }
thead th.sortable:hover { background: var(--navy-light); }
thead th.sort-asc::after  { content: ' ↑'; opacity: .65; font-size: .85em; }
thead th.sort-desc::after { content: ' ↓'; opacity: .65; font-size: .85em; }
tbody td {
  padding: 10px 14px;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}
tbody td.r { text-align: right; font-variant-numeric: tabular-nums; }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background: #f8fafc; }

/* Top-3 rank coloring */
.rk-1 td:first-child { color: var(--gold); font-weight: 800; }
.rk-2 td:first-child { color: var(--silver); font-weight: 700; }
.rk-3 td:first-child { color: var(--bronze); font-weight: 700; }

/* ── Points Bar ── */
.pts-bar-cell { display: flex; align-items: center; gap: 10px; }
.pts-bar-bg {
  width: 90px;
  height: 7px;
  background: var(--border);
  border-radius: 4px;
  overflow: hidden;
  flex-shrink: 0;
}
.pts-bar-fill { height: 100%; background: var(--blue); border-radius: 4px; }
.pts-num { font-weight: 700; font-variant-numeric: tabular-nums; min-width: 52px; }

/* ── Inline Tabs (Hitting/Pitching) ── */
.inline-tabs { display: flex; border-bottom: 2px solid var(--border); margin-bottom: 16px; }
.inline-tab {
  background: none;
  border: none;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  padding: 8px 20px;
  cursor: pointer;
  font-size: .875rem;
  font-weight: 600;
  color: var(--muted);
  transition: color .15s, border-color .15s;
}
.inline-tab.active { color: var(--blue); border-bottom-color: var(--blue); }
.tab-panel { display: none; }
.tab-panel.active { display: block; }

/* ── Positive / Negative cell colors ── */
.pos { color: var(--green); }
.neg { color: var(--red); }

/* ── Chart containers ── */
.chart-wrap { position: relative; height: 280px; }
.chart-wrap-sm { position: relative; height: 220px; }

/* ── History Grid ── */
.history-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-top: 20px;
}
.span-2 { grid-column: span 2; }

/* ── Owner Toggle ── */
.owner-toggle { display: flex; background: var(--bg); border: 1px solid var(--border); border-radius: 6px; padding: 2px; gap: 2px; }
.owner-toggle-btn {
  background: none; border: none; border-radius: 4px; padding: 4px 12px;
  font-size: .8rem; font-weight: 600; color: var(--text-light); cursor: pointer;
  transition: background .15s, color .15s;
}
.owner-toggle-btn.active { background: var(--blue); color: #fff; }
.owner-toggle-btn:not(.active):hover { background: var(--border); }

/* ── Owners Layout ── */
.owners-layout {
  display: grid;
  grid-template-columns: 270px 1fr;
  gap: 20px;
  align-items: start;
}
.owner-list-wrap .section-title { margin-bottom: 12px; }
.owner-list { display: flex; flex-direction: column; gap: 8px; max-height: calc(100vh - 180px); overflow-y: auto; }

/* ── Owner Card ── */
.owner-card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 12px 14px;
  cursor: pointer;
  transition: border-color .15s, box-shadow .15s;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}
.owner-card:hover  { border-color: var(--blue); box-shadow: var(--shadow-md); }
.owner-card.active { border-color: var(--blue); background: #eff6ff; }
.owner-card-name { font-weight: 600; font-size: .9rem; }
.owner-card-meta { font-size: .75rem; color: var(--muted); margin-top: 2px; }
.wins-badge {
  background: var(--gold);
  color: #fff;
  font-size: .7rem;
  font-weight: 700;
  padding: 2px 8px;
  border-radius: 12px;
  white-space: nowrap;
  flex-shrink: 0;
}

/* ── Owner Detail ── */
.owner-detail-cards {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  margin-bottom: 18px;
}

/* ── Upload Page ── */
.upload-wrap { max-width: 640px; }
.upload-drop {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 40px 24px;
  text-align: center;
  cursor: pointer;
  transition: border-color .15s;
}
.upload-drop:hover,
.upload-drop.drag-over { border-color: var(--blue); }
.upload-drop-icon { font-size: 2.5rem; margin-bottom: 10px; }
.upload-drop-title { font-weight: 600; margin-bottom: 4px; }
.upload-drop-sub { font-size: .85rem; color: var(--muted); }
.btn-upload {
  display: inline-block;
  margin-top: 14px;
  background: var(--blue);
  color: #fff;
  border: none;
  padding: 9px 22px;
  border-radius: 6px;
  font-size: .875rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.btn-upload:hover { background: var(--blue-hover); }
.upload-result { margin-top: 14px; }
.alert-success {
  background: var(--green-bg);
  border: 1px solid #86efac;
  border-radius: 6px;
  padding: 12px 16px;
  color: var(--green);
  font-size: .875rem;
}
.alert-error {
  background: var(--red-bg);
  border: 1px solid #fca5a5;
  border-radius: 6px;
  padding: 12px 16px;
  color: var(--red);
  font-size: .875rem;
}
.instructions {
  background: var(--green-bg);
  border: 1px solid #86efac;
  border-radius: var(--radius);
  padding: 18px 22px;
}
.instructions .section-title { color: var(--green); margin-bottom: 10px; }
.instructions ol { padding-left: 18px; line-height: 1.9; font-size: .875rem; }
.instructions code { background: rgba(0,0,0,.06); padding: 1px 6px; border-radius: 4px; font-family: monospace; }

/* ── Utility ── */
.text-muted  { color: var(--muted); }
.text-center { text-align: center; }
.fw-bold { font-weight: 700; }
.empty-state { padding: 48px 24px; text-align: center; color: var(--muted); font-size: .9rem; }

/* ── Responsive ── */
@media (max-width: 900px) {
  .history-grid { grid-template-columns: 1fr; }
  .span-2 { grid-column: span 1; }
  .owners-layout { grid-template-columns: 1fr; }
  .owner-list { max-height: none; }
}
@media (max-width: 640px) {
  .main { padding: 12px; }
  .nav-tab span { display: none; }
  .nav-brand { font-size: .85rem; }
  .season-hero { flex-direction: column; gap: 10px; }
  .season-hero-right { text-align: left; }
  .stats-cards { grid-template-columns: 1fr 1fr; }
  .owner-detail-cards { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 400px) {
  .stats-cards { grid-template-columns: 1fr; }
}
