/* =====================================================================
   EMEC Design Tokens v2.0
   Paleta extraída da marca (grupo_emec_cor.png): verde #2A963E (mesmo tom
   já usado na geração do PDF) e cinza #58595B do wordmark "emec".
   ===================================================================== */
:root {
  /* Marca */
  --emec-green: #2a963e;
  --emec-green-hover: #227b33;
  --emec-green-active: #1d692b;
  --emec-green-tint: #eaf4ec;
  --emec-green-tint-strong: #d7ecda;

  --emec-gray: #58595b;
  --emec-gray-dark: #303132;

  /* Compatibilidade com nomes antigos usados nas páginas */
  --accent: var(--emec-green);
  --accent-hover: var(--emec-green-hover);
  --accent-2: var(--emec-gray);
  --accent-blue: var(--emec-gray);

  /* Neutros / texto */
  --ink: #1a1d1f;
  --muted: #6b7280;
  --muted-2: #9aa1a9;

  /* Superfícies */
  --bg-1: #f6f8f7;
  --bg-2: #eef1f0;
  --card: #ffffff;
  --border: #e4e8e6;
  --ring: rgba(20, 24, 22, 0.08);

  /* Estados */
  --warning: #b45309;
  --warning-tint: #fdf1e2;
  --danger: #c0392b;
  --danger-tint: #fdecea;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 16px;
  --radius-full: 9999px;

  --shadow-sm: 0 1px 2px rgba(16, 24, 20, 0.06);
  --shadow-md: 0 8px 24px rgba(16, 24, 20, 0.08);
  --shadow-lg: 0 20px 50px rgba(16, 24, 20, 0.12);

  --font-sans: "Inter", "Segoe UI", system-ui, -apple-system, sans-serif;
  /* Mantido por compatibilidade — não usar em telas novas. */
  --font-serif: "Inter", "Segoe UI", system-ui, sans-serif;
}

*:focus-visible {
  outline: 2px solid var(--emec-green);
  outline-offset: 2px;
  border-radius: 4px;
}

@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    animation-duration: 0.01ms !important;
    transition-duration: 0.01ms !important;
  }
}

/* ---------------------------------------------------------------------
   Fundo padrão das páginas — neutro, sem gradientes decorativos.
   --------------------------------------------------------------------- */
.emec-page-bg {
  background: var(--bg-1);
}

/* ---------------------------------------------------------------------
   Botões
   --------------------------------------------------------------------- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  border-radius: var(--radius-md);
  cursor: pointer;
  border: 1px solid transparent;
  font-weight: 600;
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.2;
  text-decoration: none;
  transition: background-color 0.15s, border-color 0.15s, opacity 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}
.btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.btn-primary {
  background: var(--emec-green);
  color: #fff;
  box-shadow: var(--shadow-sm);
}
.btn-primary:hover:not(:disabled) { background: var(--emec-green-hover); }
.btn-primary:active:not(:disabled) { background: var(--emec-green-active); }

.btn-secondary {
  background: #fff;
  color: var(--ink);
  border-color: var(--border);
}
.btn-secondary:hover:not(:disabled) { border-color: var(--emec-green); color: var(--emec-green); }

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border-color: transparent;
}
.btn-ghost:hover:not(:disabled) { background: var(--bg-2); color: var(--ink); }

.btn-danger {
  background: transparent;
  color: var(--danger);
  border-color: rgba(192, 57, 43, 0.25);
}
.btn-danger:hover:not(:disabled) { background: var(--danger-tint); }

/* ---------------------------------------------------------------------
   Cartões / superfícies
   --------------------------------------------------------------------- */
.card {
  background: var(--card);
  border-radius: var(--radius-lg);
  border: 1px solid var(--ring);
  box-shadow: var(--shadow-md);
}

/* ---------------------------------------------------------------------
   Campos de formulário
   --------------------------------------------------------------------- */
.field-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--ink);
}
.field-label.required::after {
  content: " *";
  color: var(--danger);
  font-weight: 700;
}

input, select, textarea {
  font-family: var(--font-sans);
}
input:not([type="checkbox"]):not([type="radio"]), select, textarea {
  padding: 10px 12px;
  border-radius: var(--radius-md);
  border: 1.5px solid var(--border);
  font-size: 14px;
  background: #fff;
  color: var(--ink);
  transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
  border-color: var(--emec-green);
  outline: none;
  box-shadow: 0 0 0 3px var(--emec-green-tint);
}
input:disabled, input[readonly] {
  background: var(--bg-2);
  color: var(--muted);
}

/* ---------------------------------------------------------------------
   Badges de status
   --------------------------------------------------------------------- */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: var(--radius-full);
  font-size: 11.5px;
  font-weight: 700;
  letter-spacing: 0.2px;
  white-space: nowrap;
}
.badge-green {
  background: var(--emec-green-tint);
  color: var(--emec-green-active);
}
.badge-amber {
  background: var(--warning-tint);
  color: var(--warning);
}
.badge-gray {
  background: var(--bg-2);
  color: var(--muted);
}
.badge-red {
  background: var(--danger-tint);
  color: var(--danger);
}

/* ---------------------------------------------------------------------
   Base de celular (v2.1, 2026-09)

   O app passou a ser usado no telefone e instalado como PWA. Estas regras
   valem para TODAS as telas; ajuste específico de layout continua na
   media query de cada página.
   --------------------------------------------------------------------- */
@media (max-width: 760px) {
  /* Alvo de toque mínimo recomendado (~44px). No desktop o botão continua
     compacto — aqui ele cresce só na altura, sem virar bloco. */
  .btn { min-height: 44px; padding: 11px 16px; }

  /* iOS dá zoom automático em campo com fonte menor que 16px assim que ele
     recebe foco, e a página nunca volta ao zoom original. */
  input:not([type="checkbox"]):not([type="radio"]), select, textarea {
    font-size: 16px;
  }

  /* Cabeçalho de página empilha em vez de espremer título e botão. */
  .page-topbar { gap: 12px; }
  .page-topbar .brand h1 { font-size: 18px; }
}

/* Instalado em tela cheia no celular: reserva a barra de gestos inferior,
   que fica por cima do conteúdo. Restrito a telas pequenas de propósito —
   aplicar em qualquer standalone zeraria o padding do app instalado no
   desktop, onde env() vale 0. */
@media (display-mode: standalone) and (max-width: 760px) {
  body { padding-bottom: calc(32px + env(safe-area-inset-bottom, 0px)); }
}

/* ---------------------------------------------------------------------
   Cabeçalho padrão de página interna (admin)
   --------------------------------------------------------------------- */
.page-topbar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  margin-bottom: 20px;
  flex-wrap: wrap;
}
.page-topbar .brand {
  display: flex;
  align-items: center;
  gap: 12px;
}
.page-topbar .brand img {
  height: 34px;
  width: auto;
  object-fit: contain;
}
.page-topbar .brand h1 {
  font-family: var(--font-sans);
  font-weight: 700;
  margin: 0;
  font-size: 20px;
  color: var(--ink);
}
.page-topbar .brand p {
  margin: 2px 0 0;
  font-size: 13px;
  color: var(--muted);
}
