/* assets/css/catalogo.css — Public catalog styles v7 — M3 tokens + Mobile-first + Edge Arrows */

:root {
    --catalogo-bg: #FFFFFF;
    --catalogo-text: #000000;
    --catalogo-accent: #FFD400;
    /* M3 — cor de conteúdo sobre o acento (temas podem sobrescrever via --catalogo-on-accent) */
    --catalogo-on-accent: #3b2f00;
    --safe-top: env(safe-area-inset-top, 0px);
    --safe-bottom: env(safe-area-inset-bottom, 0px);

    /* ══ M3 Shape scale ══ */
    --m3-shape-xs: 8px;
    --m3-shape-sm: 12px;
    --m3-shape-md: 16px;
    --m3-shape-lg: 28px;
    --m3-shape-full: 999px;

    /* ══ M3 Elevation ══ */
    --m3-elev-2: 0 1px 2px rgba(0,0,0,0.3), 0 2px 6px rgba(0,0,0,0.15);
    --m3-elev-3: 0 4px 8px rgba(0,0,0,0.3), 0 6px 20px rgba(0,0,0,0.15);

    /* ══ M3 Touch targets (WCAG ≥ 44px; M3 ≥ 48px) ══ */
    --m3-touch: 44px;
    --m3-touch-lg: 48px;

    /* ══ M3 State layers ══ */
    --m3-state-hover: 0.08;
    --m3-state-focus: 0.12;
    --m3-state-pressed: 0.12;

    /* ══ M3 Motion ══ */
    --m3-dur-2: 150ms;
    --m3-dur-3: 250ms;
    --m3-dur-4: 350ms;
    --m3-ease-standard: cubic-bezier(0.2, 0, 0, 1);
    --m3-ease-emphasized: cubic-bezier(0.2, 0, 0, 1);

    /* Hotspot sizing — JS sets --hs-inv to the inverse of the zoom level,
       so hotspots keep a constant on-screen size while the page is zoomed */
    --hotspot-size: 26px;
    --hotspot-font: 15px;
    --hs-inv: 1;
}

* { margin: 0; padding: 0; box-sizing: border-box; }
html { height: 100%; -webkit-text-size-adjust: 100%; }
.material-symbols-outlined { user-select: none; }
body {
    font-family: 'Inter', sans-serif;
    background: var(--catalogo-bg);
    color: var(--catalogo-text);
    height: 100%;
    overflow: hidden;
    position: fixed;          /* prevents iOS rubber-band scroll */
    width: 100%;
    top: 0; left: 0;
}

/* Foco visível (teclado) — amarelo da identidade (contraste reforçado) */
:focus-visible {
    outline: 3px solid var(--catalogo-accent);
    outline-offset: 2px;
    box-shadow: 0 0 0 6px rgba(255, 212, 0, 0.35);
}

/* Respeita usuários que reduzem movimento */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        transition: none !important;
        animation: none !important;
    }
}

/* ══════════════════════════════════════
   PDF Fullscreen Container
   ══════════════════════════════════════ */
.pdf-fullscreen {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
    padding: 8px;
    /* Account for safe areas on notched phones */
    padding-top: calc(8px + var(--safe-top));
    padding-bottom: calc(8px + var(--safe-bottom));
}

/* Wrapper = exactly the size of the rendered canvas, centered */
.pdf-wrapper {
    position: relative;
    display: inline-block;
    line-height: 0;
    flex-shrink: 0;
    /* Never exceed the viewport */
    max-width: 100%;
    max-height: 100%;
}

.pdf-wrapper canvas {
    display: block;
    /* Constrain to viewport — JS picks the best scale within these */
    max-width: 100%;
    max-height: 100%;
}

/* Hotspot layer = same exact size as canvas via inset:0 */
.hotspots-layer {
    position: absolute;
    top: 0; left: 0; right: 0; bottom: 0;
    pointer-events: none;
    overflow: hidden;
}

/* Hotspot — área de toque ampliada (≥44px tátil) sem mudar o visual.
   O tamanho é fixo na TELA: o JS define --hs-inv (inverso do zoom),
   então os botões não crescem junto com a página ampliada. */
.hotspot {
    pointer-events: auto;
    position: absolute;
    width: var(--hotspot-size); height: var(--hotspot-size);
    background: var(--catalogo-accent);
    border-radius: 50%;
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    font-size: var(--hotspot-font); font-weight: 800; color: var(--catalogo-on-accent);
    box-shadow: 0 2px 12px rgba(0,0,0,0.2);
    transform: translate(-50%, -50%) scale(var(--hs-inv, 1));
    z-index: 10;
    transition: box-shadow 0.15s;
    -webkit-tap-highlight-color: transparent;
}
.hotspot .material-symbols-outlined {
    font-size: var(--hotspot-font);
    pointer-events: none;
}
/* Área de toque ampliada: constante NA TELA mesmo com zoom
   (o ::after é escalado por --hs-inv, então dividimos por ele) */
