/* =========================================================
   VilaBets — estilos mobile-first (iOS/Android), cores vindas de /theme.css
   ========================================================= */
*, *::before, *::after { box-sizing: border-box; }

:root {
  --radius: 14px;
  --gap: 12px;
  --tap: 48px;               /* alvo de toque mínimo */
  --border: color-mix(in srgb, var(--text) 12%, transparent);
  --soft: color-mix(in srgb, var(--text) 6%, transparent);
  --ok: #22c55e;
  --bad: #ef4444;
  --warn: #f59e0b;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --bottom-nav-h: 60px;
}

html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 16px;
  line-height: 1.4;
  background: var(--bg);
  color: var(--text);
  -webkit-tap-highlight-color: transparent;
  padding-bottom: calc(var(--bottom-nav-h) + var(--safe-bottom) + 72px);
  overscroll-behavior-y: none;
}
a { color: inherit; }
img { max-width: 100%; }
h1 { font-size: 1.35rem; margin: 4px 0 12px; }
h2 { font-size: 1.1rem; margin: 18px 0 8px; }
small, .muted { color: var(--muted); }

/* ---------- topo ---------- */
.topbar {
  position: sticky; top: 0; z-index: 30;
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: calc(8px + env(safe-area-inset-top, 0px)) 14px 8px;
  background: color-mix(in srgb, var(--bg) 92%, black);
  border-bottom: 1px solid var(--border);
  backdrop-filter: blur(8px);
}
.brand { display: flex; align-items: center; gap: 10px; text-decoration: none; min-width: 0; }
.brand img { width: 34px; height: 34px; border-radius: 8px; object-fit: contain; }
.brand span { display: flex; flex-direction: column; min-width: 0; }
.brand strong { font-size: 1.05rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.brand small { font-size: .72rem; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.topbar-right { display: flex; align-items: center; gap: 8px; }
.balance-chip {
  text-decoration: none; font-weight: 700; font-size: .9rem;
  padding: 7px 12px; border-radius: 999px;
  background: color-mix(in srgb, var(--primary) 22%, transparent);
  border: 1px solid color-mix(in srgb, var(--primary) 60%, transparent);
  white-space: nowrap;
}

/* menu (details/summary: funciona sem JavaScript) */
.menu { position: relative; }
.menu summary {
  list-style: none; cursor: pointer; width: 44px; height: 44px;
  display: grid; place-items: center; border-radius: 12px;
}
.menu summary::-webkit-details-marker { display: none; }
.burger, .burger::before, .burger::after {
  display: block; width: 20px; height: 2px; background: var(--text); border-radius: 2px; position: relative; content: "";
}
.burger::before { position: absolute; top: -6px; }
.burger::after { position: absolute; top: 6px; }
.menu-panel {
  position: absolute; right: 0; top: 50px; min-width: 230px;
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  box-shadow: 0 16px 40px rgba(0,0,0,.45); padding: 6px; display: flex; flex-direction: column;
}
.menu-panel a, .menu-panel .linklike {
  display: block; padding: 12px 14px; border-radius: 10px; text-decoration: none; text-align: left;
  font-size: 1rem; min-height: var(--tap);
}
.menu-panel a:hover, .menu-panel .linklike:hover { background: var(--soft); }
.menu-panel form { margin: 0; }
.linklike { background: none; border: 0; color: inherit; width: 100%; cursor: pointer; font: inherit; }

/* ---------- navegação inferior (celular) ---------- */
.bottom-nav {
  position: fixed; left: 0; right: 0; bottom: 0; z-index: 25;
  display: flex; justify-content: space-around;
  height: calc(var(--bottom-nav-h) + var(--safe-bottom));
  padding-bottom: var(--safe-bottom);
  background: color-mix(in srgb, var(--bg) 94%, black);
  border-top: 1px solid var(--border);
}
.bottom-nav a {
  flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-decoration: none; font-size: 1.2rem; gap: 2px;
}
.bottom-nav a span { font-size: .7rem; color: var(--muted); }

/* ---------- layout ---------- */
.page { max-width: 1200px; margin: 0 auto; padding: 12px 12px 0; }
.content { min-width: 0; }
.card {
  background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius);
  padding: 14px; margin-bottom: var(--gap);
}
.narrow { max-width: 480px; margin: 0 auto; }

/* ---------- aviso do site (cores do tema) ---------- */
.site-notice {
  display: flex; gap: 10px; align-items: flex-start;
  margin: 0 0 12px; padding: 12px 14px; border-radius: var(--radius);
  background: color-mix(in srgb, var(--primary) 14%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--primary) 55%, transparent);
  border-left: 4px solid var(--primary);
  font-size: .85rem; line-height: 1.45;
}
.site-notice p { margin: 0; }
.site-notice strong { color: color-mix(in srgb, var(--primary) 70%, var(--text)); }
.site-notice-icon { font-size: 1.1rem; line-height: 1.2; }

