/* ── Reset & Base ────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --green:       #2d6a4f;
  --green-dark:  #1b4332;
  --green-light: #40916c;
  --orange:      #e07b39;
  --orange-dark: #c46224;
  --blue:        #3b82f6;
  --bg:          #f0f4f1;
  --card:        #ffffff;
  --text:        #1a1a1a;
  --muted:       #6b7280;
  --border:      #d1d5db;
  --red:         #dc2626;
  --radius:      12px;
  --shadow:      0 2px 12px rgba(0,0,0,0.08);
}

body {
  font-family: 'Segoe UI', system-ui, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
}

/* ── Header ──────────────────────────────────────────────────────────────── */
header {
  background: var(--green-dark);
  color: white;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem 1.25rem;
  position: sticky;
  top: 0;
  z-index: 200;
  box-shadow: 0 2px 8px rgba(0,0,0,0.3);
  gap: 1rem;
}

.logo { display: flex; align-items: center; gap: 0.5rem; flex-shrink: 0; }
.logo-icon { font-size: 1.4rem; }
.logo-text { font-size: 1.2rem; font-weight: 800; letter-spacing: 0.5px; }

.header-right {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  flex: 1;
  justify-content: flex-end;
}

#evento-select {
  background: rgba(255,255,255,0.12);
  border: 1.5px solid rgba(255,255,255,0.25);
  color: white;
  border-radius: 8px;
  padding: 0.45rem 0.8rem;
  font-size: 0.88rem;
  font-weight: 600;
  cursor: pointer;
  outline: none;
  max-width: 260px;
  width: 100%;
}
#evento-select option { background: var(--green-dark); color: white; }
#evento-select:focus { border-color: rgba(255,255,255,0.6); }

.btn-icon {
  background: rgba(255,255,255,0.15);
  border: 1.5px solid rgba(255,255,255,0.3);
  color: white;
  border-radius: 8px;
  padding: 0.45rem 0.75rem;
  font-size: 1.1rem;
  font-weight: 700;
  cursor: pointer;
  flex-shrink: 0;
  transition: background 0.15s;
}
.btn-icon:hover { background: rgba(255,255,255,0.25); }

.status-dot {
  width: 9px; height: 9px;
  border-radius: 50%;
  background: var(--muted);
  flex-shrink: 0;
  transition: background 0.3s;
}
.status-dot.online  { background: #22c55e; }
.status-dot.offline { background: var(--red); }

/* ── Main ────────────────────────────────────────────────────────────────── */
main {
  max-width: 860px;
  margin: 0 auto;
  padding: 1.25rem 1rem 3rem;
}

/* ── Empty state ─────────────────────────────────────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 0.75rem;
  padding: 4rem 1rem;
  color: var(--muted);
  text-align: center;
}
.empty-state .empty-icon { font-size: 3rem; }
.empty-state p { font-size: 1rem; }
.empty-state.small { padding: 2rem 1rem; }

.hidden { display: none !important; }

/* ── Percursos bar ───────────────────────────────────────────────────────── */
.percursos-bar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.25rem;
  overflow: hidden;
}

.tabs-scroll {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  flex: 1;
  padding-bottom: 2px;
  scrollbar-width: thin;
}

.tab {
  flex-shrink: 0;
  padding: 0.5rem 1.1rem;
  border-radius: 8px;
  border: 2px solid var(--border);
  background: var(--card);
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  color: var(--muted);
  transition: all 0.15s;
  white-space: nowrap;
}
.tab:hover { border-color: var(--green-light); color: var(--green); }
.tab.active { border-color: var(--green); background: var(--green); color: white; }

.btn-icon-sm {
  flex-shrink: 0;
  padding: 0.5rem 0.9rem;
  border-radius: 8px;
  border: 2px dashed var(--border);
  background: transparent;
  font-size: 0.82rem;
  font-weight: 700;
  color: var(--muted);
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}
.btn-icon-sm:hover { border-color: var(--green); color: var(--green); }

/* ── Card form ───────────────────────────────────────────────────────────── */
.form-card {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 1rem 1.25rem;
  margin-bottom: 1.25rem;
}

.form-row {
  display: flex;
  gap: 0.6rem;
  align-items: center;
}

.inp-numero {
  width: 72px;
  flex-shrink: 0;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem 0.7rem;
  font-size: 0.9rem;
  text-align: center;
  font-weight: 700;
  outline: none;
}
.inp-numero:focus { border-color: var(--green-light); }

