/* =====================================================================
   CONTROLE DE VALIDADE — identidade visual

   Paleta:
   --brand-teal:   #0F6B5C  (cor principal — remete a "fresco/em dia")
   --brand-amber:  #F0A430  (destaque, ações secundárias)
   --brand-cream:  #FAF8F3  (fundo)
   --ink:          #1C2622  (texto principal)
   Status (seção 46 da especificação):
   --status-normal:  #2E9E6B (verde)
   --status-atencao: #E8B93B (amarelo)
   --status-breve:   #E8792E (laranja)
   --status-vencido: #D64545 (vermelho)
   ===================================================================== */

:root {
  --brand-teal: #0F6B5C;
  --brand-teal-dark: #0B4F44;
  --brand-amber: #F0A430;
  --brand-cream: #FAF8F3;
  --ink: #1C2622;
  --ink-muted: #667066;
  --border-soft: #E4E0D6;

  --status-normal: #2E9E6B;
  --status-atencao: #E8B93B;
  --status-breve: #E8792E;
  --status-vencido: #D64545;
  --status-neutro: #6B7A76;
}

* { box-sizing: border-box; }

html, body {
  height: 100%;
  background: var(--brand-cream);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  -webkit-tap-highlight-color: transparent;
}

body {
  padding-bottom: 76px; /* espaço para o menu inferior fixo */
}

/* ---------------------------------------------------------------- */
/* Topo */
/* ---------------------------------------------------------------- */
.app-header {
  background: var(--brand-teal);
  color: #fff;
  position: sticky;
  top: 0;
  z-index: 20;
  box-shadow: 0 2px 8px rgba(15, 107, 92, 0.25);
}
.app-header__inner {
  max-width: 560px;
  margin: 0 auto;
  padding: 14px 16px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.app-header__logo {
  font-size: 1.05rem;
  letter-spacing: 0.2px;
}
.app-header__logout {
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.85rem;
}

/* ---------------------------------------------------------------- */
/* Layout geral */
/* ---------------------------------------------------------------- */
.app-main {
  max-width: 560px;
  margin: 0 auto;
  padding: 16px;
  min-height: calc(100vh - 60px);
}

.tela-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
  gap: 8px;
}
.tela-header h2 {
  font-size: 1.3rem;
  font-weight: 700;
  margin: 0;
  color: var(--brand-teal-dark);
}
.btn-voltar {
  background: none;
  border: none;
  color: var(--brand-teal);
  font-weight: 600;
  padding: 4px 0;
}

.secao-titulo {
  font-size: 1rem;
  font-weight: 700;
  color: var(--brand-teal-dark);
  margin: 18px 0 10px;
}

/* ---------------------------------------------------------------- */
/* Login */
/* ---------------------------------------------------------------- */
.tela {
  animation: entrada 0.18s ease-out;
}
@keyframes entrada {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.login-card {
  max-width: 420px;
  margin: 8vh auto 0;
  padding: 8px;
  text-align: center;
}
.login-card__icone { font-size: 2.6rem; }
.login-card__titulo {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--brand-teal-dark);
  margin: 6px 0 2px;
}
.login-card__subtitulo {
  color: var(--ink-muted);
  font-size: 0.92rem;
}
.login-card form { text-align: left; }

.btn-brand {
  background: var(--brand-teal);
  border-color: var(--brand-teal);
  color: #fff;
  font-weight: 600;
}
.btn-brand:hover, .btn-brand:active, .btn-brand:focus {
  background: var(--brand-teal-dark);
  border-color: var(--brand-teal-dark);
  color: #fff;
}
.btn-outline-brand {
  border: 1.5px solid var(--brand-teal);
  color: var(--brand-teal);
  font-weight: 600;
  background: #fff;
}
.btn-outline-brand:hover { background: var(--brand-teal); color: #fff; }

.form-control:focus, .form-select:focus {
  border-color: var(--brand-teal);
  box-shadow: 0 0 0 0.2rem rgba(15, 107, 92, 0.15);
}

/* ---------------------------------------------------------------- */
/* Cards do dashboard */
/* ---------------------------------------------------------------- */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 10px;
}
.card-status {
  border-radius: 14px;
  padding: 14px;
  background: #fff;
  border: 1px solid var(--border-soft);
  display: flex;
  flex-direction: column;
  gap: 2px;
  border-left: 5px solid var(--status-neutro);
  cursor: pointer;
  transition: transform 0.12s ease;
}
.card-status:active { transform: scale(0.98); }
.card-status__valor { font-size: 1.7rem; font-weight: 800; color: var(--ink); }
.card-status__label { font-size: 0.8rem; color: var(--ink-muted); }

