/* ==========================================================================
   Reserva Esportiva Municipal - folha de estilo unica
   Pensada primeiro para celular; o desktop recebe apenas ajustes de largura.
   Nenhuma informacao depende exclusivamente de cor: sempre ha texto ou icone.
   ========================================================================== */

:root {
  --cor-tema: #0f6b3f;
  --cor-tema-escura: #0b5230;
  --cor-tema-clara: #e6f2eb;
  --cor-texto: #1b1f23;
  --cor-texto-suave: #5a6472;
  --cor-fundo: #f4f6f8;
  --cor-superficie: #ffffff;
  --cor-borda: #dde3ea;
  --cor-sucesso: #14663c;
  --cor-sucesso-fundo: #e4f4ea;
  --cor-erro: #a02128;
  --cor-erro-fundo: #fbeaea;
  --cor-alerta: #8a5a00;
  --cor-alerta-fundo: #fdf3e0;
  --cor-info: #1c4f80;
  --cor-info-fundo: #e8f1fa;
  --raio: 12px;
  --raio-pequeno: 8px;
  --sombra: 0 1px 2px rgba(16, 24, 40, 0.06), 0 4px 12px rgba(16, 24, 40, 0.06);
  --altura-nav: 62px;
  --largura-max: 1100px;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: system-ui, -apple-system, 'Segoe UI', Roboto, Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  color: var(--cor-texto);
  background: var(--cor-fundo);
  padding-bottom: calc(var(--altura-nav) + env(safe-area-inset-bottom));
  -webkit-font-smoothing: antialiased;
}

@media (min-width: 860px) {
  body { padding-bottom: 0; }
}

a { color: var(--cor-tema-escura); }

img { max-width: 100%; height: auto; display: block; }

h1, h2, h3 { line-height: 1.25; margin: 0 0 0.5rem; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.2rem; }
h3 { font-size: 1.03rem; }

/* -------------------------------------------------------------- Cabecalho */
.topo {
  background: var(--cor-tema);
  color: #fff;
  padding: calc(env(safe-area-inset-top) + 0.6rem) 1rem 0.6rem;
  position: sticky;
  top: 0;
  z-index: 30;
}

.topo__interno {
  max-width: var(--largura-max);
  margin: 0 auto;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.topo__marca {
  display: flex;
  align-items: center;
  gap: 0.6rem;
  color: #fff;
  text-decoration: none;
  min-width: 0;
}

.topo__logo {
  width: 34px;
  height: 34px;
  flex: 0 0 34px;
  border-radius: 9px;
  background: rgba(255, 255, 255, 0.16);
  display: grid;
  place-items: center;
  font-size: 1.1rem;
}

.topo__nome { font-weight: 600; font-size: 1rem; line-height: 1.15; }
.topo__orgao { font-size: 0.72rem; opacity: 0.9; line-height: 1.15; }
.topo__acoes { margin-left: auto; display: flex; align-items: center; gap: 0.4rem; }

.topo__link {
  color: #fff;
  text-decoration: none;
  font-size: 0.82rem;
  padding: 0.45rem 0.6rem;
  border-radius: var(--raio-pequeno);
  background: rgba(255, 255, 255, 0.14);
  white-space: nowrap;
}

.topo__link--simples { background: none; }

.selo-notificacao {
  display: inline-block;
  min-width: 18px;
  padding: 0 5px;
  border-radius: 9px;
  background: #fff;
  color: var(--cor-tema-escura);
  font-size: 0.7rem;
  font-weight: 700;
  text-align: center;
}

/* ------------------------------------------------------ Menu (desktop/nav) */
.menu-desktop { display: none; }

@media (min-width: 860px) {
  .menu-desktop {
    display: flex;
    gap: 0.25rem;
    max-width: var(--largura-max);
    margin: 0 auto;
    padding: 0.35rem 1rem 0;
    flex-wrap: wrap;
  }
  .menu-desktop a {
    color: rgba(255, 255, 255, 0.92);
    text-decoration: none;
    padding: 0.4rem 0.7rem;
    border-radius: var(--raio-pequeno) var(--raio-pequeno) 0 0;
    font-size: 0.88rem;
  }
  .menu-desktop a[aria-current='page'] {
    background: var(--cor-fundo);
    color: var(--cor-tema-escura);
    font-weight: 600;
  }
}

.nav-inferior {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: calc(var(--altura-nav) + env(safe-area-inset-bottom));
  padding-bottom: env(safe-area-inset-bottom);
  background: var(--cor-superficie);
  border-top: 1px solid var(--cor-borda);
  display: flex;
  z-index: 40;
}

@media (min-width: 860px) { .nav-inferior { display: none; } }

.nav-inferior a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  color: var(--cor-texto-suave);
  text-decoration: none;
  font-size: 0.68rem;
  padding: 0.3rem 0.2rem;
  min-height: 48px;
}

