/* ===================== CCR — painel do administrador =====================
   Mesma paleta do site (styles.css, que é carregado antes): cockpit escuro +
   azul #2180D4. O que muda é o CHASSI: barra fixa no topo, coluna de navegação
   à esquerda e telas (views) trocadas por hash — /admin#/usuarios etc. */

.admin-body { min-height: 100vh; }

/* ---------------- porta (login / sem permissão) ---------------- */
.gate { min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 1.5rem; }
.gate-card {
  width: 100%; max-width: 400px; background: var(--surface); border: 1px solid var(--line-2);
  border-radius: 18px; padding: 2rem 1.9rem 2.2rem; box-shadow: 0 40px 100px rgba(0, 0, 0, 0.6);
}
.gate-back { display: block; text-align: center; margin-top: 1.2rem; color: var(--muted); font-size: 0.88rem; }
.gate-back:hover { color: var(--accent); }
#gateDenied .link-btn { display: block; margin: 0.9rem auto 0; }

/* ---------------- barra superior ---------------- */
.abar {
  position: sticky; top: 0; z-index: 50; display: flex; align-items: center; justify-content: space-between;
  gap: 1rem; padding: 0.85rem 1.4rem; border-bottom: 1px solid var(--line-2);
  background: linear-gradient(var(--asphalt), rgba(14, 20, 22, 0.85)); backdrop-filter: blur(10px);
}
.abar-left, .abar-right { display: flex; align-items: center; gap: 0.8rem; }
.abar .brand-panel { border-color: var(--accent-line); color: var(--accent); }
.abar-burger { display: none; background: none; border: 1px solid var(--line-2); color: var(--ink); border-radius: 8px; padding: 0.3rem 0.6rem; font-size: 1rem; cursor: pointer; }

/* ---------------- chassi ---------------- */
.abar .btn { white-space: nowrap; }
.alayout { display: grid; grid-template-columns: 232px 1fr; align-items: start; min-width: 0; }
.aside {
  position: sticky; top: 57px; height: calc(100vh - 57px); display: flex; flex-direction: column;
  gap: 0.25rem; padding: 1.2rem 0.9rem; border-right: 1px solid var(--line);
}
.anav {
  display: flex; align-items: center; gap: 0.7rem; padding: 0.65rem 0.85rem; border-radius: 10px;
  color: var(--muted); font-family: var(--disp); font-weight: 600; font-size: 0.98rem;
  border: 1px solid transparent; transition: background 0.14s ease, color 0.14s ease;
}
.anav:hover { background: var(--surface); color: var(--ink); }
.anav.is-active { background: var(--accent-dim); border-color: var(--accent-line); color: var(--ink); }
.anav-i { font-size: 0.9rem; color: var(--accent); width: 1.1rem; text-align: center; }
.anav-out { margin-top: auto; font-size: 0.9rem; }
.anav-out .anav-i { color: var(--muted); }
.aside-foot { padding: 0.9rem 0.85rem 0; border-top: 1px solid var(--line); }
.aside-dbline { display: flex; align-items: center; gap: 0.45rem; font-family: var(--mono); font-size: 0.74rem; color: var(--muted); }
.aside-dbline i { width: 7px; height: 7px; border-radius: 50%; background: var(--muted-2); }
.aside-dbline i.ok { background: var(--verde); box-shadow: 0 0 8px var(--verde); }
.aside-dbline i.bad { background: var(--vermelho); box-shadow: 0 0 8px var(--vermelho); }
.aside-dim { font-family: var(--mono); font-size: 0.68rem; color: var(--muted-2); margin-top: 0.25rem; }

/* min-width:0 é o que impede a tabela larga de esticar a página inteira —
   sem isso o item do grid cresce e o body ganha rolagem horizontal. */
.amain { padding: 2rem 2rem 4rem; max-width: 1180px; min-width: 0; }
.view { min-width: 0; }
.view-head { display: flex; align-items: flex-end; justify-content: space-between; gap: 1rem; flex-wrap: wrap; margin-bottom: 1.8rem; }
.view-title { font-size: clamp(1.6rem, 3vw, 2.2rem); }
.view-actions { display: flex; align-items: center; gap: 0.6rem; flex-wrap: wrap; }
.view-note { color: var(--muted); font-size: 0.92rem; max-width: 70ch; margin: -0.9rem 0 1.6rem; }
.view .block-head { margin-top: 2.4rem; }

