/* Excelência mobile Wevex OS — 320 / 360 / 390 / 430 px
   Escopos: cardápio público, sacola, checkout, confirmação, tracking,
   Clube, auth/onboarding e prévia mobile de Aparência.
   Não altera regras comerciais nem dados de tenant. */

:root {
  --wx-touch: 44px;
  --wx-gutter-phone: max(12px, env(safe-area-inset-left, 0px), env(safe-area-inset-right, 0px));
  --wx-safe-bottom: env(safe-area-inset-bottom, 0px);
  --wx-safe-top: env(safe-area-inset-top, 0px);
}

html {
  -webkit-text-size-adjust: 100%;
  text-size-adjust: 100%;
}

/* —— Base anti-overflow (públicas + auth) —— */
body.wx-public,
body.wx-auth,
body.wx-club-safe,
body.wx-order-track,
body.wx-onboarding {
  overflow-x: clip;
  max-width: 100%;
}

body.wx-public *,
body.wx-auth *,
body.wx-club-safe *,
body.wx-order-track *,
body.wx-onboarding * {
  box-sizing: border-box;
}

body.wx-public img,
body.wx-public video,
body.wx-public canvas,
body.wx-public svg,
body.wx-club-safe img,
body.wx-order-track img {
  max-width: 100%;
  height: auto;
}

/* Drawers: evitar unidade de viewport total (gera rolagem horizontal com scrollbar) */
body.wx-public .drawer-panel,
body.wx-public .checkout-panel,
body.wx-public .order-confirm-panel {
  width: 100% !important;
  max-width: 100% !important;
  margin-inline: 0;
}

/* Teclado / sticky: reserva espaço para CTAs e inputs visíveis */
body.wx-public .checkout-form-layout input,
body.wx-public .checkout-form-layout select,
body.wx-public .checkout-form-layout textarea,
body.wx-auth .wx-field input,
body.wx-auth .wx-field select,
body.wx-auth .wx-field textarea,
body.wx-club-safe input,
body.wx-club-safe select,
body.wx-club-safe textarea {
  scroll-margin-bottom: calc(96px + var(--wx-safe-bottom));
  scroll-margin-top: calc(72px + var(--wx-safe-top));
}

