/* Court Reserve - shared styling for the public board and the dashboard. */

:root {
  --bg: #f4f6f4;
  --panel: #ffffff;
  --panel-2: #fafbfa;
  --line: #e2e6e2;
  --line-soft: #eef1ee;
  --ink: #16201a;
  --ink-2: #5c6a60;
  --ink-3: #8b978f;
  --accent: #1f8f4e;
  --accent-ink: #ffffff;
  --accent-soft: #e7f5ec;
  --open: #2e9c5c;
  --open-bg: #e6f6ec;
  --held: #b57a12;
  --held-bg: #fdf2dc;
  --booked: #b8402f;
  --booked-bg: #fbe8e5;
  --radius: 14px;
  --radius-sm: 9px;
  --shadow: 0 1px 2px rgba(16, 32, 22, .06), 0 8px 24px rgba(16, 32, 22, .05);
  --mono: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
}

/*
 * Dark palette. Three states, so a manual toggle wins over the OS in either
 * direction: system default (no data-theme) follows prefers-color-scheme;
 * data-theme="light" pins light; data-theme="dark" pins dark. The token values
 * live once in a mixin-style list repeated across the two dark selectors.
 */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg: #10140f;
    --panel: #191e18;
    --panel-2: #1f251e;
    --line: #2b332a;
    --line-soft: #232a22;
    --ink: #e8efe9;
    --ink-2: #a3b0a6;
    --ink-3: #76837a;
    --accent: #3fbe72;
    --accent-ink: #0c1a11;
    --accent-soft: #1b2f22;
    --open: #58cf87;
    --open-bg: #172a1e;
    --held: #e0aa4a;
    --held-bg: #2e2515;
    --booked: #e8796a;
    --booked-bg: #321d1a;
    --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px rgba(0, 0, 0, .35);
  }
}

:root[data-theme="dark"] {
  --bg: #10140f;
  --panel: #191e18;
  --panel-2: #1f251e;
  --line: #2b332a;
  --line-soft: #232a22;
  --ink: #e8efe9;
  --ink-2: #a3b0a6;
  --ink-3: #76837a;
  --accent: #3fbe72;
  --accent-ink: #0c1a11;
  --accent-soft: #1b2f22;
  --open: #58cf87;
  --open-bg: #172a1e;
  --held: #e0aa4a;
  --held-bg: #2e2515;
  --booked: #e8796a;
  --booked-bg: #321d1a;
  --shadow: 0 1px 2px rgba(0, 0, 0, .4), 0 10px 30px rgba(0, 0, 0, .35);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
}

body {
  background: var(--bg);
  color: var(--ink);
  font: 15px/1.5 system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  -webkit-text-size-adjust: 100%;
}

a { color: var(--accent); }

.wrap {
  max-width: 1120px;
  margin: 0 auto;
  padding: 20px 16px 56px;
}

/* ------------------------------------------------------------ typography */

h1, h2, h3 { margin: 0; font-weight: 650; letter-spacing: -.01em; }
h1 { font-size: 26px; }
h2 { font-size: 17px; }
h3 { font-size: 14px; }

.muted { color: var(--ink-2); }
.tiny { font-size: 12px; }
.mono { font-family: var(--mono); font-variant-numeric: tabular-nums; }

/* ------------------------------------------------------------ surfaces */

.card {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-pad { padding: 16px; }

.section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 12px;
}

/* ------------------------------------------------------------ header */

.topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}

.brand {
  display: flex;
  align-items: center;
  gap: 11px;
  min-width: 0;
}