.search {
  background: var(--asphalt); border: 1px solid var(--line-2); border-radius: 999px;
  padding: 0.5rem 1rem; color: var(--ink); font-family: var(--body); font-size: 0.92rem; min-width: 240px;
}
.search:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px var(--accent-dim); }

/* ---------------- tabelas ---------------- */
.table-wrap { border: 1px solid var(--line); border-radius: var(--radius); overflow-x: auto; background: var(--surface); }
.atable { width: 100%; border-collapse: collapse; font-size: 0.93rem; }
.atable th {
  font-family: var(--mono); font-size: 0.66rem; letter-spacing: 0.12em; text-transform: uppercase;
  color: var(--muted-2); text-align: left; padding: 0.85rem 1rem; border-bottom: 1px solid var(--line-2); white-space: nowrap;
}
.atable td { padding: 0.8rem 1rem; border-bottom: 1px solid var(--line); vertical-align: middle; }
.atable tr:last-child td { border-bottom: none; }
.atable tbody tr:hover { background: rgba(255, 255, 255, 0.02); }
.atable .num { font-family: var(--mono); text-align: right; white-space: nowrap; }
.atable .empty-row td { color: var(--muted); text-align: center; padding: 2.2rem 1rem; }
.t-name { font-family: var(--disp); font-weight: 600; }
.t-sub { font-family: var(--mono); font-size: 0.76rem; color: var(--muted); }
.t-actions { display: flex; gap: 0.4rem; justify-content: flex-end; }

.icon-btn {
  background: none; border: 1px solid var(--line-2); color: var(--muted); cursor: pointer;
  border-radius: 8px; padding: 0.3rem 0.65rem; font-size: 0.82rem; font-family: var(--body);
}
.icon-btn:hover { color: var(--ink); border-color: var(--accent); }
.icon-btn.danger:hover { color: var(--vermelho); border-color: var(--vermelho); background: rgba(231, 76, 60, 0.1); }

.tag {
  font-family: var(--mono); font-size: 0.62rem; letter-spacing: 0.1em; text-transform: uppercase;
  border: 1px solid var(--line-2); color: var(--muted); padding: 0.12rem 0.42rem; border-radius: 5px; white-space: nowrap;
}
.tag-admin { background: var(--accent); border-color: var(--accent); color: #fff; }
.tag-src { background: var(--surface-2); }

/* ---------------- eventos (cards) ---------------- */
.ev-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(330px, 1fr)); gap: 1.1rem; }
.ev {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.3rem 1.4rem; display: flex; flex-direction: column; gap: 0.9rem;
}
.ev:hover { border-color: var(--line-2); }
.ev-top { display: flex; justify-content: space-between; gap: 0.8rem; align-items: flex-start; }
.ev-name { font-family: var(--disp); font-weight: 600; font-size: 1.15rem; }
.ev-slug { font-family: var(--mono); font-size: 0.72rem; color: var(--muted-2); }
.ev-local { font-size: 0.88rem; color: var(--muted); }
.ev-tags { display: flex; gap: 0.3rem; flex-wrap: wrap; justify-content: flex-end; }
.ev-metrics { display: flex; gap: 1.4rem; padding-top: 0.9rem; border-top: 1px solid var(--line); }
.ev-metrics .m-val { font-family: var(--mono); font-weight: 700; font-size: 1.15rem; }
.ev-metrics .m-lab { font-size: 0.72rem; color: var(--muted); }
.ev-users { display: flex; gap: 0.35rem; flex-wrap: wrap; }
.ev-foot { display: flex; gap: 0.4rem; justify-content: flex-end; margin-top: auto; padding-top: 0.4rem; }

.chip-mini {
  font-family: var(--mono); font-size: 0.7rem; background: var(--surface-2); border: 1px solid var(--line-2);
  border-radius: 999px; padding: 0.15rem 0.55rem; color: var(--muted);
}

/* ---------------- configurações ---------------- */
.cfg-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 1.1rem; align-items: start; }
.panel {
  background: var(--surface); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 1.5rem 1.5rem 1.7rem; display: flex; flex-direction: column; gap: 0.9rem;
}
.panel-title { font-size: 1.15rem; margin-bottom: 0.2rem; }
.panel .btn { align-self: flex-start; margin-top: 0.3rem; }
.check { display: flex; align-items: center; gap: 0.6rem; font-size: 0.93rem; color: var(--muted); cursor: pointer; }
.check input { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }
.kv { display: flex; flex-direction: column; gap: 0.55rem; }
.kv-row { display: flex; justify-content: space-between; gap: 1rem; font-size: 0.9rem; }
.kv-k { color: var(--muted); }
.kv-v { font-family: var(--mono); }