/* —— Touch targets mínimos (AA + 44px) —— */
@media (max-width: 767px) {
  body.wx-public .btn,
  body.wx-public button.btn,
  body.wx-public a.btn,
  body.wx-public .add-btn,
  body.wx-public .cart-edit-button,
  body.wx-public .cart-remove-button,
  body.wx-public .cartbar button,
  body.wx-public .cart-fab,
  body.wx-public [data-add],
  body.wx-public [data-open-checkout],
  body.wx-public .menu-hero-cta .btn,
  body.wx-public .product-drawer-options .choice,
  body.wx-public .checkout-section .btn,
  body.wx-public .order-confirm-actions .btn,
  body.wx-public .menu-search-clear,
  body.wx-public .menu-hero button,
  body.wx-public .menu-hero [data-search],
  body.wx-club-safe .btn,
  body.wx-club-safe a.btn,
  body.wx-club-safe button.btn,
  body.wx-order-track .tracking-actions .btn,
  body.wx-auth .wx-btn,
  body.wx-onboarding .wx-btn,
  body.wx-onboarding .wx-onboarding-submit {
    min-height: var(--wx-touch);
    min-width: var(--wx-touch);
  }

  body.wx-public .add-btn,
  body.wx-public .menu-main .add-btn,
  body.wx-public .menu-rail .add-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: var(--wx-touch);
    min-width: var(--wx-touch);
    padding: 0.55rem 0.85rem;
  }

  body.wx-public .cart-edit-button,
  body.wx-public .cart-remove-button {
    padding: 10px 14px;
  }

  body.wx-auth .wx-field input,
  body.wx-auth .wx-field select,
  body.wx-auth .wx-field textarea,
  body.wx-public .checkout-form-layout input,
  body.wx-public .checkout-form-layout select,
  body.wx-public .checkout-form-layout textarea {
    min-height: var(--wx-touch);
    font-size: 16px; /* evita zoom iOS */
  }

  /* Footer Wevex: legível e discreto */
  body.wx-public .public-footer {
    gap: 0.2rem;
    padding: 0.75rem 0 calc(0.75rem + var(--wx-safe-bottom));
  }

  body.wx-public .public-footer-wevex,
  body.wx-public .public-footer-brand small,
  body.wx-public .public-footer a {
    font-size: 0.78rem;
    line-height: 1.45;
    color: var(--store-muted);
  }

  body.wx-public .public-footer-wevex img {
    width: 18px;
    height: 18px;
  }

  /* Checkout address grids empilham */
  body.wx-public .checkout-address-grid {
    grid-template-columns: 1fr !important;
  }

  body.wx-public .checkout-form-layout,
  body.wx-public .checkout-main,
  body.wx-public .checkout-aside {
    min-width: 0;
    max-width: 100%;
  }

  body.wx-public .checkout-steps {
    display: flex;
    flex-wrap: wrap;
    gap: 0.35rem;
    font-size: 0.72rem;
  }

  /* Sacola / cartbar */
  body.wx-public .cartbar,
  body.wx-public [data-cartbar] {
    left: max(8px, env(safe-area-inset-left, 0px));
    right: max(8px, env(safe-area-inset-right, 0px));
    width: auto;
    max-width: calc(100% - 16px);
    bottom: calc(10px + var(--wx-safe-bottom));
    padding: 0.65rem 0.75rem;
    gap: 0.5rem;
  }

  body.wx-public .cart-fab {
    right: max(12px, env(safe-area-inset-right, 0px));
    bottom: calc(16px + var(--wx-safe-bottom));
  }

  /* —— Catálogo: cards compactos horizontais (vence storefront-next 4:3) —— */
  body.wx-public .menu-main .product-grid {
    grid-template-columns: 1fr !important;
    gap: 0.65rem !important;
  }

  body.wx-public .menu-main .product-card {
    display: grid !important;
    grid-template-columns: 88px minmax(0, 1fr) !important;
    grid-template-rows: auto !important;
    align-items: stretch;
    gap: 0.65rem !important;
    padding: 0.65rem !important;
    min-height: 0 !important;
    width: 100%;
  }

  body.wx-public .menu-main .product-card .product-media {
    width: 88px !important;
    height: 88px !important;
    min-width: 88px !important;
    min-height: 88px !important;
    max-width: 88px !important;
    max-height: 88px !important;
    aspect-ratio: 1 / 1 !important;
    border-radius: 12px;
    overflow: hidden;
    flex: none !important;
  }

  body.wx-public .menu-main .product-card .product-media img,
  body.wx-public .menu-main .product-card .product-media-img {
    width: 100% !important;
    height: 100% !important;
    max-height: none !important;
    object-fit: cover;
  }

  body.wx-public .menu-main .product-card .product-body {
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    gap: 0.35rem;
    min-width: 0;
    min-height: 0 !important;
    padding: 0 !important;
  }

  body.wx-public .menu-main .product-card .product-copy {
    min-height: 0 !important;
  }

  body.wx-public .menu-main .product-card h3 {
    font-size: 0.95rem;
    line-height: 1.25;
    margin: 0;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
  }

  body.wx-public .menu-main .product-card .product-desc {
    font-size: 0.78rem;
    line-height: 1.35;
    margin: 0.15rem 0 0;
    min-height: 0 !important;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
    overflow: hidden;
  }

  body.wx-public .menu-main .product-card .product-sizes {
    margin: 0.2rem 0 0;
    font-size: 0.68rem;
    line-height: 1.2;
    opacity: 0.78;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  body.wx-public .menu-main .product-card .product-meta {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.5rem;
    margin-top: auto;
  }

  body.wx-public .menu-main .product-card .price-pill {
    display: flex;
    flex-direction: column;
    gap: 0.05rem;
    min-width: 0;
  }

  body.wx-public .menu-main .product-card .price-pill small {
    font-size: 0.65rem;
    line-height: 1.1;
    opacity: 0.72;
  }

  body.wx-public .menu-main .product-card .price-pill b {
    font-size: 0.92rem;
    white-space: nowrap;
  }

  body.wx-public .menu-main .product-card .badge {
    top: 0.35rem;
    left: 0.35rem;
    font-size: 0.62rem;
    padding: 0.15rem 0.4rem;
    z-index: 2;
  }

  body.wx-public .menu-main .product-card .add-btn {
    flex: none;
    width: 42px !important;
    height: 42px !important;
    min-width: 42px !important;
    min-height: 42px !important;
    padding: 0 !important;
    border-radius: 999px;
  }

  body.wx-public .menu-main .product-card .add-btn > span {
    position: absolute !important;
    width: 1px !important;
    height: 1px !important;
    overflow: hidden !important;
    clip: rect(0, 0, 0, 0) !important;
  }

  body.wx-public .menu-main .product-card .add-btn svg {
    display: block;
    width: 18px;
    height: 18px;
  }

  /* Destaques: trilho compacto */
  body.wx-public .menu-rail-track {
    grid-auto-columns: minmax(148px, 68vw) !important;
    gap: 0.65rem !important;
  }

  body.wx-public .menu-rail .product-card {
    display: flex !important;
    flex-direction: column !important;
    width: 100% !important;
    max-width: 180px;
    padding: 0.55rem !important;
    gap: 0.45rem !important;
  }

  body.wx-public .menu-rail .product-media {
    width: 100% !important;
    height: auto !important;
    min-height: 0 !important;
    max-height: var(--wx-product-media-max-sm, 8.75rem) !important;
    aspect-ratio: 16 / 10 !important;
    border-radius: 10px;
  }

  body.wx-public .menu-rail .product-body {
    min-height: 0 !important;
  }

  body.wx-public .menu-rail .product-copy {
    min-height: 0 !important;
  }

  body.wx-public .menu-rail .product-desc {
    display: none !important;
  }

  /* Busca / hero / banner */
  body.wx-public .menu-hero {
    gap: 0.75rem;
    padding-block: 0.85rem;
  }

  body.wx-public .menu-hero-logo,
  body.wx-public .menu-hero-logo-fallback {
    width: 72px !important;
    height: 72px !important;
  }

  body.wx-public .menu-search,
  body.wx-public [data-search] {
    min-height: var(--wx-touch);
  }

  body.wx-public .store-campaign {
    max-height: 140px;
    overflow: hidden;
  }

  body.wx-public .store-campaign img {
    max-height: 140px;
    width: 100%;
    object-fit: cover;
  }

  body.wx-public .menu-cats,
  body.wx-public .menu-categories {
    gap: 0.4rem;
  }

  /* Produtos: texto/preço sem overflow */
  body.wx-public .product-card,
  body.wx-public .menu-main .product-card {
    min-width: 0;
    overflow: hidden;
  }

  body.wx-public .product-card strong,
  body.wx-public .product-card .product-name,
  body.wx-public .product-card .price,
  body.wx-public .product-card .product-price {
    overflow-wrap: anywhere;
    word-break: break-word;
  }

  body.wx-public .product-card .price,
  body.wx-public .product-card .product-price {
    white-space: nowrap;
  }

  body.wx-public .menu-hero h1,
  body.wx-public .menu-store-meta,
  body.wx-public .product-desc {
    overflow-wrap: anywhere;
  }

  body.wx-public .menu-store-meta {
    flex-wrap: wrap;
    white-space: normal;
  }

  /* Confirmação */
  body.wx-public .order-confirm-sheet {
    padding: max(8px, env(safe-area-inset-left, 0px))
      max(8px, env(safe-area-inset-right, 0px))
      max(8px, var(--wx-safe-bottom));
    align-items: flex-end;
  }

  body.wx-public .order-confirm-panel {
    max-height: min(92dvh, 920px);
    overflow-y: auto;
    padding-bottom: calc(1rem + var(--wx-safe-bottom));
  }

  /* Clube */
  body.wx-club-safe .club-page {
    width: min(100% - 20px, 920px);
    margin: 14px auto calc(36px + var(--wx-safe-bottom));
  }

  body.wx-club-safe .club-hero,
  body.wx-club-safe .club-card {
    padding: 1.1rem 1rem;
    border-radius: 16px;
  }

  body.wx-club-safe .club-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  body.wx-club-safe .club-actions .btn {
    width: 100%;
  }

  /* Tracking */
  body.wx-order-track .tracking-page {
    width: min(100% - 20px, 880px);
    margin: 14px auto calc(40px + var(--wx-safe-bottom));
  }

  body.wx-order-track .tracking-hero h1 {
    font-size: clamp(1.45rem, 7vw, 2rem);
  }

  body.wx-order-track .tracking-actions {
    display: grid;
    grid-template-columns: 1fr;
  }

  /* Auth / onboarding */
  body.wx-auth .wx-auth-shell {
    width: min(calc(100% - 1rem), 440px);
    padding: calc(0.85rem + var(--wx-safe-top)) 0 calc(1.5rem + var(--wx-safe-bottom));
  }

  body.wx-auth.wx-onboarding--plan .wx-auth-shell {
    width: min(calc(100% - 1rem), 1120px);
  }

  body.wx-auth .wx-auth-card {
    padding: 1.15rem;
  }

  body.wx-auth .wx-btn-row {
    flex-direction: column;
  }

  body.wx-auth .wx-btn-row .wx-btn {
    width: 100%;
  }

  body.wx-onboarding .wx-plan-grid {
    grid-template-columns: 1fr;
  }

  body.wx-onboarding .wx-plan-card__amount,
  body.wx-onboarding .wx-plan-card__period,
  body.wx-onboarding .wx-plan-card__badge {
    white-space: nowrap;
  }
}