.hotspot::after {
    content: "";
    position: absolute;
    inset: calc(-10px / var(--hs-inv, 1));
    border-radius: 50%;
}
.hotspot:focus-visible {
    outline: 2px solid var(--catalogo-accent);
    outline-offset: 2px;
    box-shadow: 0 0 0 4px rgba(255, 212, 0, 0.4);
}
.hotspot:active {
    transform: translate(-50%, -50%) scale(calc(1.25 * var(--hs-inv, 1)));
}
.hotspot.search-match {
    animation: hotspot-pulse 1s ease-in-out 3;
    box-shadow: 0 0 0 4px rgba(255,212,0,0.5), 0 2px 12px rgba(0,0,0,0.2);
}

/* Hotspot com label (pill de texto em vez do ícone +) */
.hotspot.hotspot-has-label {
    border-radius: 999px;
    padding: 0 12px;
    width: auto;
    min-width: var(--hotspot-size);
    height: calc(var(--hotspot-size) * 0.8);
    box-sizing: border-box;
}
.hotspot-label {
    font-size: 11px;
    font-weight: 700;
    color: var(--catalogo-on-accent);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 140px;
    display: block;
    line-height: 1;
}

@keyframes hotspot-pulse {
    0%, 100% { transform: translate(-50%, -50%) scale(var(--hs-inv, 1)); }
    50% { transform: translate(-50%, -50%) scale(calc(1.35 * var(--hs-inv, 1))); }
}

/* ══════════════════════════════════════
   Floating UI Elements
   ══════════════════════════════════════ */

/* ── Toolbar (top-right) ── */
.floating-toolbar {
    position: fixed;
    top: calc(10px + var(--safe-top));
    right: 10px;
    z-index: 90;
    display: flex; align-items: center; gap: 8px;
    /* O gap colapsa junto com os botões na recolhida, senão sobraria espaço
       morto entre o carrinho e o canto */
    transition: gap var(--m3-dur-4) var(--m3-ease-standard);
}
/* Botão de ícone M3: alvo ≥ 44px, feedback por state layer (sem shift de layout) */
.toolbar-btn {
    width: var(--m3-touch); height: var(--m3-touch);
    border-radius: var(--m3-shape-full); border: none;
    background: rgba(255,255,255,0.85);
    color: var(--catalogo-text);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    position: relative;
    box-shadow: var(--m3-elev-2);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    /* opacity/transform/width participam do recolhimento da toolbar
       (body.chrome-hidden). A tab order da recolhida é feita com o
       atributo `inert`, em catalogo.js — não com transition de visibility. */
    transition: background-color var(--m3-dur-2) var(--m3-ease-standard),
                box-shadow var(--m3-dur-2) var(--m3-ease-standard),
                opacity var(--m3-dur-4) var(--m3-ease-standard),
                transform var(--m3-dur-4) var(--m3-ease-standard),
                width var(--m3-dur-4) var(--m3-ease-standard);
}
.toolbar-btn:hover { background: rgba(255,255,255,0.94); }
.toolbar-btn:hover::before,
.toolbar-btn:active::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: currentColor;
    opacity: var(--m3-state-hover);
    pointer-events: none;
}
.toolbar-btn:active::before { opacity: var(--m3-state-pressed); }
.toolbar-btn:focus-visible {
    outline: 3px solid var(--catalogo-accent);
    outline-offset: 2px;
}
.toolbar-btn .material-symbols-outlined { font-size: 24px; }
/* Toggle de hotspots: botão fica destacado enquanto os botões estão ocultos */
.toolbar-btn.is-off { background: var(--catalogo-accent); color: var(--catalogo-on-accent); }
.toolbar-btn.is-off::before { opacity: 0 !important; }

/* Modo "catálogo limpo": esconde todas as camadas de hotspots (classe no body,
   sobrevive à recriação da camada a cada página no modo imagens) */
body.hs-hidden .hotspots-layer { display: none !important; }

.toolbar-client {
    width: 36px; height: 36px; border-radius: 50%;
    background: var(--catalogo-accent); color: var(--catalogo-on-accent);
    display: flex; align-items: center; justify-content: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.12);
    /* Colapsa junto com os botões na recolhida (body.chrome-hidden) */
    transition: opacity var(--m3-dur-4) var(--m3-ease-standard),
                transform var(--m3-dur-4) var(--m3-ease-standard),
                width var(--m3-dur-4) var(--m3-ease-standard);
}

/* Contador do carrinho (badge sobre o #cartFab da toolbar) */
.cart-count {
    position: absolute; top: -4px; right: -4px;
    background: #FF5B5B; color: #fff;
    font-size: 11px; font-weight: 700;
    min-width: 20px; height: 20px;
    border-radius: 10px; padding: 0 5px;
    display: flex; align-items: center; justify-content: center;
}

/* ── Trilho inferior + DUAS pílulas flutuantes ──
   O trilho (.bottom-bar) é transparente e ocupa a largura toda, com
   pointer-events:none — só as pílulas capturam toque, então a página
   continua swipável entre elas.

   Duas pílulas separadas, e não uma larga: 5 botões (2 de página + 3 de
   zoom) + 2 chips numa pílula única estouravam max-width em telas de
   320–380px, e como .bar-btn não tem min-width, o flex encolhia SÓ a
   largura (a altura ficava em 44px) — os botões viravam ovais.

   O trilho some sozinho quando ocioso (body.chrome-hidden), voltando ao
   primeiro toque/movimento. */
