/* ============================================================
   League Score — Global Stylesheet
   ============================================================ */

/* ── Variables ─────────────────────────────────────────────── */
:root {
  --bg-base:    #0d0d1a;
  --bg-card:    #13132a;
  --bg-input:   #1a1a35;
  --border:     #2a2a4a;
  --accent:     #7c3aed;
  --accent-h:   #6d28d9;
  --accent2:    #2563eb;
  --success:    #10b981;
  --danger:     #ef4444;
  --warning:    #f59e0b;
  --text:       #e2e8f0;
  --text-muted: #94a3b8;
  --radius:     10px;
  --shadow:     0 4px 24px rgba(0,0,0,.45);
  --timer-red:  #ef4444;
}

/* ── Reset ──────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: 'Inter', 'Segoe UI', system-ui, sans-serif;
  background: var(--bg-base);
  color: var(--text);
  min-height: 100vh;
  line-height: 1.6;
}
a { color: var(--accent); text-decoration: none; }
a:hover { text-decoration: underline; }
img { max-width: 100%; }
ul { list-style: none; }

/* ── Typography ─────────────────────────────────────────────── */
h1 { font-size: 1.8rem; font-weight: 700; }
h2 { font-size: 1.4rem; font-weight: 600; }
h3 { font-size: 1.1rem; font-weight: 600; }
p  { color: var(--text-muted); font-size: .95rem; }

/* ── Layout ─────────────────────────────────────────────────── */
.container {
  width: 100%;
  max-width: 960px;
  margin: 0 auto;
  padding: 0 1rem;
}

/* ── Navbar ─────────────────────────────────────────────────── */
.navbar {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: .75rem 0;
  position: sticky;
  top: 0;
  z-index: 100;
}
.navbar .container {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.navbar-brand {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text);
  display: flex;
  align-items: center;
  gap: .5rem;
}
.navbar-brand span { color: var(--accent); }
.navbar-nav {
  display: flex;
  gap: .25rem;
  align-items: center;
}
.nav-link {
  padding: .4rem .8rem;
  border-radius: 6px;
  color: var(--text-muted);
  font-size: .9rem;
  transition: background .15s, color .15s;
}
.nav-link:hover, .nav-link.active {
  background: rgba(124,58,237,.15);
  color: var(--text);
  text-decoration: none;
}
.navbar-user {
  font-size: .85rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: .75rem;
}
.navbar-user strong { color: var(--text); }

/* ── Cards ──────────────────────────────────────────────────── */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.5rem;
  box-shadow: var(--shadow);
}
.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1.25rem;
  padding-bottom: .75rem;
  border-bottom: 1px solid var(--border);
}
.card-title { font-size: 1.1rem; font-weight: 600; }

/* ── Page sections ──────────────────────────────────────────── */
.page { padding: 2rem 0; }
.section { margin-bottom: 2rem; }
.section-title {
  font-size: 1rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

/* ── Grid ───────────────────────────────────────────────────── */
.grid-2 { display: grid; grid-template-columns: repeat(auto-fill, minmax(280px,1fr)); gap: 1rem; }
.grid-3 { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px,1fr)); gap: 1rem; }

/* ── Forms ──────────────────────────────────────────────────── */
.form-group { margin-bottom: 1.25rem; }
.form-label {
  display: block;
  margin-bottom: .4rem;
  font-size: .875rem;
  font-weight: 500;
  color: var(--text-muted);
}
.form-control {
  width: 100%;
  padding: .65rem .9rem;
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  font-size: .95rem;
  transition: border-color .15s, box-shadow .15s;
  outline: none;
}
.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(124,58,237,.2);
}
.form-control::placeholder { color: var(--text-muted); }
select.form-control option { background: var(--bg-card); }

