/* ==========================================================================
   Torneio Rotativo de Vôlei de Praia — estilos
   ========================================================================== */
:root {
  --oceano: #0a4f9e;
  --oceano-escuro: #06305f;
  --mar: #0ea5e9;
  --areia: #f4d58d;
  --sol: #f59e0b;
  --coral: #ef4444;
  --vitoria: #16a34a;
  --vitoria-bg: #dcfce7;
  --derrota: #dc2626;
  --derrota-bg: #fef2f2;
  --pendente: #d97706;
  --pendente-bg: #fef3c7;
  --encerrada: #2563eb;
  --encerrada-bg: #dbeafe;
  --classificado-bg: #ecfdf5;
  --eliminado-bg: #f8f5f5;
  --radius: .9rem;
  --bs-body-font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

body {
  background: linear-gradient(180deg, #f0f7ff 0, #f8fafc 280px, #fbf8f1 100%);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}
main { flex: 1 0 auto; }

h1, h2, h3, .display-font, .jogo-num, .brand-text, .podio-titulo, .stat-num {
  font-family: "Barlow Condensed", "Inter", sans-serif;
  letter-spacing: .01em;
}
h1, .h1 { font-weight: 800; }
h2, .h2, h3, .h3 { font-weight: 700; }

/* ---------------------------------------------------------------- navbar */
.app-navbar {
  background: linear-gradient(100deg, var(--oceano-escuro), var(--oceano) 55%, #0b7fc4);
  box-shadow: 0 2px 12px rgba(6, 48, 95, .25);
}
.area-admin .app-navbar { background: linear-gradient(100deg, #1e293b, #334155); }
.brand-text { font-size: 1.35rem; font-weight: 700; max-width: 70vw; }
.brand-ball {
  width: 36px; height: 36px; border-radius: 50%;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--areia); color: var(--oceano-escuro); font-size: 1.25rem;
}
@media (max-width: 991.98px) {
  .app-navbar .navbar-brand { flex: 1 1 0; min-width: 0; margin-right: .5rem; }
  .brand-text { max-width: none; overflow: hidden; white-space: nowrap; text-overflow: ellipsis; font-size: 1.2rem; }
  .brand-ball { flex-shrink: 0; }
}
.app-navbar .nav-link { font-weight: 500; border-radius: .5rem; padding: .5rem .75rem; }
.app-navbar .btn-admin { border: 1px solid rgba(255, 255, 255, .45); }
.app-navbar .btn-admin:hover { background: rgba(255, 255, 255, .15); }
.app-navbar .nav-link.active { background: rgba(255, 255, 255, .16); }
.app-footer { background: #0f172a; color: #94a3b8; flex-shrink: 0; }

/* ---------------------------------------------------------------- hero */
.hero {
  position: relative; overflow: hidden;
  border-radius: var(--radius);
  background:
    radial-gradient(circle at 88% -20%, rgba(244, 213, 141, .9) 0, rgba(244, 213, 141, 0) 45%),
    linear-gradient(120deg, var(--oceano-escuro), var(--oceano) 60%, var(--mar));
  color: #fff;
  padding: 1.5rem;
}
.hero::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: -1px; height: 38px;
  background: var(--areia); opacity: .85;
  clip-path: polygon(0 60%, 12% 45%, 28% 62%, 45% 40%, 62% 58%, 80% 38%, 100% 55%, 100% 100%, 0 100%);
}
.hero > * { position: relative; z-index: 1; }
.hero h1 { font-size: clamp(1.8rem, 5vw, 3rem); margin-bottom: .25rem; }
.hero .meta { opacity: .92; }
.hero .status-pill { background: rgba(255, 255, 255, .18); border: 1px solid rgba(255, 255, 255, .35); }
@media (min-width: 768px) { .hero { padding: 2.25rem 2.5rem 3rem; } }

/* ---------------------------------------------------------------- cards */
.card { border: 0; border-radius: var(--radius); box-shadow: 0 1px 3px rgba(15, 23, 42, .08), 0 4px 14px rgba(15, 23, 42, .05); }
.card > .card-header:first-child { border-radius: var(--radius) var(--radius) 0 0; }
.card-header { background: #fff; border-bottom: 1px solid #eef2f7; }
.card-footer { background: #fafbfd; border-top: 1px solid #eef2f7; }

.stat-card { padding: 1rem 1.1rem; }
.stat-card .stat-num { font-size: 2.2rem; font-weight: 800; line-height: 1; }
.stat-card .stat-label { color: #64748b; font-size: .85rem; }
.stat-card .stat-icon { font-size: 1.6rem; opacity: .35; }

/* ---------------------------------------------------------------- partidas */
.partida-card { overflow: hidden; }
.partida-card .card-header { padding: .55rem .8rem; }
.partida-card .jogo-num { font-size: 1.2rem; font-weight: 700; color: var(--oceano-escuro); }
.partida-card.is-pendente { border-left: 4px solid var(--pendente); }
.partida-card.is-encerrada { border-left: 4px solid var(--encerrada); }
.partida-card .lado { padding: .6rem .8rem; border-bottom: 1px solid #f1f5f9; min-height: 3.4rem; }
.partida-card .lado:last-of-type { border-bottom: 0; }
.partida-card .lado-vencedor { background: var(--vitoria-bg); }
.partida-card .lado-vencedor .atleta-nome { font-weight: 700; }
.partida-card .lado-perdedor { background: var(--derrota-bg); }
.partida-card .lado-perdedor .atleta-nome { color: #7f1d1d; }
.atleta-nome { font-weight: 600; }
.atleta-nome.sx-m::before, .atleta-nome.sx-f::before {
  content: ""; display: inline-block; width: .5rem; height: .5rem; border-radius: 50%; margin-right: .3rem; vertical-align: middle;
}
.atleta-nome.sx-m::before { background: #3b82f6; }
.atleta-nome.sx-f::before { background: #ec4899; }
.placar-box { display: flex; align-items: center; flex-shrink: 0; }
.placar-num { font-family: "Barlow Condensed", sans-serif; font-size: 1.9rem; font-weight: 800; min-width: 2.4rem; text-align: center; color: #0f172a; }
.lado-perdedor .placar-num { color: #991b1b; opacity: .8; }
.lado-vencedor .placar-num { color: var(--vitoria); }
.placar-input { width: 4.6rem; text-align: center; font-weight: 700; font-size: 1.35rem; padding: .3rem .2rem; }
.min-w-0 { min-width: 0; }
.hp-field { position: absolute !important; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

.badge-grupo { color: #fff; }
.g-A { background: #0a4f9e !important; }
.g-B { background: #db2777 !important; }
.g-C { background: #059669 !important; }
.g-D { background: #d97706 !important; }
.badge-cruzado { background: #6d28d9; color: #fff; }
.badge-fase { background: var(--oceano-escuro); color: #fff; }
.badge-dupla { background: var(--areia); color: #5b3c00; font-weight: 700; }
.status-pendente { background: var(--pendente-bg); color: #92400e; }
.status-encerrada { background: var(--encerrada-bg); color: #1e40af; }
.status-aguardando { background: #f1f5f9; color: #64748b; }
.badge-classificado { background: var(--vitoria); color: #fff; }
.badge-eliminado { background: #94a3b8; color: #fff; }

/* ---------------------------------------------------------------- ranking */
.ranking-tabela th { font-size: .75rem; text-transform: uppercase; color: #64748b; font-weight: 600; background: #f8fafc; }
.ranking-tabela td { padding-top: .55rem; padding-bottom: .55rem; }
.ranking-tabela tr.zona-classificacao td.pos { color: var(--vitoria); }
.ranking-tabela tr.zona-eliminacao td.pos { color: #94a3b8; }
.ranking-tabela tr.classificado > td { background: var(--classificado-bg); }
.ranking-tabela tr.eliminado > td { background: var(--eliminado-bg); color: #64748b; }
.ranking-tabela tr.linha-corte > td { border-bottom: 3px dashed var(--vitoria); }
.legenda-ranking .leg { display: inline-block; width: .7rem; height: .7rem; border-radius: 2px; margin-right: .25rem; vertical-align: middle; }
.leg-class { background: var(--vitoria); }
.leg-elim { background: #94a3b8; }

/* ---------------------------------------------------------------- tabs */
.nav-grupos { gap: .4rem; flex-wrap: nowrap; overflow-x: auto; }
.nav-grupos .nav-link {
  border-radius: 999px; font-weight: 700; font-family: "Barlow Condensed", sans-serif; font-size: 1.15rem;
  padding: .35rem 1.2rem; background: #fff; color: var(--oceano-escuro); box-shadow: 0 1px 3px rgba(0, 0, 0, .08); white-space: nowrap;
}
.nav-grupos .nav-link.active { background: var(--oceano); color: #fff; }

/* ---------------------------------------------------------------- bracket */
.bracket-scroll { overflow-x: auto; -webkit-overflow-scrolling: touch; scroll-snap-type: x proximity; padding-bottom: .5rem; }
.bracket { display: flex; gap: 1.6rem; min-width: 960px; }
.bracket-col { flex: 1 1 0; min-width: 220px; display: flex; flex-direction: column; scroll-snap-align: start; }
.bracket-col-title {
  font-family: "Barlow Condensed", sans-serif; font-weight: 700; text-transform: uppercase; letter-spacing: .05em;
  color: var(--oceano); font-size: .95rem; text-align: center; margin-bottom: .6rem;
}
.bracket-col-body { flex: 1; display: flex; flex-direction: column; justify-content: space-around; position: relative; min-height: 1040px; }
.bracket-cell { flex: 1; display: flex; align-items: center; position: relative; }
.bracket-col:not(:last-child) .bracket-cell::after {
  content: ""; position: absolute; right: -.8rem; top: 50%; width: .8rem; border-top: 2px solid #cbd5e1;
}
.bracket-col:not(:first-child) .bracket-cell::before {
  content: ""; position: absolute; left: -.8rem; top: 50%; width: .8rem; border-top: 2px solid #cbd5e1;
}
.bracket-terceiro { position: absolute; left: 0; right: 0; bottom: 0; }
.bracket-match {
  display: block; width: 100%; background: #fff; border-radius: .7rem; text-decoration: none; color: inherit;
  box-shadow: 0 1px 3px rgba(15, 23, 42, .1), 0 3px 10px rgba(15, 23, 42, .05); border-left: 4px solid #cbd5e1; overflow: hidden;
}
.bracket-match:hover { color: inherit; box-shadow: 0 2px 6px rgba(15, 23, 42, .15), 0 6px 18px rgba(15, 23, 42, .08); }
.bracket-match.is-pendente { border-left-color: var(--pendente); }
.bracket-match.is-encerrada { border-left-color: var(--encerrada); }
.bracket-match.is-final { border-left-color: var(--sol); box-shadow: 0 0 0 2px var(--areia), 0 6px 18px rgba(245, 158, 11, .25); }
.bm-head { display: flex; justify-content: space-between; font-size: .7rem; text-transform: uppercase; color: #64748b; padding: .3rem .6rem; background: #f8fafc; font-weight: 600; }
.bm-row { display: flex; align-items: center; gap: .45rem; padding: .35rem .6rem; border-top: 1px solid #f1f5f9; font-size: .82rem; }
.bm-row.win { background: var(--vitoria-bg); font-weight: 700; }
.bm-row.lose { color: #94a3b8; }
.bm-code { font-weight: 800; font-size: .72rem; background: var(--areia); color: #5b3c00; border-radius: .3rem; padding: .05rem .3rem; min-width: 1.8rem; text-align: center; }
.bm-row.lose .bm-code { background: #e2e8f0; color: #64748b; }
.bm-names { flex: 1; min-width: 0; display: flex; flex-direction: column; line-height: 1.2; }
.bm-names span { white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.bm-score { font-family: "Barlow Condensed", sans-serif; font-weight: 800; font-size: 1.2rem; min-width: 1.6rem; text-align: right; }
.bm-row.win .bm-score { color: var(--vitoria); }

/* ---------------------------------------------------------------- pódio */
.podio-card { border-radius: var(--radius); padding: 1.1rem .8rem; color: #1f2937; height: 100%; box-shadow: 0 4px 14px rgba(0, 0, 0, .08); }
.podio-card.ouro { background: linear-gradient(135deg, #fde68a, #f59e0b); }
.podio-card.prata { background: linear-gradient(135deg, #f1f5f9, #cbd5e1); }
.podio-card.bronze { background: linear-gradient(135deg, #fed7aa, #ea9a5b); }
.podio-icone { font-size: 2.4rem; line-height: 1; }
.podio-card.ouro .podio-icone { font-size: 3.2rem; }
.podio-titulo { font-weight: 800; font-size: 1.25rem; letter-spacing: .06em; margin-top: .3rem; }
.podio-nomes { font-weight: 600; }

/* ---------------------------------------------------------------- estados */
.estados { list-style: none; padding: 0; margin: 0; counter-reset: est; }
.estados li { position: relative; padding: .45rem .5rem .45rem 2.6rem; border-radius: .5rem; color: #94a3b8; }
.estados li::before {
  counter-increment: est; content: counter(est); position: absolute; left: .5rem; top: 50%; transform: translateY(-50%);
  width: 1.6rem; height: 1.6rem; border-radius: 50%; background: #e2e8f0; color: #64748b; font-size: .8rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
}
.estados li.feito { color: #334155; }
.estados li.feito::before { background: var(--vitoria); color: #fff; content: "✓"; }
.estados li.atual { background: #eff6ff; color: var(--oceano-escuro); font-weight: 700; }
.estados li.atual::before { background: var(--oceano); color: #fff; }

/* ---------------------------------------------------------------- grupos (admin) */
.grupo-box { border-top: 4px solid; }
.grupo-box.g-A-b { border-color: #0a4f9e; }
.grupo-box.g-B-b { border-color: #db2777; }
.grupo-box.g-C-b { border-color: #059669; }
.grupo-box.g-D-b { border-color: #d97706; }
.contador-ok { color: var(--vitoria); }
.contador-erro { color: var(--derrota); }

/* ---------------------------------------------------------------- utilidades */
.section-title { display: flex; align-items: center; gap: .5rem; margin: 1.5rem 0 .9rem; }
.section-title h2 { margin: 0; font-size: 1.6rem; }
.filtros .form-select, .filtros .form-control { min-width: 0; }
.table-admin td, .table-admin th { vertical-align: middle; }
.login-wrap { max-width: 420px; margin: 6vh auto; }

@media (max-width: 575.98px) {
  main.container-xl { padding-left: .75rem; padding-right: .75rem; }
  .placar-input { width: 4rem; font-size: 1.25rem; }
  .partida-card .lado { padding: .55rem .65rem; }
  .atleta-nome { font-size: .95rem; }
  .section-title h2 { font-size: 1.4rem; }
}

/* ---------------------------------------------------------------- atualização automática */
.auto-refresh { display: inline-flex; align-items: center; gap: .35rem; white-space: nowrap; }
.auto-refresh .ar-dot { width: .55rem; height: .55rem; border-radius: 50%; background: var(--vitoria); animation: ar-pulso 1.6s infinite; }
.auto-refresh.is-pausado .ar-dot { background: #94a3b8; animation: none; }
@keyframes ar-pulso { 0% { box-shadow: 0 0 0 0 rgba(22, 163, 74, .55); } 70% { box-shadow: 0 0 0 .5rem rgba(22, 163, 74, 0); } 100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0); } }

/* ---------------------------------------------------------------- ranking compacto (painel) */
.ranking-compacto .card-header { padding: .45rem .75rem; }
.ranking-compacto .ranking-tabela td, .ranking-compacto .ranking-tabela th { padding: .35rem .3rem; font-size: .9rem; }
.ranking-compacto .ranking-tabela td.text-truncate { max-width: 9rem !important; }
@media (min-width: 1600px) {
  .ranking-compacto .ranking-tabela td, .ranking-compacto .ranking-tabela th { font-size: 1rem; padding: .45rem .4rem; }
  .ranking-compacto .ranking-tabela td.text-truncate { max-width: 13rem !important; }
}
