/* ── Reset & Base ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: #f0f4f8;
  color: #1a1a1a;
  max-width: 480px;
  margin: 0 auto;
  min-height: 100vh;
}

/* ── Cores do sistema ── */
:root {
  --green: #1a6b3a;
  --green-light: #e8f5e9;
  --green-mid: #c8e6c9;
  --red: #c0392b;
  --red-light: #fdecea;
  --gray-bg: #f0f4f8;
  --gray-border: #e8ecf0;
  --text-muted: #888;
  --bottom-nav-h: 64px;
}

/* ── Top bar ── */
.topbar {
  background: var(--green);
  color: white;
  padding: 14px 16px 12px;
  position: sticky;
  top: 0;
  z-index: 10;
}
.topbar h1 { font-size: 17px; font-weight: 700; }
.topbar p  { font-size: 12px; opacity: 0.8; margin-top: 2px; }

/* ── Busca ── */
.search-wrap { padding: 10px 14px; background: var(--green); }
.search-box {
  display: flex; align-items: center; gap: 8px;
  background: white; border-radius: 10px; padding: 10px 14px;
}
.search-box input { border: none; outline: none; font-size: 16px; flex: 1; background: transparent; }

/* ── Chips de categoria ── */
.cats {
  display: flex; gap: 8px; padding: 10px 14px 4px;
  overflow-x: auto; scrollbar-width: none;
}
.cats::-webkit-scrollbar { display: none; }
.cat {
  white-space: nowrap; padding: 7px 14px; border-radius: 20px;
  font-size: 13px; font-weight: 600; cursor: pointer;
  background: var(--green-light); color: var(--green);
  border: 2px solid transparent; flex-shrink: 0;
}
.cat.active { background: var(--green); color: white; }

/* ── Section label ── */
.sec-label {
  padding: 10px 14px 6px;
  font-size: 12px; font-weight: 700;
  color: var(--text-muted); letter-spacing: 0.5px; text-transform: uppercase;
}
/* Sub-grupo dentro de categoria: "Limpeza › Higiene Pessoal" */
.sec-label:has(›) {
  font-size: 11px; font-weight: 600;
  color: var(--green); letter-spacing: 0.3px; text-transform: none;
  padding-top: 14px; border-top: 1px solid var(--gray-border);
  margin-top: 4px;
}
.sec-label:has(›):first-child { border-top: none; margin-top: 0; }