/* ── Buttons ────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .4rem;
  padding: .6rem 1.25rem;
  border: none;
  border-radius: 8px;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s, opacity .15s, transform .1s;
  text-decoration: none;
  white-space: nowrap;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn-primary  { background: var(--accent);  color: #fff; }
.btn-primary:hover  { background: var(--accent-h); text-decoration: none; }
.btn-secondary { background: var(--bg-input); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { background: var(--border); text-decoration: none; }
.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #059669; text-decoration: none; }
.btn-danger  { background: var(--danger); color: #fff; }
.btn-danger:hover  { background: #dc2626; text-decoration: none; }
.btn-warning { background: var(--warning); color: #000; }
.btn-sm { padding: .35rem .75rem; font-size: .8rem; }
.btn-block { width: 100%; }

/* ── Badges ─────────────────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: .2rem .55rem;
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 600;
  letter-spacing: .02em;
}
.badge-success  { background: rgba(16,185,129,.15); color: var(--success); }
.badge-danger   { background: rgba(239,68,68,.15);  color: var(--danger); }
.badge-warning  { background: rgba(245,158,11,.15); color: var(--warning); }
.badge-info     { background: rgba(37,99,235,.15);  color: #60a5fa; }
.badge-muted    { background: rgba(148,163,184,.1); color: var(--text-muted); }
.badge-accent   { background: rgba(124,58,237,.2);  color: #a78bfa; }

/* ── Tables ─────────────────────────────────────────────────── */
.table-wrap { overflow-x: auto; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th {
  text-align: left;
  padding: .6rem .9rem;
  background: rgba(255,255,255,.03);
  color: var(--text-muted);
  font-weight: 600;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .05em;
  border-bottom: 1px solid var(--border);
}
td {
  padding: .7rem .9rem;
  border-bottom: 1px solid rgba(42,42,74,.6);
  color: var(--text);
  vertical-align: middle;
}
tr:last-child td { border-bottom: none; }
tr:hover td { background: rgba(255,255,255,.02); }
.rank-1 td:first-child { color: #fbbf24; font-weight: 700; }
.rank-2 td:first-child { color: #94a3b8; font-weight: 600; }
.rank-3 td:first-child { color: #b45309; font-weight: 600; }

/* ── Timer ──────────────────────────────────────────────────── */
.timer-box {
  text-align: center;
  padding: 1.5rem;
  border-radius: var(--radius);
  border: 2px solid var(--border);
  background: var(--bg-input);
}
.timer-display {
  font-size: 4rem;
  font-weight: 800;
  letter-spacing: .08em;
  font-variant-numeric: tabular-nums;
  color: var(--text);
  line-height: 1;
  margin-bottom: .25rem;
}
.timer-display.warning { color: var(--warning); }
.timer-display.expired { color: var(--timer-red); animation: pulse 1s infinite; }
.timer-label { font-size: .85rem; color: var(--text-muted); text-transform: uppercase; letter-spacing: .08em; }

@keyframes pulse {
  0%, 100% { opacity: 1; }
  50%       { opacity: .4; }
}

/* ── Match card ─────────────────────────────────────────────── */
.match-vs {
  display: flex;
  align-items: center;
  gap: 1rem;
  justify-content: center;
  padding: 1rem 0;
}
.match-player {
  flex: 1;
  text-align: center;
}
.match-player.me { color: #a78bfa; }
.match-player-name { font-size: 1.1rem; font-weight: 600; }
.match-vs-divider {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--text-muted);
}
.match-games {
  display: flex;
  gap: .5rem;
  justify-content: center;
  margin-top: .75rem;
}
.game-dot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .75rem;
  font-weight: 700;
}
.game-dot.win     { background: rgba(16,185,129,.2); border-color: var(--success); color: var(--success); }
.game-dot.loss    { background: rgba(239,68,68,.2);  border-color: var(--danger);  color: var(--danger); }
.game-dot.draw    { background: rgba(245,158,11,.2); border-color: var(--warning); color: var(--warning); }
.game-dot.pending { border-style: dashed; }

/* ── Result buttons ─────────────────────────────────────────── */
.result-actions {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: .75rem;
  margin-top: 1rem;
}

/* ── Login page ─────────────────────────────────────────────── */
.login-wrap {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}
.login-card {
  width: 100%;
  max-width: 400px;
}
.login-logo {
  text-align: center;
  margin-bottom: 2rem;
}
.login-logo h1 { font-size: 2rem; }
.login-logo h1 span { color: var(--accent); }
.login-logo p { margin-top: .25rem; }

/* ── Alerts ─────────────────────────────────────────────────── */
.alert {
  padding: .75rem 1rem;
  border-radius: 8px;
  font-size: .9rem;
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.alert-error   { background: rgba(239,68,68,.1);  border: 1px solid rgba(239,68,68,.3);  color: #fca5a5; }
.alert-success { background: rgba(16,185,129,.1); border: 1px solid rgba(16,185,129,.3); color: #6ee7b7; }
.alert-info    { background: rgba(37,99,235,.1);  border: 1px solid rgba(37,99,235,.3);  color: #93c5fd; }
.alert-warning { background: rgba(245,158,11,.1); border: 1px solid rgba(245,158,11,.3); color: #fcd34d; }
.alert-hidden  { display: none; }

/* ── Store / Tournament list ────────────────────────────────── */
.store-card .store-name { font-size: 1rem; font-weight: 600; margin-bottom: .25rem; }
.store-card .store-meta { font-size: .8rem; color: var(--text-muted); }
.tournament-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .6rem 0;
  border-bottom: 1px solid var(--border);
  gap: .5rem;
}
.tournament-item:last-child { border-bottom: none; }
.tournament-item-name { font-weight: 500; font-size: .95rem; }
.tournament-item-meta { font-size: .8rem; color: var(--text-muted); }

/* ── History list ───────────────────────────────────────────── */
.history-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: .9rem 0;
  border-bottom: 1px solid var(--border);
}
.history-item:last-child { border-bottom: none; }
.result-icon {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .85rem;
  font-weight: 700;
  flex-shrink: 0;
}
.result-icon.win  { background: rgba(16,185,129,.15); color: var(--success); }
.result-icon.loss { background: rgba(239,68,68,.15);  color: var(--danger); }
.result-icon.draw { background: rgba(245,158,11,.15); color: var(--warning); }

/* ── Spinner / Loading ──────────────────────────────────────── */
.spinner {
  width: 36px; height: 36px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  margin: 2rem auto;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loading-msg { text-align: center; color: var(--text-muted); padding: 2rem; }

/* ── Empty state ────────────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--text-muted);
}
.empty-state .icon { font-size: 2.5rem; margin-bottom: .75rem; opacity: .4; }

/* ── Modal ──────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed; inset: 0;
  background: rgba(0,0,0,.7);
  display: flex; align-items: center; justify-content: center;
  z-index: 200;
  padding: 1rem;
}
.modal-backdrop.hidden { display: none; }
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.75rem;
  width: 100%;
  max-width: 460px;
  box-shadow: var(--shadow);
}
.modal-title {
  font-size: 1.1rem;
  font-weight: 600;
  margin-bottom: 1.25rem;
  padding-bottom: .75rem;
  border-bottom: 1px solid var(--border);
}
.modal-actions { display: flex; gap: .75rem; margin-top: 1.25rem; justify-content: flex-end; }

/* ── Divider ────────────────────────────────────────────────── */
.divider {
  border: none;
  border-top: 1px solid var(--border);
  margin: 1.25rem 0;
}

/* ── Utilities ──────────────────────────────────────────────── */
.flex          { display: flex; }
.flex-center   { display: flex; align-items: center; justify-content: center; }
.flex-between  { display: flex; align-items: center; justify-content: space-between; }
.gap-sm        { gap: .5rem; }
.gap-md        { gap: 1rem; }
.mt-sm         { margin-top: .5rem; }
.mt-md         { margin-top: 1rem; }
.mt-lg         { margin-top: 1.75rem; }
.mb-sm         { margin-bottom: .5rem; }
.mb-md         { margin-bottom: 1rem; }
.text-center   { text-align: center; }
.text-muted    { color: var(--text-muted); font-size: .875rem; }
.text-success  { color: var(--success); }
.text-danger   { color: var(--danger); }
.text-warning  { color: var(--warning); }
.fw-bold       { font-weight: 700; }
.hidden        { display: none !important; }

/* ── Register player autocomplete dropdown ──────────────────── */
.rp-dropdown {
  position: absolute;
  top: 100%;
  left: 0; right: 0;
  z-index: 300;
  background: var(--bg-card);
  border: 1px solid var(--accent);
  border-top: none;
  border-radius: 0 0 8px 8px;
  max-height: 200px;
  overflow-y: auto;
  box-shadow: 0 8px 24px rgba(0,0,0,.5);
}
.rp-dropdown-item {
  display: flex;
  flex-direction: column;
  padding: .55rem .9rem;
  cursor: pointer;
  border-bottom: 1px solid var(--border);
  transition: background .1s;
}
.rp-dropdown-item:last-child { border-bottom: none; }
.rp-dropdown-item:hover { background: rgba(124,58,237,.15); }
.rp-dropdown-item .rp-di-name  { font-weight: 600; font-size: .88rem; }
.rp-dropdown-item .rp-di-email { font-size: .78rem; color: var(--text-muted); }
.rp-dropdown-empty {
  padding: .6rem .9rem;
  font-size: .82rem;
  color: var(--text-muted);
}

/* ── Tournament status tabs ─────────────────────────────────── */
.t-tabs {
  display: flex;
  gap: .35rem;
  margin-bottom: 1.25rem;
  border-bottom: 1px solid var(--border);
  padding-bottom: .75rem;
  flex-wrap: wrap;
}
.t-tab-btn {
  display: inline-flex;
  align-items: center;
  gap: .4rem;
  padding: .4rem 1rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-input);
  color: var(--text-muted);
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  transition: background .15s, color .15s, border-color .15s;
}
.t-tab-btn:hover { background: var(--border); color: var(--text); }
.t-tab-btn--active {
  background: rgba(124,58,237,.2);
  border-color: var(--accent);
  color: var(--text);
}
.t-tab-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  border-radius: 99px;
  background: rgba(124,58,237,.35);
  color: #c4b5fd;
  font-size: .7rem;
  font-weight: 700;
}

/* ── Draw (Sorteio) ─────────────────────────────────────────── */
.draw-candidate-item {
  display: flex;
  align-items: center;
  gap: .6rem;
  padding: .45rem .5rem;
  border-radius: 6px;
  cursor: pointer;
  transition: background .12s;
  border-bottom: 1px solid rgba(42,42,74,.5);
  font-size: .88rem;
}
.draw-candidate-item:last-child { border-bottom: none; }
.draw-candidate-item:hover { background: rgba(124,58,237,.08); }
.draw-candidate-name { font-weight: 500; }

.draw-results-list { display: flex; flex-direction: column; gap: .5rem; }
.draw-result-item {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .65rem .75rem;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: var(--bg-input);
}
.draw-position-badge {
  min-width: 2rem;
  text-align: center;
  font-size: .9rem;
  font-weight: 700;
  color: var(--accent);
}
.draw-player-name { font-weight: 600; font-size: .95rem; }
.draw-replaced-chain {
  font-size: .75rem;
  margin-bottom: .2rem;
  display: flex;
  flex-wrap: wrap;
  gap: .3rem;
  align-items: center;
}

/* ── Responsive ─────────────────────────────────────────────── */
@media (max-width: 640px) {
  h1 { font-size: 1.4rem; }
  .navbar-nav .nav-link span { display: none; }
  .result-actions { grid-template-columns: 1fr 1fr; }
  .match-vs { flex-direction: column; gap: .5rem; }
  .match-vs-divider { transform: rotate(90deg); }
  .timer-display { font-size: 3rem; }
  .grid-2, .grid-3 { grid-template-columns: 1fr; }
  .modal-actions { flex-direction: column-reverse; }
}
