/* =====================================================================
   CARDÁPIO — catálogo de produtos (estilo delivery/fast-food)
   ===================================================================== */

.cardapio-container {
    width: 100%;
    max-width: 100%;
    height: 100vh;
    height: 100dvh;
    margin: 0;
    background: var(--bg);
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* Área central rolável — só os produtos rolam, header e footer ficam fixos */
.menu-top-fixed {
    flex: 0 0 auto;
    padding: 0 16px;
    background: var(--bg);
    z-index: 10;
}

.menu-scroll {
    flex: 1 1 auto;
    min-height: 0;
    overflow-y: auto;
    overflow-x: hidden;
    -webkit-overflow-scrolling: touch;
    padding: 0 16px 12px;
    scrollbar-width: none;
}
.menu-scroll::-webkit-scrollbar {
    width: 0;
    height: 0;
}

/* Header (fixo no topo do frame) */
.menu-header {
    flex: 0 0 auto;
    z-index: 20;
    display: grid;
    grid-template-columns: 44px 1fr auto;
    align-items: center;
    gap: 10px;
    padding: max(16px, env(safe-area-inset-top)) 16px 16px;
    background: linear-gradient(135deg, var(--brand) 0%, var(--brand-dark) 100%);
    color: #fff;
    border-radius: 0 0 20px 20px;
    box-shadow: var(--shadow-md);
}
.menu-header.balcao-header { grid-template-columns: auto 1fr auto; }
.menu-header .header-title { text-align: center; min-width: 0; }
.menu-header .header-title h1 { font-size: 1.05rem; font-weight: 800; }
.menu-header .header-title p { margin-top: 2px; font-size: .7rem; opacity: .88; }
.header-actions { display: flex; align-items: center; justify-content: flex-end; gap: 8px; }
.header-products-button {
    display: grid;
    place-items: center;
    width: 44px;
    height: 44px;
    padding: 0;
    border: 0;
    border-radius: var(--r-pill);
    background: #fff;
    color: var(--brand);
    box-shadow: 0 4px 12px rgba(0, 0, 0, .18);
    font-size: 1.25rem;
    line-height: 1;
    cursor: pointer;
    transition: background .12s ease, transform .12s ease;
}
.header-products-button:hover { background: var(--brand-soft); }
.header-products-button:active { transform: scale(.94); }
.header-products-button span { line-height: 1; }

.balcao-admin-button {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 38px;
    padding: 0 12px;
    border: 1px solid rgba(255, 255, 255, .35);
    border-radius: var(--r-pill);
    background: rgba(255, 255, 255, .16);
    color: #fff;
    font-size: .78rem;
    font-weight: 800;
    cursor: pointer;
    transition: background .12s ease, transform .12s ease;
}
.balcao-admin-button:hover { background: rgba(255, 255, 255, .28); }
.balcao-admin-button:active { transform: scale(.96); }
.balcao-admin-button.icon-only {
    width: 44px;
    height: 44px;
    min-height: 44px;
    padding: 0;
    border-radius: 50%;
}
.balcao-admin-button.icon-only svg { width: 22px; height: 22px; fill: none; stroke: currentColor; stroke-width: 1.8; }

.back-btn {
    display: grid; place-items: center;
    width: 44px; height: 44px; border: 0; border-radius: var(--r-pill);
    background: #fff; color: var(--brand); font-size: 1.6rem; font-weight: 800; line-height: 1; cursor: pointer;
    box-shadow: 0 4px 12px rgba(0, 0, 0, .18);
    transition: background .12s ease, transform .12s ease;
}
.back-btn:hover { background: var(--brand-soft); }
.back-btn span { line-height: 1; }

/* Search */
.menu-search {
    display: flex; align-items: center; gap: 10px;
    margin: 16px 0 4px;
    padding: 0 16px; height: 48px;
    background: var(--surface); border: 1px solid var(--line);
    border-radius: var(--r-pill); box-shadow: var(--shadow-sm);
}
.menu-search span { color: var(--muted); font-size: 1.15rem; }
.menu-search input { flex: 1; border: 0; outline: 0; background: transparent; color: var(--ink); font-size: .92rem; }
.menu-search input::placeholder { color: var(--muted); }

/* Category chips */
.category-bar {
    display: flex; gap: 10px; overflow-x: auto;
    padding: 14px 0 6px; scrollbar-width: none;
    flex: 0 0 auto;
    min-height: 58px;
    overflow-y: hidden;
}
.category-bar::-webkit-scrollbar { display: none; }
.cat-chip {
    flex: 0 0 auto; padding: 10px 18px; border: 1px solid var(--line);
    border-radius: var(--r-pill); background: var(--surface); color: var(--ink-2);
    font-size: .84rem; font-weight: 700; white-space: nowrap; cursor: pointer;
    transition: all .12s ease;
}
.cat-chip:hover { border-color: var(--brand-light); }
.cat-chip.active {
    background: var(--brand); color: #fff; border-color: var(--brand);
    box-shadow: 0 6px 14px rgba(134, 31, 43, .2);
}

/* Section title */
.section-title {
    display: flex; align-items: baseline; justify-content: space-between;
    padding: 16px 0 8px;
    background: var(--bg);
}
.section-title h2 { font-size: 1.15rem; font-weight: 800; }
.section-title span { color: var(--muted); font-size: .78rem; font-weight: 600; }

/* Product list — horizontal rich cards (delivery style) */
.produtos-grid {
    display: flex; flex-direction: column; gap: 12px;
    padding: 4px 0;
}

.menu-product {
    display: grid;
    grid-template-columns: 1fr 108px;
    gap: 12px;
    padding: 12px;
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--r-md);
    box-shadow: var(--shadow-sm);
    cursor: pointer;
    transition: transform .12s ease, box-shadow .12s ease;
    position: relative;
}
.menu-product:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.menu-product:focus-visible { outline: 2px solid var(--brand); outline-offset: 2px; }

