/* ====== BASE GERAL ====== */

* {
  box-sizing: border-box;
}

html,
body {
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  background: #f3f3f3;
  color: #222;
}

/* BODY — deve ser simples, sem flex para não empurrar cards */
body {
  margin: 0;
  padding: 0;
  background: #f3f3f3;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  color: #222;
  min-height: 100vh;
}

/* CORREÇÃO DEFINITIVA DO CONTAINER PRINCIPAL */
.app {
  width: 100%;
  max-width: 430px;
  margin: 0 auto;
  display: flex;
  flex-direction: column;
  min-height: 100vh; /* deixa o app ocupar a tela toda */
  padding-bottom: 60px; /* reserva espaço para o footer injetado */
}

@media (min-width: 900px) {
  .app {
    justify-content: flex-start; /* não centralizar verticalmente */
  }
}

@media (min-width: 900px) {
  .app {
    justify-content: center; /* centraliza o card na vertical apenas em telas grandes */
  }
}

/* ====== HEADER ====== */

.app-header-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 16px 0 16px;
}

.app-header-main {
  display: flex;
  align-items: center;
  gap: 12px;
}

.app-header-bar-logo img {
  height: 40px;
  width: auto;
}

.app-header-bar-title {
  font-size: 16px;
  font-weight: 600;
}

.app-header-bar-subtitle {
  font-size: 11px;
  color: #666;
}

.app-header-user {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #444;
}

.user-label {
  font-weight: 600;
}

.logout-link {
  border: none;
  background: none;
  color: #ff3b30;
  font-size: 12px;
  cursor: pointer;
  text-decoration: underline;
  padding: 0;
}

/* Header específico do login (logo central) */
.app-header {
  padding: 24px 16px 0 16px;
  text-align: center;
}

.app-header-logo img {
  max-width: 160px;
  height: auto;
}

/* ====== CARD PRINCIPAL ====== */

.card {
  background: #ffffff;
  border-radius: 24px;
  margin: 16px 16px 24px 16px;
  padding: 24px 20px 28px 20px;
  box-shadow: 0 8px 18px rgba(0, 0, 0, 0.08);
}

.card-title {
  text-align: center;
  font-size: 18px;
  font-weight: 700;
}

/* Títulos internos de seção */
.section-title {
  font-size: 15px;
  font-weight: 600;
  margin: 16px 16px 4px 16px;
}

/* ====== FORMULÁRIOS ====== */

.form-group {
  margin-top: 12px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
}

.input,
.select {
  width: 100%;
  border-radius: 999px;
  border: none;
  background: #f5f5f5;
  padding: 10px 16px;
  font-size: 14px;
  outline: none;
}

.input:focus,
.select:focus {
  outline: 2px solid #00a6ff33;
}

/* Para o período */
.period-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* ====== BOTÕES ====== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 18px;
  border-radius: 999px;
  border: none;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
}

.btn-block {
  width: 100%;
}

.btn-primary {
  background: #0bb336;
  color: #ffffff;
}
.btn-primary:hover {
  filter: brightness(0.95);
}

.btn-danger {
  background: #ff3b30;
  color: #fff;
}
.btn-danger:hover {
  filter: brightness(0.95);
}

.btn-secondary {
  background: #e0e0e0;
  color: #333;
}

/* Botão VOLTAR */
.btn-back {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 18px;
  border-radius: 999px;
  border: none;
  background: #808a86;
  color: #ffffff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  margin-bottom: 12px;
}
.btn-back:hover {
  background: #6f7975;
}

/* Margens utilitárias */
.mt-8 { margin-top: 8px; }
.mt-16 { margin-top: 16px; }
.mt-24 { margin-top: 24px; }

/* Link inferior */
.link {
  margin-top: 8px;
  text-align: center;
  font-size: 11px;
}
.link a {
  color: #007aff;
  text-decoration: none;
}

/* Erros */
.error-message {
  color: #ff3b30;
  font-size: 12px;
  margin-top: 8px;
  text-align: center;
}

/* FOOTER GLOBAL — sempre fixado ao final do fluxo */
.app-footer {
  width: 100%;
  max-width: 430px;
  margin: 20px auto 0 auto;
  padding: 6px 16px 12px 16px;
  font-size: 10px;
  color: #777;
  display: flex;
  justify-content: space-between;
}

/* ====== MENU DA TELA INICIAL ====== */

.menu-grid {
  margin-top: 24px;
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 16px;
  justify-items: center;
}

/* Em telas pequenas, reduzir para 2 colunas */
@media (max-width: 420px) {
  .menu-grid {
    grid-template-columns: repeat(2, minmax(0, 1fr));
  }
}