.inp-atleta {
  flex: 1;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem 0.9rem;
  font-size: 0.9rem;
  outline: none;
}
.inp-atleta:focus { border-color: var(--green-light); }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.6rem 1.1rem;
  border: none;
  border-radius: 8px;
  font-size: 0.88rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: filter 0.15s, transform 0.1s;
}
.btn:hover  { filter: brightness(1.08); }
.btn:active { transform: scale(0.97); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--green);  color: white; }
.btn-ghost   { background: #f3f4f6;       color: var(--text); }
.btn-partida { background: var(--orange); color: white; padding: 0.55rem 1rem; }
.btn-chegada { background: var(--red);    color: white; padding: 0.55rem 1rem; }
.btn-remove  { background: transparent;  color: var(--muted); border: 1.5px solid var(--border); padding: 0.4rem 0.65rem; font-size: 0.8rem; border-radius: 6px; }
.btn-remove:hover { color: var(--red); border-color: var(--red); }

/* ── Listas ──────────────────────────────────────────────────────────────── */
.listas {
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
}

.lista-section {
  background: var(--card);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
}

.lista-header {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.1rem;
  font-size: 0.82rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.8px;
}

.lista-header .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.lista-header.aguardando       { background: #f9fafb; color: var(--muted); }
.lista-header.aguardando .dot  { background: var(--muted); }
.lista-header.em-prova         { background: #fff8f3; color: var(--orange-dark); }
.lista-header.em-prova .dot    { background: var(--orange); }
.lista-header.finalizado        { background: #f0faf4; color: var(--green); }
.lista-header.finalizado .dot   { background: var(--green); }

.badge {
  margin-left: auto;
  background: rgba(0,0,0,0.1);
  color: inherit;
  font-size: 0.75rem;
  font-weight: 800;
  padding: 0.1rem 0.5rem;
  border-radius: 20px;
  min-width: 24px;
  text-align: center;
}

.lista-atletas {
  display: flex;
  flex-direction: column;
}

/* ── Atleta item ─────────────────────────────────────────────────────────── */
.atleta-item {
  display: flex;
  align-items: center;
  padding: 0.8rem 1.1rem;
  gap: 0.75rem;
  border-top: 1px solid var(--border);
  transition: background 0.15s;
}
.atleta-item:first-child { border-top: none; }
.atleta-item.em_prova { background: #fffaf7; }

.atleta-num {
  font-size: 0.78rem;
  font-weight: 800;
  color: var(--muted);
  min-width: 28px;
  text-align: center;
  flex-shrink: 0;
}

.atleta-nome {
  flex: 1;
  font-weight: 700;
  font-size: 0.97rem;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.cronometro {
  font-size: 0.92rem;
  font-weight: 800;
  color: var(--orange-dark);
  font-variant-numeric: tabular-nums;
  min-width: 72px;
  text-align: right;
  flex-shrink: 0;
}

.atleta-tempo {
  font-size: 0.97rem;
  font-weight: 800;
  color: var(--green);
  font-variant-numeric: tabular-nums;
  min-width: 72px;
  text-align: right;
  flex-shrink: 0;
}

.atleta-pos {
  font-size: 1rem;
  min-width: 28px;
  text-align: center;
  flex-shrink: 0;
}

.atleta-actions {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  flex-shrink: 0;
}

.lista-vazia {
  padding: 1.2rem;
  color: var(--muted);
  font-size: 0.88rem;
  text-align: center;
}

/* ── Modal ───────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 1rem;
}

.modal {
  background: white;
  border-radius: var(--radius);
  padding: 1.75rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.2);
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.modal h2 {
  font-size: 1.1rem;
  font-weight: 800;
  color: var(--green-dark);
  margin-bottom: 0.25rem;
}

.modal label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--muted);
}

.modal input[type="text"],
.modal input[type="date"] {
  width: 100%;
  border: 1.5px solid var(--border);
  border-radius: 8px;
  padding: 0.65rem 0.9rem;
  font-size: 0.95rem;
  outline: none;
}
.modal input:focus { border-color: var(--green-light); }

.modal-actions {
  display: flex;
  gap: 0.75rem;
  justify-content: flex-end;
  margin-top: 0.5rem;
}

/* ── Responsivo ──────────────────────────────────────────────────────────── */
@media (max-width: 520px) {
  .logo-text { display: none; }
  #evento-select { font-size: 0.82rem; }
  .form-row { flex-wrap: wrap; }
  .inp-atleta { width: 100%; }
  .btn-primary { width: 100%; }
  .atleta-item { flex-wrap: wrap; }
  .atleta-actions { margin-left: auto; }
}
