/* =========================================================
   site.css - shared layout for every logged-in page
   (header, navigation, footer, empty states, alerts, forms).
   Loaded after modern.css / modernLight.css and uses their
   color variables, so it follows the Dark / Light setting.
   ========================================================= */

:root {
  --success: #22c55e;
  --warning: #f59e0b;
  --danger:  #ef4444;
  --green:   #22c55e;
  --header-bg: #111827;
  --menu-bg: #0f172a;
  --hover: rgba(59, 130, 246, 0.10);
  --radius: 10px;
}
html.light {
  --header-bg: #ffffff;
  --menu-bg: #ffffff;
  --hover: rgba(37, 99, 235, 0.08);
  --danger: #dc2626;
  --success: #16a34a;
}

html.dark { color-scheme: dark; }
html.light { color-scheme: light; }
html, body { background: var(--bg); color: var(--text); }
body {
  margin: 0;
  padding: 0;
  font-family: Inter, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  line-height: 1.5;
}
html.light a { color: var(--link); }

/* ---------- Header ---------- */
.site-header {
  background: var(--header-bg);
  border-bottom: 1px solid var(--border);
  position: relative;
  z-index: 30;
}
.sh-inner { max-width: 1200px; margin: 0 auto; padding: 10px 16px; }
.sh-top { display: flex; align-items: center; gap: 12px; flex-wrap: wrap; }
.sh-brand {
  display: flex; align-items: center; gap: 8px;
  font-weight: 700; font-size: 17px; color: var(--text) !important;
  text-decoration: none !important; margin-right: auto;
}
.sh-brand svg { width: 28px; height: 28px; flex: none; }
.sh-right { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; font-size: 13px; color: var(--muted); }
.sh-right select, .page-head select {
  width: auto;
  padding: 5px 8px; border-radius: 8px; border: 1px solid var(--border);
  background: var(--panel-2); color: var(--text); font-size: 13px; max-width: 200px;
}
.sh-who strong { color: var(--text); }

/* Light/dark toggle (sun shows in dark mode, moon in light mode) */
.theme-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 32px; height: 32px; border-radius: 50%; flex: none;
  background: var(--panel-2); color: var(--text) !important; border: 1px solid var(--border);
  font-size: 17px; line-height: 1; text-decoration: none !important;
}
.theme-btn:hover { background: var(--hover); }

/* Account dropdown */
.acct { position: relative; }
.acct > button {
  display: flex; align-items: center; gap: 6px; cursor: pointer;
  background: var(--panel-2); color: var(--text); border: 1px solid var(--border);
  border-radius: 999px; padding: 5px 12px; font-size: 13px;
}
.acct-menu {
  display: none; position: absolute; right: 0; top: calc(100% + 6px);
  background: var(--menu-bg); border: 1px solid var(--border); border-radius: var(--radius);
  min-width: 220px; padding: 6px; box-shadow: 0 10px 30px rgba(0,0,0,.25); z-index: 40;
}
.acct:focus-within .acct-menu, .acct.open .acct-menu { display: block; }
.acct-menu a, .acct-menu .acct-row {
  display: flex; align-items: center; justify-content: space-between;
  padding: 8px 10px; border-radius: 8px; color: var(--text) !important; text-decoration: none !important; font-size: 14px;
}
.acct-menu a:hover { background: var(--hover); }
.acct-menu hr { border: 0; border-top: 1px solid var(--border); margin: 6px 0; }
.acct-menu .admin { color: var(--warning) !important; }