.menu-item {
  width: 100%;
  max-width: 110px;
  height: 120px;
  background: #ffffff;
  border-radius: 18px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: #333333;
  font-size: 13px;
  text-align: center;
  padding: 8px;
  transition: transform .15s ease, box-shadow .15s ease;
}

.menu-item:hover {
  background: #f6f6f6;
  transform: translateY(-2px);
}

.menu-icon {
  width: 38px;
  height: 38px;
  margin-bottom: 6px;
  object-fit: contain;
}

/* ====== RELATÓRIOS ====== */

.report-card {
  margin-top: 12px;
  padding: 14px 12px;
  border-radius: 16px;
  background: #fafafa;
  box-shadow: 0 3px 8px rgba(0,0,0,0.05);
  font-size: 13px;
}

.report-row {
  font-size: 13px;
  margin-top: 4px;
}

.tag {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
}

.tag-success {
  background: #c7f8d7;
  color: #167b31;
}

.tag-danger {
  background: #ffd6d2;
  color: #b51b16;
  cursor: pointer;
}

/* ====== LISTA DE ITENS DA EXPOSIÇÃO ====== */

.lista-itens-exposicao {
  margin-top: 6px;
}

.item-exposicao {
  padding: 8px 10px;
  border-radius: 12px;
  background: #ffffff;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
  margin-top: 6px;
}

.info-text {
  font-size: 13px;
  text-align: center;
  margin-top: 4px;
}

.login-highlight {
  font-size: 18px;
  font-weight: 700;
  text-align: center;
  margin-top: 6px;
}

/* ====== RESPONSIVIDADE GERAL ====== */

@media (max-width: 480px) {
  .app {
    max-width: 100%;
  }

  .card {
    margin: 12px 8px 20px 8px;
    padding: 20px 16px;
    border-radius: 20px;
  }
}

/* ====== ITENS — CARDS ====== */

.item-card {
  background: #f5f5f5;
  border: 1px solid #dcdcdc;
  border-radius: 14px;
  padding: 16px;
  margin-top: 16px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.03);
}

.item-card-title {
  font-size: 14px;
  font-weight: 700;
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

/* Botão limpar (🧹) dentro do título do card */
.btn-clean {
  border: none;
  background: #e0e0e0;
  color: #333;
  border-radius: 999px;
  padding: 4px 10px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}
.btn-clean:hover {
  background: #d0d0d0;
}

/* Linha com 2 colunas */
.card-row-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
}

/* Preços (cores de borda antigas, se usar) */
.preco-normal {
  border-left: 4px solid #6d6d6d;
}

.preco-promocao {
  border-left: 4px solid #ff9800;
}

.preco-especial {
  border-left: 4px solid #c7a200;
}

/* Botão redondo + */
.btn-add-round {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #444;
  color: #fff;
  border: none;
  font-size: 20px;
  font-weight: bold;
  cursor: pointer;
}
.btn-add-round:hover {
  filter: brightness(1.1);
}

/* Botão remover (card) */
.btn-remove-round {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: #ff3b30;
  color: #fff;
  border: none;
  font-size: 18px;
  cursor: pointer;
}
.btn-remove-round:hover {
  filter: brightness(1.1);
}

/* Linha dos botões */
.item-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 14px;
}

/* ====== CAIXAS DE PREÇO (NOVO LAYOUT, SE FOR USAR DEPOIS) ====== */

.card-row-3-preco {
  display: grid;
  grid-template-columns: 1fr 1fr 1fr;
  gap: 10px;
  margin-top: 10px;
}

.preco-box {
  padding: 10px;
  border-radius: 12px;
  box-shadow: 0 3px 8px rgba(0,0,0,0.10);
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.preco-box label {
  font-size: 12px;
  font-weight: 600;
  margin-bottom: 4px;
  color: #333;
}

.preco-input {
  width: 100%;
  padding: 8px 12px;
  border: none;
  border-radius: 8px;
  background: rgba(255,255,255,0.6);
  font-size: 14px;
  outline: none;
}

/* Fundo CINZA */
.preco-normal {
  background: #e8e8e8;
}

/* Fundo LARANJA */
.preco-promocao {
  background: #ff9800;
}
.preco-promocao label {
  color: #fff;
}

/* Fundo AMARELO */
.preco-especial {
  background: #f7c800;
}

/* ====== BOTÕES DE ADICIONAR E REMOVER ITENS ====== */

.btn-add {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #444;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  margin-top: 12px;
}

.btn-remove {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #ff3b30;
  color: white;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  margin-top: 12px;
  margin-left: auto;
}

/* ====== AUTOCOMPLETE / LOADING (ITENS) ====== */

.loading-mini {
  text-align: left;
  font-size: 11px;
  color: #777;
  margin-top: 4px;
  display: none;
}

.autocomplete-box {
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 4px 10px rgba(0,0,0,0.10);
  position: absolute;
  width: 100%;
  z-index: 20;
  max-height: 240px;
  overflow-y: auto;
  display: none;
}

.autocomplete-item {
  padding: 10px 12px;
  font-size: 13px;
  border-bottom: 1px solid #eee;
  cursor: pointer;
}
.autocomplete-item:hover {
  background: #f5f5f5;
}

/* ====== INPUT + ÍCONE (📷 no EAN) ====== */

.input-with-icon {
  position: relative;
  display: flex;
  align-items: center;
}

.input-with-icon .input {
  padding-right: 44px; /* espaço para o botão de câmera */
}

.input-icon-btn {
  position: absolute;
  right: 6px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: none;
  background: #ffffff;
  box-shadow: 0 2px 6px rgba(0,0,0,0.12);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  cursor: pointer;
}
.input-icon-btn:hover {
  filter: brightness(0.97);
}

/* ====== SCANNER FULL SCREEN ====== */

#scanner-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.70);
  display: none;            /* será ativado via JS */
  align-items: center;
  justify-content: center;
  z-index: 9999;
}