/* ---------------- modal (formulários) ---------------- */
.sheet-card { max-width: 560px; max-height: 88vh; overflow-y: auto; }
.sheet-card .form { gap: 0.9rem; }
.sheet-foot { display: flex; gap: 0.6rem; justify-content: flex-end; margin-top: 1.4rem; flex-wrap: wrap; }
.sheet-note { color: var(--muted); font-size: 0.88rem; margin: 0 0 1rem; }
.sheet-note strong { color: var(--ink); }

/* lista de seleção (eventos de um usuário / pilotos de um evento) */
.picker { border: 1px solid var(--line-2); border-radius: 12px; background: var(--asphalt); overflow: hidden; }
.picker-head { display: flex; align-items: center; gap: 0.5rem; padding: 0.6rem 0.7rem; border-bottom: 1px solid var(--line); }
.picker-head .search { flex: 1; min-width: 0; padding: 0.4rem 0.8rem; font-size: 0.86rem; }
.picker-list { max-height: 232px; overflow-y: auto; padding: 0.35rem; display: flex; flex-direction: column; gap: 0.1rem; }
.pick {
  display: flex; align-items: center; gap: 0.65rem; padding: 0.5rem 0.6rem; border-radius: 8px;
  cursor: pointer; font-size: 0.92rem;
}
.pick:hover { background: var(--surface); }
.pick input { width: 17px; height: 17px; accent-color: var(--accent); cursor: pointer; flex: none; }
.pick-main { display: flex; flex-direction: column; line-height: 1.25; min-width: 0; }
/* dentro de .field o styles.css deixa todo <span> em mono/caixa-alta (é o rótulo
   do campo); nos itens do seletor a gente volta ao texto normal. */
.pick-main > span { font-family: var(--body); font-size: 0.92rem; letter-spacing: 0; text-transform: none; color: var(--ink); }
.pick-main > .pick-sub { font-family: var(--mono); font-size: 0.72rem; color: var(--muted-2); overflow: hidden; text-overflow: ellipsis; }
.picker-foot { display: flex; justify-content: space-between; align-items: center; padding: 0.5rem 0.75rem; border-top: 1px solid var(--line); }
.picker-foot span { font-family: var(--mono); font-size: 0.74rem; letter-spacing: 0; text-transform: none; color: var(--muted-2); }
.mini-link { background: none; border: none; color: var(--accent); font-size: 0.76rem; cursor: pointer; font-family: var(--body); padding: 0.1rem 0.25rem; }
.mini-link:hover { text-decoration: underline; }
.picker-empty { color: var(--muted-2); font-size: 0.86rem; padding: 1rem 0.7rem; text-align: center; }

/* ---------------- responsivo ---------------- */
@media (max-width: 900px) {
  .alayout { grid-template-columns: 1fr; }
  .aside {
    position: fixed; top: 57px; left: 0; width: 240px; z-index: 45; background: var(--asphalt-2);
    border-right: 1px solid var(--line-2); transform: translateX(-100%); transition: transform 0.18s ease;
  }
  .aside.is-open { transform: none; }
  .abar-burger { display: inline-block; }
  .amain { padding: 1.5rem 1.1rem 3.5rem; }
  .abar-right .user-name { display: none; }
  .ev-grid { grid-template-columns: 1fr; }
}
/* colunas secundárias somem antes de a tabela precisar rolar de lado */
@media (max-width: 1000px) {
  .atable .col-opt { display: none; }
}
@media (max-width: 620px) {
  /* no celular a barra fica só com marca + Sair; o caminho de volta ao painel
     do piloto vive no menu lateral (.anav-out). */
  .abar-right .btn-ghost[href="/"] { display: none; }
  .view-head { align-items: stretch; }
  .view-actions { width: 100%; }
  .search { min-width: 0; flex: 1; }
  /* no celular a tabela guarda só a identidade e as ações */
  .atable .col-opt2 { display: none; }
  .atable th, .atable td { padding: 0.7rem 0.75rem; }
}
