/* Cricket nets booking — shared styles for public + admin pages */

/* Andoversford CC colours — red taken from the club badge */
:root {
  --brand: #c0272d;
  --brand-dark: #8f1a1f;
  --brand-pale: #fbe9ea;
  --cream: #fbf7f4;
  --ink: #26201f;
  --muted: #756a68;
  --line: #e7dcda;
  --free: #2f9e57;   /* availability stays green — universally readable */
  --taken: #d3c8c6;
  --danger: #8f1a1f;
  --radius: 10px;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: "Segoe UI", system-ui, -apple-system, sans-serif;
  background: var(--cream);
  color: var(--ink);
  line-height: 1.5;
}
.container { max-width: 860px; margin: 0 auto; padding: 0 16px; }

.site-header {
  background: linear-gradient(135deg, var(--brand-dark), var(--brand));
  color: #fff;
  padding: 28px 0 24px;
  margin-bottom: 20px;
}
.site-header h1 { margin: 0 0 4px; font-size: 1.7rem; }
.header-row { display: flex; align-items: center; gap: 18px; }
.btn-header {
  margin-left: auto; background: rgba(255,255,255,.15); color: #fff;
  border: 1px solid rgba(255,255,255,.45); white-space: nowrap;
}
.btn-header:hover { background: rgba(255,255,255,.28); }
.header-tabs { display: flex; gap: 4px; margin-top: 16px; }
.header-tab {
  font: inherit; cursor: pointer; text-decoration: none;
  background: none; border: none; color: rgba(255,255,255,.85);
  padding: 8px 14px; border-radius: 8px 8px 0 0;
  border-bottom: 3px solid transparent;
}
.header-tab:hover { color: #fff; background: rgba(255,255,255,.12); }
.header-tab.active { color: #fff; border-bottom-color: #fff; font-weight: 600; }
.header-tab .caret { font-size: .75em; opacity: .85; }

/* "Net bookings" dropdown menu */
.nav-dropdown { position: relative; display: inline-block; }
.nav-menu {
  position: absolute; top: 100%; left: 0; z-index: 30; min-width: 190px;
  background: #fff; border: 1px solid var(--line); border-radius: 8px;
  box-shadow: 0 6px 18px rgba(0,0,0,.22); overflow: hidden; margin-top: 4px;
}
.nav-menu-item {
  display: block; width: 100%; text-align: left; font: inherit; cursor: pointer;
  background: none; border: none; padding: 12px 18px; color: var(--ink);
}
.nav-menu-item:hover { background: var(--brand-pale); color: var(--brand-dark); }
.nav-menu-item + .nav-menu-item { border-top: 1px solid var(--line); }
.logo {
  width: 72px; height: 72px; flex: none;
  background: #fff; border-radius: 14px; padding: 5px;
  object-fit: contain; box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
@media (max-width: 560px) { .logo { width: 54px; height: 54px; } }
.tagline { margin: 0; opacity: .9; font-size: .95rem; }

.panel {
  background: #fff;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 20px;
  margin-bottom: 20px;
}
.hidden { display: none !important; }

h2 { margin: 8px 0 14px; font-size: 1.25rem; }

/* Buttons */
.btn {
  font: inherit;
  border: none;
  border-radius: 8px;
  padding: 10px 18px;
  cursor: pointer;
  transition: filter .15s;
}
.btn:hover { filter: brightness(1.08); }
.btn:disabled { opacity: .55; cursor: not-allowed; }
.btn-primary { background: var(--brand); color: #fff; width: 100%; padding: 14px; font-size: 1.05rem; }
.btn-secondary { background: var(--brand-pale); color: var(--brand-dark); }
.btn-danger { background: var(--danger); color: #fff; }
.btn-link {
  background: none; color: var(--brand); padding: 4px 0; text-decoration: underline;
}

/* Calendar */
.cal-nav { display: flex; align-items: center; justify-content: space-between; margin-bottom: 12px; }
.cal-nav h2 { margin: 0; }
.cal-weekdays, .cal-grid { display: grid; grid-template-columns: repeat(7, 1fr); gap: 6px; }
.cal-weekdays { font-size: .78rem; color: var(--muted); text-align: center; margin-bottom: 6px; }
.cal-day {
  aspect-ratio: 1 / .85;
  border: 1px solid var(--line);
  border-radius: 8px;
  background: #fff;
  font: inherit;
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 2px;
  cursor: pointer;
  padding: 2px;
}
.cal-day .num { font-weight: 600; }
.cal-day .sub { font-size: .68rem; color: var(--muted); }
.cal-day:hover:not(:disabled) { border-color: var(--brand); background: var(--brand-pale); }
.cal-day:disabled { background: #f2f2ee; color: #b7bcb0; cursor: default; }
.cal-day.full:not(:disabled) .sub { color: var(--danger); }
.cal-day.empty { visibility: hidden; }
/* Availability dots — visible at every screen size (the text label hides on phones) */
.cal-day.has-free::after,
.cal-day.full::after { content: ''; width: 8px; height: 8px; border-radius: 50%; flex: none; }
.cal-day.has-free::after { background: var(--free); }
.cal-day.full::after { background: var(--danger); }
.cal-legend { font-size: .8rem; color: var(--muted); margin: 12px 0 0; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; vertical-align: middle; }
.dot-free { background: var(--free); }
.dot-full { background: var(--danger); }
.dot-closed { background: var(--taken); }

/* Slot grid */
.slot-table { width: 100%; border-collapse: separate; border-spacing: 6px; }
.slot-table th { font-size: .8rem; color: var(--muted); font-weight: 600; }
.slot-table td:first-child { font-size: .85rem; color: var(--muted); white-space: nowrap; width: 1%; }
.slot-btn {
  width: 100%;
  font: inherit;
  padding: 10px 4px;
  border-radius: 8px;
  border: 1px solid var(--line);
  background: var(--brand-pale);
  color: var(--brand-dark);
  cursor: pointer;
  font-size: .9rem;
}
.slot-btn:hover:not(:disabled) { background: var(--brand); color: #fff; }
.slot-btn:disabled { background: var(--taken); color: #83887d; cursor: not-allowed; border-color: var(--taken); }
.slot-btn.blocked-label { font-size: .75rem; }
.slot-btn.selected, .slot-btn.selected:hover { background: var(--brand); color: #fff; border-color: var(--brand-dark); font-weight: 600; }

/* Running selection bar under the slot grid */
.selection-bar {
  position: sticky; bottom: 0; margin-top: 12px;
  display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
  background: #fff; border: 1px solid var(--line); border-radius: var(--radius);
  padding: 12px 14px; box-shadow: 0 -2px 10px rgba(0,0,0,.06);
}
.selection-bar #sel-summary { flex: 1 1 200px; font-size: .95rem; }
.selection-bar .sel-price { color: var(--brand-dark); font-weight: 700; }
.selection-bar .btn { flex: none; width: auto; }

/* Form */
#booking-form label { display: block; margin-bottom: 14px; font-size: .92rem; font-weight: 600; }
#booking-form input, #booking-form select {
  display: block; width: 100%; margin-top: 4px;
  font: inherit; padding: 10px; border: 1px solid var(--line); border-radius: 8px;
  background: #fff;
}
#booking-form input:focus, #booking-form select:focus { outline: 2px solid var(--brand); border-color: var(--brand); }
.code-row { display: flex; gap: 8px; }
.code-row input { flex: 1; }
.code-row .btn { margin-top: 4px; white-space: nowrap; }
.code-msg { display: block; font-weight: 400; font-size: .85rem; margin-top: 4px; min-height: 1.2em; }
.code-msg.ok { color: var(--free); }
.code-msg.err { color: var(--danger); }
.slot-summary { background: var(--brand-pale); border-radius: 8px; padding: 10px 14px; font-weight: 600; }
.price-box {
  display: flex; justify-content: space-between; align-items: center;
  background: var(--cream); border: 1px solid var(--line); border-radius: 8px;
  padding: 12px 16px; margin: 16px 0; font-size: 1.1rem;
}
.form-error { color: var(--danger); font-weight: 600; }
.hint { font-size: .8rem; color: var(--muted); }
.std-form label { display: block; margin-bottom: 14px; font-size: .92rem; font-weight: 600; }
.std-form input {
  display: block; width: 100%; max-width: 420px; margin-top: 4px;
  font: inherit; padding: 10px; border: 1px solid var(--line); border-radius: 8px;
}
.std-form input:focus { outline: 2px solid var(--brand); border-color: var(--brand); }
.std-form .btn-primary { max-width: 420px; }
.price-row { display: flex; justify-content: space-between; align-items: center; }
.price-row + .price-row { margin-top: 6px; padding-top: 6px; border-top: 1px dashed var(--line); }
.policy-note { border-left: 4px solid var(--brand); margin: 14px 0; }
#booking-form .terms-row { display: flex; gap: 10px; align-items: flex-start; font-weight: 400; }
#booking-form .terms-row input { display: inline-block; width: auto; margin: 3px 0 0; }
.terms-row a, .terms-row strong { color: var(--brand); }
#booking-form .both-nets-row {
  display: flex; gap: 10px; align-items: center; font-weight: 600;
  background: var(--brand-pale); color: var(--brand-dark);
  padding: 11px 13px; border-radius: 8px; margin-top: 4px; cursor: pointer;
}
#booking-form .both-nets-row input { display: inline-block; width: auto; margin: 0; flex: none; }
#map-frame { width: 100%; height: 320px; border: 0; border-radius: 8px; }

/* Confirmation */
.confirm-ok h2 { color: var(--brand); }
.confirm-fail h2 { color: var(--danger); }
.confirm-details {
  background: var(--cream); border: 1px solid var(--line); border-radius: 8px;
  padding: 14px 18px; margin: 12px 0; white-space: pre-line;
}

.site-footer {
  padding: 18px 0 30px; color: var(--muted); font-size: .85rem; text-align: center;
}
.site-footer a { color: var(--muted); }

/* Admin */
.admin-toolbar { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; margin-bottom: 14px; }
.admin-toolbar h2 { margin: 0 auto 0 0; }
.tabs { display: flex; gap: 6px; flex-wrap: wrap; margin-bottom: 16px; }
.tab-btn { background: var(--brand-pale); color: var(--brand-dark); }
.tab-btn.active { background: var(--brand); color: #fff; }
.admin-table { width: 100%; border-collapse: collapse; font-size: .9rem; }
.admin-table th, .admin-table td { text-align: left; padding: 8px 10px; border-bottom: 1px solid var(--line); }
.admin-table th { color: var(--muted); font-size: .8rem; }
.badge { padding: 2px 8px; border-radius: 99px; font-size: .75rem; font-weight: 600; }
.badge.CONFIRMED { background: var(--brand-pale); color: var(--brand-dark); }
.badge.PAID { background: #e7f3ec; color: #14522b; }
.badge.OWED { background: #fdeeed; color: var(--danger); }

/* Dashboard stat tiles */
.stat-tiles { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 12px; }
.stat-tile {
  background: var(--cream); border: 1px solid var(--line); border-radius: 10px;
  padding: 14px 16px;
}
.stat-tile .stat-num { font-size: 1.9rem; font-weight: 700; color: var(--brand-dark); line-height: 1.1; }
.stat-tile .stat-label { font-size: .82rem; color: var(--muted); margin-top: 2px; }
.stat-tile.accent { background: var(--brand-pale); border-color: var(--brand); }
.dash-empty { color: var(--muted); font-size: .9rem; padding: 6px 0; }

/* Collapsible category sections (admin match-fees) */
.cat-section { margin: 14px 0; }
.cat-summary {
  list-style: none; cursor: pointer; user-select: none;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; margin-bottom: 8px;
  background: var(--brand); color: #fff; border-radius: 8px;
  font-weight: 600;
}
.cat-summary::-webkit-details-marker { display: none; }
.cat-summary::before { content: '▸'; transition: transform .15s; }
.cat-section[open] > .cat-summary::before { transform: rotate(90deg); }
.cat-summary .cat-count { margin-left: auto; font-weight: 400; font-size: .82rem; opacity: .9; }
/* Guarantee a folded section hides its content (independent of UA details behaviour). */
.cat-section:not([open]) > :not(summary) { display: none; }

/* Match cards (admin match-fees) */
.match-card { border: 1px solid var(--line); border-radius: 10px; margin-bottom: 10px; overflow: hidden; }
.match-head {
  display: flex; align-items: center; gap: 12px; width: 100%;
  padding: 12px 14px; background: var(--cream); border: none; cursor: pointer;
  font: inherit; text-align: left;
}
.match-head:hover { background: var(--brand-pale); }
.match-head .mh-title { font-weight: 600; }
.match-head .mh-meta { color: var(--muted); font-size: .85rem; }
.match-head .mh-count { margin-left: auto; font-size: .8rem; color: var(--muted); white-space: nowrap; }
.match-head .chev { transition: transform .15s; }
.match-card.open .chev { transform: rotate(90deg); }
.match-body { padding: 6px 14px 14px; }
.player-row {
  display: flex; align-items: center; gap: 10px; flex-wrap: wrap;
  padding: 8px 0; border-bottom: 1px solid var(--line);
}
.player-row:last-child { border-bottom: none; }
.player-row .pname { font-weight: 600; min-width: 140px; }
.player-row select { font: inherit; padding: 5px 8px; border: 1px solid var(--line); border-radius: 8px; max-width: 240px; }
.player-row .pay-toggle { margin-left: auto; display: flex; gap: 6px; }
.play-check { display: flex; align-items: center; gap: 6px; font-size: .85rem; }
.play-check input { width: auto; }
.btn-toggle { padding: 5px 12px; font-size: .82rem; border: 1px solid var(--line); background: #fff; border-radius: 8px; cursor: pointer; }
.btn-toggle.on-paid { background: var(--free); color: #fff; border-color: var(--free); }
.btn-toggle.on-owed { background: var(--danger); color: #fff; border-color: var(--danger); }
.pill { font-size: .72rem; padding: 1px 7px; border-radius: 99px; background: var(--brand-pale); color: var(--brand-dark); }
.badge.BLOCKED { background: #fdeeed; color: var(--danger); }
.badge.PENDING { background: #fff7e0; color: #8a6d00; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 12px; }
.form-grid label { display: block; font-size: .85rem; font-weight: 600; }
.form-grid input, .form-grid select {
  display: block; width: 100%; margin-top: 4px; font: inherit;
  padding: 8px; border: 1px solid var(--line); border-radius: 8px;
}
.row-actions { display: flex; gap: 6px; }
.btn-sm { padding: 5px 10px; font-size: .8rem; }
.notice { background: var(--brand-pale); border-radius: 8px; padding: 10px 14px; font-size: .88rem; }

@media (max-width: 560px) {
  .cal-day .sub { display: none; }
  .panel { padding: 14px; }
}

/* Treasurer income/expenditure entry forms */
.fin-entry-form { display: flex; flex-wrap: wrap; gap: 10px; align-items: flex-end; margin: 8px 0 6px; }
.fin-entry-form label { display: flex; flex-direction: column; font-size: .78rem; color: var(--muted); gap: 3px; }
.fin-entry-form input { font: inherit; padding: 7px 9px; border: 1px solid var(--line); border-radius: 8px; }
.fin-entry-form input[type=date] { min-width: 145px; }
.fin-entry-form input[type=number] { width: 110px; }
.fin-entry-form button { flex: none; }

/* Printing the Treasurer's report — show just the report, no chrome/controls */
@media print {
  .no-print, .tabs, .site-header, .admin-toolbar .btn, #tr-msg { display: none !important; }
  .panel { border: none; box-shadow: none; padding: 0; }
  body { background: #fff; }
  .admin-table th, .admin-table td { border-color: #999; }
}