.nav-inferior a[aria-current='page'] { color: var(--cor-tema); font-weight: 600; }
.nav-inferior__icone { font-size: 1.25rem; line-height: 1; }

/* ------------------------------------------------------------- Estrutura */
.conteudo {
  max-width: var(--largura-max);
  margin: 0 auto;
  padding: 1rem 1rem 2rem;
}

.cartao {
  background: var(--cor-superficie);
  border: 1px solid var(--cor-borda);
  border-radius: var(--raio);
  padding: 1rem;
  box-shadow: var(--sombra);
  margin-bottom: 1rem;
}

.cartao--compacto { padding: 0.75rem; }
.cartao__titulo { display: flex; align-items: center; justify-content: space-between; gap: 0.5rem; flex-wrap: wrap; }

.grade { display: grid; gap: 0.85rem; }
.grade--2 { grid-template-columns: 1fr; }
.grade--3 { grid-template-columns: 1fr; }

@media (min-width: 640px) {
  .grade--2 { grid-template-columns: repeat(2, 1fr); }
  .grade--3 { grid-template-columns: repeat(2, 1fr); }
}

@media (min-width: 960px) {
  .grade--3 { grid-template-columns: repeat(3, 1fr); }
}

.linha { display: flex; gap: 0.6rem; flex-wrap: wrap; align-items: center; }
.entre { justify-content: space-between; }
.suave { color: var(--cor-texto-suave); }
.pequeno { font-size: 0.83rem; }
.miudo { font-size: 0.75rem; }
.negrito { font-weight: 600; }
.centro { text-align: center; }
.mt { margin-top: 1rem; }
.mb { margin-bottom: 1rem; }
.sem-margem { margin: 0; }

/* --------------------------------------------------------------- Botoes */
.botao {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  min-height: 46px;
  padding: 0.6rem 1.1rem;
  border-radius: var(--raio-pequeno);
  border: 1px solid transparent;
  background: var(--cor-tema);
  color: #fff;
  font-size: 0.95rem;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  font-family: inherit;
}

