/* =========================================================================
   Design tokens — paleta de marca (azul corporativo)
   ========================================================================= */
:root {
  --color-primary: #1565C0;       /* CTAs, pill ativa, preço, links */
  --color-primary-dark: #0D47A1;  /* hover/pressed, fallback do banner */
  --color-primary-light: #64B5F6; /* realces, foco, tons suaves do azul */
  --color-on-primary: #FFFFFF;    /* texto/ícone sobre fundo primary */
  --color-text: #263238;          /* texto principal */
  --color-bg-light: #E0E0E0;      /* fundo externo do app + tiras internas */
  --color-border: #EEEEEE;        /* divisórias finas sobre o card branco */
  --color-success: #22c55e;
  --color-success-bg: #dcfce7;
  --color-success-text: #15803d;

  --radius-card: 1rem;      /* rounded-2xl */
  --radius-modal: 1.5rem;   /* rounded-3xl */
  --radius-section: 2rem;   /* rounded-lg (token custom) */
  --radius-cta: 3rem;       /* rounded-xl (token custom) */
  --radius-pill: 9999px;

  --transition-fast: all 150ms ease-in-out;
  --transition-theme: color 300ms ease-in-out, background-color 300ms ease-in-out, border-color 300ms ease-in-out;
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: 'Plus Jakarta Sans', sans-serif;
  background: var(--color-bg-light);
  color: var(--color-text);
  transition: var(--transition-theme);
}

img { max-width: 100%; display: block; }
button { font-family: inherit; cursor: pointer; }

:focus-visible {
  outline: 3px solid var(--color-primary-light);
  outline-offset: 2px;
}

/* =========================================================================
   Shell — mobile-first, centralizado como "cartão" em telas largas
   ========================================================================= */
.app-shell {
  position: relative;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  width: 100%;
  max-width: 480px;
  margin: 0 auto;
  background: #fff;
  box-shadow: 0 0 40px rgba(0,0,0,0.08);
}

.app-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  min-height: 60vh;
  padding: 24px;
  text-align: center;
  color: #6b7280;
  font-size: 14px;
}