.bottom-bar {
    position: fixed;
    bottom: calc(14px + var(--safe-bottom));
    left: 12px;
    right: 12px;
    z-index: 80;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    pointer-events: none;
    opacity: 1;
    transition: opacity var(--m3-dur-4) var(--m3-ease-standard),
                transform var(--m3-dur-4) var(--m3-ease-standard);
}
.bottom-bar-pages,
.bottom-bar-zoom {
    display: flex; align-items: center; gap: 3px;
    /* Nunca deixa o grupo encolher: encolher deformaria os botões */
    flex-shrink: 0;
    padding: 5px 8px;
    border-radius: var(--m3-shape-full);
    background: rgba(255,255,255,0.72);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: var(--m3-elev-2);
    pointer-events: auto;
}

/* Botão de ícone unificado (M3): alvo 44px, state layer no hover/active.
   State layer em vez de troca de background evita shift de layout. */
.bar-btn {
    width: var(--m3-touch); height: var(--m3-touch);
    flex-shrink: 0;
    border-radius: var(--m3-shape-full); border: none;
    background: transparent;
    color: var(--catalogo-text);
    cursor: pointer;
    display: flex; align-items: center; justify-content: center;
    padding: 0;
    position: relative;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    transition: background-color var(--m3-dur-2) var(--m3-ease-standard);
}
.bar-btn::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: currentColor;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--m3-dur-2) var(--m3-ease-standard);
}
.bar-btn:hover::before { opacity: var(--m3-state-hover); }
.bar-btn:active::before { opacity: var(--m3-state-pressed); }
.bar-btn:disabled { opacity: 0.3; pointer-events: none; }
.bar-btn svg { pointer-events: none; }

/* ── Page counter ── */
.page-counter {
    color: var(--catalogo-text);
    padding: 5px 12px; border-radius: var(--m3-shape-full);
    font-size: 12px; font-weight: 600;
    min-width: 48px; text-align: center;
    flex-shrink: 0;
    pointer-events: none; user-select: none;
    white-space: nowrap;
}

/* ── Zoom indicator ── */
.zoom-indicator {
    background: var(--catalogo-accent);
    color: var(--catalogo-on-accent);
    padding: 5px 12px; border-radius: var(--m3-shape-full);
    font-size: 12px; font-weight: 700;
    min-width: 48px; text-align: center;
    flex-shrink: 0;
    user-select: none;
    white-space: nowrap;
}

@media (max-width: 400px) {
    .bottom-bar { gap: 6px; }
    .bottom-bar-pages, .bottom-bar-zoom { gap: 2px; padding: 4px 6px; }
    .page-counter { font-size: 11px; padding: 4px 6px; min-width: 40px; }
    .zoom-indicator { font-size: 11px; padding: 4px 6px; min-width: 38px; }
}

/* Telas estreitas: o cluster de zoom perde o botão de reset — o duplo-toque
   já reseta (ver catalogo.js, tapCount === 2) — para as DUAS pílulas caberem
   numa linha só. Medido: pílula de páginas ~152px + pílula de zoom ~146px +
   gap 8px ≈ 306px, contra 296px disponíveis a 320px de largura. */
@media (max-width: 430px) {
    .bottom-bar-zoom #zoomReset { display: none; }
}

/* Ainda mais estreito (iPhone SE 1ª geração, Galaxy Fold fechado, ~320px):
   as pílulas empilham em duas linhas centralizadas. Preferível a espremer
   os botões — o alvo de 44px é requisito de WCAG/M3 e vale mais. */
@media (max-width: 345px) {
    .bottom-bar { flex-wrap: wrap; justify-content: center; row-gap: 8px; }
}

@media (max-height: 500px) and (orientation: landscape) {
    .bottom-bar { gap: 6px; bottom: calc(6px + var(--safe-bottom)); }
    .bottom-bar-pages, .bottom-bar-zoom { gap: 2px; padding: 3px 6px; }
    .page-counter { font-size: 11px; padding: 3px 6px; min-width: 40px; }
    .zoom-indicator { font-size: 11px; padding: 3px 6px; min-width: 38px; }
}

/* ── Auto-hide: o chrome some quando ocioso, sem display:none (sem reflow).
   Na toolbar a opacidade sozinha não bastava: os botões colapsam de fato
   (width+gap → 0) para o carrinho fechar no canto sem espaço morto ao lado.
   Só o #cartFab fica visível — busca, compartilhamento e hide-hotspots
   voltam ao primeiro toque/movimento (gatilhos em catalogo.js). */
body.chrome-hidden .bottom-bar {
    opacity: 0;
    transform: translateY(12px);
    pointer-events: none;
}

/* ── Barra inferior oculta para o cliente (2026-10-07) ──
   Contador de página, botões de paginação e cluster de zoom estavam
   sobrepostos ao conteúdo e atrapalhando a visualização do catálogo.
   display:none (não opacity) para nem capturar clique nem ocupar espaço.
   A navegação não quebra: no desktop seguem as setas .edge-nav nas
   bordas; no mobile o swipe; o zoom continua por pinça, roda do mouse,
   duplo-toque e teclado (+ - 0). Os handlers em catalogo.js toleram
   os elementos existirem e ficarem ocultos. */
