/* ====================================
   EcoPonto Digital — Stylesheet
   HTML + CSS + JavaScript puro
   Projeto Integrador II — UNIVESP 2026
   Contrastes calculados para WCAG 2.1 AA (texto ≥ 4,5:1; componentes ≥ 3:1)
==================================== */

:root {
  --bg:            #0f0f10;
  --surface:       #1a1a1e;
  --surface2:      #232328;
  --border:        #3a3a44;   /* bordas decorativas */
  --borda-campo:   #74747f;   /* bordas de campos e botões (≥ 3:1) */
  --accent:        #52b788;
  --accent-hover:  #6cc79b;
  --on-accent:     #0b1a12;
  --text:          #f0efe8;
  --text-muted:    #a3a3ae;
  --danger:        #f07070;
  --warn:          #f5c842;
  --radius:        10px;
  font-size: 16px;
}

*, *::before, *::after { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; }
body {
  margin: 0;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  font-family: 'DM Sans', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
  line-height: 1.55;
  background: var(--bg);
  color: var(--text);
}
@media (prefers-reduced-motion: reduce) {
  html { scroll-behavior: auto; }
  * { transition: none !important; animation: none !important; }
}

h1, h2, h3 { font-family: 'Syne', system-ui, sans-serif; line-height: 1.2; margin: 0 0 .75rem; }
h1 { font-size: clamp(1.6rem, 4vw, 2.2rem); }
h2 { font-size: 1.3rem; margin-top: 2rem; }
h1:focus { outline: none; }
p { margin: 0 0 1rem; }
a { color: var(--accent); text-underline-offset: 3px; }
a:hover { color: var(--accent-hover); }
small { color: var(--text-muted); }

/* Foco visível em todos os controles (WCAG 2.4.7) */
:focus-visible { outline: 3px solid var(--warn); outline-offset: 2px; }

.sr-only {
  position: absolute; width: 1px; height: 1px; margin: -1px; padding: 0;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}
.skip-link {
  position: absolute; left: .5rem; top: -4rem; z-index: 300;
  background: var(--warn); color: #000; padding: .6rem 1rem; border-radius: var(--radius);
  font-weight: 700; text-decoration: none;
}
.skip-link:focus { top: .5rem; }

/* ===== CABEÇALHO ===== */
.topo { background: var(--surface); border-bottom: 1px solid var(--border); position: sticky; top: 0; z-index: 100; }
.topo-in { max-width: 1100px; margin: 0 auto; padding: .6rem 1rem; display: flex; align-items: center; gap: 1rem; flex-wrap: wrap; }
.marca { font-family: 'Syne', sans-serif; font-weight: 800; font-size: 1.2rem; color: var(--text); text-decoration: none; display: inline-flex; gap: .5rem; align-items: center; min-height: 44px; }
.marca span { color: var(--accent); }
.menus { display: flex; gap: 1.5rem; flex-wrap: wrap; align-items: center; margin-left: auto; }
.menus nav { display: flex; gap: .25rem; flex-wrap: wrap; align-items: center; }
.menus nav[hidden] { display: none; }
#nav-operador { padding-left: 1rem; border-left: 1px solid var(--border); }
.menus a, .link-btn {
  color: var(--text); text-decoration: none; padding: .6rem .8rem; border-radius: var(--radius);
  min-height: 44px; display: inline-flex; align-items: center; background: none; border: 0; cursor: pointer; font: inherit;
}
.menus a:hover, .link-btn:hover { background: var(--surface2); }
.menus a[aria-current="page"] { color: var(--accent); box-shadow: inset 0 -3px 0 var(--accent); border-radius: 0; }
.btn-menu { display: none; }

@media (max-width: 760px) {
  .btn-menu { display: inline-flex; margin-left: auto; }
  .menus { display: none; width: 100%; flex-direction: column; align-items: stretch; gap: .5rem; margin-left: 0; }
  .menus.aberto { display: flex; }
  .menus nav { flex-direction: column; align-items: stretch; }
  #nav-operador { padding-left: 0; border-left: 0; border-top: 1px solid var(--border); padding-top: .5rem; }
}

/* ===== LAYOUT ===== */
main { flex: 1; width: 100%; max-width: 1100px; margin: 0 auto; padding: 1.5rem 1rem 3rem; }
main:focus { outline: none; }
.view[hidden] { display: none; }
.rodape { text-align: center; color: var(--text-muted); font-size: .85rem; padding: 1.5rem 1rem; border-top: 1px solid var(--border); }
.rodape p { margin: 0; }

.hero { padding: 1.5rem 0 .5rem; max-width: 720px; }
.lead { font-size: 1.1rem; color: var(--text-muted); }
.acoes { display: flex; gap: .75rem; flex-wrap: wrap; margin: 1rem 0; }

