/* Home mobile premium — só ≤768px. Desktop não é afetado (regras abaixo ficam dentro da media query,
   e os elementos exclusivos do mobile são escondidos acima de 768px). */
:root { --zd-gold: #e3b565; --zd-gold-grad: linear-gradient(135deg, #f2d594 0%, #d9a548 100%); }

.home-bottom-nav, .btn-card-cart-m, .card-discount-flag,
.category-section-view-all--m { display: none; }

@media (max-width: 768px) {
  body { padding-bottom: calc(72px + env(safe-area-inset-bottom)); overflow-x: hidden; }

  /* Busca */
  .search-bar-mobile { background: #071d34; padding: .65rem 1rem .85rem; }
  .search-bar-mobile .search-input-wrapper { border: none; border-radius: 16px; overflow: hidden; background: #fff; box-shadow: 0 8px 20px -12px rgba(0,0,0,.6); }
  .search-bar-mobile .search-bar-inner { align-items: center; padding: 0; }
  .search-bar-mobile input { height: 48px; padding: 0 1rem; font-size: .95rem; font-weight: 500; color: #16181d; background: transparent; }
  .search-bar-mobile input::placeholder { color: #7b8494; }
  .search-bar-mobile .search-btn-mobile {
    width: 60px; min-width: 60px; height: 48px; border: none; border-radius: 0 16px 16px 0;
    background: var(--zd-gold-grad); color: #071d34; font-size: 1.05rem; display: flex; align-items: center; justify-content: center;
  }

  /* Folha branca de categorias sobrepondo o fim da faixa */
  .departments-section { position: relative; z-index: 2; margin-top: -1.35rem; background: #fff; border-radius: 28px 28px 0 0; padding: 1.1rem 0 .6rem; }
  .departments-carousel { padding: .35rem 1rem .9rem !important; gap: .6rem !important; }
  .department-card { width: 78px; gap: .45rem; }
  .department-image-container { width: 72px; height: 72px; border-radius: 20px; }
  .department-name { font-size: .7rem; font-weight: 600; letter-spacing: 0; text-transform: none; color: #16181d; padding: 0; max-width: 78px; }
  .departments-cta { margin: .2rem 1rem 0; }
  .departments-cta__btn {
    width: 100%; height: 56px; border-radius: 20px; padding: 0 .55rem 0 1.1rem; justify-content: flex-start; gap: .75rem;
    background: #071d34; box-shadow: 0 14px 26px -14px rgba(7,29,52,.7);
  }
  .departments-cta__btn > span:not(.departments-cta__arrow) { flex: 1; text-align: center; font-size: 1rem; font-weight: 800; }
  .departments-cta__cube { display: inline-block; color: var(--zd-gold); font-size: 1.25rem; }
  .departments-cta__arrow { display: inline-flex; align-items: center; justify-content: center; width: 42px; height: 42px; border-radius: 50%; background: var(--zd-gold-grad); color: #071d34; }
  .departments-cta__arrow i { font-size: .9rem; }

  /* Títulos das seções */
  .category-section-head { border: none !important; padding: 0 1rem; margin-bottom: .9rem; align-items: center; }
  .category-section-head .category-section-title { gap: .65rem; align-items: center; font-size: 1.4rem; font-weight: 800; color: #071d34; }
  .category-section-head .category-section-title::before {
    width: 22px; height: 4px; min-height: 0; border-radius: 4px; background: var(--zd-gold-grad); box-shadow: none;
  }
  .category-section-view-all--m {
    display: inline-flex; align-items: center; gap: .35rem; height: auto; padding: 0; border: none; border-radius: 0; background: none; box-shadow: none;
    color: #c8922f; font-size: .9rem; font-weight: 700;
  }
  .category-section-view-all--m:hover { background: none; color: #a8761c; }

  /* Cards de produto */
  .products-carousel .product-card { position: relative; border-radius: 20px; background: #fff; box-shadow: 0 10px 24px -16px rgba(7,29,52,.35); }
  .card-discount-flag {
    display: inline-flex; position: absolute; top: 10px; left: 10px; z-index: 3; padding: .2rem .5rem; border-radius: 6px;
    background: #ef4444; color: #fff; font-size: .78rem; font-weight: 800;
  }
  .products-carousel .product-card .price-row .discount-badge { display: none; }
  .btn-card-cart-m {
    display: flex; align-items: center; justify-content: center; position: absolute; right: 12px; bottom: 12px; z-index: 4;
    width: 44px; height: 44px; border: none; border-radius: 50%; background: var(--zd-gold-grad); color: #071d34; font-size: 1.05rem;
    box-shadow: 0 8px 16px -8px rgba(217,165,72,.9); cursor: pointer;
  }
  .btn-card-cart-m:active { transform: scale(.92); }

  /* Barra inferior */
  .home-bottom-nav {
    display: flex; position: fixed; left: 0; right: 0; bottom: 0; z-index: 9000; height: calc(66px + env(safe-area-inset-bottom));
    padding: 0 .35rem env(safe-area-inset-bottom); background: #071d34; border-radius: 22px 22px 0 0; box-shadow: 0 -10px 28px -12px rgba(7,29,52,.55);
  }
  .home-bottom-nav__item {
    position: relative; flex: 1; display: flex; flex-direction: column; align-items: center; justify-content: center; gap: .25rem;
    background: none; border: none; color: #fff; text-decoration: none; font: inherit; font-size: .72rem; font-weight: 600; cursor: pointer;
  }
  .home-bottom-nav__item i { font-size: 1.3rem; }
  .home-bottom-nav__item.is-active { color: var(--zd-gold); }
  .home-bottom-nav__badge {
    position: absolute; top: 8px; left: calc(50% + 8px); min-width: 18px; height: 18px; padding: 0 5px; border-radius: 9px;
    background: #ef4444; color: #fff; font-size: .65rem; font-weight: 800; display: flex; align-items: center; justify-content: center;
  }
  .home-bottom-nav__badge[hidden] { display: none; }

  /* WhatsApp/chat: acima da barra, sem cobrir botões dos cards */
  .zdmix-chat-bubble:not(.zdmix-chat-bubble--in-header) { bottom: calc(82px + env(safe-area-inset-bottom)) !important; right: 12px !important; width: 50px !important; height: 50px !important; }
  /* some a barra quando o carrinho ou o menu lateral estão abertos */
  body.cart-drawer-open .home-bottom-nav, body.cart-sidebar-open .home-bottom-nav,
  body.mobile-drawer-open .home-bottom-nav, body.filter-drawer-open .home-bottom-nav { display: none; }
}

/* ── Ajustes após validação visual ── */
@media (max-width: 768px) {
  /* busca: especificidade para vencer o CSS inline das páginas */
  body .search-bar-mobile { background: #071d34 !important; padding: .65rem 1rem .85rem !important; border: none !important; }
  body .search-bar-mobile .search-input-wrapper { border: none !important; border-radius: 16px !important; overflow: hidden; background: #fff; }
  body .search-bar-mobile .search-bar-inner { display: flex; align-items: center; border-radius: 16px; }
  body .search-bar-mobile #searchInputMobile { height: 48px; padding: 0 1rem !important; font-size: .95rem; }
  body .search-bar-mobile .search-btn-mobile {
    width: 60px; min-width: 60px; height: 48px; border: none !important; border-radius: 0 !important; margin: 0;
    background: linear-gradient(135deg, #f2d594 0%, #d9a548 100%) !important; color: #071d34 !important;
  }


  /* nomes: só a primeira letra maiúscula (o JS entrega caixa mista/alta) */
  .department-name { text-transform: lowercase !important; }
  .department-name::first-letter { text-transform: uppercase; }

  /* cabeçalho de seção: título + "Ver todos" na mesma linha */
  .category-section-head { display: flex; flex-wrap: nowrap; justify-content: space-between; }
  .category-section-head .category-section-title { flex: 1 1 auto; min-width: 0; }
  .category-section-head .category-section-title::before {
    content: ""; display: block; flex: 0 0 22px; width: 22px; height: 4px; min-height: 0; border-radius: 4px;
    background: linear-gradient(135deg, #f2d594 0%, #d9a548 100%); box-shadow: none; align-self: center;
  }
  .category-section-head .category-section-view-all.category-section-view-all--m {
    display: inline-flex; flex: 0 0 auto; height: auto; padding: 0; border: none; border-radius: 0; background: none; box-shadow: none;
    color: #c8922f; font-size: .9rem; font-weight: 700;
  }

  /* carrossel de produtos: sem setas (rola com o dedo); preço não encosta no botão */
  .products-carousel-wrapper .carousel-nav-btn { display: none !important; }
  .products-carousel .product-card .product-prices { padding-right: 56px; text-align: left; }
  .products-carousel .product-card .price-row,
  .products-carousel .product-card .price-info { justify-content: flex-start; text-align: left; }

  .zdmix-chat-bubble:not(.zdmix-chat-bubble--in-header) { width: 46px !important; height: 46px !important; bottom: calc(76px + env(safe-area-inset-bottom)) !important; right: 10px !important; opacity: .95; }
}

@media (max-width: 768px) {
  /* wrapper precisa ficar overflow:visible (dropdown do autocomplete) → arredonda os filhos */
  body .search-bar-mobile .search-input-wrapper { overflow: visible !important; }
  body .search-bar-mobile #searchInputMobile { border-radius: 16px 0 0 16px !important; font-size: .95rem !important; }
  body .search-bar-mobile .search-btn-mobile { border-radius: 0 16px 16px 0 !important; }

  .category-section-head { flex-direction: row !important; align-items: center !important; }
  .category-section-head .category-section-title { display: flex !important; flex-direction: row !important; align-items: center !important; }

  .department-card { width: 68px; }
  .department-image-container { width: 62px; height: 62px; border-radius: 18px; }
  .department-name { font-size: .66rem; max-width: 68px; }
}

@media (max-width: 768px) {
  body .departments-section { margin-top: -1.5rem !important; border-radius: 28px 28px 0 0 !important; position: relative; z-index: 2; background: #fff !important; }
}

/* Desktop: elementos exclusivos do mobile ficam ocultos (especificidade > regras globais) */
@media (min-width: 769px) {
  .category-section-head .category-section-view-all.category-section-view-all--m { display: none !important; }
}

@media (max-width: 768px) {
  /* Menu inferior: nada fica escondido atrás dele (inclusive rodapé) + safe area */
  body { padding-bottom: calc(96px + env(safe-area-inset-bottom)) !important; }
  .home-bottom-nav { padding-left: max(.35rem, env(safe-area-inset-left)); padding-right: max(.35rem, env(safe-area-inset-right)); }
  html { scroll-padding-bottom: calc(96px + env(safe-area-inset-bottom)); }

  /* Cards de produto: título, preço e botão sempre visíveis e alinhados */
  .products-carousel .product-card { display: flex; flex-direction: column; height: 100%; padding-bottom: 0; }
  .products-carousel .product-card .product-info { display: flex; flex-direction: column; flex: 1 1 auto; padding: .75rem .8rem 3.6rem; min-height: 0; }
  .products-carousel .product-card .product-name { font-size: .95rem; line-height: 1.3; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; min-height: 2.6em; margin: 0 0 .4rem; }
  .products-carousel .product-card .product-prices { margin-top: auto; padding-right: 54px; }
  .products-carousel .product-card .price-original { font-size: .8rem; color: #8b93a1; }
  .products-carousel .product-card .price-value { font-size: 1.05rem; font-weight: 800; color: #071d34; }
  .btn-card-cart-m { right: 10px; bottom: 10px; width: 44px; height: 44px; }
}
@media (max-width: 360px) {
  .products-carousel .product-card .product-name { font-size: .88rem; }
}

/* ── Área de produtos: clean / minimalista ── */
@media (max-width: 768px) {
  /* categorias coladas no banner, sem folha sobreposta */
  body .departments-section { margin-top: 0 !important; border-radius: 0 !important; padding: .75rem 0 .25rem; }
  .departments-section-head { margin-bottom: .5rem; }

  /* "Ver todos os produtos": branco, borda navy sutil, seta simples */
  .departments-cta { margin: .1rem 1rem 0; }
  .departments-cta__btn {
    height: 46px; padding: 0 1rem; border-radius: 14px; justify-content: center; gap: .6rem;
    background: #fff; color: #071d34; border: 1px solid rgba(7,29,52,.28); box-shadow: none;
  }
  .departments-cta__btn > span:not(.departments-cta__arrow) { flex: 0 1 auto; font-size: .92rem; font-weight: 700; }
  .departments-cta__btn:active { background: #f1f4f9; transform: none; }
  .departments-cta__arrow { width: auto; height: auto; background: none; border-radius: 0; color: #071d34; display: inline-flex; }
  .departments-cta__arrow i { font-size: .8rem; }

  /* cards uniformes */
  .products-carousel { align-items: stretch; }
  .products-carousel .product-card { border: 1px solid rgba(16,48,112,.12); border-radius: 16px; box-shadow: 0 6px 16px -12px rgba(7,29,52,.3); overflow: hidden; }
  .products-carousel .product-card .product-image { height: 150px; padding: .5rem .5rem 0; display: flex; align-items: center; justify-content: center; }
  .products-carousel .product-card .product-image img { max-height: 100%; width: 100%; object-fit: contain; }
  .products-carousel .product-card .product-info { padding: .5rem .7rem .7rem; gap: 0; }
  .products-carousel .product-card .product-name { font-size: .88rem; min-height: 2.4em; margin: 0 0 .35rem; }
  .products-carousel .product-card .product-meta-row { display: none; }
  .products-carousel .product-card .product-prices { margin-top: auto; padding-right: 0; min-height: 2.6rem; display: flex; flex-direction: column; justify-content: flex-end; }
  .products-carousel .product-card .price-original { font-size: .74rem; line-height: 1.2; }
  .products-carousel .product-card .price-value { font-size: 1.02rem; line-height: 1.25; }

  /* selo de desconto menor */
  .card-discount-flag { top: 8px; left: 8px; padding: .12rem .38rem; border-radius: 5px; font-size: .66rem; font-weight: 800; letter-spacing: .01em; }

  /* botão Adicionar: navy compacto, no fluxo do card */
  .btn-card-cart-m {
    position: static; display: flex; width: 100%; height: 38px; margin-top: .55rem; padding: 0 .6rem; border-radius: 10px; gap: .45rem;
    background: #071d34; color: #fff; font-size: .8rem; font-weight: 700; box-shadow: none;
  }
  .btn-card-cart-m i { font-size: .85rem; }
  .btn-card-cart-m span { white-space: nowrap; }
  .btn-card-cart-m:active { background: #0d2c52; transform: scale(.98); }
}
@media (max-width: 360px) {
  .products-carousel .product-card .product-image { height: 130px; }
  .btn-card-cart-m { font-size: .74rem; padding: 0 .4rem; }
}

/* ── Barra inferior compacta (64px + safe area), ícones Lucide outline ── */
@media (max-width: 768px) {
  .home-bottom-nav {
    height: calc(64px + env(safe-area-inset-bottom)); padding-top: 0; padding-bottom: env(safe-area-inset-bottom);
    align-items: stretch; box-shadow: none;
  }
  .home-bottom-nav__item {
    min-width: 44px; min-height: 44px; gap: 3px; padding: 0; justify-content: center; color: #fff; font-size: .68rem; font-weight: 600; line-height: 1;
    -webkit-tap-highlight-color: transparent;
  }
  .home-bottom-nav__icon { width: 23px; height: 23px; flex: 0 0 23px; display: block; fill: none; stroke: currentColor; filter: none; }
  .home-bottom-nav__item span { display: block; line-height: 1; }
  .home-bottom-nav__item.is-active { color: #e9bb68; }
  .home-bottom-nav__badge { top: 7px; left: calc(50% + 6px); }
  body { padding-bottom: calc(64px + 20px + env(safe-area-inset-bottom)) !important; }
  html { scroll-padding-bottom: calc(64px + 20px + env(safe-area-inset-bottom)); }
  .zdmix-chat-bubble:not(.zdmix-chat-bubble--in-header) { bottom: calc(74px + env(safe-area-inset-bottom)) !important; }
}

/* ── Banner exclusivo mobile (arte vertical única; sem HTML por cima) ── */
.home-m-banner { display: none; }
@media (max-width: 768px) {
  .home-m-banner { display: block; width: 100%; line-height: 0; background: #071d34; }
  .home-m-banner img { display: block; width: 100%; height: auto; aspect-ratio: 1122 / 1402; }
  .home-hero-banner-slot { display: none !important; }
}

/* ── Categorias mobile: carrossel ~2,5 cards, snap, cards brancos grandes ── */
@media (max-width: 768px) {
  body .departments-section { padding: 1rem 0 .25rem; }
  body .departments-section-head { margin: 0; padding: 0; min-height: 0; }
  body .departments-carousel-wrapper { margin: 0; }
  body .departments-carousel {
    display: flex !important; flex-wrap: nowrap; gap: .75rem !important; padding: .25rem 1rem .9rem !important;
    overflow-x: auto; overflow-y: hidden; scroll-snap-type: x mandatory; scroll-padding-left: 1rem; scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch; scrollbar-width: none; -ms-overflow-style: none; justify-content: flex-start !important;
  }
  body .departments-carousel::-webkit-scrollbar { display: none; width: 0; height: 0; }
  body .departments-carousel::after { content: ""; flex: 0 0 .25rem; }
  body .department-card {
    --dept-w: clamp(130px, calc((100vw - 2rem - 1.5rem) / 2.5), 150px);
    flex: 0 0 var(--dept-w) !important; width: var(--dept-w) !important; min-width: var(--dept-w) !important; max-width: var(--dept-w) !important; box-sizing: border-box; scroll-snap-align: start;
    display: flex; flex-direction: column; align-items: center; gap: .55rem; padding: .85rem .6rem .8rem;
    background: #fff; border: 1px solid rgba(16,48,112,.12); border-radius: 18px; box-shadow: 0 4px 12px -10px rgba(7,29,52,.28);
  }
  body .department-card:hover, body .department-card:active { transform: none; box-shadow: 0 4px 12px -10px rgba(7,29,52,.28); border-color: rgba(16,48,112,.12); }
  body .department-card:active { border-color: #071d34; }
  body .department-image-container,
  body .department-card:hover .department-image-container,
  body .department-card:active .department-image-container {
    width: 100%; height: auto; aspect-ratio: 1 / 1; max-height: 112px; border: none; border-radius: 0; background: #fff !important; box-shadow: none; transform: none;
  }
  body .department-image { width: 100%; height: 100%; object-fit: contain; object-position: center; transform: none !important; }
  body .department-name {
    width: 100%; max-width: 100%; min-height: 2.5em; padding: 0; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
    text-align: center; font-size: .8rem; font-weight: 700; line-height: 1.25; letter-spacing: 0; color: #071d34; background: none !important;
  }

  /* ritmo vertical: banner → categorias → CTA → produtos */
  body .departments-cta { margin: .15rem 1rem 0; }
  body .departments-section { margin-bottom: 1.25rem; }
}

@media (max-width: 768px) {
  /* sem moldura dupla: a borda é só do card */
  body .department-card .department-image-container { border: 0 !important; box-shadow: none !important; background: #fff !important; border-radius: 0 !important; }
}

/* Rolagem: carrosséis aceitam arrasto horizontal E deixam o gesto vertical rolar a página
   (home-mobile-fluid.css fixava touch-action: pan-x e travava a rolagem vertical sobre as categorias) */
@media (max-width: 768px) {
  body .departments-carousel, body.home-page .departments-carousel,
  body .departments-carousel .department-card, body .products-carousel { touch-action: pan-x pan-y !important; }
  body .departments-carousel { overscroll-behavior-x: contain; overscroll-behavior-y: auto; }
}

/* ── Busca premium (cabeçalho mobile) ── */
@media (max-width: 768px) {
  body .search-bar-mobile { padding: .6rem 1rem .9rem !important; }
  body .search-bar-mobile .search-input-wrapper {
    height: 54px; border-radius: 18px !important; background: #fff !important; border: 1px solid rgba(255,255,255,.55) !important;
    box-shadow: 0 10px 24px -14px rgba(0,0,0,.65), 0 0 0 3px rgba(255,255,255,.07);
  }
  body .search-bar-mobile .search-bar-inner { height: 100%; align-items: center; padding: 5px; box-sizing: border-box; gap: 0; border-radius: 18px; }
  body .search-bar-mobile #searchInputMobile {
    height: 100%; padding: 0 .5rem 0 2.6rem !important; font-size: .95rem !important; font-weight: 500; color: #16181d; border-radius: 0 !important; background: transparent
      url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%23071d34' stroke-width='1.8' stroke-linecap='round' stroke-linejoin='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cpath d='m21 21-4.3-4.3'/%3E%3C/svg%3E")
      no-repeat .7rem center / 20px 20px;
  }
  body .search-bar-mobile #searchInputMobile::placeholder { color: #7b8494; font-weight: 500; font-size: .88rem; text-overflow: ellipsis; }
  body .search-bar-mobile .search-btn-mobile {
    flex: 0 0 44px; width: 44px !important; min-width: 44px !important; height: 44px !important; border-radius: 14px !important; margin: 0;
    background: linear-gradient(135deg, #f2d594 0%, #d9a548 100%) !important; color: #071d34 !important; box-shadow: 0 6px 14px -8px rgba(217,165,72,.9);
  }
}

/* busca mobile — acabamento: placeholder menor, botão realmente dentro da pílula */
@media (max-width: 768px) {
  body .search-bar-mobile .search-input-wrapper { height: 50px; border-radius: 16px !important; }
  body .search-bar-mobile .search-bar-inner { padding: 0 !important; border-radius: 16px; overflow: hidden; }
  body .search-bar-mobile #searchInputMobile { padding: 0 .5rem 0 2.5rem !important; font-size: .84rem !important; background-position: .8rem center; background-size: 18px 18px; }
  body .search-bar-mobile #searchInputMobile::placeholder { font-size: .8rem !important; font-weight: 500; color: #8a93a3; }
  body .search-bar-mobile .search-btn-mobile {
    flex: 0 0 40px; width: 40px !important; min-width: 40px !important; height: 40px !important; margin: 0 5px 0 0 !important; padding: 0 !important;
    border-radius: 12px !important; align-self: center; font-size: .9rem; box-shadow: 0 4px 10px -6px rgba(217,165,72,.9);
  }
}