.produto-image {
    grid-row: 1;
    grid-column: 2;
    width: 108px; height: 108px;
    aspect-ratio: 1;
    border-radius: var(--r-sm);
    overflow: hidden; background: #eee;
    align-self: center;
}
.produto-image img { width: 100%; height: 100%; object-fit: contain; }

.product-info {
    grid-column: 1;
    display: flex; flex-direction: column;
    min-width: 0;
}
.product-info .produto-nome { font-size: .98rem; font-weight: 800; color: var(--ink); line-height: 1.25; }
.produto-descricao {
    margin-top: 5px; color: var(--muted); font-size: .78rem; line-height: 1.4;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.produto-preco { margin-top: auto; padding-top: 10px; font-size: 1.05rem; font-weight: 800; color: var(--brand); }

/* Add / quantity controls anchored bottom-right */
.produto-actions,
.qty-controls.compact {
    position: absolute;
    right: 12px;
    bottom: 12px;
}

.btn-adicionar {
    display: grid; place-items: center;
    width: 40px; height: 40px; min-width: 40px;
    border: 0; border-radius: 12px;
    background: var(--brand); color: #fff;
    font-size: 1.4rem; font-weight: 700; line-height: 1; cursor: pointer;
    box-shadow: 0 6px 14px rgba(134, 31, 43, .22);
    transition: transform .12s ease, background .12s ease;
}
.btn-adicionar:hover { background: var(--brand-dark); }
.btn-adicionar:active { transform: scale(.94); }

.qty-controls.compact {
    display: inline-flex; align-items: center; gap: 4px;
    padding: 4px; background: var(--surface); border: 1px solid var(--brand);
    border-radius: 12px; box-shadow: var(--shadow-sm);
}
.qty-controls.compact .qty-btn {
    display: grid; place-items: center;
    width: 36px; height: 36px; border: 0; border-radius: 9px;
    background: var(--brand-soft); color: var(--brand); font-size: 1.2rem; line-height: 1; cursor: pointer;
}
.qty-controls.compact .qty-btn:hover { background: var(--brand); color: #fff; }
.qty-controls.compact .qty-value { min-width: 22px; text-align: center; font-weight: 800; color: var(--ink); font-size: .9rem; }

@media (min-width: 640px) {
    .menu-header {
        padding-left: 24px;
        padding-right: 24px;
        border-radius: 0 0 26px 26px;
    }

    .menu-search, .category-bar, .menu-scroll {
        width: min(calc(100% - 48px), 1440px);
        margin-left: auto;
        margin-right: auto;
    }

    .menu-search { margin-top: 20px; }
    .category-bar { gap: 12px; padding-top: 16px; }
    .menu-scroll { padding: 0 0 20px; }

    .produtos-grid {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(min(100%, 260px), 1fr));
        gap: clamp(14px, 2vw, 22px);
        align-items: stretch;
    }

    .menu-product {
        display: grid;
        grid-template-columns: minmax(0, 1fr);
        grid-template-rows: auto 1fr auto;
        min-height: 0;
        padding: 0;
        overflow: hidden;
        border-radius: var(--r-lg);
    }

    .product-info {
        grid-column: 1;
        grid-row: 2;
        padding: 14px 16px 8px;
    }

    .produto-image {
        width: 100%;
        height: auto;
        aspect-ratio: 4 / 3;
        grid-row: 1;
        grid-column: 1;
        border-radius: 0;
    }

    .produto-actions,
    .qty-controls.compact {
        position: static;
        grid-column: 1;
        grid-row: 3;
        justify-self: end;
        margin: 0 14px 14px;
    }

    .produto-preco {
        padding-top: 12px;
    }

    .figma-cart-cta {
        width: min(72vw, 820px);
    }
}

@media (max-width: 420px) {
    .menu-header {
        grid-template-columns: 36px minmax(0, 1fr) auto;
        gap: 6px;
        padding: max(12px, env(safe-area-inset-top)) 12px 12px;
    }

    .menu-header .back-btn,
    .menu-header .cart-button {
        width: 38px;
        height: 38px;
    }

    .menu-header .header-title h1 { font-size: .92rem; }
    .menu-header .header-title p { font-size: .64rem; }
    .header-actions { gap: 4px; }
    .header-actions > .balcao-admin-button,
    .header-actions > .header-products-button { width: 34px; height: 34px; min-height: 34px; }
    .header-actions > .balcao-admin-button svg { width: 18px; height: 18px; }
    .header-products-button { font-size: 1rem; }
    .menu-search { margin-top: 12px; }
}

/* Floating cart CTA */
.figma-cart-cta {
    position: fixed;
    z-index: 30;
    left: 50%;
    bottom: max(14px, env(safe-area-inset-bottom));
    transform: translateX(-50%);
    display: grid;
    grid-template-columns: auto 1fr auto;
    align-items: center;
    gap: 12px;
    width: min(calc(100% - 32px), calc(var(--frame) - 32px));
    min-height: 60px;
    padding: 0 20px;
    border: 0; border-radius: var(--r-md);
    background: var(--brand); color: #fff;
    box-shadow: 0 12px 28px rgba(134, 31, 43, .24);
    cursor: pointer;
    transition: transform .12s ease, background .12s ease;
}
.figma-cart-cta:hover { background: var(--brand-dark); }
.figma-cart-cta:active { transform: translateX(-50%) scale(.99); }
.figma-cart-cta span { font-size: .78rem; opacity: .9; }
.figma-cart-cta strong { font-size: .95rem; font-weight: 800; }
.figma-cart-cta b { font-size: 1.05rem; font-weight: 800; }

/* State cards (loading / error) — only when NOT a product tile */
.produto-card:not(.menu-product) {
    max-width: var(--frame); margin: 40px auto; padding: 32px 24px;
    background: var(--surface); border-radius: var(--r-lg); box-shadow: var(--shadow-md); text-align: center;
}
.produto-card:not(.menu-product) h2 { font-size: 1.3rem; margin-bottom: 8px; }
.produto-card:not(.menu-product) p { color: var(--muted); line-height: 1.6; }

.empty-order-toast { /* alias used by page */ }

/* -------- Footer do cardápio: fixo e centralizado (igual ao botão finalizar pedido) -------- */
.cardapio-container > .order-footer {
    position: sticky;
    bottom: 0;
    left: auto;
    transform: none !important;
    width: 100%;
    max-width: 100%;
    margin: 0;
    padding: 12px 16px max(16px, calc(12px + env(safe-area-inset-bottom)));
    background: linear-gradient(180deg, rgba(247, 244, 239, 0) 0%, var(--bg) 28%);
    box-shadow: 0 -6px 20px rgba(20, 20, 30, .08);
    z-index: 30;
    flex: 0 0 auto;
}
.cardapio-container > .order-footer .footer-btn {
    animation: none !important;
}

.menu-product {
    border-color: var(--line);
    border-radius: var(--r-lg);
    box-shadow: var(--shadow-sm);
}
.menu-product:active { transform: scale(.995); }
.produto-image { background: #eee8e1; }
.produto-image img { object-fit: cover; }
.product-info .produto-nome { letter-spacing: -.015em; }
.produto-descricao { color: var(--muted); }
.produto-preco { color: var(--brand); }
.qty-controls.compact .qty-btn { width: 36px; height: 36px; }
.qty-controls.compact { gap: 6px; padding: 4px; }
.menu-empty {
    display: grid;
    justify-items: center;
    gap: 8px;
    padding: 44px 20px;
    border: 1px dashed var(--line);
    border-radius: var(--r-lg);
    background: var(--surface);
    text-align: center;
}
.menu-empty strong { color: var(--ink); font-size: 1rem; }
.menu-empty span { color: var(--muted); font-size: .84rem; line-height: 1.5; }
.cardapio-container > .order-footer {
    background: linear-gradient(180deg, rgba(247, 244, 239, 0) 0%, var(--bg) 32%);
}
.cardapio-container > .order-footer .footer-btn {
    width: min(100%, 1440px);
    margin: 0 auto;
    min-height: 58px;
    border-radius: var(--r-lg);
    box-shadow: 0 10px 24px rgba(134, 31, 43, .24);
}
@media (max-width: 380px) {
    .menu-scroll { padding-left: 12px; padding-right: 12px; }
    .menu-product { grid-template-columns: minmax(0, 1fr) 92px; gap: 10px; padding: 10px; }
    .produto-image { width: 92px; height: 92px; }
    .product-info .produto-nome { font-size: .92rem; }
    .produto-descricao { font-size: .74rem; }
    .section-title h2 { font-size: 1.02rem; }
}