.ball {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: radial-gradient(circle at 32% 28%, #f4ef62, #cbd228 60%, #9fae13);
  box-shadow: inset -3px -4px 8px rgba(0, 0, 0, .18);
  position: relative;
  flex: none;
}

.ball::after {
  content: "";
  position: absolute;
  inset: 6px;
  border-radius: 50%;
  background:
    radial-gradient(circle at 50% 20%, rgba(0,0,0,.28) 1.4px, transparent 1.6px),
    radial-gradient(circle at 22% 55%, rgba(0,0,0,.28) 1.4px, transparent 1.6px),
    radial-gradient(circle at 78% 55%, rgba(0,0,0,.28) 1.4px, transparent 1.6px),
    radial-gradient(circle at 50% 86%, rgba(0,0,0,.28) 1.4px, transparent 1.6px);
}

/* ------------------------------------------------------------ controls */

button, .btn {
  font: inherit;
  font-weight: 560;
  border: 1px solid var(--line);
  background: var(--panel);
  color: var(--ink);
  padding: 9px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  text-decoration: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 7px;
  transition: background .12s, border-color .12s, opacity .12s;
}

button:hover, .btn:hover { background: var(--panel-2); }
button:disabled { opacity: .5; cursor: default; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.btn-primary:hover { background: var(--accent); opacity: .9; }

.btn-danger { color: var(--booked); border-color: var(--line); }
.btn-danger:hover { background: var(--booked-bg); }

.btn-sm { padding: 5px 10px; font-size: 13px; }

/* theme toggle - a compact icon button; the icon is swapped by the script */
.themebtn {
  width: 38px;
  height: 38px;
  padding: 0;
  border-radius: 50%;
  font-size: 17px;
  line-height: 1;
  flex: none;
}
.themebtn:hover { background: var(--panel-2); }

input, select, textarea {
  font: inherit;
  width: 100%;
  color: var(--ink);
  background: var(--panel-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
}

input:focus, select:focus, textarea:focus {
  outline: 2px solid var(--accent);
  outline-offset: -1px;
  border-color: var(--accent);
}

textarea { resize: vertical; min-height: 62px; }

.field {
  display: block;
  margin-bottom: 12px;
}

.field > span {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: var(--ink-2);
  margin-bottom: 5px;
  letter-spacing: .02em;
  text-transform: uppercase;
}

.row {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
}

.check {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
  font-size: 14px;
}

.check input { width: auto; }

/* rate ladder rows in the court editor */
.tierrow {
  display: flex;
  align-items: center;
  gap: 7px;
  margin-bottom: 7px;
}

.tierrow input { width: 88px; padding: 7px 9px; }
.tierrow .lbl { font-size: 12px; color: var(--ink-2); white-space: nowrap; }
.tierrow button { padding: 6px 10px; line-height: 1; }

.ladder {
  font-size: 12px;
  color: var(--ink-2);
  line-height: 1.45;
}

.ladder b { color: var(--ink); font-weight: 620; }

/* ------------------------------------------------------------ date strip */

.datestrip {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding: 2px 2px 8px;
  scrollbar-width: thin;
}

.daybtn {
  flex: none;
  min-width: 74px;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  border: 1px solid var(--line);
  background: var(--panel);
  text-align: center;
  line-height: 1.25;
  cursor: pointer;
}

.daybtn b { display: block; font-size: 17px; }
.daybtn small { color: var(--ink-3); font-size: 11px; text-transform: uppercase; letter-spacing: .04em; }

.daybtn.on {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.daybtn.on small { color: var(--accent-ink); opacity: .85; }

/* ------------------------------------------------------------ grid */

.gridscroll {
  overflow-x: auto;
  border-radius: var(--radius);
}

table.grid {
  border-collapse: separate;
  border-spacing: 0;
  width: 100%;
  min-width: 620px;
}

table.grid th, table.grid td {
  border-bottom: 1px solid var(--line-soft);
  padding: 0;
}

table.grid thead th {
  position: sticky;
  top: 0;
  background: var(--panel);
  z-index: 2;
  font-size: 11px;
  font-weight: 600;
  color: var(--ink-2);
  padding: 9px 4px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

.courtcell {
  position: sticky;
  left: 0;
  background: var(--panel);
  z-index: 1;
  padding: 10px 14px 10px 16px !important;
  border-right: 1px solid var(--line);
  min-width: 158px;
  text-align: left;
}

.courtcell .cname { font-weight: 650; }
.courtcell .crate { font-size: 12px; color: var(--ink-2); }

thead .courtcell { z-index: 3; }

.slot {
  height: 44px;
  min-width: 62px;
  border-right: 1px solid var(--line-soft);
  text-align: center;
  font-size: 11px;
  font-weight: 600;
  vertical-align: middle;
  padding: 2px 4px !important;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.slot.open   { background: var(--open-bg);   color: var(--open); }
.slot.held   { background: var(--held-bg);   color: var(--held); }
.slot.booked { background: var(--booked-bg); color: var(--booked); }
.slot.past   { background: var(--panel-2);   color: var(--ink-3); opacity: .65; }

/*
 * Split cells. A booking that starts or ends mid-slot only shades the minutes
 * it actually takes - a 07:00-07:30 booking on an hourly grid leaves the 07:00
 * cell half red, half open, instead of swallowing the whole hour.
 */
.slot.part { position: relative; padding: 0 !important; background: var(--panel); }

.slot .segs {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
}

.slot .seg { display: block; height: 100%; }
.slot .seg.open   { background: var(--open-bg); }
.slot .seg.held   { background: var(--held-bg); }
.slot .seg.booked { background: var(--booked-bg); }
.slot .seg + .seg { box-shadow: inset 1px 0 0 var(--panel); }

.slot .txt { position: relative; pointer-events: none; }   /* clicks belong to the segments */

/* The label sits on its own chip so it stays readable over any mix of fills. */
.slot.part .txt {
  display: inline-block;
  background: var(--panel);
  border-radius: 5px;
  padding: 1px 5px;
  font-size: 10.5px;
  color: var(--booked);
}
.slot.part .txt.free { color: var(--open); }

.slot.clickable .seg { cursor: pointer; }
.slot.clickable .seg:hover { outline: 2px solid var(--accent); outline-offset: -2px; }

.slot.clickable { cursor: pointer; }
.slot.clickable:hover { outline: 2px solid var(--accent); outline-offset: -2px; }

.legend {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  font-size: 12.5px;
  color: var(--ink-2);
  align-items: center;
}

.dot {
  display: inline-block;
  width: 11px;
  height: 11px;
  border-radius: 3px;
  margin-right: 6px;
  vertical-align: -1px;
}

/* ------------------------------------------------------------ badges */

.pill {
  display: inline-block;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 11.5px;
  font-weight: 650;
  letter-spacing: .01em;
}

.pill.confirmed { background: var(--open-bg);   color: var(--open); }
.pill.pending   { background: var(--held-bg);   color: var(--held); }
.pill.cancelled { background: var(--line-soft); color: var(--ink-3); }
.pill.paid      { background: var(--accent-soft); color: var(--accent); }
.pill.off       { background: var(--line-soft); color: var(--ink-3); }

/* ------------------------------------------------------------ suggestions */

.chips {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.chip {
  display: inline-flex;
  flex-direction: column;
  gap: 1px;
  align-items: flex-start;
  padding: 7px 12px;
  border: 1px solid var(--line);
  border-radius: 999px;
  background: var(--panel);
  color: inherit;
  font: inherit;
  text-align: left;
  cursor: pointer;
  white-space: nowrap;
}

.chip:hover { border-color: var(--accent); background: var(--accent-soft); }

.chip .t { font-size: 13.5px; font-weight: 640; letter-spacing: -.01em; }
.chip .s { font-size: 11px; color: var(--ink-3); }
.chip:hover .s { color: var(--ink-2); }

.chip.first {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}
.chip.first .s { color: var(--accent); opacity: .8; }

.chip.on {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.chip.on .s { color: var(--accent-ink); opacity: .85; }

/* Read-only chips on the public board - nothing to click, booking is by phone. */
.chip.static { cursor: default; }
.chip.static:hover { border-color: var(--line); background: var(--panel); }
.chip.static.first:hover { border-color: var(--accent); background: var(--accent-soft); }

/* ------------------------------------------------------------ tables */

table.list {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

table.list th {
  text-align: left;
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--ink-3);
  padding: 8px 10px;
  border-bottom: 1px solid var(--line);
  white-space: nowrap;
}

table.list td {
  padding: 10px;
  border-bottom: 1px solid var(--line-soft);
  vertical-align: middle;
}

table.list tr:last-child td { border-bottom: 0; }

.tablescroll { overflow-x: auto; }

/* ------------------------------------------------------------ misc */

.stats {
  display: grid;
  gap: 12px;
  grid-template-columns: repeat(auto-fit, minmax(148px, 1fr));
  margin-bottom: 16px;
}

.stat { padding: 13px 15px; }
.stat .k { font-size: 11px; text-transform: uppercase; letter-spacing: .05em; color: var(--ink-3); }
.stat .v { font-size: 23px; font-weight: 680; margin-top: 3px; letter-spacing: -.02em; }

.empty {
  text-align: center;
  padding: 34px 16px;
  color: var(--ink-3);
  font-size: 14px;
}

.toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%) translateY(120%);
  background: var(--ink);
  color: var(--bg);
  padding: 11px 18px;
  border-radius: 999px;
  font-size: 14px;
  font-weight: 560;
  box-shadow: var(--shadow);
  transition: transform .22s ease;
  z-index: 90;
  max-width: 90vw;
  text-align: center;
}

.toast.show { transform: translateX(-50%) translateY(0); }
.toast.bad { background: var(--booked); color: #fff; }

.modal-back {
  position: fixed;
  inset: 0;
  background: rgba(8, 14, 10, .55);
  display: none;
  align-items: flex-start;
  justify-content: center;
  padding: 22px 14px;
  overflow-y: auto;
  z-index: 80;
}

.modal-back.show { display: flex; }

.modal {
  background: var(--panel);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  width: 100%;
  max-width: 520px;
  padding: 18px;
  margin: auto;
}

.tabs {
  display: flex;
  gap: 6px;
  margin-bottom: 18px;
  flex-wrap: wrap;
}

.tab {
  padding: 8px 15px;
  border-radius: 999px;
  border: 1px solid var(--line);
  background: var(--panel);
  cursor: pointer;
  font-weight: 560;
  font-size: 14px;
}

.tab.on { background: var(--ink); border-color: var(--ink); color: var(--bg); }

.hide { display: none !important; }

.actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
  margin-top: 16px;
}

@media (max-width: 620px) {
  h1 { font-size: 21px; }
  .wrap { padding: 16px 12px 48px; }
  .card-pad { padding: 13px; }
}