.card-status--neutro  { border-left-color: var(--status-neutro); }
.card-status--vencido { border-left-color: var(--status-vencido); }
.card-status--hoje    { border-left-color: var(--status-breve); }
.card-status--breve   { border-left-color: var(--status-atencao); }

/* ---------------------------------------------------------------- */
/* Listas (produtos, lotes) */
/* ---------------------------------------------------------------- */
.busca-wrap { margin-bottom: 12px; }

.lista-produtos, .lista-lotes {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.item-produto, .item-lote {
  background: #fff;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 12px 14px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.item-produto__info, .item-lote__info { min-width: 0; }
.item-produto__nome, .item-lote__nome {
  font-weight: 600;
  font-size: 0.95rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.item-produto__meta, .item-lote__meta {
  font-size: 0.78rem;
  color: var(--ink-muted);
}
.item-produto__preco {
  font-weight: 700;
  color: var(--brand-teal-dark);
  white-space: nowrap;
}

.badge-status {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
}
.badge-status--NORMAL       { background: var(--status-normal); }
.badge-status--VENCE_EM_BREVE { background: var(--status-atencao); color: #4a3a00; }
.badge-status--VENCE_HOJE   { background: var(--status-breve); }
.badge-status--VENCIDO      { background: var(--status-vencido); }
.badge-status--SEM_VALIDADE { background: var(--status-neutro); }

.estado-vazio {
  text-align: center;
  color: var(--ink-muted);
  padding: 40px 10px;
  font-size: 0.9rem;
}

/* ---------------------------------------------------------------- */
/* Filtros (chips) da tela de validade */
/* ---------------------------------------------------------------- */
.filtros-scroll {
  display: flex;
  gap: 8px;
  overflow-x: auto;
  padding-bottom: 10px;
  margin-bottom: 4px;
  -webkit-overflow-scrolling: touch;
}
.chip {
  flex: 0 0 auto;
  border: 1.5px solid var(--border-soft);
  background: #fff;
  color: var(--ink);
  border-radius: 20px;
  padding: 7px 16px;
  font-size: 0.85rem;
  font-weight: 600;
  white-space: nowrap;
}
.chip--ativo {
  background: var(--brand-teal);
  border-color: var(--brand-teal);
  color: #fff;
}

/* ---------------------------------------------------------------- */
/* Formulários */
/* ---------------------------------------------------------------- */
.form-produto .form-label { font-weight: 600; font-size: 0.88rem; }

/* ---------------------------------------------------------------- */
/* Scanner */
/* ---------------------------------------------------------------- */
.scanner-viewport {
  position: relative;
  background: #000;
  border-radius: 14px;
  overflow: hidden;
  aspect-ratio: 3/4;
}
#qr-reader { width: 100%; height: 100%; }
#qr-reader video { object-fit: cover; }
.scanner-mira {
  position: absolute;
  inset: 20% 12%;
  border: 3px solid rgba(240, 164, 48, 0.9);
  border-radius: 12px;
  pointer-events: none;
}
.scanner-resultado {
  margin-top: 14px;
  background: #fff;
  border: 1px solid var(--border-soft);
  border-radius: 12px;
  padding: 14px;
}

/* ---------------------------------------------------------------- */
/* Menu inferior */
/* ---------------------------------------------------------------- */
.app-bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: #fff;
  border-top: 1px solid var(--border-soft);
  display: flex;
  justify-content: space-around;
  align-items: center;
  padding: 8px 6px calc(8px + env(safe-area-inset-bottom));
  z-index: 30;
}
.nav-item {
  background: none;
  border: none;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 2px;
  color: var(--ink-muted);
  font-size: 0.7rem;
  padding: 4px 10px;
}
.nav-item.ativo { color: var(--brand-teal); font-weight: 700; }
.nav-item__icone { font-size: 1.3rem; line-height: 1; }
.nav-item--central .nav-item__icone {
  background: var(--brand-amber);
  color: #fff;
  width: 52px; height: 52px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 1.5rem;
  margin-top: -26px;
  box-shadow: 0 4px 10px rgba(240, 164, 48, 0.4);
}

/* ---------------------------------------------------------------- */
/* Toasts */
/* ---------------------------------------------------------------- */
.toast-container {
  position: fixed;
  top: 70px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 50;
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: calc(100% - 32px);
  max-width: 500px;
  pointer-events: none;
}
.toast-msg {
  background: var(--ink);
  color: #fff;
  padding: 10px 16px;
  border-radius: 10px;
  font-size: 0.85rem;
  text-align: center;
  box-shadow: 0 4px 14px rgba(0,0,0,0.2);
  animation: toast-in 0.2s ease-out;
}
.toast-msg--erro { background: var(--status-vencido); }
.toast-msg--sucesso { background: var(--status-normal); }
@keyframes toast-in {
  from { opacity: 0; transform: translateY(-8px); }
  to { opacity: 1; transform: translateY(0); }
}

/* ---------------------------------------------------------------- */
/* Notificações */
/* ---------------------------------------------------------------- */
.app-header__acoes { display: flex; align-items: center; gap: 8px; }
.badge-offline {
  background: rgba(255,255,255,0.15);
  color: #fff;
  font-size: 0.7rem;
  font-weight: 700;
  padding: 4px 8px;
  border-radius: 12px;
}
.app-header__sino {
  position: relative;
  background: rgba(255,255,255,0.15);
  border: none;
  color: #fff;
  width: 34px; height: 34px;
  border-radius: 50%;
  font-size: 1.05rem;
}
.badge-notif {
  position: absolute;
  top: -4px; right: -4px;
  background: var(--status-vencido);
  color: #fff;
  font-size: 0.62rem;
  font-weight: 800;
  min-width: 16px;
  height: 16px;
  border-radius: 8px;
  display: flex; align-items: center; justify-content: center;
  padding: 0 3px;
}

.painel-overlay {
  position: fixed;
  inset: 0;
  background: rgba(28, 38, 34, 0.4);
  z-index: 40;
  display: flex;
  justify-content: flex-end;
}
.painel-notificacoes {
  background: #fff;
  width: min(360px, 88vw);
  height: 100%;
  padding: 16px;
  overflow-y: auto;
  animation: painel-in 0.18s ease-out;
}
@keyframes painel-in {
  from { transform: translateX(24px); opacity: 0; }
  to { transform: translateX(0); opacity: 1; }
}
.painel-notificacoes__header {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
}
.painel-notificacoes__header h3 {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--brand-teal-dark);
  margin: 0;
  flex: 1;
}
.btn-fechar {
  background: none;
  border: none;
  font-size: 1rem;
  color: var(--ink-muted);
}
.lista-notificacoes { display: flex; flex-direction: column; gap: 8px; }
.item-notificacao {
  border: 1px solid var(--border-soft);
  border-radius: 10px;
  padding: 10px 12px;
  background: var(--brand-cream);
}
.item-notificacao--lida { background: #fff; opacity: 0.75; }
.item-notificacao__titulo { font-weight: 700; font-size: 0.88rem; }
.item-notificacao__mensagem { font-size: 0.82rem; color: var(--ink-muted); margin-top: 2px; }
.item-notificacao__data { font-size: 0.7rem; color: var(--ink-muted); margin-top: 4px; }

/* Utilitário */
.d-none { display: none !important; }
