/* Estilo do layout base (barra de cima, barra de baixo, faixas, medidas). Veio do <style> do templates/base.html:
   fora da página, o navegador guarda uma vez só. Carregado depois do meulucro.css, como o <style> de antes. */
/* ── Medidas do layout ──────────────────────────────────────────────────── */
:root {
  /* Altura da barra de navegação inferior (mobile) — único ponto de ajuste */
  --altura-bottom-nav: 56px;
  /* Espaço que a barra ocupa de fato: altura + área segura (barra de gestos).
     O faixas.js troca pela altura medida (fonte maior no celular aumenta a barra). */
  --espaco-bottom-nav: calc(var(--altura-bottom-nav) + env(safe-area-inset-bottom, 0px));
  /* Altura das faixas de aviso (topo: offline, nova versão; rodapé: instalar).
     Medidas por static/js/faixas.js — 0px quando não há faixa. */
  --faixa-topo: 0px;
  --faixa-rodape: 0px;
  --transicao-faixa: .2s ease;
}

/* ── Tipografia e tamanhos base ─────────────────────────────────────────── */
body { font-size: 1.1rem; background-color: #f8f9fa; }
body.sistema-bg { background: linear-gradient(135deg, #f0faf4 0%, #ffffff 60%, #f0faf4 100%); }
.btn { font-size: 1.05rem; padding: 0.6rem 1.2rem; }
.btn-lg { font-size: 1.2rem; padding: 0.8rem 1.5rem; }
.btn-sm { font-size: 0.95rem; padding: 0.4rem 0.85rem; }
.form-control, .form-select { font-size: 1.1rem; padding: 0.7rem 0.9rem; min-height: 3rem; }
label { font-weight: 600; margin-bottom: 0.35rem; }
.navbar-brand { font-size: 1.4rem; font-weight: 700; }
.min-width-0 { min-width: 0; }

/* ── Conteúdo principal ─────────────────────────────────────────────────── */
/* Espaçamento definido só aqui (sem a classe py-4 no main: o !important do
   Bootstrap anulava o espaço reservado para a barra inferior). */
main {
  padding-top: 1.5rem;
  padding-bottom: calc(1.5rem + var(--faixa-rodape));
}
/* Sem navbar superior (login, cadastro): não encostar na status bar */
body:not(.com-bottom-nav) main {
  padding-top: calc(1.5rem + env(safe-area-inset-top, 0px));
}
/* Com faixa no topo, é ela que ocupa a área da status bar */
html.com-faixa-topo body:not(.com-bottom-nav) main { padding-top: 1.5rem; }

/* ── Faixas de aviso ────────────────────────────────────────────────────── */
/* Mesmo padrão da barra inferior: a faixa é fixa, mas a altura dela vira
   espaço reservado (--faixa-topo / --faixa-rodape), então empurra a página
   e o menu em vez de ficar por cima. Várias faixas empilham. */
body { padding-top: var(--faixa-topo); transition: padding-top var(--transicao-faixa); }
.faixas {
  position: fixed; left: 0; right: 0; z-index: 1035;  /* acima dos menus, abaixo de modais/offcanvas */
  display: flex; flex-direction: column;
}
.faixas-topo { top: 0; }
/* No app instalado a status bar é translúcida: a faixa começa abaixo dela,
   e o fundo da 1ª faixa preenche essa área (cor aplicada pelo faixas.js) */
html.com-faixa-topo .faixas-topo { padding-top: env(safe-area-inset-top, 0px); }
.faixas-rodape {
  bottom: env(safe-area-inset-bottom, 0px);
  gap: .5rem; pointer-events: none;
}
html.com-faixa-rodape .faixas-rodape { padding: 0 .5rem .5rem; }
.faixas-rodape > * { pointer-events: auto; }
.faixas > * { animation: faixa-entra var(--transicao-faixa); }
.faixas-topo .faixa-offline { order: 1; }
.faixas-topo .faixa-atualizar { order: 2; }
.faixas-topo .faixa-email { order: 3; }
@keyframes faixa-entra { from { opacity: 0; } }
.faixa-offline {
  background: #c0392b; color: #fff; text-align: center;
  padding: .45rem 1rem; font-size: .88rem; font-weight: 600;
}
.faixa-email {
  background: #fff8e1; color: #5c4400; border-bottom: 1px solid #f0d58a;
  padding: .4rem 1rem; font-size: .88rem; text-align: center;
}
.faixa-atualizar {
  background: #e9f5ee; color: #14532d; border-bottom: 1px solid #b7dfc6;
  padding: .45rem 1rem; font-size: .95rem;
}
.faixa-atualizar .btn { padding: .3rem .8rem; }
.faixa-cartao {
  width: 100%; max-width: 560px; margin: 0 auto; background: #fff; color: #212529;
  border: 1px solid #d1e7dd; border-left: 5px solid #198754; border-radius: .6rem;
  box-shadow: 0 .5rem 1.5rem rgba(0,0,0,.15); padding: .75rem .9rem; font-size: .98rem;
}
@media (prefers-reduced-motion: reduce) {
  :root { --transicao-faixa: 0s; }
}

/* ── Navbar ─────────────────────────────────────────────────────────────── */
.navbar .nav-link {
  font-size: 1rem;
  padding: 0.5rem 0.75rem;
  border-radius: 0.375rem;
  transition: background-color 0.15s;
}
/* No app instalado, a navbar fixa no topo não fica sob a status bar.
   Com faixa no topo, gruda logo abaixo dela (e a faixa já cobre a status bar). */
.navbar.sticky-top {
  top: var(--faixa-topo);
  padding-top: calc(var(--bs-navbar-padding-y) + env(safe-area-inset-top, 0px));
  transition: top var(--transicao-faixa);
}
html.com-faixa-topo .navbar.sticky-top { padding-top: var(--bs-navbar-padding-y); }
.navbar .nav-link.active,
.navbar .nav-link:focus { background-color: rgba(255,255,255,0.18); }
.navbar .nav-link:hover  { background-color: rgba(255,255,255,0.12); }

/* ── Barra de navegação inferior (mobile) ───────────────────────────────── */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  z-index: 1030;
  background: #fff;
  border-top: 1px solid #dee2e6;
  display: flex;
  padding-bottom: env(safe-area-inset-bottom, 0);
  box-shadow: 0 -2px 8px rgba(0,0,0,0.08);
}
.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 0.45rem 0.25rem 0.35rem;
  text-decoration: none;
  color: #6c757d;
  font-size: 0.68rem;
  font-weight: 600;
  line-height: 1.2;
  min-height: var(--altura-bottom-nav);
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.bottom-nav a i { font-size: 1.55rem; margin-bottom: 2px; }
.bottom-nav a.active { color: #198754; }
.bottom-nav a:hover  { color: #198754; }

/* Início, Engorda e Cria | Guri em destaque no meio | Foto e Offline. Os dois lados têm a mesma largura: o Guri fica no centro
   mesmo sem a Cria ou o Offline no plano. */
.bottom-nav__lado { flex: 1 1 0; display: flex; min-width: 0; }
/* Três itens de cada lado em 360 px: sem folga lateral e letra um pouco menor para caber "Vistoria" e "Engorda" inteiros */
.bottom-nav__lado a { min-width: 44px; position: relative; padding-left: 0; padding-right: 0; font-size: 0.64rem; }
.bottom-nav .bottom-nav__guri, .bottom-nav__guri-vazio { flex: 0 0 68px; }
.bottom-nav .bottom-nav__guri { position: relative; justify-content: flex-end; padding-top: 0; color: #198754; }
.bottom-nav__guri-bolha {
  display: flex; align-items: center; justify-content: center;
  width: 56px; height: 56px; margin-top: -26px; margin-bottom: 1px;
  border-radius: 50%; background: #198754; color: #fff; border: 4px solid #fff;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.28);
}
.bottom-nav .bottom-nav__guri i { font-size: 1.6rem; margin: 0; }
.bottom-nav__guri-nome { font-size: 0.62rem; line-height: 1.05; text-align: center; white-space: nowrap; }
.bottom-nav .bottom-nav__guri.active .bottom-nav__guri-bolha { background: #157347; }
.bottom-nav .bottom-nav__guri.com-pendente .bottom-nav__guri-bolha::after {
  content: ''; position: absolute; top: -22px; right: 14px; width: 14px; height: 14px; border-radius: 50%;
  background: #ffc107; border: 2px solid #fff;
}
.bottom-nav .badge-offline-pendentes { position: absolute; top: 2px; right: 6px; font-size: 0.62rem; }
/* Guri e Foto precisam de internet: sem sinal bom saem da barra (conexao.js põe .sem-sinal no <html>) */
html.sem-sinal .bottom-nav [data-so-online] { display: none; }

/* Espaço para a bottom-nav não cobrir o fim do conteúdo no mobile — vale
   para todas as páginas com a barra (body.com-bottom-nav). Os toasts do
   rodapé também sobem para não ficar atrás dela. */
.toast-container.bottom-0 { bottom: var(--faixa-rodape) !important; }
@media (max-width: 991.98px) {
  body.com-bottom-nav main {
    padding-bottom: calc(var(--espaco-bottom-nav) + 1.5rem + var(--faixa-rodape));
  }
  body.com-bottom-nav .toast-container.bottom-0 {
    bottom: calc(var(--espaco-bottom-nav) + var(--faixa-rodape)) !important;
  }
  /* A faixa do rodapé (instalar) fica acima da barra inferior */
  body.com-bottom-nav .faixas-rodape { bottom: var(--espaco-bottom-nav); }
}

/* ── Cards ──────────────────────────────────────────────────────────────── */
.card { border-radius: 0.75rem; }
.list-group-item { font-size: 1rem; }
.alert { border-radius: 0.75rem; }

/* Modo começo (apps/fazenda/comeco.py): com sinal, sem o Menu e sem a barra de baixo. Sem sinal (html.sem-sinal) os dois voltam:
   a cópia guardada da página não prende a pessoa no cartão "Comece por aqui". */
html:not(.sem-sinal) body.modo-comeco .ml-botao-menu,
html:not(.sem-sinal) body.modo-comeco .bottom-nav { display: none !important; }
@media (max-width: 991.98px) {
  html:not(.sem-sinal) body.modo-comeco main { padding-bottom: calc(1.5rem + var(--faixa-rodape)); }
}

/* "+ Lançar" no meio da barra (v2.12.0): é um <button>, com a mesma cara do item do meio */
.bottom-nav button.bottom-nav__lancar {
  display: flex; flex-direction: column; align-items: center; background: none; border: 0; font-weight: 600;
  min-height: var(--altura-bottom-nav); padding-bottom: .35rem; -webkit-tap-highlight-color: transparent;
}
/* Guri com conversa sem enviar: o ponto amarelo fica no item do Menu (antes ficava na barra de baixo) */
.ml-menu__item[data-guri-nav].com-pendente::after { content: ''; display: inline-block; width: 10px; height: 10px; margin-left: .5rem; border-radius: 50%; background: #ffc107; }