.scanner-panel {
  background: #ffffff;
  border-radius: 22px;
  width: 100%;
  max-width: 420px;
  margin: 0 12px;
  padding: 16px 16px 14px 16px;
  box-shadow: 0 10px 26px rgba(0,0,0,0.4);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.scanner-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.scanner-title {
  font-size: 16px;
  font-weight: 700;
}

.scanner-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 6px;
}

.scanner-hint {
  font-size: 11px;
  color: #555;
  text-align: center;
  margin-top: 4px;
}

/* Botões ícone do scanner (fechar / trocar câmera) */
.btn-icon {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  border: none;
  background: #f0f0f0;
  box-shadow: 0 2px 6px rgba(0,0,0,0.20);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  cursor: pointer;
}
.btn-icon:hover {
  filter: brightness(0.95);
}

/* Janela de visualização da câmera */
#scanner-viewfinder {
  width: 100%;
  border-radius: 16px;
  background: #000;
  overflow: hidden;
  position: relative;
}

/* Vídeo da câmera */
#scanner-video {
  width: 100%;
  height: auto;
  display: block;
}

/* Moldura central (guiar código) */
#scanner-viewfinder::after {
  content: "";
  position: absolute;
  inset: 15%;
  border: 2px solid rgba(255,255,255,0.8);
  border-radius: 14px;
  box-shadow: 0 0 0 9999px rgba(0,0,0,0.25);
  pointer-events: none;
}

/* ====== DETALHES DO PONTO (ADMIN) — /pages/ponto/detalhes-ponto.html ====== */

.ponto-header {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}

.ponto-codigo {
  font-size: 18px;
  font-weight: 700;
  color: #1a237e;
}

.ponto-meta {
  font-size: 13px;
  color: #555;
}

.card-subtitle {
  font-size: 13px;
  font-weight: 600;
  color: #555;
  margin-bottom: 6px;
}

/* Linha com info + botão definir atual */
.ponto-actions-row {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

@media (min-width: 420px) {
  .ponto-actions-row {
    flex-direction: row;
    justify-content: space-between;
    align-items: center;
  }
}

/* Select de exposição + botão */
.expo-select-row {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 8px;
  margin-top: 8px;
}

.expo-select-row .select {
  border-radius: 999px;
}

/* Lista de exposições do ponto */
.expo-admin-list {
  margin-top: 8px;
}

.expo-admin-card {
  background: #f7f7f7;
  border-radius: 14px;
  padding: 12px 12px;
  margin-top: 10px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.05);
}

.expo-admin-title {
  font-size: 14px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 6px;
}

.expo-admin-periodo {
  font-size: 12px;
  color: #555;
  margin-top: 2px;
}

.expo-admin-footer {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 8px;
}

/* Badges genéricos de status */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
}

.badge-atual {
  background: #c8e6c9;
  color: #1b5e20;
}

.badge-antiga {
  background: #ffe0b2;
  color: #e65100;
}

.badge-futura {
  background: #bbdefb;
  color: #0d47a1;
}

.badge-pendente {
  background: #fff3cd;
  color: #856404;
}

/* Histórico dentro do detalhes-ponto */
.historico-list {
  margin-top: 6px;
}

.historico-item {
  padding: 8px 0;
  border-bottom: 1px solid #e0e0e0;
  font-size: 13px;
}

.historico-item:last-child {
  border-bottom: none;
}

.historico-acao {
  font-size: 12px;
  color: #555;
}

.historico-meta {
  font-size: 11px;
  color: #777;
  margin-top: 2px;
}