.botao:hover { background: var(--cor-tema-escura); }
.botao:disabled { opacity: 0.55; cursor: not-allowed; }
.botao--largo { width: 100%; }
.botao--secundario { background: var(--cor-superficie); color: var(--cor-tema-escura); border-color: var(--cor-borda); }
.botao--secundario:hover { background: var(--cor-tema-clara); }
.botao--perigo { background: var(--cor-erro); }
.botao--perigo:hover { background: #7f191f; }
.botao--pequeno { min-height: 38px; padding: 0.35rem 0.7rem; font-size: 0.85rem; }

/* ------------------------------------------------------------ Formularios */
.campo { margin-bottom: 0.9rem; }
.campo > label { display: block; font-size: 0.86rem; font-weight: 600; margin-bottom: 0.3rem; }
.campo__dica { font-size: 0.78rem; color: var(--cor-texto-suave); margin-top: 0.25rem; }

input[type='text'],
input[type='email'],
input[type='tel'],
input[type='password'],
input[type='date'],
input[type='time'],
input[type='number'],
input[type='search'],
input[type='file'],
select,
textarea {
  width: 100%;
  min-height: 46px;
  padding: 0.55rem 0.7rem;
  border: 1px solid var(--cor-borda);
  border-radius: var(--raio-pequeno);
  font-size: 16px; /* evita zoom automático no iOS */
  font-family: inherit;
  background: #fff;
  color: var(--cor-texto);
}

textarea { min-height: 92px; resize: vertical; }

input:focus, select:focus, textarea:focus, .botao:focus-visible, a:focus-visible {
  outline: 3px solid rgba(15, 107, 63, 0.35);
  outline-offset: 1px;
}

.caixa-selecao { display: flex; align-items: flex-start; gap: 0.55rem; margin-bottom: 0.5rem; }
.caixa-selecao input { width: 22px; height: 22px; min-height: 22px; margin-top: 2px; flex: 0 0 22px; }

/* ------------------------------------------------------------- Mensagens */
.mensagem {
  border-radius: var(--raio-pequeno);
  padding: 0.75rem 0.9rem;
  margin-bottom: 1rem;
  border: 1px solid;
  display: flex;
  gap: 0.5rem;
  align-items: flex-start;
  font-size: 0.92rem;
}

.mensagem--sucesso { background: var(--cor-sucesso-fundo); border-color: #b9dfc8; color: var(--cor-sucesso); }
.mensagem--erro { background: var(--cor-erro-fundo); border-color: #eeb9bc; color: var(--cor-erro); }
.mensagem--alerta { background: var(--cor-alerta-fundo); border-color: #eedcb0; color: var(--cor-alerta); }
.mensagem--info { background: var(--cor-info-fundo); border-color: #bcd6ef; color: var(--cor-info); }

/* --------------------------------------------------------------- Selos */
.selo {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.16rem 0.55rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  border: 1px solid;
  white-space: nowrap;
}

.selo--pendente { background: var(--cor-alerta-fundo); border-color: #eedcb0; color: var(--cor-alerta); }
.selo--aprovada { background: var(--cor-sucesso-fundo); border-color: #b9dfc8; color: var(--cor-sucesso); }
.selo--recusada { background: var(--cor-erro-fundo); border-color: #eeb9bc; color: var(--cor-erro); }
.selo--cancelada { background: #eef0f3; border-color: #d5dae1; color: #4b535d; }
.selo--concluida { background: var(--cor-info-fundo); border-color: #bcd6ef; color: var(--cor-info); }
.selo--bloqueio { background: #efe7f7; border-color: #d9c9ea; color: #59308c; }
.selo--pago { background: #fff3d9; border-color: #f0dcae; color: #7a5300; }
.selo--gratuito { background: var(--cor-sucesso-fundo); border-color: #b9dfc8; color: var(--cor-sucesso); }
.selo--neutro { background: #eef0f3; border-color: #d5dae1; color: #4b535d; }

/* --------------------------------------------------------- Cartao espaco */
.espaco { display: flex; flex-direction: column; height: 100%; }
.espaco__foto {
  height: 132px;
  border-radius: var(--raio-pequeno);
  background: linear-gradient(135deg, var(--cor-tema) 0%, var(--cor-tema-escura) 100%);
  color: #fff;
  display: grid;
  place-items: center;
  font-size: 2.1rem;
  margin-bottom: 0.7rem;
  overflow: hidden;
}
.espaco__foto img { width: 100%; height: 100%; object-fit: cover; }
.espaco__nome { font-size: 1rem; font-weight: 600; margin-bottom: 0.2rem; }
.espaco__meta { font-size: 0.8rem; color: var(--cor-texto-suave); margin-bottom: 0.5rem; }
.espaco__rodape { margin-top: auto; padding-top: 0.7rem; }

/* ------------------------------------------------------------- Horarios */
.horarios { display: grid; grid-template-columns: repeat(auto-fill, minmax(104px, 1fr)); gap: 0.55rem; }

.horario {
  border: 1px solid var(--cor-borda);
  border-radius: var(--raio-pequeno);
  padding: 0.55rem 0.4rem;
  background: #fff;
  text-align: center;
  font-size: 0.9rem;
  cursor: pointer;
  min-height: 60px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  gap: 2px;
  font-family: inherit;
  color: inherit;
}

.horario:hover:not(:disabled) { border-color: var(--cor-tema); background: var(--cor-tema-clara); }
.horario[aria-pressed='true'] { border-color: var(--cor-tema); background: var(--cor-tema); color: #fff; }
.horario:disabled { background: #f1f3f5; color: #8b939d; cursor: not-allowed; text-decoration: line-through; }
.horario__nota { font-size: 0.66rem; font-weight: 600; text-decoration: none; display: block; }

/* --------------------------------------------------------------- Tabelas */
.tabela-rolagem { overflow-x: auto; -webkit-overflow-scrolling: touch; }

table.tabela {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.86rem;
  min-width: 560px;
}

table.tabela th, table.tabela td {
  text-align: left;
  padding: 0.5rem 0.6rem;
  border-bottom: 1px solid var(--cor-borda);
  vertical-align: top;
}

table.tabela th { background: #f7f9fb; font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.02em; color: var(--cor-texto-suave); }
table.tabela tr:last-child td { border-bottom: none; }

/* -------------------------------------------------------------- Numeros */
.indicadores { display: grid; grid-template-columns: repeat(2, 1fr); gap: 0.7rem; }
@media (min-width: 760px) { .indicadores { grid-template-columns: repeat(5, 1fr); } }

.indicador {
  background: var(--cor-superficie);
  border: 1px solid var(--cor-borda);
  border-radius: var(--raio);
  padding: 0.8rem;
  text-decoration: none;
  color: inherit;
  display: block;
}

.indicador__valor { font-size: 1.6rem; font-weight: 700; line-height: 1.1; }
.indicador__rotulo { font-size: 0.78rem; color: var(--cor-texto-suave); }

/* --------------------------------------------------------------- Agenda */
.agenda-dia { border: 1px solid var(--cor-borda); border-radius: var(--raio); background: #fff; margin-bottom: 0.7rem; overflow: hidden; }
.agenda-dia__cabecalho { padding: 0.5rem 0.75rem; background: #f7f9fb; font-size: 0.85rem; font-weight: 600; display: flex; justify-content: space-between; gap: 0.5rem; }
.agenda-dia__cabecalho--hoje { background: var(--cor-tema-clara); color: var(--cor-tema-escura); }
.agenda-item { display: flex; gap: 0.6rem; padding: 0.55rem 0.75rem; border-top: 1px solid var(--cor-borda); text-decoration: none; color: inherit; align-items: flex-start; }
.agenda-item:hover { background: #f7f9fb; }
.agenda-item__hora { font-variant-numeric: tabular-nums; font-weight: 600; font-size: 0.85rem; white-space: nowrap; }
.agenda-item__texto { min-width: 0; font-size: 0.85rem; }
.agenda-vazia { padding: 0.6rem 0.75rem; color: var(--cor-texto-suave); font-size: 0.82rem; }

/* --------------------------------------------------------------- Legenda */
.legenda { display: flex; flex-wrap: wrap; gap: 0.4rem; font-size: 0.75rem; }

/* --------------------------------------------------------------- Passos */
.passos { display: flex; gap: 0.4rem; margin-bottom: 1rem; flex-wrap: wrap; font-size: 0.78rem; }
.passo { padding: 0.25rem 0.6rem; border-radius: 999px; background: #eef0f3; color: var(--cor-texto-suave); }
.passo--atual { background: var(--cor-tema); color: #fff; font-weight: 600; }
.passo--feito { background: var(--cor-tema-clara); color: var(--cor-tema-escura); }

/* --------------------------------------------------------------- Detalhe */
.definicoes { display: grid; grid-template-columns: 1fr; gap: 0.5rem; margin: 0; }
@media (min-width: 620px) { .definicoes { grid-template-columns: repeat(2, 1fr); } }
.definicao { border-bottom: 1px dashed var(--cor-borda); padding-bottom: 0.4rem; }
.definicao__rotulo { font-size: 0.74rem; text-transform: uppercase; letter-spacing: 0.03em; color: var(--cor-texto-suave); }
.definicao__valor { font-size: 0.95rem; }

.linha-tempo { list-style: none; margin: 0; padding: 0; }
.linha-tempo li { border-left: 2px solid var(--cor-borda); padding: 0 0 0.9rem 0.85rem; position: relative; }
.linha-tempo li::before { content: ''; position: absolute; left: -6px; top: 4px; width: 10px; height: 10px; border-radius: 50%; background: var(--cor-tema); }
.linha-tempo li:last-child { padding-bottom: 0; }

/* ------------------------------------------------------------- Rodape */
.rodape { border-top: 1px solid var(--cor-borda); background: var(--cor-superficie); padding: 1.2rem 1rem 1.6rem; font-size: 0.82rem; color: var(--cor-texto-suave); }
.rodape__interno { max-width: var(--largura-max); margin: 0 auto; display: grid; gap: 0.5rem; }

/* ------------------------------------------------------------- Dialogo */
dialog {
  border: none;
  border-radius: var(--raio);
  padding: 0;
  width: min(560px, 92vw);
  max-height: 86vh;
  overflow: auto;
  box-shadow: 0 20px 40px rgba(16, 24, 40, 0.22);
}
dialog::backdrop { background: rgba(16, 24, 40, 0.5); }
.dialogo__corpo { padding: 1rem; }
.dialogo__titulo { font-size: 1.05rem; font-weight: 600; margin-bottom: 0.6rem; }

/* ------------------------------------------------------ Aviso de instalacao */
.aviso-instalacao {
  position: fixed;
  left: 0.75rem;
  right: 0.75rem;
  bottom: calc(var(--altura-nav) + env(safe-area-inset-bottom) + 0.6rem);
  background: var(--cor-superficie);
  border: 1px solid var(--cor-borda);
  border-radius: var(--raio);
  box-shadow: 0 10px 28px rgba(16, 24, 40, 0.18);
  padding: 0.85rem;
  z-index: 50;
  display: none;
}
.aviso-instalacao[data-visivel='true'] { display: block; }
@media (min-width: 860px) { .aviso-instalacao { left: auto; right: 1rem; bottom: 1rem; max-width: 360px; } }

/* ------------------------------------------------------------ Impressao */
@media print {
  .topo, .nav-inferior, .rodape, .botao, .sem-impressao, .aviso-instalacao { display: none !important; }
  body { background: #fff; padding: 0; }
  .cartao { box-shadow: none; border: 1px solid #ccc; page-break-inside: avoid; }
  table.tabela { min-width: 0; font-size: 0.75rem; }
  a { text-decoration: none; color: #000; }
}

/* -------------------------------------------------- Preferencias do usuario */
@media (prefers-reduced-motion: reduce) {
  * { animation: none !important; transition: none !important; }
}

.carregando { opacity: 0.55; pointer-events: none; }

.oculto { display: none !important; }

.pular-para-conteudo {
  position: absolute;
  left: -9999px;
  background: #fff;
  color: var(--cor-tema-escura);
  padding: 0.6rem 1rem;
  z-index: 60;
}
.pular-para-conteudo:focus { left: 0.5rem; top: 0.5rem; }
