/* ============================================================
   SF Mallet Club — stylesheet
   Colors drawn from the club logo:
     cream bg  #fdf5e4
     dark brown #3d2200
     gold       #f5a623
   ============================================================ */

:root {
  --bg:          #fdf5e4;
  --primary:     #3d2200;
  --accent:      #f5a623;
  --accent-dark: #d4890a;
  --text:        #2c1800;
  --muted:       #8a6a45;
  --card-bg:     #ffffff;
  --border:      #e8d5b0;
  --danger:      #c0392b;
  --success-bg:  #fef9ec;
  --success-fg:  #3d2200;
  --error-bg:    #fdecea;
  --error-fg:    #922b21;
  --radius:      12px;
  --shadow:      0 2px 8px rgba(61,34,0,.10);
}

/* ── Reset & base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  line-height: 1.5;
  min-height: 100vh;
}

a { color: inherit; text-decoration: none; }

/* ── Header ── */
.site-header {
  background: var(--bg);
  border-top: 10px solid var(--primary);
  border-bottom: 10px solid var(--primary);
  padding: 10px 16px;
  display: flex;
  align-items: center;
  justify-content: center;
  position: sticky;
  top: 0;
  z-index: 100;
}

.site-logo {
  max-height: 80px;
  width: auto;
  display: block;
}

/* ── Flash messages ── */
.flash-container { padding: 12px 16px 0; display: flex; flex-direction: column; gap: 8px; }

.flash {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: .95rem;
  font-weight: 500;
}
.flash-success { background: var(--success-bg); color: var(--success-fg); border: 1px solid #e8d5b0; }
.flash-error   { background: var(--error-bg);   color: var(--error-fg);   border: 1px solid #f5c6c2; }
.flash-info    { background: #eef4ff;            color: #1a3a6b;           border: 1px solid #b8d0f5; }

/* ── Main content ── */
.main-content {
  padding: 16px 16px 24px;
  max-width: 600px;
  margin: 0 auto;
}

/* ── Cards ── */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 16px;
  box-shadow: var(--shadow);
}

.card-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 14px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--accent);
}

/* ── Page title area ── */
.page-title-area {
  margin-bottom: 16px;
}

.page-title {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--primary);
  letter-spacing: -.5px;
}

.page-subtitle {
  font-size: .95rem;
  color: var(--muted);
  margin-top: 2px;
}

/* ── Buttons ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 20px;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: background .15s, transform .1s;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }

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

.btn-outline {
  background: transparent;
  border: 2px solid var(--accent);
  color: var(--primary);
}
.btn-outline:hover { background: var(--accent); }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1px solid var(--border);
  font-size: .85rem;
}
.btn-ghost:hover { color: var(--danger); border-color: var(--danger); }

.btn-sm { padding: 7px 14px; font-size: .85rem; }
.btn-full { width: 100%; }

/* ── Inputs ── */
.input-field {
  width: 100%;
  padding: 12px 14px;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  font-size: 1rem;
  background: #fff;
  color: var(--text);
  margin-bottom: 12px;
  outline: none;
  transition: border-color .15s;
}
.input-field:focus { border-color: var(--accent); }

.select-field { appearance: none; cursor: pointer; }

.inline-form {
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.inline-form .input-field { margin-bottom: 0; flex: 1; }

.form-label {
  font-weight: 600;
  font-size: .9rem;
  color: var(--primary);
  margin-bottom: 8px;
}

/* ── Bottom nav ── */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0; right: 0;
  background: var(--primary);
  display: flex;
  justify-content: space-around;
  align-items: stretch;
  height: 58px;
  z-index: 200;
  border-top: 3px solid var(--accent);
}

.nav-item {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  color: rgba(255,255,255,.65);
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .3px;
  text-transform: uppercase;
  transition: color .15s, background .15s;
}
.nav-item:hover,
.nav-item.active {
  color: var(--accent);
  background: rgba(255,255,255,.05);
}