/* ---------- abas de dias e ligas (rolagem horizontal) ---------- */
.scroller {
  display: flex; gap: 8px; overflow-x: auto; padding: 2px 2px 10px; margin: 0 -12px; padding-inline: 12px;
  scrollbar-width: none; -webkit-overflow-scrolling: touch; scroll-snap-type: x proximity;
}
.scroller::-webkit-scrollbar { display: none; }
.pill {
  flex: 0 0 auto; scroll-snap-align: start; text-decoration: none; white-space: nowrap;
  padding: 9px 14px; border-radius: 999px; font-size: .9rem; min-height: 40px;
  display: inline-flex; align-items: center;
  background: var(--soft); border: 1px solid var(--border);
}
.pill.active { background: var(--primary); border-color: var(--primary); color: #fff; font-weight: 700; }
.updated { font-size: .75rem; color: var(--muted); margin: 0 0 8px; }

/* ---------- jogos ---------- */
.league-head { display: flex; align-items: center; gap: 8px; margin: 18px 2px 8px; font-weight: 700; }
.league-head img { width: 22px; height: 22px; object-fit: contain; }
.flag {
  width: 20px !important; height: 15px !important; flex: 0 0 20px; object-fit: cover;
  border-radius: 3px; box-shadow: 0 0 0 1px rgba(255,255,255,.18);
}
.pill .flag { margin-right: 7px; }
.league-inline { display: inline-flex; align-items: center; gap: 7px; }
.match { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 12px; margin-bottom: 10px; }
.match-top { display: flex; justify-content: space-between; align-items: center; font-size: .8rem; color: var(--muted); margin-bottom: 8px; }
.match-top a { color: var(--secondary); text-decoration: none; font-weight: 600; padding: 4px 0 4px 8px; }
.teams { display: flex; flex-direction: column; gap: 6px; margin-bottom: 10px; }
.team { display: flex; align-items: center; gap: 8px; font-weight: 600; min-width: 0; }
.team img { width: 22px; height: 22px; object-fit: contain; flex: 0 0 22px; }
/* escudo: imagem salva no servidor ou, se indisponível, as iniciais nas cores do tema (sem requisição) */
.crest { width: 22px; height: 22px; flex: 0 0 22px; display: inline-grid; place-items: center; }
.crest.no-logo {
  border-radius: 50%;
  background: color-mix(in srgb, var(--primary) 30%, var(--surface));
  border: 1px solid color-mix(in srgb, var(--primary) 70%, transparent);
}
.crest.no-logo::after {
  content: attr(data-initials);
  font-size: 7.5px; font-weight: 800; letter-spacing: -.2px; color: var(--text); line-height: 1;
}
.team span { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.odds { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.odds.two { grid-template-columns: repeat(2, 1fr); }
.odd {
  min-height: var(--tap); border-radius: 12px; border: 1px solid var(--border);
  background: color-mix(in srgb, var(--text) 5%, var(--surface)); color: var(--text);
  display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 1px;
  font: inherit; cursor: pointer; padding: 6px 4px; touch-action: manipulation;
  transition: transform .06s ease, background .15s ease;
}
.odd:active { transform: scale(.97); }
.odd .lbl { font-size: .72rem; color: var(--muted); max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.odd .val { font-weight: 800; font-size: 1rem; }
.odd.selected { background: var(--secondary); border-color: var(--secondary); color: #111; }
.odd.selected .lbl { color: #333; }
.market { margin-top: 14px; }
.market h3 { font-size: .9rem; margin: 0 0 8px; color: var(--muted); font-weight: 600; }
.empty { text-align: center; padding: 40px 16px; color: var(--muted); }

/* ---------- cupom: bottom sheet no celular ---------- */
.slip-panel {
  position: fixed; left: 0; right: 0; z-index: 28;
  bottom: calc(var(--bottom-nav-h) + var(--safe-bottom));
  max-height: calc(100dvh - 120px);
  display: flex; flex-direction: column;
}
body.no-bottom-nav .slip-panel { bottom: var(--safe-bottom); }
.slip { display: flex; flex-direction: column; max-height: inherit; }
.slip.is-empty:not(.has-result) { display: none; }
.slip-bar {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  margin: 0 10px; padding: 12px 16px; border-radius: 16px 16px 0 0; cursor: pointer;
  background: var(--primary); color: #fff; font-weight: 700; border: 0; font: inherit; font-weight: 700;
  box-shadow: 0 -8px 24px rgba(0,0,0,.35); min-height: 52px; width: calc(100% - 20px);
}
.slip-bar .count {
  background: #fff; color: var(--primary); border-radius: 999px; min-width: 26px; height: 26px;
  display: inline-grid; place-items: center; font-size: .85rem; margin-right: 6px;
}
.slip-bar .chev { display: inline-block; margin-left: 6px; transition: transform .2s; }
.slip-panel.open .slip-bar .chev { transform: rotate(180deg); }
.slip-body {
  display: none; overflow-y: auto; -webkit-overflow-scrolling: touch;
  background: var(--surface); margin: 0 10px; padding: 12px 14px 14px;
  border: 1px solid var(--border); border-top: 0;
}
.slip-panel.open .slip-body { display: block; }
.slip-panel.open::before {
  content: ""; position: fixed; inset: 0; background: rgba(0,0,0,.5); z-index: -1;
}
.slip-line {
  display: grid; grid-template-columns: 1fr auto auto; gap: 8px; align-items: center;
  padding: 10px 0; border-bottom: 1px solid var(--border);
}
.slip-line .what { min-width: 0; }
.slip-line .what strong { display: block; font-size: .92rem; }
.slip-line .what small { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.slip-line .problem { color: var(--bad); font-size: .78rem; }
.slip-line .price { font-weight: 800; }
.remove {
  width: 36px; height: 36px; border-radius: 10px; border: 1px solid var(--border); background: transparent;
  color: var(--muted); font-size: 1.1rem; cursor: pointer;
}
.slip-summary { margin-top: 12px; display: grid; gap: 6px; }
.slip-summary .row { display: flex; justify-content: space-between; }
.slip-summary .row strong { font-size: 1.05rem; }
.cap-note { font-size: .78rem; color: var(--warn); }
.cancel-note { font-size: .82rem; color: var(--muted); margin: 8px 0 0; }
.badge.CANCELLED { color: var(--muted); }
.code-box {
  text-align: center; padding: 16px; border-radius: var(--radius);
  background: color-mix(in srgb, var(--secondary) 18%, transparent);
  border: 1px dashed var(--secondary); margin: 10px 0;
}
.code-box .code { font-size: 2rem; font-weight: 900; letter-spacing: 3px; font-family: ui-monospace, Menlo, Consolas, monospace; }

/* ---------- formulários e botões ---------- */
label { display: block; font-size: .85rem; color: var(--muted); margin: 10px 0 4px; }
input, select, textarea {
  width: 100%; min-height: var(--tap); padding: 10px 12px; border-radius: 12px;
  border: 1px solid var(--border); background: var(--bg); color: var(--text);
  font-size: 16px; /* evita zoom automático no iOS */
}
input:focus, select:focus { outline: 2px solid var(--primary); outline-offset: 1px; }
.checkbox { display: flex; align-items: center; gap: 10px; color: var(--text); font-size: 1rem; }
.checkbox input { width: 22px; min-height: 22px; height: 22px; }
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--tap); padding: 10px 18px; border-radius: 12px; border: 1px solid var(--border);
  background: var(--soft); color: var(--text); font: inherit; font-weight: 700; text-decoration: none;
  cursor: pointer; touch-action: manipulation;
}
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-block { width: 100%; }
.btn-sm { min-height: 38px; padding: 6px 14px; font-size: .9rem; }
.btn-danger { background: var(--bad); border-color: var(--bad); color: #fff; }
.btn[disabled], .btn.htmx-request { opacity: .6; pointer-events: none; }
.form-row { display: grid; gap: 10px; }
.stake-row { display: grid; grid-template-columns: 1fr; gap: 8px; margin-top: 10px; }
.quick-stakes { display: grid; grid-template-columns: repeat(4, 1fr); gap: 6px; }
.quick-stakes button { min-height: 40px; }

/* ---------- alertas / status ---------- */
.alert { padding: 12px 14px; border-radius: 12px; margin: 8px 0; font-size: .95rem; }
.alert-ok { background: color-mix(in srgb, var(--ok) 18%, transparent); border: 1px solid var(--ok); }
.alert-error { background: color-mix(in srgb, var(--bad) 18%, transparent); border: 1px solid var(--bad); }
.alert-warn { background: color-mix(in srgb, var(--warn) 18%, transparent); border: 1px solid var(--warn); }
.badge {
  display: inline-block; padding: 3px 10px; border-radius: 999px; font-size: .75rem; font-weight: 700;
  background: var(--soft); border: 1px solid var(--border); white-space: nowrap;
}
.badge.OPEN, .badge.PENDING, .badge.PENDING_VALIDATION { border-color: var(--warn); color: var(--warn); }
.badge.WON { background: var(--ok); border-color: var(--ok); color: #fff; }
.badge.LOST { background: var(--bad); border-color: var(--bad); color: #fff; }
.badge.VOID { color: var(--muted); }

/* ---------- bilhetes ---------- */
.ticket-head { display: flex; justify-content: space-between; align-items: center; gap: 8px; }
.ticket-code { font-family: ui-monospace, Menlo, Consolas, monospace; font-weight: 800; letter-spacing: 1px; }
.ticket-legs { margin: 10px 0 0; padding: 0; list-style: none; }
.ticket-legs li { padding: 8px 0; border-top: 1px solid var(--border); display: grid; grid-template-columns: 1fr auto; gap: 4px 10px; }
.ticket-legs .leg-sub { grid-column: 1 / -1; font-size: .8rem; color: var(--muted); }
.ticket-totals { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; margin-top: 10px; text-align: center; }
.ticket-totals div { background: var(--soft); border-radius: 10px; padding: 8px 4px; }
.ticket-totals small { display: block; font-size: .7rem; }
.ticket-totals strong { font-size: .95rem; }
.filters { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.filters .full { grid-column: 1 / -1; }
.pager { display: flex; justify-content: space-between; align-items: center; margin: 14px 0; }

/* ---------- tabelas (admin) ---------- */
.table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; }
table { width: 100%; border-collapse: collapse; font-size: .9rem; }
th, td { text-align: left; padding: 10px 8px; border-bottom: 1px solid var(--border); white-space: nowrap; }
th { color: var(--muted); font-weight: 600; font-size: .8rem; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.pos { color: var(--ok); }
.neg { color: var(--bad); }
.grid-2 { display: grid; gap: var(--gap); }
.stat { font-size: 1.6rem; font-weight: 800; }

.mt-8 { margin-top: 8px; }
.mt-12 { margin-top: 12px; }
.small-note { font-size: .8rem; margin: 8px 0 0; }
.actions { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 12px; }

/* ---------- telas maiores ---------- */
@media (min-width: 720px) {
  .teams { flex-direction: row; justify-content: space-between; }
  .teams .team:last-child { flex-direction: row-reverse; text-align: right; }
  .grid-2 { grid-template-columns: 1fr 1fr; }
  .filters { grid-template-columns: repeat(4, 1fr) auto; align-items: end; }
  .filters .full { grid-column: auto; }
}

@media (min-width: 1024px) {
  body { padding-bottom: 24px; }
  .bottom-nav { display: none; }
  .page.with-slip { display: grid; grid-template-columns: minmax(0, 1fr) 360px; gap: 20px; align-items: start; }
  .slip-panel {
    position: sticky; top: 76px; bottom: auto; left: auto; right: auto;
    max-height: calc(100vh - 96px);
  }
  .slip.is-empty:not(.has-result) { display: flex; }
  .slip-bar { margin: 0; width: 100%; border-radius: var(--radius) var(--radius) 0 0; cursor: default; box-shadow: none; }
  .slip-bar .chev { display: none; }
  .slip-body { display: block; margin: 0; border-radius: 0 0 var(--radius) var(--radius); }
  .slip-panel.open::before { display: none; }
}

body.no-bottom-nav { padding-bottom: 24px; }

/* ---------- envio do código pelo WhatsApp ---------- */
.btn-whatsapp {
  display: flex; align-items: center; justify-content: center; width: 100%; margin: 4px 0 12px;
  background: #25D366; border-color: #25D366; color: #06301a; font-weight: 700; text-decoration: none;
}
.btn-whatsapp:hover { filter: brightness(1.05); }
