/* ==========================================================================
   Sport VIP — shared design system
   Every page (except the scoreboard display) extends templates/base.html,
   which loads this file. Page-specific styles live in calendar.css and
   purchases.css and build on the tokens below.
   ========================================================================== */

:root {
  /* Brand */
  --brand: #E30613;
  --brand-dark: #B9050F;
  --brand-50: #FFF1F2;
  --brand-100: #FFE0E3;
  --brand-200: #FFC2C8;

  /* Neutrals */
  --ink: #1C1F24;
  --ink-2: #3D434C;
  --muted: #6B7280;
  --line: #E6E8EC;
  --line-strong: #D4D8DE;
  --bg: #F4F5F7;
  --surface: #FFFFFF;
  --surface-2: #FAFAFB;

  /* Status */
  --success: #16794A;
  --success-bg: #E8F7EF;
  --success-line: #B7E2C9;
  --warning: #8A5A00;
  --warning-bg: #FFF6E0;
  --warning-line: #F1DA9C;
  --danger: #B42318;
  --danger-bg: #FEECEB;
  --danger-line: #F7C1BC;
  --info: #1F4F99;
  --info-bg: #EAF1FD;
  --info-line: #BCD0F4;

  /* Shape */
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow-sm: 0 1px 2px rgba(16, 24, 40, .06);
  --shadow: 0 1px 3px rgba(16, 24, 40, .08), 0 4px 14px rgba(16, 24, 40, .04);
  --ring: 0 0 0 3px rgba(227, 6, 19, .16);

  --font: "Segoe UI", system-ui, -apple-system, Roboto, "Helvetica Neue", Arial, sans-serif;
  --header-h: 60px;

  /* Legacy aliases (older page CSS still references these) */
  --brand-red: var(--brand);
  --brand-red-dark: var(--brand-dark);
  --brand-soft: var(--brand-50);
  --border: var(--line);
}

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

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

body {
  margin: 0;
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
  color: var(--ink);
  background: var(--bg);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { color: var(--ink); line-height: 1.25; margin: 0 0 .5em; }
h1 { font-size: 26px; font-weight: 800; letter-spacing: -.01em; }
h2 { font-size: 19px; font-weight: 750; }
h3 { font-size: 16px; font-weight: 700; }

a { color: var(--brand); text-decoration: none; }
a:hover { color: var(--brand-dark); text-decoration: underline; }

p { margin: 0 0 1em; }
pre {
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 12px;
  overflow: auto;
  font-size: 12px;
}

:focus-visible { outline: none; box-shadow: var(--ring); }

.muted { color: var(--muted); }
.small { font-size: 13px; }
.nowrap { white-space: nowrap; }
.text-right { text-align: right; }
.strong { font-weight: 700; }

/* ---------- Top navigation ---------- */
.topbar {
  position: sticky;
  top: 0;
  z-index: 50;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
  box-shadow: var(--shadow-sm);
}
.topbar::before {            /* brand accent stripe */
  content: "";
  display: block;
  height: 3px;
  background: var(--brand);
}
.topbar-inner {
  max-width: 1440px;
  margin: 0 auto;
  height: var(--header-h);
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 20px;
}
.brand {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--ink);
  font-weight: 800;
  font-size: 17px;
  letter-spacing: -.01em;
  white-space: nowrap;
}
.brand:hover { color: var(--ink); text-decoration: none; }
.brand img { height: 34px; width: auto; display: block; }
.brand span b { color: var(--brand); }