.cartao { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1.25rem; margin-bottom: 1.25rem; }
.form-estreito { max-width: 460px; }
.passos { padding-left: 1.25rem; margin: 0; display: grid; gap: .6rem; max-width: 720px; }
.grade-residuos { list-style: none; padding: 0; margin: 0; display: grid; grid-template-columns: repeat(auto-fill, minmax(230px, 1fr)); gap: .75rem; }
.grade-residuos li { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; }
.grade-residuos .icone { font-size: 1.6rem; display: block; }
.grade-residuos strong { display: block; }
.nota { color: var(--text-muted); font-size: .9rem; }

/* ===== BOTÕES ===== */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: .4rem;
  min-height: 44px; padding: .6rem 1.2rem; border-radius: var(--radius);
  font: inherit; font-weight: 600; text-decoration: none; cursor: pointer;
  border: 2px solid var(--borda-campo); background: transparent; color: var(--text);
  transition: background 150ms ease;
}
.btn:hover { background: var(--surface2); color: var(--text); }
.btn-primario { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.btn-primario:hover { background: var(--accent-hover); border-color: var(--accent-hover); color: var(--on-accent); }
.btn-perigo { border-color: var(--danger); color: var(--danger); }
.btn-sm { min-height: 44px; padding: .4rem .8rem; font-size: .9rem; }
.btn[disabled], .btn[aria-disabled="true"] { opacity: .6; cursor: not-allowed; }
.modo { display: flex; gap: .5rem; flex-wrap: wrap; margin-bottom: 1rem; }
.modo .btn[aria-pressed="true"] { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }

/* ===== FORMULÁRIOS ===== */
.campo { margin-bottom: 1.1rem; border: 0; padding: 0; min-width: 0; }
label, legend { display: block; font-weight: 600; margin-bottom: .35rem; padding: 0; }
.campo-radio { display: flex; align-items: center; gap: .6rem; min-height: 44px; font-weight: 400; margin: 0; }
input[type="text"], input[type="tel"], input[type="email"], input[type="password"],
input[type="date"], input[type="time"], input[type="number"], select, textarea {
  width: 100%; min-height: 44px; padding: .6rem .8rem; font: inherit;
  color: var(--text); background: var(--bg);
  border: 2px solid var(--borda-campo); border-radius: var(--radius);
}
input::placeholder, textarea::placeholder { color: var(--text-muted); opacity: 1; }
input[type="checkbox"], input[type="radio"] { width: 1.3rem; height: 1.3rem; accent-color: var(--accent); flex: none; }
select:disabled, input:disabled { opacity: .6; cursor: not-allowed; }
.dica { color: var(--text-muted); font-size: .92rem; margin: .4rem 0 0; }
.form-erro {
  color: var(--danger); background: var(--surface2); border: 2px solid var(--danger);
  border-radius: var(--radius); padding: .7rem 1rem; margin: 0 0 1rem; font-weight: 500;
}
.form-erro[hidden] { display: none; }
.linha-campos { display: grid; grid-template-columns: repeat(auto-fit, minmax(190px, 1fr)); gap: 0 1rem; }
.grupo-checks { display: grid; grid-template-columns: repeat(auto-fill, minmax(170px, 1fr)); gap: .1rem 1rem; }
.linha-cep { display: flex; gap: .5rem; align-items: stretch; }
.linha-cep input { flex: 1; }

/* Horários (radio estilizado, navegável por teclado) */
.slots { display: grid; grid-template-columns: repeat(auto-fill, minmax(112px, 1fr)); gap: .5rem; }
.slot { position: relative; margin: 0; font-weight: 400; }
.slot input { position: absolute; opacity: 0; inset: 0; width: 100%; height: 100%; margin: 0; cursor: pointer; }
.slot-box {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  min-height: 56px; padding: .4rem; border: 2px solid var(--borda-campo); border-radius: var(--radius);
  background: var(--bg);
}
.slot-box small { color: var(--text-muted); }
.slot input:checked + .slot-box { background: var(--accent); border-color: var(--accent); color: var(--on-accent); }
.slot input:checked + .slot-box small { color: var(--on-accent); }
.slot input:focus-visible + .slot-box { outline: 3px solid var(--warn); outline-offset: 2px; }
.slot input:disabled { cursor: not-allowed; }
.slot input:disabled + .slot-box { opacity: .55; }

/* ===== TABELAS ===== */
.tabela-wrap { overflow-x: auto; }
.tabela { width: 100%; border-collapse: collapse; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); }
.tabela th, .tabela td { padding: .75rem .9rem; text-align: left; vertical-align: top; border-bottom: 1px solid var(--border); }
.tabela th { background: var(--surface2); font-family: 'Syne', sans-serif; font-size: .9rem; }
.tabela tr:last-child td { border-bottom: 0; }
.acoes-linha { display: flex; gap: .4rem; flex-wrap: wrap; }
.vazio { color: var(--text-muted); padding: 1rem 0; }

@media (max-width: 760px) {
  .tabela thead { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); }
  .tabela, .tabela tbody { display: block; background: none; border: 0; }
  .tabela tr { display: block; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); margin-bottom: .75rem; padding: .4rem 0; }
  .tabela td { display: flex; justify-content: space-between; gap: 1rem; border-bottom: 0; padding: .45rem .9rem; text-align: right; }
  .tabela td::before { content: attr(data-label); font-weight: 600; color: var(--text-muted); text-align: left; flex: none; }
  .tabela td.celula-acoes { justify-content: flex-end; }
  .tabela td.celula-acoes::before { content: none; }
}

