/* ==========================================================================
   Tournament Manager — Design System
   Re-themes Bootstrap 5 primitives in place. No markup changes required.
   ========================================================================== */

:root {
  /* Neutrals — warm stone, not pure black/white */
  --ink-900: #1c1917;
  --ink-700: #3f3a35;
  --ink-500: #6b6259;
  --ink-400: #8a8177;
  --ink-200: #e4e0d8;
  --ink-100: #efece5;
  --ink-50:  #f7f5f0;

  /* Dark surfaces — charcoal navy (sidebar, footer, login) */
  --navy-900: #14181f;
  --navy-800: #1b212b;
  --navy-700: #232a36;
  --navy-600: #333d4d;
  --navy-500: #566072;

  /* Single accent — championship gold, desaturated */
  --gold-700: #96691f;
  --gold-600: #b8842c;
  --gold-500: #c99a44;
  --gold-300: #e4c98a;
  --gold-100: #f6ecd6;

  /* Semantic status (muted, not neon) */
  --ok-600:   #3f8a4c;
  --ok-100:   #e2f0e3;
  --warn-600: #b9791f;
  --warn-100: #f6e9d3;
  --bad-600:  #b1483a;
  --bad-100:  #f5e0dc;
  --info-600: #3d6f92;
  --info-100: #e0ebf1;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --shadow-sm: 0 1px 2px rgba(28, 25, 23, 0.06), 0 1px 1px rgba(28, 25, 23, 0.04);
  --shadow-md: 0 4px 16px rgba(28, 25, 23, 0.08), 0 2px 4px rgba(28, 25, 23, 0.04);
  --shadow-gold: 0 6px 20px rgba(150, 105, 31, 0.18);

  --ease: cubic-bezier(0.4, 0, 0.2, 1);

  /* z-index scale */
  --z-sidebar: 1030;
  --z-backdrop: 1025;
  --z-header: 1010;
  --z-dropdown: 1050;
}

@import url('https://fonts.googleapis.com/css2?family=Be+Vietnam+Pro:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;1,400&display=swap');

/* ---- Base ------------------------------------------------------------- */

html { scroll-behavior: smooth; }

body {
  font-family: 'Be Vietnam Pro', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: var(--ink-900);
  -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4, h5, h6 {
  font-family: 'Be Vietnam Pro', sans-serif;
  font-weight: 700;
  letter-spacing: -0.01em;
  color: var(--ink-900);
  text-wrap: balance;
}

a { color: var(--gold-700); }
a:hover { color: var(--gold-600); }

::selection { background: var(--gold-300); color: var(--ink-900); }

:focus-visible {
  outline: 2px solid var(--gold-600);
  outline-offset: 2px;
  border-radius: 3px;
}

.skip-link {
  position: absolute; left: -9999px; top: 0; z-index: 2000;
  background: var(--navy-900); color: #fff; padding: 0.6rem 1rem;
  border-radius: 0 0 var(--radius-sm) 0;
}
.skip-link:focus { left: 0; }

table, .table { font-variant-numeric: tabular-nums; }

/* ---- Cards -------------------------------------------------------------- */

.card {
  border: 1px solid var(--ink-100);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  transition: box-shadow .2s var(--ease), transform .2s var(--ease);
}
.card.hover-card:hover,
a.card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}
.card-header {
  background: var(--ink-50);
  border-bottom: 1px solid var(--ink-100);
  font-weight: 600;
}

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

.btn {
  border-radius: var(--radius-sm);
  font-weight: 500;
  transition: transform .12s var(--ease), box-shadow .2s var(--ease), background-color .15s var(--ease), border-color .15s var(--ease);
}
.btn:active { transform: scale(0.97); }

.btn-primary {
  background: var(--gold-600);
  border-color: var(--gold-600);
  color: #fff;
}
.btn-primary:hover, .btn-primary:focus {
  background: var(--gold-700);
  border-color: var(--gold-700);
  color: #fff;
  box-shadow: var(--shadow-gold);
}
.btn-outline-primary {
  color: var(--gold-700);
  border-color: var(--gold-500);
}
.btn-outline-primary:hover {
  background: var(--gold-600);
  border-color: var(--gold-600);
}
.btn-outline-secondary:hover { transform: translateY(-1px); }
.btn-link { text-decoration: none; }

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