.nav {
  display: flex;
  align-items: stretch;
  gap: 2px;
  height: 100%;
  flex: 1;
  min-width: 0;
}
.nav-link {
  position: relative;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px;
  color: var(--ink-2);
  font-weight: 600;
  font-size: 14px;
  white-space: nowrap;
}
.nav-link:hover { color: var(--brand); text-decoration: none; background: var(--surface-2); }
.nav-link.active { color: var(--brand); }
.nav-link.active::after {
  content: "";
  position: absolute;
  left: 10px; right: 10px; bottom: 0;
  height: 3px;
  border-radius: 3px 3px 0 0;
  background: var(--brand);
}
.nav-count {
  display: inline-block;
  min-width: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--brand);
  color: #fff;
  font-size: 11px;
  font-weight: 800;
  line-height: 18px;
  text-align: center;
}

/* Dropdown menus (admin, user) */
.menu { position: relative; display: flex; align-items: stretch; }
.menu > summary {
  list-style: none;
  cursor: pointer;
  user-select: none;
}
.menu > summary::-webkit-details-marker { display: none; }
.menu > summary .caret { font-size: 10px; opacity: .6; margin-left: 2px; }
.menu-panel {
  position: absolute;
  top: calc(100% + 6px);
  min-width: 220px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  box-shadow: 0 10px 30px rgba(16, 24, 40, .12);
  padding: 6px;
  z-index: 60;
}
.menu-panel.right { right: 0; }
.menu-panel a, .menu-panel .menu-label {
  display: block;
  padding: 9px 12px;
  border-radius: var(--radius-sm);
  color: var(--ink-2);
  font-weight: 600;
  font-size: 14px;
}
.menu-panel a:hover { background: var(--brand-50); color: var(--brand); text-decoration: none; }
.menu-panel a.active { color: var(--brand); }
.menu-panel .menu-label {
  color: var(--muted);
  font-size: 12px;
  font-weight: 600;
  padding-bottom: 4px;
}
.menu-panel hr { border: 0; border-top: 1px solid var(--line); margin: 6px 0; }

.user-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 0 4px 0 8px;
  color: var(--ink-2);
  font-weight: 600;
  font-size: 14px;
}
.avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  display: grid; place-items: center;
  background: var(--brand-50);
  color: var(--brand);
  border: 1px solid var(--brand-100);
  font-weight: 800;
  font-size: 13px;
  text-transform: uppercase;
}

.nav-toggle {
  display: none;
  margin-left: auto;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius-sm);
  width: 40px; height: 38px;
  font-size: 20px;
  cursor: pointer;
  color: var(--ink-2);
}

/* Progress bar shown while the next page loads */
#pageProgress {
  position: fixed;
  top: 0; left: 0;
  height: 3px;
  width: 0;
  background: linear-gradient(90deg, var(--brand), #ff5a64);
  z-index: 100;
  opacity: 0;
  transition: width 8s cubic-bezier(.1, .7, .2, 1), opacity .2s;
}
#pageProgress.run { width: 85%; opacity: 1; }

/* ---------- Page layout ---------- */
.page {
  max-width: 1440px;
  margin: 0 auto;
  padding: 24px 20px 56px;
}
.page.narrow { max-width: 760px; }
.page.medium { max-width: 1040px; }

.page-header {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 12px 20px;
  flex-wrap: wrap;
  margin-bottom: 18px;
}
.page-header h1 { margin: 0; }
.page-header .subtitle { color: var(--muted); margin: 4px 0 0; font-size: 14px; }
.page-actions { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

.back-link {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  color: var(--muted);
  font-weight: 600;
  font-size: 13px;
  margin-bottom: 6px;
}
.back-link:hover { color: var(--brand); text-decoration: none; }

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  flex-wrap: wrap;
  margin: 28px 0 12px;
}
.section-title h2 { margin: 0; }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.stack > * + * { margin-top: 16px; }

/* ---------- Cards ---------- */
.card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 20px;
}
.card + .card { margin-top: 16px; }
.card-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  margin: 0 0 14px;
  font-size: 16px;
  font-weight: 750;
}
.card.flush { padding: 0; overflow: hidden; }
.card.flush > .card-title { padding: 16px 20px 0; }