.nav-spacer { height: 58px; }

/* ── Gate page ── */
.gate-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--primary);
}

.gate-container {
  width: 100%;
  max-width: 380px;
  padding: 24px 20px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 24px;
}

.gate-logo {
  max-width: 100%;
  max-height: 160px;
  width: auto;
}

.gate-card {
  width: 100%;
}

.gate-title {
  font-size: 1.3rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 4px;
}

.gate-subtitle {
  font-size: .9rem;
  color: var(--muted);
  margin-bottom: 18px;
}

/* ── Home nav grid ── */
.nav-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
  margin-bottom: 16px;
}

.nav-card {
  background: var(--card-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 28px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  box-shadow: var(--shadow);
  transition: transform .15s, box-shadow .15s;
}
.nav-card:hover, .nav-card:active {
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(61,34,0,.15);
}

.nav-card-icon {
  font-size: 2.2rem;
  line-height: 1;
}

.nav-card-label {
  font-size: 1rem;
  font-weight: 700;
  color: var(--primary);
  text-align: center;
}

.logout-area {
  text-align: center;
  padding: 8px 0 4px;
}

.logout-link {
  font-size: .85rem;
  color: var(--muted);
  text-decoration: underline;
}

/* ── Members list ── */
.member-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.member-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  gap: 10px;
}
.member-item:last-child { border-bottom: none; }

.member-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.member-name  { font-weight: 600; font-size: 1rem; }
.member-record { font-size: .8rem; color: var(--muted); }

.muted { color: var(--muted); }

.empty-state {
  color: var(--muted);
  font-style: italic;
  font-size: .95rem;
  padding: 8px 0;
}

/* ── Leaderboard table ── */
.standings-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .95rem;
}

.standings-table th {
  text-align: left;
  padding: 8px 6px;
  color: var(--muted);
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .4px;
  border-bottom: 2px solid var(--border);
}
.standings-table th:not(:first-child):not(:nth-child(2)) { text-align: center; }

.standings-table td {
  padding: 11px 6px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}
.standings-table tr:last-child td { border-bottom: none; }

.standings-table .rank       { color: var(--muted); font-size: .85rem; width: 24px; }
.standings-table .player-name { font-weight: 600; }
.standings-table .wins       { text-align: center; font-weight: 700; color: var(--primary); }
.standings-table .losses     { text-align: center; color: var(--muted); }
.standings-table .pct        { text-align: center; font-size: .85rem; color: var(--muted); }

.row-inactive td { opacity: .5; }

.badge-inactive {
  font-size: .7rem;
  background: var(--border);
  color: var(--muted);
  padding: 1px 6px;
  border-radius: 10px;
  margin-left: 4px;
  font-weight: 500;
}

/* ── Checkbox grid (record game) ── */
.checkbox-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

.checkbox-item {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  font-size: .95rem;
  transition: border-color .15s, background .15s;
}
.checkbox-item:has(input:checked) {
  border-color: var(--accent);
  background: #fffbf2;
}
.checkbox-item input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
  flex-shrink: 0;
}

/* ── Recent games ── */
.game-list { list-style: none; display: flex; flex-direction: column; gap: 2px; }

.game-item {
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
}
.game-item:last-child { border-bottom: none; }