.form-control, .form-select {
  border-radius: var(--radius-sm);
  border-color: var(--ink-200);
}
.form-control:focus, .form-select:focus {
  border-color: var(--gold-500);
  box-shadow: 0 0 0 0.2rem rgba(185, 132, 44, 0.18);
}
.form-label { font-weight: 500; color: var(--ink-700); }
.form-check-input:checked {
  background-color: var(--gold-600);
  border-color: var(--gold-600);
}

/* ---- Tables -------------------------------------------------------------- */

.table {
  --bs-table-hover-bg: var(--ink-50);
}
.table th {
  font-size: .75rem;
  text-transform: uppercase;
  letter-spacing: .06em;
  font-weight: 600;
  color: var(--ink-500);
  border-bottom-width: 1px;
}
.table td { vertical-align: middle; }
.table-responsive { border-radius: var(--radius-md); }

/* ---- Badges -------------------------------------------------------------- */

.badge {
  font-weight: 600;
  letter-spacing: .02em;
  border-radius: 5px;
  padding: 0.38em 0.6em;
}
.badge.bg-success { background: var(--ok-600) !important; }
.badge.bg-warning { background: var(--warn-600) !important; color: #fff !important; }
.badge.bg-danger  { background: var(--bad-600) !important; }
.badge.bg-info    { background: var(--info-600) !important; }
.badge.bg-primary { background: var(--gold-600) !important; }
.badge.bg-secondary { background: var(--ink-400) !important; }

/* ---- Alerts -------------------------------------------------------------- */

.alert { border: 0; border-radius: var(--radius-md); border-left: 4px solid transparent; }
.alert-success { background: var(--ok-100); color: #204d28; border-left-color: var(--ok-600); }
.alert-danger  { background: var(--bad-100); color: #6b2418; border-left-color: var(--bad-600); }
.alert-warning { background: var(--warn-100); color: #6b4a10; border-left-color: var(--warn-600); }
.alert-info    { background: var(--info-100); color: #1f3d51; border-left-color: var(--info-600); }

/* ---- Breadcrumb -------------------------------------------------------------- */

.breadcrumb { font-size: .85rem; }
.breadcrumb-item a { color: var(--ink-500); text-decoration: none; }
.breadcrumb-item a:hover { color: var(--gold-700); }
.breadcrumb-item.active { color: var(--ink-900); font-weight: 500; }

/* ---- Nav tabs -------------------------------------------------------------- */

.nav-tabs .nav-link {
  color: var(--ink-500);
  border: 0;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  font-weight: 500;
  transition: color .15s var(--ease), border-color .15s var(--ease);
}
.nav-tabs .nav-link:hover { color: var(--ink-900); border-color: var(--ink-200); }
.nav-tabs .nav-link.active {
  color: var(--gold-700);
  border-color: var(--gold-600);
  background: transparent;
}

.nav-pills .nav-link {
  color: var(--ink-700);
  font-weight: 500;
  border-radius: 999px;
  padding: .5rem 1.1rem;
  transition: color .15s var(--ease), background-color .15s var(--ease);
}
.nav-pills .nav-link:hover { background: var(--ink-100); }
.nav-pills .nav-link.active {
  color: #fff;
  background: var(--navy-900);
}

/* ---- Modal -------------------------------------------------------------- */

.modal-content { border: 0; border-radius: var(--radius-lg); box-shadow: var(--shadow-md); }
.modal-header { border-bottom: 1px solid var(--ink-100); }
.modal-footer { border-top: 1px solid var(--ink-100); }

/* Score-entry modal: comfortable centered dialog on desktop, full-height
   bottom sheet on mobile so there's no wasted chrome around the form. */
.modal-score .modal-dialog { max-width: 460px; }
@media (max-width: 575.98px) {
  .modal-score { padding: 0 !important; }
  .modal-score .modal-dialog {
    margin: 0; max-width: 100%; min-height: 100dvh;
    display: flex; align-items: flex-end;
  }
  .modal-score .modal-content { width: 100%; max-height: 92dvh; border-radius: var(--radius-lg) var(--radius-lg) 0 0; }
  .modal-score .modal-body { max-height: 92dvh; }
}

/* Dedicated header strip for the close button + drag handle, kept in its
   own row so it never overlaps the match teams/title below it. */
.modal-score-handle-bar {
  position: relative; display: flex; align-items: center; justify-content: center;
  padding: .6rem .75rem .25rem;
}
.modal-score-handle { width: 36px; height: 4px; border-radius: 999px; background: var(--ink-200); }
.modal-score-handle-bar .btn-close { position: absolute; right: .75rem; top: .55rem; }
@media (min-width: 576px) {
  .modal-score-handle { display: none; }
  .modal-score-handle-bar { justify-content: flex-end; padding: .6rem .75rem 0; }
}

/* ---- Score entry form (used standalone and inside .modal-score) --------- */

.score-form-header { padding: .5rem 1rem 1rem; border-bottom: 1px solid var(--ink-100); }
.score-form-teams { display: flex; align-items: flex-start; justify-content: space-between; gap: .5rem; }
.score-form-team { flex: 1; min-width: 0; }
.score-form-team-name { font-weight: 700; font-size: 1.05rem; line-height: 1.25; }
.score-form-team-sub { color: var(--ink-500); font-size: .78rem; margin-top: .15rem; }
.score-form-vs { color: var(--ink-400); font-weight: 700; font-size: .78rem; padding-top: .25rem; flex-shrink: 0; }
.score-form-meta { color: var(--ink-500); font-size: .8rem; margin-top: .65rem; text-align: center; }

.status-segmented .btn {
  flex: 1; font-weight: 600; font-size: .85rem; padding: .65rem .5rem;
  min-height: 44px;
}

.score-set-row {
  display: flex; align-items: center; gap: .5rem;
  padding: .6rem 0; border-bottom: 1px solid var(--ink-100);
}
.score-set-row:last-child { border-bottom: 0; }
.score-set-label { width: 48px; flex-shrink: 0; font-weight: 600; font-size: .82rem; color: var(--ink-500); }
.score-stepper-group { display: flex; align-items: center; gap: .5rem; flex: 1; justify-content: center; }
.score-stepper { display: flex; align-items: center; background: var(--ink-50); border-radius: var(--radius-md); overflow: hidden; }
.score-step-btn {
  width: 44px; height: 44px; border: 0; background: transparent;
  font-size: 1.3rem; font-weight: 700; line-height: 1; color: var(--gold-700);
  cursor: pointer; transition: background-color .12s var(--ease);
}
.score-step-btn:active { background: var(--gold-100); }
.score-step-value {
  width: 44px; height: 44px; text-align: center; border: 0; background: transparent;
  font-size: 1.15rem; font-weight: 700; color: var(--ink-900);
  font-variant-numeric: tabular-nums; -moz-appearance: textfield;
}
.score-step-value::-webkit-inner-spin-button, .score-step-value::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }
.score-step-value:focus { outline: none; }
.score-set-dash { color: var(--ink-400); font-weight: 700; }
.btn-remove-set {
  width: 36px; height: 36px; flex-shrink: 0; border: 0; background: transparent; color: var(--ink-400);
  border-radius: 50%; transition: background-color .12s var(--ease), color .12s var(--ease);
}
.btn-remove-set:hover { background: var(--bad-100); color: var(--bad-600); }

.score-form-footer {
  position: sticky; bottom: 0; background: #fff;
  padding: .85rem 1rem calc(.85rem + env(safe-area-inset-bottom));
  border-top: 1px solid var(--ink-100); margin-top: .5rem;
}
.score-form-footer .btn { min-height: 46px; font-weight: 600; }

/* ==========================================================================
   Admin layout — sidebar, off-canvas drawer, page header
   ========================================================================== */

#sidebar {
  width: 248px;
  min-height: 100vh;
  background: var(--navy-900);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  z-index: var(--z-sidebar);
  transition: transform .25s var(--ease);
}
#sidebar .brand { padding: 1.1rem 1.25rem; border-bottom: 1px solid var(--navy-600); }
#sidebar .brand a {
  color: #fff; text-decoration: none; font-weight: 700; font-size: 1rem;
  display: flex; align-items: center;
}
#sidebar .nav-section {
  padding: .9rem 1.25rem .3rem;
  font-size: .68rem; text-transform: uppercase;
  color: var(--navy-500); letter-spacing: .09em; font-weight: 600;
}
#sidebar .nav-link {
  color: #b7bfcc; padding: .55rem 1.25rem;
  display: flex; align-items: center; gap: .6rem;
  font-size: .875rem; border-radius: 0;
  border-left: 3px solid transparent;
  transition: all .15s var(--ease);
}
#sidebar .nav-link:hover { color: #fff; background: rgba(255,255,255,.06); }
#sidebar .nav-link.active {
  color: #fff; background: rgba(201, 154, 68, .14);
  border-left-color: var(--gold-500);
}
#sidebar .nav-link i { width: 16px; text-align: center; color: var(--navy-500); }
#sidebar .nav-link.active i, #sidebar .nav-link:hover i { color: var(--gold-500); }