/* Stat tiles */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(190px, 1fr));
  gap: 12px;
  margin-bottom: 16px;
}
.stat {
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 14px 16px;
  box-shadow: var(--shadow-sm);
}
.stat-label { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.stat-value { font-size: 24px; font-weight: 800; margin-top: 2px; font-variant-numeric: tabular-nums; }
.stat-sub { color: var(--muted); font-size: 13px; }

.meter {
  height: 6px;
  border-radius: 999px;
  background: var(--line);
  overflow: hidden;
  margin-top: 8px;
}
.meter > span { display: block; height: 100%; background: var(--brand); border-radius: inherit; }

/* Navigation tiles (admin menu) */
.tiles { display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: 14px; }
.tile {
  display: block;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius-lg);
  padding: 18px;
  color: var(--ink);
  box-shadow: var(--shadow-sm);
  transition: border-color .15s, box-shadow .15s, transform .08s;
}
.tile:hover { border-color: var(--brand-200); box-shadow: var(--shadow); text-decoration: none; color: var(--ink); }
.tile:active { transform: translateY(1px); }
.tile-icon {
  width: 38px; height: 38px;
  border-radius: 10px;
  display: grid; place-items: center;
  background: var(--brand-50);
  color: var(--brand);
  font-size: 18px;
  margin-bottom: 10px;
}
.tile-title { font-weight: 750; font-size: 16px; }
.tile-desc { color: var(--muted); font-size: 13px; margin-top: 2px; }

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  min-height: 38px;
  padding: 8px 14px;
  border-radius: 10px;
  border: 1px solid transparent;
  font: inherit;
  font-size: 14px;
  font-weight: 700;
  line-height: 1.2;
  white-space: nowrap;
  cursor: pointer;
  text-decoration: none;
  transition: background .15s, border-color .15s, color .15s, box-shadow .15s, transform .06s;
  background: var(--surface);
  color: var(--ink-2);
  border-color: var(--line-strong);
}
.btn:hover { text-decoration: none; background: var(--surface-2); color: var(--ink); }
.btn:active { transform: translateY(1px); }
.btn:disabled, .btn[aria-disabled="true"] { opacity: .5; cursor: not-allowed; transform: none; }