/* ===== BADGES, CARDS DE RESUMO ===== */
.badge { display: inline-block; padding: .15rem .6rem; border-radius: 99px; font-size: .85rem; font-weight: 600; border: 1px solid currentColor; background: var(--surface2); }
.badge-confirmado { color: var(--warn); }
.badge-concluido  { color: var(--accent); }
.badge-cancelado  { color: var(--danger); }
.badge-inativo    { color: var(--text-muted); }
.resumo { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: .75rem; margin: 1rem 0; }
.resumo div { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: .9rem 1rem; }
.resumo dt { color: var(--text-muted); font-size: .9rem; }
.resumo dd { margin: 0; font-family: 'Syne', sans-serif; font-size: 1.8rem; font-weight: 800; color: var(--accent); }
.filtros { display: grid; grid-template-columns: repeat(auto-fit, minmax(170px, 1fr)); gap: .75rem 1rem; align-items: end; }
.filtros .campo { margin: 0; }
.cabecalho-pagina { display: flex; justify-content: space-between; align-items: flex-start; gap: 1rem; flex-wrap: wrap; }

/* Dados (dl) */
.dados { display: grid; grid-template-columns: max-content 1fr; gap: .5rem 1.25rem; margin: 1rem 0; }
.dados dt { color: var(--text-muted); }
.dados dd { margin: 0; font-weight: 500; }
@media (max-width: 520px) { .dados { grid-template-columns: 1fr; gap: 0; } .dados dd { margin-bottom: .6rem; } }

/* ===== GRÁFICOS (barras em HTML: texto legível por leitores de tela) ===== */
.graficos { display: grid; grid-template-columns: repeat(auto-fit, minmax(340px, 1fr)); gap: 1rem; }
.graficos figure { margin: 0; background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 1rem; }
.graficos figcaption { font-family: 'Syne', sans-serif; font-weight: 700; margin-bottom: .8rem; }
.barras { list-style: none; margin: 0; padding: 0; display: grid; gap: .6rem; }
.barras li { display: grid; grid-template-columns: minmax(90px, 30%) 1fr 2.6rem; gap: .75rem; align-items: center; }
.barra-rotulo { overflow-wrap: anywhere; }
.barra-trilho { height: 14px; background: var(--surface2); border-radius: 99px; overflow: hidden; }
.barra-preenchida { display: block; height: 100%; background: var(--accent); }
.barra-valor { text-align: right; font-weight: 700; }
@media (max-width: 420px) { .graficos { grid-template-columns: 1fr; } }

/* ===== DIÁLOGOS (elemento <dialog> nativo) ===== */
dialog { padding: 0; border: 1px solid var(--borda-campo); border-radius: var(--radius); background: var(--surface); color: var(--text); width: min(680px, calc(100vw - 1.5rem)); max-height: 92vh; }
dialog::backdrop { background: rgba(0, 0, 0, .75); }
.dialogo-topo { display: flex; justify-content: space-between; align-items: center; padding: 1rem 1.25rem; border-bottom: 1px solid var(--border); }
.dialogo-topo h2 { margin: 0; font-size: 1.2rem; }
.dialogo-corpo { padding: 1.25rem; overflow-y: auto; max-height: 68vh; }
.dialogo-rodape { display: flex; justify-content: flex-end; gap: .6rem; padding: 1rem 1.25rem; border-top: 1px solid var(--border); flex-wrap: wrap; }

/* ===== AVISO (região ao vivo) ===== */
.aviso {
  position: fixed; left: 50%; bottom: 1.2rem; transform: translateX(-50%); z-index: 400;
  max-width: min(560px, calc(100vw - 2rem)); padding: .8rem 1.2rem; border-radius: var(--radius);
  background: var(--surface2); border: 2px solid var(--accent); color: var(--text); font-weight: 500;
  box-shadow: 0 8px 28px rgba(0,0,0,.5);
}
.aviso:empty { display: none; }
.aviso.erro { border-color: var(--danger); }

.print-only { display: none; }

/* ===== IMPRESSÃO (comprovante do histórico PJ / confirmação) ===== */
@media print {
  body { background: #fff; color: #000; display: block; }
  body * { visibility: hidden; }
  .imprimir, .imprimir * { visibility: visible; }
  .imprimir { position: absolute; left: 0; top: 0; width: 100%; }
  .imprimir .cartao, .imprimir .tabela, .imprimir .tabela th, .imprimir .tabela td { background: #fff !important; color: #000 !important; border-color: #888 !important; }
  .imprimir .badge { color: #000 !important; background: #fff !important; border-color: #000 !important; }
  .imprimir .resumo dd, .imprimir a { color: #000 !important; }
  .imprimir small, .imprimir .dados dt, .imprimir .nota { color: #333 !important; }
  .print-only { display: block !important; }
  .no-print { display: none !important; }
}