.sidebar-backdrop {
  position: fixed; inset: 0; background: rgba(20, 24, 31, .55);
  z-index: var(--z-backdrop); opacity: 0; pointer-events: none;
  transition: opacity .2s var(--ease);
}
.sidebar-backdrop.show { opacity: 1; pointer-events: auto; }

.sidebar-toggle {
  display: none;
  align-items: center; justify-content: center;
  width: 40px; height: 40px;
  border: 1px solid var(--ink-200); border-radius: var(--radius-sm);
  background: #fff; color: var(--ink-900);
}

#main { margin-left: 248px; padding: 1.75rem; min-height: 100vh; background: var(--ink-50); }

.topbar { display: none; }

.page-header { margin-bottom: 1.75rem; padding-bottom: 1rem; border-bottom: 1px solid var(--ink-200); }
.page-header h1 { font-size: 1.5rem; font-weight: 700; margin: 0; }
.page-header .page-subtitle { color: var(--ink-500); font-size: .9rem; margin-top: .2rem; }

@media (max-width: 991.98px) {
  #sidebar { transform: translateX(-100%); box-shadow: var(--shadow-md); }
  #sidebar.show { transform: translateX(0); }
  #main { margin-left: 0; padding: 1.1rem; }
  .sidebar-toggle { display: inline-flex; }
  .topbar {
    display: flex; align-items: center; gap: .75rem;
    margin: -1.1rem -1.1rem 1.1rem; padding: .75rem 1.1rem;
    background: #fff; border-bottom: 1px solid var(--ink-200);
    position: sticky; top: 0; z-index: var(--z-header);
  }
  .topbar .brand-mini { font-weight: 700; color: var(--ink-900); text-decoration: none; }
}