.bottom-bar { display: none; }

/* Toolbar recolhida: permanece apenas o carrinho. Os hotspots mapeados NÃO
   entram nesta regra — continuam 100% visíveis e clicáveis.
   overflow:hidden fica só aqui (e não no .toolbar-btn) para não cortar o
   badge .cart-count, que é posicionado fora da caixa.
   A tab order do recolhido é garantida por `inert` (catalogo.js), não por
   transition de visibility — aqui só colapsa a caixa. */
body.chrome-hidden .floating-toolbar { gap: 0; }
body.chrome-hidden .toolbar-btn:not(#cartFab),
body.chrome-hidden .toolbar-client {
    width: 0;
    opacity: 0;
    transform: scale(0.7);
    overflow: hidden;
    pointer-events: none;
    transition: opacity var(--m3-dur-4) var(--m3-ease-standard),
                transform var(--m3-dur-4) var(--m3-ease-standard),
                width var(--m3-dur-4) var(--m3-ease-standard);
}

/* ── Setas de página nas bordas (desktop) ──
   Rail espelhando o trilho inferior: transparente e largo, só os botões
   capturam clique. Fica fora do fluxo no mobile (display:none) porque lá a
   navegação acontece na pílula da base; no desktop volta para as bordas,
   onde o polegar não disputa espaço com o conteúdo. */
.edge-nav { display: none; }
.edge-btn {
    width: 48px; height: 48px;
    flex-shrink: 0;
    border-radius: var(--m3-shape-full);
    border: none;
    background: rgba(255,255,255,0.72);
    backdrop-filter: blur(14px);
    -webkit-backdrop-filter: blur(14px);
    box-shadow: var(--m3-elev-2);
    color: var(--catalogo-text);
    cursor: pointer;
    /* O trilho .edge-nav é pointer-events:none (spanela larga, para não
       roubar o pan/swipe da página), então quem devolve a captura de clique
       é o botão — mesmo truque das pílulas .bottom-bar-pages. Sem esta
       linha as setas ficam visíveis e mortas no desktop, onde a pílula de
       baixo esconde os botões de página. */
    pointer-events: auto;
    display: flex; align-items: center; justify-content: center;
    padding: 0;
    position: relative;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    transition: background-color var(--m3-dur-2) var(--m3-ease-standard);
}
.edge-btn::before {
    content: "";
    position: absolute;
    inset: 0;
    border-radius: inherit;
    background: currentColor;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--m3-dur-2) var(--m3-ease-standard);
}
.edge-btn:hover::before { opacity: var(--m3-state-hover); }
.edge-btn:active::before { opacity: var(--m3-state-pressed); }
.edge-btn:disabled { opacity: 0.3; pointer-events: none; }
.edge-btn svg { pointer-events: none; }

/* ══════════════════════════════════════
   Search Overlay
   ══════════════════════════════════════ */
.search-overlay {
    position: fixed; inset: 0; z-index: 200;
    background: var(--catalogo-bg);
    display: none; flex-direction: column;
}
.search-overlay.open { display: flex; }
.search-overlay-bar {
    display: flex; align-items: center; gap: 8px;
    padding: calc(12px + var(--safe-top)) 16px 12px;
    border-bottom: 1px solid rgba(0,0,0,0.08);
}
.search-overlay-close {
    background: none; border: none; cursor: pointer; color: var(--catalogo-text);
    display: flex; align-items: center; justify-content: center;
    width: var(--m3-touch); height: var(--m3-touch); border-radius: var(--m3-shape-full); flex-shrink: 0;
    transition: background-color var(--m3-dur-2) var(--m3-ease-standard);
}
.search-overlay-close:hover { background: rgba(0,0,0,0.08); }
.search-overlay-close:active { background: rgba(0,0,0,0.12); }
.search-clear {
    background: none; border: none; cursor: pointer; color: var(--catalogo-text);
    display: flex; align-items: center; justify-content: center;
    width: var(--m3-touch); height: var(--m3-touch); border-radius: var(--m3-shape-full);
    flex-shrink: 0;
    transition: background-color var(--m3-dur-2) var(--m3-ease-standard);
}
.search-clear:hover { background: rgba(0,0,0,0.08); }
.search-overlay-input {
    flex: 1; border: none; background: none; font-size: 16px;
    font-family: inherit; outline: none; color: var(--catalogo-text);
}
.search-overlay-input::placeholder { color: rgba(0,0,0,0.3); }
.search-overlay-results { flex: 1; overflow-y: auto; padding: 0; -webkit-overflow-scrolling: touch; }
.search-result-item {
    display: flex; align-items: center; gap: 12px;
    padding: 14px 20px; cursor: pointer;
    border-bottom: 1px solid rgba(0,0,0,0.04);
    -webkit-tap-highlight-color: transparent;
}
.search-result-item:active { background: rgba(0,0,0,0.06); }
.search-result-page {
    font-size: 11px; font-weight: 700; color: var(--catalogo-accent);
    background: rgba(0,0,0,0.06); padding: 3px 10px; border-radius: 6px; white-space: nowrap;
}
.search-result-name { font-size: 15px; font-weight: 600; flex: 1; min-width: 0; }
.search-result-code { font-size: 12px; color: rgba(0,0,0,0.4); }
.search-result-arrow { font-size: 18px; color: rgba(0,0,0,0.2); flex-shrink: 0; }
.search-highlight { background: rgba(255,212,0,0.4); border-radius: 2px; padding: 0 2px; }
.search-empty { text-align: center; padding: 40px 20px; color: rgba(0,0,0,0.3); font-size: 14px; }