/* Theme switch (inside account menu) */
.theme-switch { position: relative; width: 36px; height: 20px; flex: none; }
.theme-switch input { opacity: 0; width: 0; height: 0; position: absolute; }
.theme-switch span { position: absolute; inset: 0; background: #374151; border-radius: 20px; cursor: pointer; transition: .2s; }
.theme-switch span:before { content: ""; position: absolute; width: 14px; height: 14px; left: 3px; top: 3px; background: #fff; border-radius: 50%; transition: .2s; }
.theme-switch input:checked + span { background: var(--brand); }
.theme-switch input:checked + span:before { transform: translateX(16px); }

/* ---------- Main navigation ---------- */
.nav-toggle { display: none; }
.nav-burger {
  display: none; cursor: pointer; padding: 6px 10px; border-radius: 8px;
  border: 1px solid var(--border); color: var(--text); font-size: 14px; background: var(--panel-2);
}
.site-nav { display: flex; align-items: center; gap: 4px; margin-top: 8px; flex-wrap: wrap; }
.site-nav > ul { list-style: none; margin: 0; padding: 0; display: flex; gap: 2px; flex-wrap: wrap; }
.site-nav > ul > li { position: relative; }
.site-nav a, .site-nav .nav-top {
  display: block; padding: 7px 12px; border-radius: 8px; color: var(--text) !important;
  font-size: 14px; text-decoration: none !important; background: none; border: 0; cursor: pointer; font-family: inherit;
}
.site-nav a:hover, .site-nav .nav-top:hover { background: var(--hover); }
.site-nav a.active, .site-nav .nav-top.active { background: var(--hover); color: var(--brand) !important; font-weight: 600; }
.site-nav .nav-top:after { content: " \25BE"; font-size: 11px; opacity: .7; }
.site-nav .sub {
  display: none; position: absolute; left: 0; top: 100%; min-width: 230px; z-index: 35;
  list-style: none; margin: 0; padding: 6px; background: var(--menu-bg);
  border: 1px solid var(--border); border-radius: var(--radius); box-shadow: 0 10px 30px rgba(0,0,0,.25);
}
.site-nav li:hover > .sub, .site-nav li:focus-within > .sub { display: block; }
.site-nav .sub a { white-space: nowrap; }
.site-nav .sub .sub-label { padding: 6px 12px 2px; font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); }

/* Standard / High Stakes switch */
.league-switch {
  margin-left: auto; display: inline-flex; border: 1px solid var(--border);
  border-radius: 999px; overflow: hidden; font-size: 13px;
}
.league-switch a {
  padding: 5px 12px; color: var(--muted) !important; text-decoration: none !important;
}
.league-switch a.on { background: var(--brand); color: #fff !important; font-weight: 600; }

/* ---------- Page body ---------- */
.page { padding: 18px 0 8px; }
.page > .container, main.page .container { max-width: 1200px; margin: 0 auto; padding: 0 16px; }
.page h1 { font-size: 1.6rem; margin: 4px 0 14px; }
.page-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 14px; }
.page-head h1 { margin: 0; }
.page-head .sub { color: var(--muted); font-size: 14px; }

/* Make old border=1 tables look like the rest of the site */
.page table[border] { border-collapse: collapse; border: 1px solid var(--border) !important; border-radius: 8px; }
.page table[border] td, .page table[border] th { padding: 7px 10px; border-top: 1px solid var(--border); }
.page table[border] thead td, .page table[border] tr:first-child td { font-weight: 600; }

/* Wide tables scroll sideways on phones instead of breaking the page */
.table-scroll { width: 100%; overflow-x: auto; -webkit-overflow-scrolling: touch; }

/* modern.css clips every table (overflow:hidden, for round corners), which stops sticky cells working */
.table-scroll > table { overflow: visible; }
/* A column that stays put while the rest of the table scrolls sideways (team / golfer name) */
.table-scroll .stick, .table-scroll tr:nth-child(odd) td.stick, .table-scroll tr:hover td.stick {
  position: sticky; left: 0; z-index: 1; background: var(--panel);
  box-shadow: inset -1px 0 0 var(--border);
}
/* A panel opened under a table row (a week's golfers, a scorecard). Stays on screen
   even when the table is scrolled sideways. */
.row-panel > td { padding: 0 !important; background: var(--panel-2) !important; }
.row-panel .row-panel-in {
  position: sticky; left: 0; box-sizing: border-box;
  width: min(100%, calc(100vw - 32px)); max-width: 720px; padding: 10px 12px;
}
.row-panel .row-panel-bar { display: flex; justify-content: space-between; align-items: center; gap: 8px; font-size: 13px; color: var(--muted); margin-bottom: 8px; }
.row-panel .row-panel-bar button {
  background: none; border: 1px solid var(--border); border-radius: 8px; color: var(--text);
  width: 36px; height: 36px; font-size: 18px; line-height: 1; cursor: pointer; flex: none;
}
.row-panel .table-scroll table { width: 100%; }

/* ---------- Empty states, alerts, chips ---------- */
.empty {
  text-align: center; padding: 36px 20px; border: 1px dashed var(--border);
  border-radius: var(--radius); background: var(--panel); color: var(--muted); margin: 8px 0 18px;
}
.empty h2, .empty h3 { color: var(--text); margin: 6px 0; font-size: 1.15rem; }
.empty .icon { font-size: 30px; line-height: 1; }
.empty p { color: var(--muted); margin: 6px 0 0; }
.empty .btn { margin-top: 14px; }

.alert { padding: 10px 14px; border-radius: 8px; margin: 0 0 14px; border: 1px solid var(--border); font-size: 14px; }
.alert-error   { background: rgba(239,68,68,.10);  border-color: rgba(239,68,68,.35); color: var(--danger); }
.alert-success { background: rgba(34,197,94,.10);  border-color: rgba(34,197,94,.35); color: var(--success); }
.alert-info    { background: rgba(59,130,246,.10); border-color: rgba(59,130,246,.35); color: var(--text); }
.alert-warn    { background: rgba(245,158,11,.12); border-color: rgba(245,158,11,.4);  color: var(--text); }

.chip { display: inline-block; padding: 2px 8px; border-radius: 999px; font-size: 12px; font-weight: 600; border: 1px solid var(--border); color: var(--muted); }
.chip.s { color: #60a5fa; border-color: rgba(96,165,250,.4); }
.chip.h { color: #fbbf24; border-color: rgba(251,191,36,.45); }
.chip.b { color: #c084fc; border-color: rgba(192,132,252,.45); }
.chip.ok { color: var(--success); border-color: rgba(34,197,94,.4); }
.chip.bad { color: var(--danger); border-color: rgba(239,68,68,.4); }

.muted { color: var(--muted); }
.right { text-align: right; }
.nowrap { white-space: nowrap; }

/* ---------- Footer ---------- */
.site-footer {
  max-width: 1200px; margin: 28px auto 0; padding: 18px 16px 28px; border-top: 1px solid var(--border);
  color: var(--muted); font-size: 13px; display: flex; gap: 16px; flex-wrap: wrap; justify-content: space-between;
}
.site-footer a { color: var(--muted) !important; }

/* ---------- Phones ---------- */
@media (max-width: 760px) {
  .sh-who, .sh-right .team-label { display: none; }
  /* Header fits on one row: brand, then round Settings and Menu buttons; team picker below */
  .sh-top { row-gap: 8px; }
  .sh-right { display: contents; }
  .sh-right .theme-btn { display: none; }                /* the switch is in the Settings menu */
  .sh-right .lbl { display: none; }
  .acct > button, .nav-burger { width: 40px; height: 40px; padding: 0; justify-content: center; align-items: center; font-size: 18px; border-radius: 10px; }
  .nav-burger { display: inline-flex; }
  .team-form { order: 10; flex: 1 0 100%; }
  .team-form select { width: 100%; max-width: none; padding: 8px 10px; font-size: 15px; }
  .site-nav { display: none; flex-direction: column; align-items: stretch; margin-top: 10px; }
  .nav-toggle:checked ~ .site-nav { display: flex; }
  .site-nav > ul { flex-direction: column; }
  .site-nav .nav-top:after { content: ""; }
  .site-nav .nav-top { font-size: 12px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted) !important; padding: 10px 12px 2px; cursor: default; }
  .site-nav .sub { display: block; position: static; box-shadow: none; border: 0; padding: 0 0 4px 8px; min-width: 0; background: none; }
  .site-nav a { padding: 9px 12px; font-size: 15px; }
  .league-switch { margin: 8px 0 0; align-self: flex-start; }
  .page h1 { font-size: 1.35rem; }
  .card { padding: 14px; }
  .hide-sm { display: none !important; }
  .table-scroll .stick { max-width: 9.5em; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
}

/* Buttons that are links keep white text in both themes */
a.btn, a.btn:visited, html.light a.btn { color: #fff !important; text-decoration: none !important; }
a.btn.btn-secondary, html.light a.btn.btn-secondary { color: var(--text) !important; }
html.light .btn-secondary { background: #f1f5f9; border: 1px solid var(--border); color: var(--text); }
a.add-team-card, html.light a.add-team-card { color: var(--muted) !important; }