.spinner {
  width: 32px;
  height: 32px;
  border: 3px solid var(--color-border);
  border-top-color: var(--color-primary);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* =========================================================================
   Hero — banner + nome + status (sem avatar sobreposto: o HTML não tem
   logo separado do banner, então o bloco de info fica abaixo, não por
   cima — texto escuro sobre o banner ficava ilegível).
   ========================================================================= */
.hero {
  position: relative;
}
.hero-banner {
  position: relative;
  width: 100%;
  height: 11rem;
  border-radius: 0 0 1.5rem 1.5rem;
  overflow: hidden;
  background: var(--color-primary-dark) center/cover no-repeat;
  box-shadow: inset 0 0 20px rgba(0,0,0,0.2);
}
.hero-banner::after {
  content: "";
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.2);
}
.hero-info {
  position: relative;
  padding: 16px 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  border-bottom: 1px solid var(--color-border);
}
.hero-nome {
  font-size: 22px;
  font-weight: 800;
  margin: 12px 0 8px;
  text-align: center;
}
.status-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 12px;
  border-radius: var(--radius-pill);
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.1em;
}
.status-badge--aberto { background: var(--color-success-bg); color: var(--color-success-text); }
.status-badge--fechado { background: var(--color-border); color: #6b7280; }
.status-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--color-success);
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}
.status-badge--fechado .status-dot { background: #9ca3af; animation: none; }
@keyframes pulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

.loja-fechada-aviso {
  margin: 12px 16px 0;
  padding: 12px 16px;
  background: #fef2f2;
  color: #991b1b;
  border-radius: var(--radius-card);
  font-size: 13px;
  font-weight: 700;
  text-align: center;
}

/* =========================================================================
   Navegação de categorias — pills horizontais com scroll
   ========================================================================= */
.categorias-nav {
  display: flex;
  gap: 8px;
  padding: 12px 16px;
  overflow-x: auto;
  scrollbar-width: none;
  position: sticky;
  top: 0;
  z-index: 20;
  background: rgba(255,255,255,0.95);
  backdrop-filter: blur(8px);
  border-bottom: 1px solid var(--color-border);
}
.categorias-nav::-webkit-scrollbar { display: none; }

.categoria-pill {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  height: 40px;
  padding: 0 20px;
  border-radius: var(--radius-pill);
  background: var(--color-bg-light);
  color: var(--color-text);
  font-weight: 700;
  font-size: 14px;
  text-decoration: none;
  border: none;
  transition: var(--transition-fast);
  scroll-snap-align: start;
}
.categoria-pill.is-active {
  background: var(--color-primary);
  color: var(--color-on-primary);
}

/* =========================================================================
   Destaques — cards horizontais
   ========================================================================= */
.secao-titulo {
  margin: 0;
  padding: 8px 16px;
  font-size: 20px;
  font-weight: 700;
  background: var(--color-primary);
  color: var(--color-on-primary);
  display: inline-block;
  border-radius: var(--radius-section);
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.secao-titulo-wrap {
  position: sticky;
  top: 65px;
  z-index: 10;
  padding: 16px 16px 8px;
  background: var(--color-bg-light);
}

.destaques-scroll {
  display: flex;
  gap: 12px;
  padding: 4px 16px 16px;
  overflow-x: auto;
  scrollbar-width: none;
}
.destaques-scroll::-webkit-scrollbar { display: none; }

.destaque-card {
  flex-shrink: 0;
  width: 160px;
  border: none;
  background: #fff;
  border-radius: var(--radius-card);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  text-align: left;
  padding: 0;
}
.destaque-card-foto {
  width: 100%;
  height: 110px;
  background: var(--color-bg-light) center/cover no-repeat;
}
.destaque-card-corpo { padding: 10px 12px 12px; }
.destaque-card-nome {
  font-size: 13px;
  font-weight: 700;
  margin: 0 0 4px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.destaque-card-preco { font-size: 14px; font-weight: 700; margin: 0; }

/* =========================================================================
   Listagem de estabelecimentos (index.html sem ?loja=)
   ========================================================================= */
.hero--listagem { padding-top: 24px; }
.hero-subtitulo { color: #6b7280; font-size: 14px; margin: 0 0 8px; }

.lojas-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 12px;
  padding: 16px;
}
@media (min-width: 640px) {
  .lojas-grid { grid-template-columns: repeat(2, 1fr); }
}

.loja-card {
  display: flex;
  gap: 12px;
  align-items: center;
  background: #fff;
  border-radius: var(--radius-card);
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  text-decoration: none;
  color: inherit;
  padding: 8px;
}
.loja-card-foto {
  flex-shrink: 0;
  width: 72px;
  height: 72px;
  border-radius: var(--radius-card);
  background: var(--color-bg-light) center/cover no-repeat;
}
.loja-card-corpo {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 0;
}
.loja-card-nome {
  font-size: 15px;
  font-weight: 700;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.loja-card-endereco {
  font-size: 12px;
  color: #6b7280;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* =========================================================================
   Cardápio agrupado por categoria
   ========================================================================= */
.produto-item {
  display: flex;
  gap: 16px;
  align-items: flex-start;
  width: 100%;
  padding: 16px;
  border: none;
  border-bottom: 1px solid var(--color-border);
  background: transparent;
  text-align: left;
}
.produto-info { flex: 1; min-width: 0; }
.produto-nome { font-size: 16px; font-weight: 700; margin: 0 0 4px; }
.produto-obs {
  font-size: 14px;
  color: #6b7280;
  margin: 0 0 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.produto-preco { font-size: 18px; font-weight: 700; margin: 0; }

.produto-foto-wrap { position: relative; flex-shrink: 0; }
.produto-foto {
  width: 96px;
  height: 96px;
  border-radius: var(--radius-card);
  background: var(--color-bg-light) center/cover no-repeat;
  box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.produto-add {
  position: absolute;
  bottom: -8px;
  right: -8px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--color-primary);
  color: var(--color-on-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  box-shadow: 0 2px 6px rgba(0,0,0,0.15);
  transition: var(--transition-fast);
}
.produto-add:active { transform: scale(0.9); }
.produto-add[disabled] { background: var(--color-border); color: #9ca3af; cursor: not-allowed; }

/* =========================================================================
   Modal de produto
   ========================================================================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.8);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  z-index: 100;
}
.modal-overlay[hidden] { display: none; }

.modal-panel {
  position: relative;
  width: 100%;
  max-width: 480px;
  max-height: 85vh;
  overflow-y: auto;
  background: #fff;
  border-radius: var(--radius-modal) var(--radius-modal) 0 0;
  animation: slide-up 200ms ease-out;
}
@keyframes slide-up {
  from { transform: translateY(24px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.modal-produto-foto {
  width: 100%;
  height: 220px;
  background: var(--color-bg-light) center/cover no-repeat;
}
.modal-produto-corpo { padding: 20px; }
.modal-produto-nome { font-size: 20px; font-weight: 800; margin: 0 0 8px; }
.modal-produto-obs { font-size: 14px; color: #6b7280; margin: 0 0 16px; line-height: 1.5; }
.modal-produto-preco { font-size: 22px; font-weight: 700; margin: 0; }

.btn-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: #fff;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 1px 4px rgba(0,0,0,0.2);
  z-index: 1;
}

/* =========================================================================
   Formulários — usado no modal de produto e no checkout
   ========================================================================= */
.form-section { margin-top: 16px; }
.form-label {
  display: block;
  font-size: 12px;
  font-weight: 700;
  color: #6b7280;
  margin-bottom: 8px;
}
.form-section input[type="text"],
.form-section input[type="tel"],
.form-section textarea {
  width: 100%;
  padding: 12px 14px;
  margin-bottom: 8px;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-card);
  background: var(--color-bg-light);
  font-family: inherit;
  font-size: 14px;
  color: var(--color-text);
}
.form-section input:focus,
.form-section textarea:focus {
  outline: none;
  border-color: var(--color-primary-light);
  background: #fff;
}
.form-grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px;
}

/* Botão CTA principal — usa o token --radius-cta, definido mas sem uso
   até agora no design system. */
.btn-cta {
  width: 100%;
  padding: 14px;
  margin-top: 16px;
  background: var(--color-primary);
  color: var(--color-on-primary);
  border: none;
  border-radius: var(--radius-cta);
  font-family: inherit;
  font-size: 15px;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(21,101,192,0.3);
  transition: var(--transition-fast);
}
.btn-cta:active { transform: scale(0.97); }
.btn-cta[disabled] { background: var(--color-border); color: #9ca3af; box-shadow: none; cursor: not-allowed; }

.modal-titulo { font-size: 20px; font-weight: 800; margin: 0 0 16px; }

/* =========================================================================
   Adicionais — dentro do modal de produto
   ========================================================================= */
.modal-produto-adicionais { margin-top: 16px; }
.adicional-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--color-border);
  font-size: 14px;
}
.adicional-item input[type="checkbox"] { width: 18px; height: 18px; accent-color: var(--color-primary); }
.adicional-item span:nth-child(2) { flex: 1; }
.adicional-preco { color: #6b7280; font-weight: 600; font-size: 13px; }

/* Stepper de quantidade */
.stepper { display: inline-flex; align-items: center; gap: 12px; }
.stepper-btn {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: 1px solid var(--color-border);
  background: var(--color-bg-light);
  color: var(--color-text);
  font-size: 18px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}
.stepper--sm .stepper-btn { width: 24px; height: 24px; font-size: 14px; }
.stepper-valor { min-width: 20px; text-align: center; font-weight: 700; }

.modal-produto-rodape {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-top: 20px;
}
.modal-produto-rodape .btn-cta { flex: 1; margin-top: 0; }

/* =========================================================================
   Sacola (carrinho)
   ========================================================================= */
.carrinho-vazio { color: #6b7280; font-size: 14px; text-align: center; padding: 24px 0; }

.carrinho-item {
  display: flex;
  gap: 12px;
  padding: 12px 0;
  border-bottom: 1px solid var(--color-border);
}
.carrinho-item-foto {
  width: 56px;
  height: 56px;
  flex-shrink: 0;
  border-radius: var(--radius-card);
  background: var(--color-bg-light) center/cover no-repeat;
}
.carrinho-item-info { flex: 1; min-width: 0; }
.carrinho-item-nome { font-size: 14px; font-weight: 700; margin: 0 0 2px; }
.carrinho-item-adicionais { font-size: 12px; color: #6b7280; margin: 0 0 2px; }
.carrinho-item-obs { font-size: 12px; color: #6b7280; font-style: italic; margin: 0 0 6px; }
.carrinho-item-direita {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  justify-content: space-between;
}
.carrinho-item-subtotal { font-size: 14px; font-weight: 700; margin: 0; }
.carrinho-item-remover {
  border: none;
  background: transparent;
  color: #9ca3af;
  display: flex;
}

.carrinho-resumo {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-top: 16px;
  padding-top: 16px;
  border-top: 1px solid var(--color-border);
  font-size: 16px;
  font-weight: 700;
}

/* =========================================================================
   Checkout — entrega/retirada e forma de pagamento
   ========================================================================= */
.tipo-entrega-toggle {
  display: flex;
  gap: 8px;
  background: var(--color-bg-light);
  border-radius: var(--radius-pill);
  padding: 4px;
}
.tipo-entrega-opcao {
  flex: 1;
  padding: 10px;
  border: none;
  border-radius: var(--radius-pill);
  background: transparent;
  color: var(--color-text);
  font-family: inherit;
  font-weight: 700;
  font-size: 14px;
  transition: var(--transition-fast);
}
.tipo-entrega-opcao.is-active { background: var(--color-primary); color: var(--color-on-primary); }

.pagamento-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
  border-bottom: 1px solid var(--color-border);
  font-size: 14px;
}
.pagamento-item input[type="radio"] { width: 18px; height: 18px; accent-color: var(--color-primary); }

/* =========================================================================
   Barra flutuante "Ver sacola"
   ========================================================================= */
.barra-sacola {
  position: sticky;
  bottom: 0;
  z-index: 30;
  padding: 12px 16px calc(12px + env(safe-area-inset-bottom));
  background: linear-gradient(0deg, #fff 60%, transparent);
}
.barra-sacola button {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px;
  background: var(--color-primary);
  color: var(--color-on-primary);
  border: none;
  border-radius: var(--radius-cta);
  font-family: inherit;
  font-weight: 700;
  font-size: 15px;
  box-shadow: 0 8px 20px rgba(21,101,192,0.35);
}
.barra-sacola button span:nth-child(2) { flex: 1; text-align: left; }
.barra-sacola-contagem {
  background: rgba(255,255,255,0.25);
  border-radius: var(--radius-pill);
  padding: 2px 9px;
  font-size: 13px;
}

/* =========================================================================
   Confirmação de pedido
   ========================================================================= */
.app-state--confirmacao { color: var(--color-text); }
.confirmacao-icone { font-size: 56px; color: var(--color-success); }
.app-state--confirmacao h2 { margin: 0; font-size: 20px; }

/* =========================================================================
   Toast simples (feedback de interação)
   ========================================================================= */
.toast {
  position: fixed;
  left: 50%;
  bottom: 24px;
  transform: translateX(-50%);
  background: var(--color-text);
  color: #fff;
  padding: 10px 20px;
  border-radius: var(--radius-pill);
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 4px 12px rgba(0,0,0,0.2);
  z-index: 200;
  opacity: 0;
  pointer-events: none;
  transition: opacity 200ms ease-in-out;
}
.toast.is-visible { opacity: 1; }

.app-state--erro { color: #991b1b; }