.game-winner  { font-weight: 700; font-size: 1rem; color: var(--primary); }
.game-detail  { font-size: .85rem; color: var(--muted); margin-top: 2px; }
.game-date    { font-size: .78rem; color: #aaa; margin-top: 2px; }

/* ── Dinner page ── */
.dinner-member-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.dinner-member-row {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 12px 14px;
  background: var(--bg);
  border: 1.5px solid var(--border);
  border-radius: 8px;
  cursor: pointer;
  transition: border-color .15s, background .15s;
}
.dinner-member-row:has(input:checked) {
  border-color: var(--accent);
  background: #fffbf2;
}
.dinner-check {
  width: 20px;
  height: 20px;
  accent-color: var(--accent);
  flex-shrink: 0;
}

.dinner-member-info {
  display: flex;
  flex-direction: column;
}

.dinner-member-name { font-weight: 600; font-size: 1rem; }
.dinner-last-paid   { font-size: .8rem; color: var(--muted); }

.dinner-history-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.dinner-history-item {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  padding: 12px 0;
  border-bottom: 1px solid var(--border);
  gap: 12px;
}
.dinner-history-item:last-child { border-bottom: none; }

.dinner-history-payer  { font-weight: 700; font-size: 1rem; min-width: 90px; }
.dinner-history-detail { font-size: .8rem; color: var(--muted); text-align: right; line-height: 1.4; }
.dinner-history-present { font-size: .75rem; }

/* ── Rules page ── */
.rules-card { padding: 24px 20px; }

.rules-body h2 {
  font-size: 1.15rem;
  font-weight: 800;
  color: var(--primary);
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 3px solid var(--accent);
}

.rules-body h3 {
  font-size: 1rem;
  font-weight: 800;
  color: var(--primary);
  margin-top: 28px;
  margin-bottom: 12px;
  text-transform: uppercase;
  letter-spacing: .3px;
}

.rules-body h4 {
  font-size: .95rem;
  font-weight: 700;
  color: var(--text);
  margin-top: 16px;
  margin-bottom: 6px;
}

.rules-body p {
  font-size: .93rem;
  line-height: 1.65;
  color: var(--text);
  margin-bottom: 8px;
}

.rules-body ul {
  margin: 6px 0 10px 18px;
}

.rules-body ul li {
  font-size: .93rem;
  line-height: 1.65;
  margin-bottom: 3px;
}

/* ── Responsive tweaks ── */
@media (max-width: 380px) {
  .nav-grid { grid-template-columns: 1fr 1fr; gap: 10px; }
  .checkbox-grid { grid-template-columns: 1fr; }
  .nav-card { padding: 22px 12px; }
  .nav-card-icon { font-size: 1.8rem; }
}

@media (min-width: 600px) {
  .main-content { padding: 24px 24px 32px; }
  .site-logo { max-height: 64px; }
}

/* ── Ledger: delete button ── */
.btn-ghost-delete {
  background: none;
  border: none;
  color: var(--muted);
  font-size: .75rem;
  cursor: pointer;
  padding: 2px 6px;
  opacity: .5;
  line-height: 1;
  align-self: flex-start;
}
.btn-ghost-delete:hover { opacity: 1; color: var(--danger); }

/* ── Ledger: manual past-entry panel ── */
.ledger-manual-entry {
  margin-top: 1rem;
  border-top: 1px solid var(--border);
  padding-top: .75rem;
}
.ledger-manual-entry summary {
  font-size: .78rem;
  color: var(--muted);
  cursor: pointer;
  user-select: none;
  list-style: none;
}
.ledger-manual-entry summary::-webkit-details-marker { display: none; }
.ledger-manual-form {
  margin-top: .75rem;
}
.ledger-manual-form .form-row {
  display: flex;
  gap: .75rem;
  flex-wrap: wrap;
}
.ledger-manual-form label {
  display: flex;
  flex-direction: column;
  font-size: .82rem;
  color: var(--muted);
  gap: .25rem;
  flex: 1;
  min-width: 120px;
}
.ledger-manual-form select,
.ledger-manual-form input[type="date"] {
  padding: .4rem .5rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: .9rem;
  background: var(--bg);
  color: var(--text);
}

/* ── Ledger: notes ── */
.input-notes {
  width: 100%;
  padding: .45rem .6rem;
  border: 1px solid var(--border);
  border-radius: 6px;
  font-size: .9rem;
  background: var(--bg);
  color: var(--text);
  margin-top: .75rem;
}
.dinner-history-notes {
  font-style: italic;
  color: var(--muted);
  font-size: .82rem;
}