/* ==========================================================================
   Public site
   ========================================================================== */

body.public-body { background: var(--ink-50); }
body.public-body.has-tabbar { padding-bottom: calc(60px + env(safe-area-inset-bottom)); }

.public-navbar {
  background: rgba(20, 24, 31, .92) !important;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  box-shadow: 0 1px 0 rgba(255,255,255,.05);
}
.public-navbar .navbar-brand { font-weight: 800; letter-spacing: -.01em; }
.public-navbar .nav-link {
  color: #b7bfcc !important; font-weight: 500;
  position: relative; transition: color .15s var(--ease);
}
.public-navbar .nav-link:hover, .public-navbar .nav-link.active { color: #fff !important; }
.public-navbar .nav-link.active::after {
  content: ''; position: absolute; left: .5rem; right: .5rem; bottom: -2px;
  height: 2px; background: var(--gold-500); border-radius: 2px;
}
.public-navbar .navbar-toggler { border-color: var(--navy-600); }

/* Bottom tab bar (mobile-only, replaces footer) */
.tabbar {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: var(--z-header);
  display: flex; background: rgba(255,255,255,.94);
  backdrop-filter: blur(10px); -webkit-backdrop-filter: blur(10px);
  border-top: 1px solid var(--ink-200);
  padding-bottom: env(safe-area-inset-bottom);
  box-shadow: 0 -2px 12px rgba(28,25,23,.06);
}
.tabbar-link {
  flex: 1; display: flex; flex-direction: column; align-items: center; gap: .2rem;
  padding: .55rem 0 .45rem; color: var(--ink-500); text-decoration: none;
  font-size: .68rem; font-weight: 500; transition: color .15s var(--ease);
}
.tabbar-link i { font-size: 1.05rem; }
.tabbar-link.active { color: var(--gold-700); }

.section-title { font-weight: 700; font-size: 1.35rem; color: var(--ink-900); letter-spacing: -.01em; }

.round-badge {
  display: inline-flex; align-items: center; justify-content: center;
  min-width: 28px; height: 28px; padding: 0 .4rem;
  border-radius: 999px; background: var(--navy-900); color: var(--gold-300);
  font-weight: 700; font-size: .8rem; font-variant-numeric: tabular-nums;
}

/* ---- Public hero -------------------------------------------------------------- */

.hero-public {
  border-radius: var(--radius-lg);
  background:
    radial-gradient(circle at 20% 20%, rgba(201,154,68,.12), transparent 45%),
    radial-gradient(circle at 85% 75%, rgba(61,111,146,.10), transparent 40%),
    var(--navy-900);
  color: #fff;
}
.hero-public h1 { color: #fff; font-size: 2rem; }
.hero-public p { color: #b7bfcc; }
.hero-eyebrow {
  display: inline-flex; align-items: center;
  font-size: .72rem; font-weight: 600; letter-spacing: .08em; text-transform: uppercase;
  color: var(--gold-300); background: rgba(201,154,68,.14);
  padding: .3rem .7rem; border-radius: 999px;
}

.icon-tile {
  display: flex; align-items: center; justify-content: center;
  width: 52px; height: 52px; border-radius: var(--radius-md); flex-shrink: 0;
}
.icon-tile-gold { background: var(--gold-100); color: var(--gold-700); }
.icon-tile-ok   { background: var(--ok-100); color: var(--ok-600); }
.icon-tile-info { background: var(--info-100); color: var(--info-600); }

.match-card {
  border: 1px solid var(--ink-100);
  border-left: 4px solid var(--info-600);
  border-radius: var(--radius-md);
  transition: box-shadow .2s var(--ease), transform .2s var(--ease);
}
.match-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.match-card.completed { border-left-color: var(--ok-600); }
.match-card.ongoing { border-left-color: var(--warn-600); }

/* table-row variant: accent border only, no card chrome */
tr.match-card { border: 0; border-radius: 0; box-shadow: none; }
tr.match-card:hover { box-shadow: none; transform: none; }

/* ---- Match row list (mobile-first, replaces the schedule table) --------- */

.match-list {
  background: #fff; border: 1px solid var(--ink-100); border-radius: var(--radius-md);
  overflow: hidden;
}
.match-row {
  padding: .7rem .9rem;
  border-bottom: 1px solid var(--ink-100);
  border-left: 3px solid var(--info-600);
  transition: background-color .12s var(--ease);
}
.match-row:last-child { border-bottom: 0; }
.match-row:hover { background: var(--ink-50); }
.match-row.completed { border-left-color: var(--ok-600); }
.match-row.ongoing { border-left-color: var(--warn-600); }

.match-row-tags { display: flex; align-items: center; gap: .4rem; margin-bottom: .45rem; }
.tag-chip {
  font-size: .68rem; font-weight: 700; letter-spacing: .01em;
  padding: .15rem .55rem; border-radius: 999px;
  background: var(--ink-100); color: var(--ink-500);
}
.tag-chip-group { background: var(--gold-100); color: var(--gold-700); }

.match-row-body { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: .6rem; }
.match-row-team { font-weight: 600; font-size: .92rem; line-height: 1.3; min-width: 0; word-break: break-word; }
.match-row-team.is-winner { color: var(--ok-600); }
.match-row-team-2 { text-align: right; }
.match-row-score {
  font-weight: 700; font-size: .85rem; color: var(--ink-700);
  font-variant-numeric: tabular-nums; white-space: nowrap; text-align: center; min-width: 40px;
}

/* ---- Bracket -------------------------------------------------------------- */

.bracket-scroll {
  overflow-x: auto;
  scroll-snap-type: x proximity;
  padding-bottom: .5rem;
  -webkit-overflow-scrolling: touch;
}
.bracket-scroll::-webkit-scrollbar { height: 8px; }
.bracket-scroll::-webkit-scrollbar-thumb { background: var(--ink-200); border-radius: 8px; }

.bracket-round { scroll-snap-align: start; }

.bracket-match {
  border: 1px solid var(--ink-100);
  border-radius: var(--radius-sm);
  background: #fff;
  transition: box-shadow .18s var(--ease), transform .18s var(--ease);
}
.bracket-match:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }
.bracket-match .winner { font-weight: 700; color: var(--ok-600); }

/* ---- Utility -------------------------------------------------------------- */

.text-gold { color: var(--gold-700) !important; }
.bg-gold-soft { background: var(--gold-100) !important; }
.text-muted-ink { color: var(--ink-500) !important; }