/* —— Breakpoints finos (mesma especificidade do bloco 767) —— */
@media (max-width: 430px) {
  body.wx-public .menu-main .product-card {
    grid-template-columns: 84px minmax(0, 1fr) !important;
    gap: 0.6rem !important;
  }

  body.wx-public .menu-main .product-card .product-media {
    width: 84px !important;
    height: 84px !important;
    min-width: 84px !important;
    min-height: 84px !important;
    max-width: 84px !important;
    max-height: 84px !important;
  }

  body.wx-public .menu-hero h1 {
    font-size: clamp(1.45rem, 7.2vw, 1.85rem);
  }
}

@media (max-width: 390px) {
  body.wx-public .menu-main .product-card {
    grid-template-columns: 80px minmax(0, 1fr) !important;
  }

  body.wx-public .menu-main .product-card .product-media {
    width: 80px !important;
    height: 80px !important;
    min-width: 80px !important;
    min-height: 80px !important;
    max-width: 80px !important;
    max-height: 80px !important;
  }
}

@media (max-width: 360px) {
  body.wx-public .menu-layout {
    padding-inline: 12px;
  }

  body.wx-public .menu-main .product-card {
    grid-template-columns: 76px minmax(0, 1fr) !important;
    gap: 0.55rem !important;
    padding: 0.55rem !important;
  }

  body.wx-public .menu-main .product-card .product-media {
    width: 76px !important;
    height: 76px !important;
    min-width: 76px !important;
    min-height: 76px !important;
    max-width: 76px !important;
    max-height: 76px !important;
  }

  body.wx-public .cartbar {
    padding: 0.5rem 0.55rem;
  }

  body.wx-club-safe .club-hero h1,
  body.wx-club-safe .club-card h1 {
    font-size: clamp(1.35rem, 8vw, 1.75rem);
  }
}

