/* Purafiltra — tema mobile (até 860px).
   Vale para a loja (layout.php) e para as duas LPs (injetado por mobile_inject()).
   Usa variáveis próprias com fallback, porque as LPs não carregam app.css. */
:root {
  --m-accent: var(--verde, #188751);
  --m-accent-dark: var(--verde-esc, #168a52);
  --m-ink: var(--azul-esc, #0F2D4A);
  --m-text: var(--texto, #1A2230);
  --m-muted: var(--cinza-tx, #5A6470);
  --m-line: var(--cinza-bd, #E2E6EB);
  --m-bg: #fff;
  --m-tabbar-h: 62px;
  --m-safe: env(safe-area-inset-bottom, 0px);
}
.theme-social, .m-social { --m-accent: #16847B; --m-accent-dark: #18866C; }

/* Escondidos no desktop */
.m-tabbar, .m-burger, .m-buybar, .m-gallery { display: none; }
.m-scrim[hidden], .m-drawer[hidden], .m-zoom[hidden] { display: none !important; }

/* ---------- Gavetas (desktop também usa a do carrinho) ---------- */
.m-scrim { position: fixed; inset: 0; z-index: 90; background: rgba(10, 25, 40, .45); animation: m-fade .18s ease-out; }
.m-drawer { position: fixed; top: 0; bottom: 0; z-index: 95; width: min(400px, 92vw); background: var(--m-bg); color: var(--m-text);
  display: flex; flex-direction: column; box-shadow: 0 0 40px rgba(0, 0, 0, .2); font-family: inherit; }
.m-drawer-right { right: 0; animation: m-in-right .22s ease-out; }
.m-drawer-left { left: 0; animation: m-in-left .22s ease-out; }
.m-drawer-head { display: flex; align-items: center; justify-content: space-between; padding: 14px 16px 14px 20px; border-bottom: 1px solid var(--m-line); }
.m-drawer-head h2 { margin: 0; font-size: 1.15rem; color: var(--m-ink); }
.m-drawer-body { flex: 1; overflow-y: auto; padding: 16px 20px calc(24px + var(--m-safe)); -webkit-overflow-scrolling: touch; overscroll-behavior: contain; }
.m-close { width: 44px; height: 44px; border: 0; border-radius: 50%; background: transparent; color: var(--m-ink); font-size: 30px; line-height: 1; cursor: pointer; }
.m-close:hover { background: rgba(0, 0, 0, .06); }
.m-drawer .btn-block { margin-top: 10px; }
.m-empty { text-align: center; padding: 30px 0; }
.m-cart-items, .m-suggest { list-style: none; margin: 0 0 12px; padding: 0; }
.m-cart-items li, .m-suggest li { display: grid; grid-template-columns: 64px 1fr auto; gap: 12px; align-items: center; padding: 12px 0; border-bottom: 1px solid var(--m-line); }
.m-cart-items img, .m-suggest img { border-radius: 10px; background: #eef4f9; object-fit: cover; }
.m-cart-items a, .m-suggest a { display: block; color: var(--m-ink); font-weight: 700; text-decoration: none; line-height: 1.3; font-size: .95rem; }
.m-cart-items .muted { display: block; color: var(--m-muted); font-size: .85rem; }
.m-cart-totals { display: grid; grid-template-columns: 1fr auto; gap: 4px 12px; margin: 14px 0 6px; }
.m-cart-totals dt, .m-cart-totals dd { margin: 0; }
.m-cart-totals dd { font-weight: 800; text-align: right; }
.m-cart-totals .pix { color: var(--m-accent); }
.m-suggest-title { margin: 24px 0 4px; font-size: 1rem; color: var(--m-ink); }
.m-suggest li { grid-template-columns: 56px 1fr auto; }
.m-suggest .small { display: block; color: var(--m-muted); font-size: .85rem; }
.m-suggest .btn-small { min-height: 40px; padding: 0 12px; font-size: .82rem; }
.free-ship { background: #eef7f2; border-radius: 12px; padding: 10px 14px; margin-bottom: 8px; font-size: .9rem; }
.free-ship p { margin: 0 0 6px; }
.free-ship-bar { display: block; height: 6px; border-radius: 3px; background: #d4e9dd; overflow: hidden; }
.free-ship-bar i { display: block; height: 100%; background: var(--m-accent); border-radius: 3px; transition: width .3s; }
.m-menu a { display: flex; align-items: center; min-height: 48px; color: var(--m-ink); font-weight: 600; text-decoration: none; border-bottom: 1px solid var(--m-line); }
.m-menu hr { border: 0; margin: 10px 0; }
.m-menu .m-menu-other { color: var(--m-accent); border-bottom: 0; }
.m-search { margin-bottom: 8px; }
.m-search input { width: 100%; min-height: 46px; padding: 0 16px; border: 1px solid #c9d3dd; border-radius: 999px; font: inherit; font-size: 16px; }
.m-toast { position: fixed; left: 50%; bottom: calc(var(--m-tabbar-h) + 16px + var(--m-safe)); z-index: 99; transform: translateX(-50%);
  max-width: calc(100vw - 32px); padding: 12px 18px; border-radius: 12px; background: var(--m-ink); color: #fff; font-weight: 600; font-size: .92rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25); animation: m-fade .2s ease-out; }
@media (min-width: 861px) { .m-toast { bottom: 24px; } }
body.m-lock { overflow: hidden; }

/* Zoom de foto: tela cheia, pinça nativa do navegador */
.m-zoom { position: fixed; inset: 0; z-index: 100; background: #000; display: grid; place-items: center; overflow: auto; touch-action: pinch-zoom pan-x pan-y; }
.m-zoom img { max-width: 100%; max-height: 100%; object-fit: contain; }
.m-zoom .m-close { position: fixed; top: calc(10px + env(safe-area-inset-top, 0px)); right: 10px; color: #fff; background: rgba(255, 255, 255, .15); z-index: 1; }

/* Frete na página do produto e "Leve também" do carrinho */
.ship-estimate { margin: 18px 0 8px; display: grid; gap: 8px; }
.ship-estimate label { font-weight: 700; }
.ship-estimate-result:empty { display: none; }
.ship-estimate-result ul { list-style: none; margin: 0; padding: 0; border: 1px solid var(--m-line); border-radius: 12px; overflow: hidden; }
.ship-estimate-result li { display: flex; justify-content: space-between; gap: 12px; padding: 10px 14px; font-size: .92rem; }
.ship-estimate-result li + li { border-top: 1px solid var(--m-line); }
.ship-estimate-result .free { color: var(--m-accent); font-weight: 800; }
.ship-estimate .small { font-size: .82rem; }
.cart-suggest { margin-top: 28px; }
.cart-suggest h2 { font-size: 1.2rem; }
.seals { display: flex; flex-wrap: wrap; gap: 8px 16px; margin: 14px 0 0; padding: 0; list-style: none; font-size: .82rem; color: var(--m-muted); }
.seals li { display: flex; align-items: center; gap: 6px; }
.seals svg { width: 18px; height: 18px; flex: none; fill: none; stroke: var(--m-accent); stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }

/* FAQ */
.faq-group { margin: 32px 0 10px; font-size: 1.25rem; }
.faq-list { border-top: 1px solid var(--m-line); }
.faq-item { border-bottom: 1px solid var(--m-line); }
.faq-item summary { cursor: pointer; list-style: none; padding: 16px 36px 16px 0; font-weight: 700; color: var(--m-ink); position: relative; }
.faq-item summary::-webkit-details-marker { display: none; }
.faq-item summary::after { content: "+"; position: absolute; right: 6px; top: 12px; font-size: 1.4rem; color: var(--m-accent); }
.faq-item[open] summary::after { content: "−"; }
.faq-answer p { margin: 0 0 16px; color: var(--m-text); }

/* ================= Celular ================= */
@media (max-width: 860px) {
  body { padding-bottom: calc(var(--m-tabbar-h) + var(--m-safe)); }

  /* Barra inferior */
  .m-tabbar { display: grid; grid-auto-flow: column; grid-auto-columns: 1fr; position: fixed; left: 0; right: 0; bottom: 0; z-index: 80;
    height: calc(var(--m-tabbar-h) + var(--m-safe)); padding-bottom: var(--m-safe); background: rgba(255, 255, 255, .97);
    border-top: 1px solid var(--m-line); box-shadow: 0 -4px 18px rgba(15, 45, 74, .08); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif; }
  .m-tabbar a { position: relative; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 3px;
    color: var(--m-muted); text-decoration: none; font-size: 11px; font-weight: 600; letter-spacing: .01em; -webkit-tap-highlight-color: transparent; }
  .m-tabbar svg { width: 24px; height: 24px; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linejoin: round; stroke-linecap: round; }
  .m-tabbar a[aria-current="page"] { color: var(--m-accent); }
  .m-tabbar a[aria-current="page"] svg { stroke-width: 2.2; }
  .m-tabbar .m-tab-wa { color: #1ea958; }
  .m-tabbar .m-tab-wa svg { fill: currentColor; stroke: none; }
  .m-badge { position: absolute; top: 6px; left: calc(50% + 6px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
    background: var(--m-accent); color: #fff; font-size: 11px; line-height: 18px; text-align: center; font-weight: 800; }
  .m-badge.bump { animation: m-bump .4s ease-out; }

  /* A barra já tem o WhatsApp: os botões flutuantes saem (loja, LP Tripla Ação, LP Rural) */
  .wa-float, .fab, .s-wa, .r-wa-float { display: none !important; }
  /* LP nova do Rural (lp/rural, em desenvolvimento em 03/10): a barra de ação dela sobe para cima da barra inferior */
  .r-bar { bottom: calc(var(--m-tabbar-h) + var(--m-safe)) !important; }
  body:has(.r-bar) { padding-bottom: calc(var(--m-tabbar-h) + 76px + var(--m-safe)); }
  .r-cookie { bottom: calc(var(--m-tabbar-h) + 84px + var(--m-safe)) !important; }
  .cookie-bar { bottom: calc(var(--m-tabbar-h) + 10px + var(--m-safe)); }

  /* Cabeçalho compacto da loja: menu em gaveta, encolhe ao rolar */
  .topbar { font-size: .74rem; padding: 4px 10px; }
  .site-header .header-row { min-height: 56px; padding-block: 6px; flex-wrap: nowrap; gap: 10px; }
  .site-header .main-nav, .site-header .search, .site-header .icon-link { display: none; }
  .site-header .brand img { height: 26px; }
  .m-burger { display: inline-grid; align-content: center; gap: 5px; width: 44px; height: 44px; margin-left: -8px; padding: 0 10px; border: 0; background: transparent; cursor: pointer; }
  .m-burger span { display: block; height: 2px; border-radius: 1px; background: #fff; }
  .theme-social .m-burger span { background: currentColor; }
  .site-header { transition: transform .22s ease; }
  body.m-scrolled .site-header { box-shadow: 0 2px 14px rgba(0, 0, 0, .18); }
  body.m-hide-header .site-header { transform: translateY(-100%); }
  .cart-link { font-size: .9rem; }

  /* Página de produto: galeria por swipe + barra "Comprar" fixa */
  .m-gallery { display: block; position: relative; margin: 0 -20px; }
  .m-gallery-track { display: flex; overflow-x: auto; scroll-snap-type: x mandatory; list-style: none; margin: 0; padding: 0; scrollbar-width: none; -webkit-overflow-scrolling: touch; }
  .m-gallery-track::-webkit-scrollbar { display: none; }
  .m-gallery-track li { flex: 0 0 100%; scroll-snap-align: center; }
  .m-gallery-zoom { display: block; width: 100%; padding: 0; border: 0; background: #eef4f9; cursor: zoom-in; }
  .m-gallery-zoom img { width: 100%; aspect-ratio: 1; object-fit: contain; }
  .m-gallery-dots { display: flex; justify-content: center; gap: 6px; padding: 10px 0 0; }
  .m-gallery-dots span { width: 7px; height: 7px; border-radius: 50%; background: #c6d3df; transition: background .2s, width .2s; }
  .m-gallery-dots span.on { width: 18px; border-radius: 4px; background: var(--m-accent); }
  .product-media:has(.m-gallery) .product-main-img, .product-media:has(.m-gallery) .product-thumbs { display: none; }
  .product-page .product-info h1 { font-size: 1.55rem; }
  .crumbs { font-size: .8rem; overflow-x: auto; white-space: nowrap; }

  .m-buybar { display: flex; align-items: center; gap: 12px; position: fixed; left: 0; right: 0; z-index: 79;
    bottom: calc(var(--m-tabbar-h) + var(--m-safe)); padding: 10px 16px; background: #fff; border-top: 1px solid var(--m-line);
    box-shadow: 0 -6px 18px rgba(15, 45, 74, .1); transform: translateY(0); transition: transform .2s ease, opacity .2s; }
  .m-buybar.is-hidden { transform: translateY(120%); opacity: 0; pointer-events: none; visibility: hidden; transition: transform .2s ease, opacity .2s, visibility 0s .2s; }
  .m-buybar-price { flex: 1; display: grid; line-height: 1.2; }
  .m-buybar-price strong { font-size: 1.2rem; color: var(--m-accent); }
  .m-buybar-price span { font-size: .78rem; color: var(--m-muted); }
  .m-buybar .btn { flex: 0 0 auto; min-width: 140px; min-height: 50px; font-size: 1rem; }
  body:has(.m-buybar) { padding-bottom: calc(var(--m-tabbar-h) + 72px + var(--m-safe)); }
  body:has(.m-buybar) .cookie-bar { bottom: calc(var(--m-tabbar-h) + 80px + var(--m-safe)); }

  /* Pix no celular: quem paga está no próprio aparelho, então "copiar" vem antes do QR */
  .pay-box-pix { display: flex; flex-direction: column; }
  .pay-box-pix > * { order: 5; }
  .pay-box-pix h2, .pay-box-pix > p:first-of-type { order: 1; }
  .pay-box-pix .pix-copy { order: 2; width: 100%; min-height: 56px; font-size: 1.08rem; margin-bottom: 12px; }
  .pay-box-pix .pix-label { order: 3; }
  .pay-box-pix .pix-code { order: 4; font-size: 13px !important; }
  .pay-box-pix .pix-qr { order: 6; margin: 16px auto 0; max-width: 200px; }

  /* Toque e digitação: alvos de 44px+ e campos com 16px (o iOS não dá zoom sozinho) */
  input, select, textarea, .search input { font-size: 16px !important; }
  .btn { min-height: 48px; }
  .link-btn { min-height: 44px; padding: 0 8px; }
  .buy-row { gap: 8px; }
  .qty { min-width: 64px; }

  /* Carrinho e checkout em uma coluna, resumo primeiro no fim com botão grande */
  .summary { position: static; }
  .summary .btn-block { min-height: 54px; font-size: 1.05rem; }
  .checkout-layout { gap: 18px; }
  .pay-options label { min-height: 56px; }

  /* Minha conta: tabela de pedidos vira cartões */
  .orders-table thead { display: none; }
  .orders-table, .orders-table tbody, .orders-table tr, .orders-table td { display: block; width: 100%; }
  .orders-table tr { border: 1px solid var(--m-line); border-radius: 14px; padding: 12px 14px; margin-bottom: 12px; background: #fff; }
  .orders-table td { display: flex; justify-content: space-between; gap: 12px; padding: 4px 0; border: 0; text-align: right; }
  .orders-table td::before { content: attr(data-label); color: var(--m-muted); font-weight: 600; text-align: left; }
  .account-nav { display: flex; overflow-x: auto; gap: 8px; scrollbar-width: none; margin-bottom: 16px; }
  .account-nav a { flex: none; white-space: nowrap; padding: 8px 14px; border: 1px solid var(--m-line); border-radius: 999px; }
  .timeline { padding-left: 0; }
}

@media (prefers-reduced-motion: reduce) { .m-drawer, .m-scrim, .m-toast, .m-badge.bump { animation: none !important; } }
@keyframes m-fade { from { opacity: 0; } }
@keyframes m-in-right { from { transform: translateX(100%); } }
@keyframes m-in-left { from { transform: translateX(-100%); } }
@keyframes m-bump { 50% { transform: scale(1.35); } }