/* ══════════════════════════════════════
   Cart Panel
   ══════════════════════════════════════ */
.cart-panel {
    position: fixed; top: 0; right: min(-100%, -400px);
    width: 340px; max-width: 85vw;
    height: 100%; height: 100dvh;
    background: var(--catalogo-bg);
    box-shadow: -4px 0 24px rgba(0,0,0,0.15);
    z-index: 150;
    display: flex; flex-direction: column;
    transition: right var(--m3-dur-4) var(--m3-ease-emphasized);
}
.cart-panel.open { right: 0; }
.cart-header {
    padding: 16px; padding-top: calc(16px + var(--safe-top));
    border-bottom: 1px solid rgba(0,0,0,0.1);
    font-weight: 700;
    display: flex; align-items: center; justify-content: space-between;
}
.cart-close {
    background: none; border: none; cursor: pointer; color: var(--catalogo-text);
    display: flex; align-items: center; justify-content: center;
    width: var(--m3-touch); height: var(--m3-touch);
    border-radius: var(--m3-shape-full);
    transition: background-color var(--m3-dur-2) var(--m3-ease-standard);
}
.cart-close:hover { background: rgba(0,0,0,0.08); }
.cart-items { flex: 1; overflow-y: auto; padding: 8px 16px; -webkit-overflow-scrolling: touch; }
.cart-item { display: flex; align-items: center; gap: 12px; padding: 10px 0; border-bottom: 1px solid rgba(0,0,0,0.05); }
.cart-item-info { flex: 1; min-width: 0; }
.cart-item-name { font-size: 13px; font-weight: 600; }
.cart-item-price { font-size: 12px; color: rgba(0,0,0,0.5); }
.cart-item-remove {
    background: none; border: none; color: #FF5B5B; cursor: pointer;
    width: var(--m3-touch); height: var(--m3-touch);
    border-radius: var(--m3-shape-full);
    display: flex; align-items: center; justify-content: center;
    flex-shrink: 0;
    transition: background-color var(--m3-dur-2) var(--m3-ease-standard);
}
.cart-item-remove:hover { background: rgba(255, 91, 91, 0.12); }
.cart-item-remove .material-symbols-outlined { font-size: 20px; }
.cart-footer {
    padding: 16px; padding-bottom: calc(16px + var(--safe-bottom));
    border-top: 1px solid rgba(0,0,0,0.1);
}
.cart-total { font-size: 18px; font-weight: 800; margin-bottom: 12px; text-align: right; }
.btn-checkout {
    width: 100%; min-height: var(--m3-touch-lg); padding: 12px; background: #25D366; color: #fff;
    border: none; border-radius: var(--m3-shape-full); font-size: 14px; font-weight: 700;
    cursor: pointer; font-family: inherit;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    transition: filter var(--m3-dur-2) var(--m3-ease-standard), opacity var(--m3-dur-2) var(--m3-ease-standard);
}
.btn-checkout:hover { filter: brightness(1.06); }
.btn-checkout:active { background: #1da851; }

/* ══════════════════════════════════════
   Modals
   ══════════════════════════════════════ */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(0,0,0,0.6);
    z-index: 250; display: none; align-items: center; justify-content: center;
    padding: 16px;
}
.modal-overlay.open { display: flex; }
.modal {
    background: var(--catalogo-bg); border-radius: var(--m3-shape-md);
    width: 100%; max-width: 400px;
    padding: 24px 24px 28px;
    position: relative;
    max-height: 85vh; max-height: 85dvh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.modal-close {
    position: absolute; top: 8px; right: 8px;
    background: none; border: none;
    cursor: pointer; color: var(--catalogo-text);
    width: var(--m3-touch); height: var(--m3-touch);
    border-radius: var(--m3-shape-full);
    display: flex; align-items: center; justify-content: center;
    transition: background-color var(--m3-dur-2) var(--m3-ease-standard);
}
.modal-close:hover { background: rgba(0,0,0,0.08); }
.modal-close .material-symbols-outlined { font-size: 22px; }
/* Foto do produto ajustada ao quadro SEM cortar nem distorcer (object-fit: contain).
   Fundo neutro preenche a diferença de proporção entre foto e quadro. */
.modal-product-img { width: 100%; height: 200px; object-fit: contain; border-radius: 10px; margin-bottom: 16px; background: rgba(0,0,0,0.04); transition: opacity 0.3s ease; }
/* A foto do produto abre em tela cheia no tamanho original ao clique */
.modal-product-img.img-zoom { cursor: zoom-in; }

/* Visualizador de foto em tela cheia (tamanho original + zoom/scroll).
   Fica acima dos modais (z-index 250). */
.img-viewer {
    position: fixed; inset: 0; z-index: 400;
    display: none; background: rgba(0,0,0,0.92);
}
.img-viewer.open { display: block; }
.img-viewer-stage {
    position: absolute; inset: 0; overflow: auto;
    -webkit-overflow-scrolling: touch;
    touch-action: none;             /* rolagem e zoom controlados por JS */
    cursor: grab;
    display: flex;                  /* com margin:auto na imagem, o topo de fotos maiores não é cortado */
}
.img-viewer-stage.dragging { cursor: grabbing; }
.img-viewer-img {
    margin: auto; flex: 0 0 auto; display: block;
    max-width: none; max-height: none;   /* tamanho oficial, sem teto de layout */
    user-select: none; -webkit-user-drag: none;
}
.img-viewer-close {
    position: absolute; top: 12px; right: 12px; z-index: 2;
    width: 44px; height: 44px; border: none; border-radius: 50%;
    background: rgba(255,255,255,0.14); color: #fff; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.img-viewer-close:hover { background: rgba(255,255,255,0.26); }
.img-viewer-close .material-symbols-outlined { font-size: 24px; }
.img-viewer-hint {
    position: absolute; top: 18px; left: 16px; z-index: 2;
    color: rgba(255,255,255,0.7); font-size: 12px; line-height: 1.4; max-width: 46%;
}
.img-viewer-tools {
    position: absolute; bottom: calc(16px + var(--safe-bottom)); left: 50%; transform: translateX(-50%);
    z-index: 2; display: flex; align-items: center; gap: 6px;
    background: rgba(0,0,0,0.55); border-radius: 999px; padding: 6px 8px;
}
.img-viewer-tools button {
    width: 40px; height: 40px; border: none; border-radius: 50%;
    background: rgba(255,255,255,0.12); color: #fff; cursor: pointer;
    display: flex; align-items: center; justify-content: center;
}
.img-viewer-tools button:hover { background: rgba(255,255,255,0.24); }
.img-viewer-tools .material-symbols-outlined { font-size: 20px; }
.img-viewer-zoom {
    color: #fff; font-size: 13px; font-weight: 600;
    min-width: 52px; text-align: center; font-variant-numeric: tabular-nums;
}
.modal-product-name { font-size: 20px; font-weight: 700; margin-bottom: 4px; }
.modal-product-code { font-size: 13px; color: rgba(0,0,0,0.5); margin-bottom: 8px; }
.modal-product-desc { font-size: 13px; color: rgba(0,0,0,0.5); margin-bottom: 8px; }
.modal-product-price { font-size: 22px; font-weight: 800; color: var(--catalogo-accent); margin-bottom: 20px; }
.qty-control { display: flex; align-items: center; gap: 16px; margin-bottom: 20px; }
.qty-btn {
    width: var(--m3-touch); height: var(--m3-touch); border-radius: var(--m3-shape-full);
    border: 2px solid var(--catalogo-accent); background: transparent;
    font-size: 20px; font-weight: 700; cursor: pointer; color: var(--catalogo-text);
    transition: background-color var(--m3-dur-2) var(--m3-ease-standard);
}
.qty-btn:hover { background: rgba(255, 212, 0, 0.12); }
.qty-btn:active { background: rgba(255, 212, 0, 0.24); }
.qty-value { font-size: 20px; font-weight: 700; min-width: 30px; text-align: center; }
/* Aviso de quantidade em caixas (ex.: "2 caixas (24 un)") quando o produto tem qtd/caixa */
.btn-add-cart {
    width: 100%; min-height: var(--m3-touch-lg); padding: 14px;
    background: var(--catalogo-accent); color: var(--catalogo-on-accent);
    border: none; border-radius: var(--m3-shape-full); font-size: 14px; font-weight: 700;
    cursor: pointer; font-family: inherit;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    transition: filter var(--m3-dur-2) var(--m3-ease-standard), background-color var(--m3-dur-2) var(--m3-ease-standard);
}
.btn-add-cart:hover { filter: brightness(1.05); }
.btn-add-cart:active { opacity: 0.88; }
.btn-add-cart.added { background: #2DD881; color: #00391C; }

/* WhatsApp direto no modal do produto */
.btn-whatsapp-produto {
    width: 100%; min-height: var(--m3-touch-lg); padding: 14px; margin-top: 10px;
    background: #25D366; color: #fff;
    border: none; border-radius: var(--m3-shape-full); font-size: 14px; font-weight: 700;
    cursor: pointer; font-family: inherit;
    display: flex; align-items: center; justify-content: center; gap: 8px;
    transition: filter var(--m3-dur-2) var(--m3-ease-standard), opacity var(--m3-dur-2) var(--m3-ease-standard);
}
.btn-whatsapp-produto:hover { filter: brightness(1.06); }
.btn-whatsapp-produto:active { opacity: 0.88; }

/* ── Customer Modal ── */
.modal-customer-title { font-size: 22px; font-weight: 800; margin-bottom: 4px; padding-right: 48px; }
.modal-customer-subtitle { font-size: 13px; color: rgba(0,0,0,0.5); margin-bottom: 20px; }
.form-input-customer {
    width: 100%; padding: 12px 14px; border: 2px solid rgba(0,0,0,0.1);
    border-radius: 10px; font-size: 16px; font-family: inherit; outline: none;
    transition: border-color 0.2s;
    -webkit-appearance: none;  /* prevent iOS zoom on focus */
}
.form-input-customer:focus { border-color: var(--catalogo-accent); }

/* ── Extra product info ── */
.modal-extra-info { display: flex; flex-wrap: wrap; gap: 8px; margin-bottom: 12px; }
.modal-extra-tag {
    font-size: 11px; padding: 4px 10px; background: rgba(0,0,0,0.05);
    border-radius: var(--m3-shape-xs); font-weight: 500;
    display: inline-flex; align-items: center; gap: 4px;
}
.modal-extra-tag .material-symbols-outlined { font-size: 14px; }

/* ── Extra fields (campos_extras) ── */
.modal-extra-fields { margin-bottom: 12px; border-top: 1px solid rgba(0,0,0,0.08); padding-top: 10px; }
.modal-field-row { display: flex; justify-content: space-between; align-items: center; padding: 5px 0; font-size: 13px; border-bottom: 1px solid rgba(0,0,0,0.04); }
.modal-field-row:last-child { border-bottom: none; }
.modal-field-label { color: rgba(0,0,0,0.5); font-weight: 500; }
.modal-field-value { font-weight: 600; text-align: right; max-width: 60%; word-break: break-word; }

/* ── Group Modal ── */
.modal-group-title { font-size: 16px; font-weight: 700; margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid rgba(0,0,0,0.1); }
.modal-group-list { max-height: 60vh; max-height: 60dvh; overflow-y: auto; -webkit-overflow-scrolling: touch; }
.group-product-item {
    display: flex; align-items: center; gap: 12px; padding: 12px;
    border: 1px solid rgba(0,0,0,0.08); border-radius: 12px;
    margin-bottom: 8px; cursor: pointer;
    -webkit-tap-highlight-color: transparent;
}
.group-product-item:active { background: rgba(0,0,0,0.04); }
.group-product-img-wrap {
    width: 56px; height: 56px; border-radius: 8px; overflow: hidden;
    background: rgba(0,0,0,0.05); display: flex; align-items: center;
    justify-content: center; flex-shrink: 0;
}
.group-product-img-wrap img { width: 100%; height: 100%; object-fit: contain; padding: 3px; box-sizing: border-box; }
.group-product-info { flex: 1; min-width: 0; }
.group-product-name { font-size: 14px; font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.group-product-code { font-size: 11px; color: rgba(0,0,0,0.4); margin-top: 2px; }
.group-product-price { font-size: 13px; font-weight: 700; color: var(--catalogo-accent); margin-top: 4px; }

/* ── Back to group button ── */
.modal-product-back { display: flex; align-items: center; gap: 4px; font-size: 13px; font-weight: 600; color: var(--catalogo-accent); cursor: pointer; margin-bottom: 12px; opacity: 0.8; }
.modal-product-back:active { opacity: 1; }

/* ── Variant Selectors ── */
.modal-variantes { margin-bottom: 16px; }
.variacao-group { margin-bottom: 12px; }
.variacao-label { font-size: 12px; font-weight: 700; color: rgba(0,0,0,0.6); margin-bottom: 8px; text-transform: uppercase; letter-spacing: 0.5px; }
.variacao-options { display: flex; flex-wrap: wrap; gap: 8px; }
.variacao-btn {
    padding: 8px 14px; border: 2px solid rgba(0,0,0,0.12);
    border-radius: 8px; background: transparent;
    font-size: 13px; font-weight: 600; cursor: pointer;
    font-family: inherit; transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}
.variacao-btn:hover { border-color: var(--catalogo-accent); }
.variacao-btn.active {
    border-color: var(--catalogo-accent);
    background: var(--catalogo-accent);
    color: var(--catalogo-on-accent);
    box-shadow: inset 0 0 0 1px var(--catalogo-accent);
}
.variacao-btn:disabled {
    opacity: 0.3; cursor: not-allowed;
}
.color-options { gap: 10px; }
.color-btn {
    width: 36px; height: 36px; border-radius: 50%;
    border: 3px solid rgba(0,0,0,0.12);
    padding: 0; cursor: pointer;
    transition: all 0.2s;
    -webkit-tap-highlight-color: transparent;
}
.color-btn:hover { transform: scale(1.1); }
.color-btn.active {
    border-color: var(--catalogo-accent);
    box-shadow: inset 0 0 0 3px var(--catalogo-bg), 0 0 0 2px var(--catalogo-accent);
}
.cart-item-variant {
    font-size: 11px; color: var(--catalogo-accent);
    background: rgba(255,212,0,0.1); padding: 2px 8px;
    border-radius: 4px; margin-top: 4px; display: inline-block;
    font-weight: 500;
}

/* ══════════════════════════════════════
   Desktop Overrides
   ══════════════════════════════════════ */
@media (min-width: 769px) {
    .pdf-fullscreen { padding: 12px; }

    :root { --hotspot-size: 30px; --hotspot-font: 17px; }

    .toolbar-btn { width: 46px; height: 46px; }
    .floating-toolbar { gap: 10px; }

    /* Setas de página voltam para as bordas, na vertical média da tela. */
    .edge-nav {
        display: flex;
        align-items: center;
        justify-content: space-between;
        position: fixed;
        top: 50%;
        transform: translateY(-50%);
        left: 16px;
        right: 16px;
        z-index: 80;
        pointer-events: none;
        opacity: 1;
        transition: opacity var(--m3-dur-4) var(--m3-ease-standard);
    }
    body.chrome-hidden .edge-nav {
        opacity: 0;
        pointer-events: none;
    }

    /* Na base sobra o contador + zoom, centralizados como um par de chips. */
    .bottom-bar {
        left: 0;
        right: 0;
        justify-content: center;
        gap: 10px;
    }
    .bottom-bar-pages { padding: 5px 14px; }
    .bottom-bar-pages .bar-btn { display: none; }
    .bar-btn { width: 44px; height: 44px; }

    .cart-panel { width: 380px; max-width: 90vw; }
    
    .modal { padding: 28px; }
    .modal-product-img { height: 240px; }}

/* ══════════════════════════════════════
   Mobile Small (≤400px)
   ══════════════════════════════════════ */
@media (max-width: 400px) {
    .pdf-fullscreen { padding: 4px; padding-top: calc(4px + var(--safe-top)); padding-bottom: calc(4px + var(--safe-bottom)); }

    :root { --hotspot-size: 22px; --hotspot-font: 13px; }
    
    .floating-toolbar { gap: 6px; }
    .toolbar-btn { width: var(--m3-touch); height: var(--m3-touch); }
    .toolbar-btn .material-symbols-outlined { font-size: 22px; }
    .toolbar-client { width: 32px; height: 32px; }
    
    .bottom-bar { bottom: calc(8px + var(--safe-bottom)); gap: 6px; }
    .bottom-bar-pages, .bottom-bar-zoom { gap: 2px; padding: 4px 6px; }
    .bar-btn { width: var(--m3-touch); height: var(--m3-touch); }
    .page-counter { font-size: 11px; padding: 4px 6px; min-width: 40px; }
    .zoom-indicator { font-size: 11px; padding: 4px 6px; min-width: 38px; }
    
    .modal { padding: 20px; border-radius: 14px; }
    .modal-product-img { height: 160px; }

    .modal-product-name { font-size: 18px; }
    .modal-product-price { font-size: 20px; }
}

/* ══════════════════════════════════════
   Landscape mobile
   ══════════════════════════════════════ */
@media (max-height: 500px) and (orientation: landscape) {
    .pdf-fullscreen { padding: 4px; padding-top: 4px; padding-bottom: 4px; }
    
    .floating-toolbar { top: 6px; right: 6px; gap: 4px; }
    .toolbar-btn { width: 40px; height: 40px; }
    .toolbar-btn .material-symbols-outlined { font-size: 20px; }
    .toolbar-client { width: 28px; height: 28px; font-size: 14px; }
    
    .bottom-bar { gap: 6px; }
    .bottom-bar-pages, .bottom-bar-zoom { gap: 2px; padding: 3px 6px; }
    .bar-btn { width: 38px; height: 38px; }
    .page-counter { font-size: 11px; padding: 3px 6px; min-width: 40px; }
    .zoom-indicator { font-size: 11px; padding: 3px 6px; min-width: 38px; }
}

/* ══════════════════════════════════════
   Confirmation Toast (carrinho enviado)
   ══════════════════════════════════════ */
.cart-toast {
    position: fixed;
    left: 50%;
    bottom: calc(20px + var(--safe-bottom));
    transform: translateX(-50%) translateY(16px);
    background: #25D366;
    color: #00391C;
    padding: 12px 22px;
    border-radius: var(--m3-shape-full);
    font-size: 14px;
    font-weight: 700;
    font-family: 'Inter', sans-serif;
    box-shadow: 0 6px 24px rgba(0, 0, 0, 0.25);
    z-index: 400;
    opacity: 0;
    pointer-events: none;
    display: flex;
    align-items: center;
    gap: 8px;
    max-width: calc(100vw - 32px);
    text-align: center;
    transition: opacity 0.25s ease, transform 0.25s ease;
}
.cart-toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

/* ══════════════════════════════════════
   Embed mode (catálogo dentro de iframe)
   ══════════════════════════════════════ */
body.embed-mode .pdf-fullscreen { padding: 0 4px; }
body.embed-mode .floating-toolbar { top: calc(6px + var(--safe-top)); right: 6px; }

/* O trilho da base é posicionado por left/right (não mais por transform),
   então o embed precisa só encurtar as margens laterais — antes,
   `body.embed-mode .zoom-cluster { right: 10px }` conflitava com o
   `left: 16px` da regra base e esticava o contêiner fixo. */
body.embed-mode .bottom-bar { bottom: calc(6px + var(--safe-bottom)); left: 8px; right: 8px; }
body.embed-mode .edge-nav { left: 8px; right: 8px; }
body.embed-mode .edge-btn { width: 42px; height: 42px; }
