/* Quadro Serve: shared styles (booking site and admin) */

@property --tilt { syntax: '<angle>'; inherits: true; initial-value: 0deg; }
@property --spin { syntax: '<angle>'; inherits: true; initial-value: 0deg; }
@property --lift { syntax: '<number>'; inherits: true; initial-value: 0; }

:root {
  color-scheme: dark;
  --night: #0a1330;
  --night-2: #101d44;
  --night-3: #172857;
  --line: rgba(255, 255, 255, 0.12);
  --line-strong: rgba(255, 255, 255, 0.22);
  --text: #eef2ff;
  --muted: #a8b3d8;
  --faint: #6f7ba6;
  --accent: #f2e35b;
  --accent-ink: #1c1a04;
  --court: #2a7ad8;
  --promo: #ff5a4f;
  --ok: #3ddc97;
  --warn: #ffb547;
  --danger: #ff6b6b;
  --radius: 12px;
  --radius-lg: 18px;
  --shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
  --font: 'Montserrat', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  --font-display: 'Oranienbaum', 'Didot', 'Bodoni 72', Georgia, serif;
  --font-script: 'Sacramento', 'Snell Roundhand', cursive;
}

*,
*::before,
*::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; scroll-behavior: smooth; }

body {
  margin: 0;
  min-height: 100vh;
  background: var(--night);
  color: var(--text);
  font-family: var(--font);
  font-size: 16px;
  line-height: 1.5;
}

a { color: var(--accent); }
img, svg { max-width: 100%; }
h1, h2, h3 { line-height: 1.15; margin: 0 0 0.5em; }
p { margin: 0 0 1em; }
[hidden] { display: none !important; }

.wrap { width: min(1080px, 100% - 32px); margin-inline: auto; }
.muted { color: var(--muted); }
.small { font-size: 0.85rem; }
.nowrap { white-space: nowrap; }
.visually-hidden {
  position: absolute !important;
  width: 1px; height: 1px;
  overflow: hidden;
  clip: rect(0 0 0 0);
  white-space: nowrap;
}