/* Chip de “itens pendentes / em execução” */
.status-chip {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 4px 10px;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 600;
}

.status-chip-pendente {
  background: #fff3cd;
  color: #856404;
}

.status-chip-executado {
  background: #c8e6c9;
  color: #1b5e20;
}

/* Link para ver items / editar */
.link-mini {
  font-size: 11px;
  color: #1565c0;
  text-decoration: underline;
  cursor: pointer;
}

/* =======================================================
   ALTERAÇÕES PENDENTES — /pages/alteracoes/pendentes.html
======================================================= */

.pendentes-list {
  margin-top: 10px;
}

.pendente-card {
  background: #ffffff;
  border-radius: 18px;
  padding: 14px 12px;
  margin-top: 10px;
  box-shadow: 0 3px 10px rgba(0,0,0,0.08);
  font-size: 13px;
}

.pendente-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
}

.pendente-ponto {
  font-weight: 700;
  font-size: 14px;
}

.pendente-motivo {
  margin-top: 4px;
  font-size: 12px;
  color: #555;
}

.pendente-meta {
  margin-top: 6px;
  font-size: 11px;
  color: #777;
}

.pendente-foto-thumb {
  margin-top: 8px;
  max-width: 100%;
  border-radius: 10px;
  border: 1px solid #e0e0e0;
}

.pendente-actions {
  display: flex;
  gap: 8px;
  margin-top: 10px;
}

.btn-validar {
  background: #0bb336;
  color: #ffffff;
}

.btn-recusar {
  background: #ff3b30;
  color: #ffffff;
}

/* Badge pequeno de status (pendente/validada/recusada) */
.badge-status {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3px 8px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 600;
}

.badge-status-pendente {
  background: #fff3cd;
  color: #856404;
}

.badge-status-validada {
  background: #c8e6c9;
  color: #1b5e20;
}

.badge-status-recusada {
  background: #ffcdd2;
  color: #b71c1c;
}

/* =======================================================
   HISTÓRICO DE ALTERAÇÕES — /pages/alteracoes/historico.html
======================================================= */

.historico-alteracoes-list {
  margin-top: 10px;
}

.historico-alt-card {
  background: #ffffff;
  border-radius: 18px;
  padding: 14px 12px;
  margin-top: 10px;
  box-shadow: 0 3px 10px rgba(0,0,0,0.06);
  font-size: 13px;
}

.historico-alt-top {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.historico-alt-ponto {
  font-size: 14px;
  font-weight: 700;
}

.historico-alt-body {
  margin-top: 6px;
  font-size: 12px;
  color: #555;
}

.historico-alt-meta {
  margin-top: 6px;
  font-size: 11px;
  color: #777;
}

/* =======================================================
   PÁGINA PÚBLICA — SOLICITAR ALTERAÇÃO (Ajustes gerais)
======================================================= */

.public-container {
  max-width: 430px;
  margin: 0 auto;
  padding: 16px;
}

.public-card {
  background: #ffffff;
  border-radius: 22px;
  padding: 20px 18px 22px 18px;
  box-shadow: 0 6px 16px rgba(0,0,0,0.10);
}

.public-title {
  font-size: 18px;
  font-weight: 700;
  color: #1a237e;
  margin-bottom: 10px;
}

.public-label {
  font-size: 13px;
  font-weight: 600;
  margin-top: 10px;
  margin-bottom: 4px;
}

.public-select,
.public-textarea {
  width: 100%;
  font-size: 14px;
  border-radius: 14px;
  border: 1px solid #d0d0d0;
  padding: 10px 12px;
  background: #fafafa;
  outline: none;
}

.public-textarea {
  min-height: 90px;
  resize: vertical;
}

.public-select:focus,
.public-textarea:focus {
  border-color: #1565c0;
  box-shadow: 0 0 0 2px #1565c033;
}

/* Mensagens de feedback */
.msg-ok {
  background: #c8e6c9;
  color: #1b5e20;
  padding: 10px;
  border-radius: 10px;
  margin-top: 10px;
  font-size: 13px;
}

.msg-erro {
  background: #ffebee;
  color: #b71c1c;
  padding: 10px;
  border-radius: 10px;
  margin-top: 10px;
  font-size: 13px;
}

/* =======================================================
   PARTE 4 — Correção estrutural global
======================================================= */

.app main {
  flex: 1;
  display: block;
  width: 100%;
}

/* Evita que componentes externos (ex: cards duplicados,
   formulários ou telas públicas) ultrapassem a área do app */
.app > main > .card,
.public-container .public-card {
  position: relative;
  z-index: 2;
}

/* Garante que nenhum elemento abaixo do main invada
   o layout antes do footer global */
#footer-root {
  width: 100%;
  margin-top: auto;
  z-index: 1;
}