/* ── Product card ── */
.product-card {
  display: flex; align-items: center; gap: 12px;
  padding: 12px 14px; background: white;
  margin: 0 10px 8px; border-radius: 12px;
  box-shadow: 0 1px 4px rgba(0,0,0,.07); cursor: pointer;
}
.prod-emoji {
  font-size: 30px; background: var(--gray-bg); border-radius: 10px;
  width: 52px; height: 52px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.prod-info { flex: 1; min-width: 0; }
.prod-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.prod-unit { display: inline-block; font-size: 10px; font-weight: 500; color: #fff; background: var(--green); border-radius: 4px; padding: 1px 5px; margin-left: 5px; vertical-align: middle; }
.prod-meta { font-size: 12px; color: var(--text-muted); margin-top: 3px; }
.prod-right { text-align: right; flex-shrink: 0; }
.prod-price { font-size: 20px; font-weight: 800; color: var(--green); }
.prod-super { font-size: 11px; color: var(--text-muted); margin-top: 2px; font-weight: 600; }
.prod-date  { font-size: 10px; color: #bbb; margin-top: 2px; }
.add-btn {
  width: 30px; height: 30px; background: var(--green); color: white;
  border-radius: 50%; display: flex; align-items: center; justify-content: center;
  font-size: 20px; flex-shrink: 0; margin-left: 4px; cursor: pointer; border: none;
}

/* ── Preços concorrentes (expansão) ── */
.competitors {
  background: #f8faf8; margin: -4px 10px 8px;
  padding: 8px 14px; border-radius: 0 0 12px 12px;
  border-top: 1px solid #eee; display: none;
}
.competitors.open { display: block; }
.comp-row { display: flex; justify-content: space-between; align-items: center; padding: 4px 0; }
.comp-row span { font-size: 13px; color: #555; }
.comp-price { font-size: 15px; font-weight: 700; }
.comp-price.higher { color: var(--red); }
.comp-price.best   { color: var(--green); }

/* ── Bottom nav ── */
.bottom-nav {
  position: fixed; bottom: 0;
  left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px;
  background: white; border-top: 1px solid var(--gray-border);
  display: flex; z-index: 20;
}
.nav-item {
  flex: 1; display: flex; flex-direction: column; align-items: center;
  padding: 10px 0 14px; font-size: 10px; color: var(--text-muted);
  font-weight: 600; cursor: pointer; text-decoration: none;
}
.nav-item.active { color: var(--green); }
.nav-icon { font-size: 22px; margin-bottom: 3px; position: relative; }
.cart-count {
  position: absolute; top: -4px; right: -6px;
  background: var(--red); color: white;
  font-size: 9px; font-weight: 700;
  width: 16px; height: 16px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
}
.cart-count.hidden { display: none; }
.spacer { height: calc(var(--bottom-nav-h) + 16px); }

/* ── Status bar ── */
.status-bar {
  display: flex; align-items: center; gap: 6px;
  padding: 7px 14px; font-size: 11px; color: var(--text-muted);
  background: #fffbe6; border-bottom: 1px solid #f0e68c;
}

/* ── Empty state ── */
.empty { padding: 60px 20px; text-align: center; }
.empty .icon { font-size: 56px; margin-bottom: 14px; }
.empty p { font-size: 15px; color: var(--text-muted); line-height: 1.6; }

/* ── Modal ── */
.modal-overlay {
  position: fixed; inset: 0; background: rgba(0,0,0,.5);
  display: flex; align-items: flex-end; z-index: 100; display: none;
}
.modal-overlay.open { display: flex; }
.modal {
  background: white; border-radius: 20px 20px 0 0;
  padding: 24px 20px 32px; width: 100%; max-width: 480px; margin: 0 auto;
}
.modal h2 { font-size: 18px; font-weight: 800; margin-bottom: 6px; }
.modal p { font-size: 14px; color: var(--text-muted); margin-bottom: 16px; }
.modal input {
  width: 100%; padding: 14px 16px;
  border: 2px solid var(--gray-border); border-radius: 12px;
  font-size: 18px; outline: none; margin-bottom: 12px;
}
.modal input:focus { border-color: #25D366; }
.btn-wa {
  width: 100%; padding: 15px; background: #25D366; color: white;
  border: none; border-radius: 12px; font-size: 17px; font-weight: 700;
  cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px;
}
.btn-cancel {
  width: 100%; padding: 12px; background: none; border: none;
  color: var(--text-muted); font-size: 15px; cursor: pointer; margin-top: 6px;
}

/* ── Chart page ── */
.price-hero { padding: 16px; border-bottom: 1px solid var(--gray-border); }
.price-big { font-size: 38px; font-weight: 900; }
.price-change {
  display: inline-flex; align-items: center; gap: 4px;
  padding: 4px 12px; border-radius: 20px; font-size: 14px; font-weight: 700;
  margin-top: 6px;
}
.price-change.down { background: var(--green-light); color: var(--green); }
.price-change.up   { background: var(--red-light); color: var(--red); }
.price-change.flat { background: #f5f5f5; color: var(--text-muted); }
.time-filter {
  display: flex; gap: 6px; padding: 10px 14px;
  background: #f8faf8; border-bottom: 1px solid var(--gray-border);
}
.tf {
  padding: 6px 14px; border-radius: 20px; font-size: 13px; font-weight: 600;
  background: white; color: var(--text-muted); border: 1.5px solid var(--gray-border);
  cursor: pointer;
}
.tf.active { background: var(--green); color: white; border-color: var(--green); }
.tf:disabled { opacity: 0.4; cursor: not-allowed; }
.chart-wrap { padding: 14px; }
.chart-container { position: relative; height: 200px; }
.compare-label { padding: 4px 14px 6px; font-size: 12px; font-weight: 700; color: var(--text-muted); text-transform: uppercase; }
.compare-row {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px; border-bottom: 1px solid #f5f5f5;
}
.market-dot { width: 10px; height: 10px; border-radius: 50%; flex-shrink: 0; }
.market-name { flex: 1; font-size: 14px; font-weight: 500; }
.market-price { font-size: 17px; font-weight: 700; }
.market-price.best   { color: var(--green); }
.market-price.higher { color: var(--red); }
.market-diff { font-size: 11px; font-weight: 600; color: var(--red); margin-left: 4px; }
.market-diff.best { color: var(--green); }
.market-valid { font-size: 11px; color: #bbb; margin-left: auto; }
.data-note {
  margin: 10px 14px; padding: 10px 12px;
  background: #fffbe6; border-radius: 8px; border-left: 3px solid #f0e68c;
  font-size: 12px; color: var(--text-muted);
}

/* ── Cart page ── */
.cart-item {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 14px; border-bottom: 1px solid var(--gray-border); background: white;
}
.item-emoji {
  font-size: 26px; background: var(--gray-bg); border-radius: 8px;
  width: 44px; height: 44px;
  display: flex; align-items: center; justify-content: center; flex-shrink: 0;
}
.item-info { flex: 1; min-width: 0; }
.item-name { font-size: 13px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.item-meta { font-size: 12px; color: var(--green); margin-top: 2px; font-weight: 600; }
.qty-wrap { display: flex; align-items: center; gap: 0; flex-shrink: 0; }
.qty-btn {
  width: 30px; height: 30px; border-radius: 50%; border: none;
  font-size: 18px; font-weight: 300; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
}
.qty-btn.minus { background: var(--gray-bg); color: #555; }
.qty-btn.plus  { background: var(--green); color: white; }
.qty-num { width: 26px; text-align: center; font-size: 16px; font-weight: 700; }
.item-price-col { text-align: right; flex-shrink: 0; min-width: 58px; }
.item-price { font-size: 15px; font-weight: 700; }
.item-unit  { font-size: 11px; color: #bbb; }
.remove-btn { font-size: 16px; color: #ddd; cursor: pointer; padding: 4px; background: none; border: none; }
.summary-bar {
  position: fixed; bottom: var(--bottom-nav-h);
  left: 50%; transform: translateX(-50%);
  width: 100%; max-width: 480px;
  background: white; border-top: 2px solid var(--gray-border);
  padding: 10px 14px 8px;
}
.summary-row { display: flex; justify-content: space-between; align-items: center; }
.summary-label { font-size: 13px; color: var(--text-muted); }
.summary-label small { font-size: 10px; display: block; color: #bbb; }
.summary-total { font-size: 22px; font-weight: 900; }
.btn-wa-main {
  width: 100%; margin-top: 8px; padding: 14px; background: #25D366; color: white;
  border: none; border-radius: 12px; font-size: 16px; font-weight: 700;
  cursor: pointer; display: flex; align-items: center; justify-content: center; gap: 8px;
}
.msg-preview {
  background: #e7fdd8; border-radius: 10px; padding: 12px 14px;
  margin-bottom: 14px; font-size: 12px; color: #333;
  line-height: 1.7; font-family: monospace; white-space: pre-wrap;
}
.cart-spacer { height: calc(var(--bottom-nav-h) + 110px); }

/* ── Fase 3 ── */
.sub-cat-tag {
  display: inline-block; font-size: 10px;
  background: var(--green-light); color: var(--green);
  border-radius: 4px; padding: 1px 5px; margin-left: 4px; font-weight: 500;
}
.ver-todos-link {
  text-align: center; padding: 8px 0 14px;
  font-size: 13px; color: var(--green); font-weight: 600; cursor: pointer;
  border-bottom: 2px solid var(--gray-border); margin-bottom: 4px;
}

/* ── Fase 4: Navegação drill-down ── */

/* Back button na topbar */
.back-btn {
  background: none; border: none; color: white;
  font-size: 22px; cursor: pointer; padding: 0 8px 0 0;
  opacity: 0.9; line-height: 1; flex-shrink: 0;
}

/* Topbar com back button */
.topbar-row { display: flex; align-items: center; gap: 0; }
.topbar-text { flex: 1; min-width: 0; }

/* Breadcrumb de navegação */
.nav-breadcrumb {
  padding: 6px 14px 7px; font-size: 11px;
  background: #f8f9fa; border-bottom: 1px solid #eee;
  color: #999; display: flex; align-items: center; gap: 4px;
  flex-wrap: wrap; line-height: 1.4;
}
.nav-breadcrumb .bc-link {
  color: var(--green); font-weight: 600; cursor: pointer;
}
.nav-breadcrumb .bc-link:hover { text-decoration: underline; }
.nav-breadcrumb .bc-sep { color: #ccc; }
.nav-breadcrumb .bc-cur { color: #555; font-weight: 600; }

/* Grade de categorias (tela home) */
.cat-grid {
  display: grid; grid-template-columns: 1fr 1fr; gap: 10px;
  padding: 12px 14px;
}
.cat-card {
  border-radius: 16px; padding: 18px 12px; text-align: center;
  cursor: pointer; transition: transform .12s, box-shadow .12s;
  user-select: none;
}
.cat-card:active { transform: scale(0.97); }
.cat-card .cc-emoji { font-size: 30px; display: block; margin-bottom: 8px; }
.cat-card .cc-name  { font-size: 13px; font-weight: 800; display: block; }
.cat-card .cc-count { font-size: 11px; opacity: 0.65; margin-top: 3px; display: block; }

/* Lista de sub-categorias */
.sub-list { padding: 8px 14px; display: flex; flex-direction: column; gap: 6px; }
.sub-row {
  display: flex; align-items: center; gap: 12px;
  background: white; border-radius: 12px; padding: 13px 14px;
  cursor: pointer; border: 1.5px solid #eee;
  transition: border-color .12s, background .12s;
  user-select: none;
}
.sub-row:active { background: var(--green-light); border-color: var(--green); }
.sub-icon  { font-size: 26px; flex-shrink: 0; }
.sub-info  { flex: 1; }
.sub-name  { font-size: 14px; font-weight: 700; color: #222; }
.sub-desc  { font-size: 11px; color: #aaa; margin-top: 2px; }
.sub-count { font-size: 12px; color: var(--green); font-weight: 700; flex-shrink: 0; }
.sub-chevron { color: #ccc; font-size: 16px; margin-left: 4px; }

/* Lista de tipos de produto */
.type-list { padding: 6px 14px; display: flex; flex-direction: column; gap: 5px; }
.type-row {
  display: flex; align-items: center; gap: 10px;
  background: white; border-radius: 10px; padding: 11px 14px;
  cursor: pointer; border: 1.5px solid #eee;
  transition: border-color .12s, background .12s;
  user-select: none;
}
.type-row:active { background: var(--green-light); border-color: var(--green); }
.type-dot  { width: 8px; height: 8px; border-radius: 50%; flex-shrink: 0; }
.type-info { flex: 1; }
.type-name  { font-size: 13px; font-weight: 600; color: #222; }
.type-range { font-size: 11px; color: var(--green); font-weight: 700; margin-top: 1px; }
.type-count { font-size: 11px; color: #ccc; flex-shrink: 0; margin-right: 4px; }
.type-chevron { color: #ccc; font-size: 14px; }

/* "Ver todos" na tela de tipos */
.ver-todos-row {
  display: flex; align-items: center; gap: 10px;
  background: var(--green-light); border-radius: 10px; padding: 11px 14px;
  cursor: pointer; border: 1.5px solid var(--green-mid); margin-top: 2px;
  user-select: none; transition: background .12s;
}
.ver-todos-row:active { background: var(--green-mid); }
.ver-todos-row span { font-size: 13px; font-weight: 700; color: var(--green); flex: 1; }

/* Seção header dentro da lista de produtos no drill-down */
.sec-label:has(›) {
  font-size: 11px; font-weight: 600;
  color: var(--green); letter-spacing: 0.3px; text-transform: none;
  padding-top: 14px; border-top: 1px solid var(--gray-border);
  margin-top: 4px;
}
.sec-label:has(›):first-child { border-top: none; margin-top: 0; }