@media (max-width: 320px) {
  body.wx-public .menu-layout {
    padding-inline: 10px;
  }

  body.wx-public .menu-main .product-card {
    grid-template-columns: 72px minmax(0, 1fr) !important;
  }

  body.wx-public .menu-main .product-card .product-media {
    width: 72px !important;
    height: 72px !important;
    min-width: 72px !important;
    min-height: 72px !important;
    max-width: 72px !important;
    max-height: 72px !important;
  }

  body.wx-public .menu-hero-logo,
  body.wx-public .menu-hero-logo-fallback {
    width: 64px !important;
    height: 64px !important;
  }

  body.wx-public .btn,
  body.wx-public .add-btn {
    font-size: 0.88rem;
  }

  body.wx-auth .wx-auth-shell {
    width: min(calc(100% - 0.75rem), 440px);
  }
}

/* —— Aparência: painel Wevex fixo; tenant só na prévia —— */
@media (max-width: 767px) {
  .wx-panel-wevex {
    overflow-x: clip;
    max-width: 100%;
  }

  .wx-panel-wevex .wx-appear-layout,
  .wx-panel-wevex .wx-appear-card,
  .wx-panel-wevex .wx-appear-preview-shell {
    min-width: 0;
    max-width: 100%;
  }

  .wx-panel-wevex .wx-appear-actions .btn {
    min-height: var(--wx-touch);
    width: 100%;
    justify-content: center;
  }

  .wx-panel-wevex .wx-appear-preview[data-preview-stage="mobile"] {
    width: min(100%, 320px);
    margin-inline: auto;
  }

  .wx-panel-wevex .wx-tenant-preview {
    overflow: hidden;
  }

  .wx-panel-wevex .wx-appear-preview__brand,
  .wx-panel-wevex .wx-appear-preview__cards,
  .wx-panel-wevex .wx-appear-preview__rail {
    min-width: 0;
  }

  .wx-panel-wevex .wx-appear-preview__cards article b,
  .wx-panel-wevex .wx-appear-preview__brand strong {
    overflow-wrap: anywhere;
  }
}

/* Polimento pré-produção: hierarquia do catálogo sem alterar sua lógica. */
@media (max-width: 767px) {
  body.wx-public .menu-sidebar a {
    min-height: var(--wx-touch);
  }

  body.wx-public .menu-sidebar a[data-cat-link="active"] {
    box-shadow: 0 4px 14px color-mix(in srgb, var(--brand-accent) 16%, transparent);
  }

  body.wx-public .menu-main .product-card h3 {
    font-size: 1rem;
    line-height: 1.28;
  }

  body.wx-public .menu-main .product-card .product-sizes {
    font-size: 0.72rem;
    line-height: 1.3;
  }

  body.wx-public .menu-main .product-card .add-btn {
    width: var(--wx-touch) !important;
    height: var(--wx-touch) !important;
    min-width: var(--wx-touch) !important;
    min-height: var(--wx-touch) !important;
  }
}

@media (prefers-reduced-motion: reduce) {
  body.wx-public .product-card,
  body.wx-public .cartbar,
  body.wx-onboarding .wx-plan-card {
    transition: none !important;
  }
}