/* Buttons ---------------------------------------------------------------- */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 10px 18px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: transparent;
  color: var(--text);
  font: inherit;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, border-color 0.15s, transform 0.1s;
}
.btn:hover { border-color: var(--text); }
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: 0.45; cursor: not-allowed; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-ink); }
.btn-primary:hover { background: #fff27a; border-color: #fff27a; }
.btn-danger { border-color: rgba(255, 107, 107, 0.6); color: #ffb3b3; }
.btn-danger:hover { border-color: var(--danger); background: rgba(255, 107, 107, 0.12); }
.btn-sm { min-height: 34px; padding: 6px 12px; font-size: 0.85rem; }
.btn-block { width: 100%; }
.btn.is-busy { pointer-events: none; opacity: 0.7; }
.btn.is-busy::after {
  content: '';
  width: 14px; height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

:focus-visible { outline: 3px solid var(--accent); outline-offset: 2px; }

/* Forms ------------------------------------------------------------------ */

.field { display: grid; gap: 6px; margin-bottom: 14px; align-content: start; }
.field > span, .label { font-size: 0.85rem; font-weight: 600; line-height: 1.4; color: var(--muted); }
.label { display: block; margin-bottom: 6px; }
.field > .label { margin-bottom: 0; }
.field small { color: var(--faint); font-size: 0.78rem; }
.input,
.field input,
.field select,
.field textarea {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font: inherit;
  line-height: 1.5;
}
/* A native select ignores line-height, so it lands ~2px shorter than an input
   beside it in a .row-2. Drawing our own chevron makes the two match. */
.field select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a8b3d8' stroke-width='2.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px 16px;
}
/* Chrome's date/time editor is 2px taller than a plain text line, which knocks
   these out of line with the inputs beside them; trim the padding to match. */
.input[type='date'], .input[type='time'],
.field input[type='date'], .field input[type='time'] { padding-block: 9px; }
.field textarea { min-height: 84px; resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus, .input:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(242, 227, 91, 0.2);
}
.field select option { background: var(--night-2); }
.row-2 { display: grid; gap: 0 14px; grid-template-columns: 1fr 1fr; }
@media (max-width: 520px) { .row-2 { grid-template-columns: 1fr; } }

.check { display: flex; align-items: center; gap: 10px; cursor: pointer; margin-bottom: 12px; }
.check input { width: 20px; height: 20px; accent-color: var(--accent); }

.form-error {
  padding: 10px 14px;
  border-radius: 10px;
  background: rgba(255, 107, 107, 0.12);
  border: 1px solid rgba(255, 107, 107, 0.4);
  color: #ffc9c9;
  font-size: 0.9rem;
}

/* Chips & badges --------------------------------------------------------- */

.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  background: rgba(255, 255, 255, 0.08);
  color: var(--muted);
  white-space: nowrap;
}
.badge-pending { background: rgba(255, 181, 71, 0.16); color: var(--warn); }
.badge-confirmed { background: rgba(61, 220, 151, 0.16); color: var(--ok); }
.badge-completed { background: rgba(137, 170, 255, 0.16); color: #a9c1ff; }
.badge-cancelled, .badge-no_show { background: rgba(255, 107, 107, 0.14); color: #ff9d9d; }
.badge-paid { background: rgba(61, 220, 151, 0.16); color: var(--ok); }
.badge-unpaid { background: rgba(255, 255, 255, 0.08); color: var(--muted); }
.badge-promo { background: rgba(255, 90, 79, 0.18); color: #ff8c84; }
.badge-block { background: rgba(255, 255, 255, 0.12); color: var(--text); }

.seg {
  display: inline-flex;
  padding: 3px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--line);
}
.seg-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  font: inherit;
  font-size: 0.8rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  padding: 6px 14px;
  border-radius: 999px;
  cursor: pointer;
}
.seg-btn[aria-pressed='true'] { background: var(--accent); color: var(--accent-ink); }

/* Cards & panels ----------------------------------------------------------- */

.card {
  background: linear-gradient(180deg, rgba(255, 255, 255, 0.045), rgba(255, 255, 255, 0.02));
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: clamp(16px, 3vw, 28px);
}

.summary-lines { display: grid; gap: 6px; margin: 0; padding: 0; list-style: none; }
.summary-lines li { display: flex; justify-content: space-between; gap: 12px; }
.summary-lines .total {
  margin-top: 6px;
  padding-top: 10px;
  border-top: 1px solid var(--line);
  font-weight: 700;
  font-size: 1.1rem;
}
.strike { text-decoration: line-through; color: var(--faint); font-weight: 400; margin-right: 6px; }

/* Dialog ------------------------------------------------------------------ */

dialog {
  width: min(560px, 100% - 24px);
  max-height: calc(100vh - 32px);
  padding: 0;
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-lg);
  background: var(--night-2);
  color: var(--text);
  box-shadow: var(--shadow);
}
dialog::backdrop { background: rgba(3, 7, 20, 0.7); backdrop-filter: blur(2px); }
.dialog-head {
  position: sticky;
  top: 0;
  z-index: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 16px 20px;
  background: var(--night-2);
  border-bottom: 1px solid var(--line);
}
.dialog-head h2 { margin: 0; font-size: 1.1rem; }
.dialog-body { padding: 18px 20px 22px; }
.icon-btn {
  width: 36px; height: 36px;
  display: inline-grid;
  place-items: center;
  border: 1px solid var(--line);
  border-radius: 50%;
  background: transparent;
  color: var(--text);
  font-size: 1.2rem;
  cursor: pointer;
}

/* Toasts ------------------------------------------------------------------ */

.toasts {
  position: fixed;
  z-index: 100;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  display: grid;
  gap: 8px;
  width: min(420px, 100% - 32px);
}
.toast {
  padding: 12px 16px;
  border-radius: 12px;
  background: #1f2f63;
  border: 1px solid var(--line-strong);
  box-shadow: var(--shadow);
  animation: toast-in 0.25s ease-out;
  transition: opacity 0.4s, transform 0.4s;
}
.toast-error { background: #4a1f2c; border-color: rgba(255, 107, 107, 0.5); }
.toast-success { background: #173f38; border-color: rgba(61, 220, 151, 0.5); }
.toast.is-leaving { opacity: 0; transform: translateY(8px); }
@keyframes toast-in { from { opacity: 0; transform: translateY(8px); } }

/* Court view (2D plan / 3D model) ------------------------------------------ */

.cv-bar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 8px 12px;
  margin-bottom: 10px;
}
.cv-hint { margin: 0; color: var(--muted); font-size: 0.85rem; }

.cv-stage {
  perspective: 1200px;
  perspective-origin: 50% 20%;
  padding: 20px clamp(10px, 3vw, 28px);
  border-radius: var(--radius-lg);
  border: 1px solid var(--line);
  background:
    radial-gradient(90% 60% at 50% 0%, rgba(120, 150, 255, 0.18), transparent 65%),
    radial-gradient(120% 90% at 50% 10%, #16306b 0%, #0c1736 62%, #081026 100%);
  overflow: hidden;
  user-select: none;
  -webkit-user-select: none;
}
.courtview[data-mode='3d'] .cv-stage {
  padding-top: clamp(64px, 13vw, 110px);
  padding-bottom: 18px;
  cursor: grab;
  touch-action: pan-y;
}
.courtview.is-dragging .cv-stage { cursor: grabbing; }

/* The concrete slab the courts sit on. */
.cv-scene {
  position: relative;
  max-width: 720px;
  margin: 0 auto;
  border-radius: 6px;
  background: linear-gradient(165deg, #d3d7dc 0%, #c1c6cd 55%, #b1b7bf 100%);
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.5);
  transform-style: preserve-3d;
  transform: rotateX(var(--tilt)) rotateZ(var(--spin)) scale(calc(1 - var(--lift) * 0.08));
  transition:
    --tilt 0.8s cubic-bezier(0.2, 0.75, 0.25, 1),
    --spin 0.8s cubic-bezier(0.2, 0.75, 0.25, 1),
    --lift 0.8s cubic-bezier(0.2, 0.75, 0.25, 1);
}
.courtview.is-night .cv-scene {
  background:
    radial-gradient(35% 55% at 0% 0%, rgba(255, 246, 210, 0.45), transparent 70%),
    radial-gradient(35% 55% at 100% 0%, rgba(255, 246, 210, 0.45), transparent 70%),
    radial-gradient(30% 50% at 50% 0%, rgba(255, 246, 210, 0.35), transparent 70%),
    linear-gradient(165deg, #c9ced4 0%, #b3b9c1 55%, #9fa6af 100%);
}
.courtview.is-dragging .cv-scene { transition: none; }

.court {
  position: absolute;
  transform-style: preserve-3d;
  transform: translateZ(1px);
  cursor: pointer;
  transition: transform 0.35s ease;
}
.court-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  display: block;
  transition: box-shadow 0.3s, filter 0.3s;
}
.c-play { fill: #2170d8; }
.c-lines { fill: none; stroke: #fff; stroke-width: 3; }
.c-net { stroke: #15171c; stroke-width: 3.5; }
.c-ball { opacity: 0; transition: opacity 0.3s; }
.c-ball circle { fill: var(--accent); }
.c-ball .c-hole { fill: #a8981f; }

.court:hover .court-svg { box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.9); }
.court.is-selected .court-svg { box-shadow: 0 0 0 3px var(--accent), 0 0 34px rgba(242, 227, 91, 0.6); }
.court.is-selected .c-ball { opacity: 1; }
.courtview[data-mode='3d'] .court.is-selected { transform: translateZ(9px); }
.courtview.has-many .court:not(.is-selected) .court-svg { filter: saturate(0.75) brightness(0.86); }
.courtview.has-many .court:not(.is-selected):hover .court-svg { filter: none; }

/* Things that stand up in 3D and are edge-on (hidden) in the 2D plan. */
.court-net, .cv-wall, .cv-banner, .cv-pole { position: absolute; opacity: var(--lift); pointer-events: none; }

/* Portable net: black frame and mesh, white top tape. */
.court-net {
  left: 50%;
  top: -5%;
  height: 110%;
  width: 7.5%;
  transform-origin: 0 50%;
  transform: rotateY(-90deg);
  background:
    repeating-linear-gradient(0deg, rgba(10, 10, 12, 0.85) 0 1px, transparent 1px 4px),
    repeating-linear-gradient(90deg, rgba(10, 10, 12, 0.85) 0 1px, transparent 1px 4px);
  border-left: 2px solid #15171c;
  border-top: 3px solid #15171c;
  border-bottom: 3px solid #15171c;
  border-right: 3px solid #fff;
}

.cv-wall { background: linear-gradient(#a3a9b1, #7f8791); }
.cv-wall.is-back {
  left: 0;
  width: 100%;
  top: calc(var(--wall-h) * -1);
  height: var(--wall-h);
  transform-origin: 50% 100%;
  transform: rotateX(-90deg);
  border-top: 2px solid #d5d9de;
}
.cv-wall.is-left {
  top: 0;
  height: 100%;
  left: calc(var(--wall-w) * -1);
  width: var(--wall-w);
  transform-origin: 100% 50%;
  transform: rotateY(90deg);
}
.cv-wall.is-right {
  top: 0;
  height: 100%;
  left: 100%;
  width: var(--wall-w);
  transform-origin: 0 50%;
  transform: rotateY(-90deg);
}

.cv-banner { transform-origin: 50% 100%; transform: rotateX(-90deg) translateZ(1px); }
.cv-banner svg { display: block; width: 100%; height: 100%; }
.cv-banner .b-name { font: 800 30px var(--font); fill: #1b2a6b; }
.cv-banner .b-sub { font: 700 15px var(--font); fill: #1b2a6b; letter-spacing: 4px; }

.cv-pole {
  transform-origin: 50% 100%;
  transform: rotateX(-90deg);
  border-radius: 2px;
  background: linear-gradient(90deg, #6b727c, #b3bac3, #6b727c);
}
.cv-pole::before {
  content: '';
  position: absolute;
  left: 50%;
  top: 0;
  width: 700%;
  height: 4%;
  min-height: 3px;
  transform: translateX(-50%);
  border-radius: 2px;
  background: #d9dde2;
}
.courtview.is-night .cv-pole::before {
  background: #fffbea;
  box-shadow: 0 0 10px 3px rgba(255, 244, 200, 0.95), 0 0 36px 12px rgba(255, 238, 170, 0.45);
}

/* Name tag: flat on the court in 2D, a floating sign facing you in 3D. */
.court-tag {
  position: absolute;
  left: 50%;
  top: 50%;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px 4px 8px;
  border-radius: 999px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  background: rgba(7, 12, 32, 0.9);
  color: var(--text);
  font-size: clamp(0.66rem, 2vw, 0.8rem);
  white-space: nowrap;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  transform:
    translate(-50%, -50%)
    translateZ(calc(var(--lift) * 44px))
    rotateZ(calc(var(--spin) * -1))
    rotateX(calc(var(--tilt) * -1));
}
.court-tag::before, .cv-chip i {
  content: '';
  flex: none;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--ok);
  box-shadow: 0 0 8px var(--ok);
}
.court.is-busy .court-tag::before, .cv-chip.is-busy i { background: var(--warn); box-shadow: 0 0 8px var(--warn); }
.court.is-full .court-tag::before, .cv-chip.is-full i { background: var(--danger); box-shadow: 0 0 8px var(--danger); }
.court-tag span { color: var(--muted); }
.court-tag span:empty { display: none; }
.courtview.has-many .court:not(.is-selected) .court-tag span { display: none; }
.court.is-selected .court-tag { background: var(--accent); border-color: transparent; color: var(--accent-ink); }
.court.is-selected .court-tag span { color: rgba(28, 26, 4, 0.72); }

/* Court buttons under the view: easy to tap and keyboard-friendly. */
.cv-list { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 8px; margin-top: 12px; }
.courtview:not(.has-many) .cv-list { display: none; }
.cv-chip {
  display: grid;
  grid-template-columns: auto 1fr;
  align-items: center;
  column-gap: 9px;
  min-height: 44px;
  padding: 7px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 12px;
  text-align: left;
  background: rgba(255, 255, 255, 0.04);
  color: var(--text);
  font: inherit;
  font-size: 0.85rem;
  cursor: pointer;
}
.cv-chip i { grid-row: span 2; }
.cv-chip strong { line-height: 1.25; }
.cv-chip span { grid-column: 2; color: var(--muted); font-size: 0.78rem; line-height: 1.25; }
.cv-chip span:empty { display: none; }
.cv-chip:hover { border-color: var(--text); }
.cv-chip.is-selected { border-color: var(--accent); background: rgba(242, 227, 91, 0.12); }

@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  .cv-scene, .court, .court-svg, .toast { transition: none; animation: none; }
}

/* Games played on a booking --------------------------------------------------- */

.games-card { margin-top: 14px; text-align: left; }
.games-card h3 { margin: 0 0 8px; font-size: 0.95rem; }
.games-list { display: grid; gap: 6px; margin: 0; padding: 0 0 0 20px; }
.games-list li { padding-left: 4px; }
.games-list li::marker { color: var(--faint); font-size: 0.8rem; }
.g-line { display: inline-flex; flex-wrap: wrap; align-items: baseline; gap: 6px; font-size: 0.9rem; }
.g-line strong { color: var(--text); }
.g-line span { color: var(--muted); }
.g-score { font-variant-numeric: tabular-nums; font-weight: 700; color: var(--accent) !important; }
.games-list .icon-btn { width: 24px; height: 24px; margin-left: 6px; font-size: 0.9rem; vertical-align: middle; }
.games-box { margin-top: 4px; }

/* Confirm dialog ---------------------------------------------------------- */

.confirm-dialog { width: min(420px, 100% - 24px); }
.confirm-dialog .dialog-head { border-bottom: 0; padding-bottom: 4px; }
.confirm-dialog .dialog-body { padding-top: 0; }
.confirm-message { margin: 0 0 18px; color: var(--muted); line-height: 1.5; }
.confirm-dialog .dialog-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; margin-top: 0; }
.confirm-dialog .dialog-actions .btn { flex: 1 1 auto; }
@media (max-width: 420px) {
  .confirm-dialog .dialog-actions { flex-direction: column-reverse; }
}