.btn-primary { background: var(--brand); border-color: var(--brand); color: #fff; }
.btn-primary:hover { background: var(--brand-dark); border-color: var(--brand-dark); color: #fff; }

.btn-secondary { background: var(--surface); border-color: var(--brand-200); color: var(--brand); }
.btn-secondary:hover { background: var(--brand-50); color: var(--brand-dark); }

.btn-ghost { background: transparent; border-color: transparent; color: var(--ink-2); }
.btn-ghost:hover { background: var(--surface-2); }

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

.btn-info { background: var(--info); border-color: var(--info); color: #fff; }
.btn-info:hover { background: #173d78; color: #fff; }

.btn-success { background: var(--success); border-color: var(--success); color: #fff; }
.btn-success:hover { background: #10603a; color: #fff; }

.btn-sm { min-height: 30px; padding: 5px 10px; font-size: 13px; border-radius: 8px; }
.btn-block { width: 100%; }

.inline-form { display: inline; margin: 0; }
.btn-row { display: flex; gap: 8px; flex-wrap: wrap; align-items: center; }

/* ---------- Forms ---------- */
label, .label {
  display: block;
  font-weight: 650;
  font-size: 13px;
  color: var(--ink-2);
  margin-bottom: 6px;
}
.hint { color: var(--muted); font-size: 12px; font-weight: 400; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"],
input[type="date"], input[type="search"], input[type="url"], input[type="tel"],
select, textarea {
  width: 100%;
  min-height: 40px;
  padding: 8px 12px;
  border: 1px solid var(--line-strong);
  border-radius: 10px;
  background: var(--surface);
  color: var(--ink);
  font: inherit;
  font-size: 14px;
  transition: border-color .15s, box-shadow .15s;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--brand);
  box-shadow: var(--ring);
}
input[readonly] { background: var(--surface-2); color: var(--muted); }
textarea { min-height: 96px; resize: vertical; line-height: 1.45; }

select {
  appearance: none;
  -webkit-appearance: none;
  padding-right: 36px;
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1.5l5 5 5-5' fill='none' stroke='%23E30613' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
}

input[type="checkbox"], input[type="radio"] {
  width: 16px; height: 16px;
  accent-color: var(--brand);
  margin: 0;
}
.check {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  font-size: 14px;
  color: var(--ink-2);
  margin: 0;
  cursor: pointer;
}

.field { margin-bottom: 14px; }
.field:last-child { margin-bottom: 0; }
.form-grid {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 14px 16px;
}
.form-grid .full { grid-column: 1 / -1; }
.form-actions {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-top: 18px;
  padding-top: 16px;
  border-top: 1px solid var(--line);
}

/* Filter toolbar (dashboard, special events) */
.toolbar {
  display: flex;
  gap: 12px;
  flex-wrap: wrap;
  align-items: flex-end;
}
.toolbar .field { margin: 0; min-width: 200px; }
.toolbar .field.grow { flex: 1 1 320px; }

/* Inline add form (sections etc.) */
.inline-add { display: flex; gap: 8px; }
.inline-add input { flex: 1; }

/* ---------- Tables ---------- */
.table-wrap {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border: 1px solid var(--line);
  border-radius: var(--radius);
  background: var(--surface);
}
.card > .table-wrap { margin: 0 -1px; }
.card.flush > .table-wrap { border: 0; border-radius: 0; margin: 0; }

.table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
  background: var(--surface);
}
.table th {
  text-align: left;
  padding: 10px 12px;
  font-size: 12px;
  font-weight: 700;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
  background: var(--surface-2);
  border-bottom: 1px solid var(--line);
}
.table td {
  padding: 10px 12px;
  border-bottom: 1px solid var(--line);
  vertical-align: top;
}
.table tbody tr:last-child td { border-bottom: 0; }
.table tbody tr:hover td { background: #FFF8F8; }
.table tfoot td {
  border-top: 2px solid var(--line);
  font-weight: 800;
  background: var(--surface-2);
}
.table .num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.table .actions { white-space: nowrap; text-align: right; }
.table .actions > * + * { margin-left: 6px; }
.table tr.row-sub td { background: var(--surface-2); color: var(--ink-2); }
.table tr.row-free td { color: var(--muted); }
.table td.empty-cell { text-align: center; color: var(--muted); padding: 28px; }
.table.compact td, .table.compact th { padding: 7px 10px; }

/* Key-value table (detail pages) */
.kv { width: 100%; border-collapse: collapse; font-size: 14px; }
.kv th {
  width: 34%;
  text-align: left;
  color: var(--muted);
  font-weight: 650;
  padding: 9px 12px 9px 0;
  vertical-align: top;
  border-bottom: 1px solid var(--line);
}
.kv td { padding: 9px 0; border-bottom: 1px solid var(--line); overflow-wrap: anywhere; }
.kv tr:last-child th, .kv tr:last-child td { border-bottom: 0; }

/* Simple list rows (sections, subsections) */
.list { list-style: none; margin: 0; padding: 0; }
.list-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 0;
  border-bottom: 1px solid var(--line);
}
.list-row:last-child { border-bottom: 0; }
.list-row .grow { flex: 1; min-width: 0; font-weight: 650; }
.list-row .grow a { color: var(--ink); }
.list-row .grow a:hover { color: var(--brand); }

/* ---------- Badges & alerts ---------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 9px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  line-height: 1.5;
  white-space: nowrap;
  border: 1px solid var(--line);
  background: var(--surface-2);
  color: var(--ink-2);
}
.badge-brand { background: var(--brand-50); border-color: var(--brand-100); color: var(--brand); }
.badge-success { background: var(--success-bg); border-color: var(--success-line); color: var(--success); }
.badge-warning { background: var(--warning-bg); border-color: var(--warning-line); color: var(--warning); }
.badge-danger { background: var(--danger-bg); border-color: var(--danger-line); color: var(--danger); }
.badge-info { background: var(--info-bg); border-color: var(--info-line); color: var(--info); }

.alert {
  padding: 12px 14px;
  border-radius: var(--radius);
  border: 1px solid var(--line);
  background: var(--surface);
  font-weight: 600;
  font-size: 14px;
  margin-bottom: 12px;
}
.alert-success { background: var(--success-bg); border-color: var(--success-line); color: var(--success); }
.alert-error { background: var(--danger-bg); border-color: var(--danger-line); color: var(--danger); }
.alert-info { background: var(--info-bg); border-color: var(--info-line); color: var(--info); }
.alert-warning { background: var(--warning-bg); border-color: var(--warning-line); color: var(--warning); }
.flashes { margin-bottom: 8px; }

.empty {
  text-align: center;
  color: var(--muted);
  padding: 36px 16px;
}
.empty-title { color: var(--ink); font-weight: 750; font-size: 16px; margin-bottom: 4px; }

/* Info strip (reservation meta etc.) */
.meta-strip {
  display: flex;
  flex-wrap: wrap;
  gap: 8px 28px;
  padding: 14px 16px;
  background: var(--surface-2);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  margin-bottom: 18px;
}
.meta-strip .meta-label { color: var(--muted); font-size: 12px; font-weight: 700; text-transform: uppercase; letter-spacing: .04em; }
.meta-strip .meta-value { font-weight: 700; }

/* ---------- Auth (login) ---------- */
.auth-body {
  min-height: 100vh;
  display: grid;
  place-items: center;
  padding: 24px 16px;
  background:
    radial-gradient(1200px 500px at 50% -10%, var(--brand-50), transparent 70%),
    var(--bg);
}
.auth-card {
  width: 100%;
  max-width: 400px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-top: 4px solid var(--brand);
  border-radius: var(--radius-lg);
  box-shadow: 0 12px 40px rgba(16, 24, 40, .10);
  padding: 28px;
}
.auth-logo { display: block; height: 72px; margin: 0 auto 10px; }
.auth-card h1 { text-align: center; font-size: 22px; margin-bottom: 4px; }
.auth-card .subtitle { text-align: center; color: var(--muted); margin-bottom: 22px; font-size: 14px; }

/* ---------- Responsive (secondary priority) ---------- */
@media (max-width: 1100px) {
  .nav-toggle { display: block; }
  .topbar-inner { flex-wrap: wrap; height: auto; min-height: var(--header-h); padding-top: 10px; padding-bottom: 10px; }
  .nav {
    display: none;
    order: 3;
    flex-basis: 100%;
    flex-direction: column;
    height: auto;
    padding: 6px 0 4px;
    border-top: 1px solid var(--line);
  }
  .topbar.open .nav { display: flex; }
  .nav-link { padding: 10px 8px; border-radius: var(--radius-sm); }
  .nav-link.active::after { display: none; }
  .nav-link.active { background: var(--brand-50); }
  .menu { flex-direction: column; }
  .menu-panel { position: static; box-shadow: none; border: 0; padding: 0 0 0 12px; }
  .nav .user-menu-spacer { display: none; }
}

@media (max-width: 760px) {
  .page { padding: 16px 16px 40px; }
  h1 { font-size: 22px; }
  .grid-2, .grid-3, .form-grid { grid-template-columns: 1fr; }
  .toolbar .field { min-width: 0; flex: 1 1 100%; }
  .card { padding: 16px; }
  .brand span { display: none; }
}

@media print {
  .topbar, #pageProgress, .page-actions, .no-print { display: none !important; }
  body { background: #fff; }
  .card { box-shadow: none; border: 0; padding: 0; }
}
