/* ===================================================================
   Hesed Delivery — Storefront (cardápio do cliente)
   Design premium clean/moderno (ref. CardápioWeb / iFood) — v3.0.0
   Mantém TODAS as classes/data-* do markup e do JS.
   --brand / --accent vêm do tema da loja (inline no <body>).
   =================================================================== */

:root {
    --brand: #d43b2f;
    --accent: #f3b63f;
    --ink: #0f172a;
    --ink-2: #334155;
    --muted: #64748b;
    --bg: #f4f5f7;
    --surface: #ffffff;
    --surface-2: #f8fafc;
    --line: #e7e9ee;
    --line-2: #eef1f5;
    --radius: 18px;
    --radius-sm: 12px;
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow: 0 6px 24px -8px rgba(15, 23, 42, 0.16);
    --shadow-lg: 0 24px 60px -18px rgba(15, 23, 42, 0.30);
    --brand-soft: color-mix(in srgb, var(--brand) 10%, #fff);
    --brand-ink: color-mix(in srgb, var(--brand) 72%, #0f172a);
    --font: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

* { box-sizing: border-box; }
[hidden] { display: none !important; }
html { scroll-behavior: smooth; -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    color: var(--ink);
    background: var(--bg);
    font-family: var(--font);
    font-size: 15px;
    line-height: 1.5;
    min-height: 100vh;
    -webkit-font-smoothing: antialiased;
}

img { display: block; max-width: 100%; }
button, input, textarea, select { font: inherit; color: inherit; }
button, a { -webkit-tap-highlight-color: transparent; }
button { cursor: pointer; }
a { color: inherit; }

/* scrollbar discreta */
* { scrollbar-width: thin; scrollbar-color: #cbd5e1 transparent; }
*::-webkit-scrollbar { width: 8px; height: 8px; }
*::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 99px; }

/* ---------- banner offline ---------- */
.offline-banner {
    position: sticky; top: 0; z-index: 100;
    padding: 9px 16px; color: #fff; background: var(--ink);
    text-align: center; font-size: 0.82rem; font-weight: 600;
}
.status-dot {
    display: inline-block; width: 8px; height: 8px; margin-right: 7px;
    border-radius: 50%; background: var(--accent);
}

/* ---------- header ---------- */
.site-header {
    position: sticky; top: 0; z-index: 30;
    display: flex; align-items: center; justify-content: space-between;
    gap: 12px; padding: 12px 18px;
    background: color-mix(in srgb, var(--surface) 86%, transparent);
    backdrop-filter: saturate(160%) blur(12px);
    border-bottom: 1px solid var(--line);
}
.brand-lockup { display: inline-flex; gap: 11px; align-items: center; text-decoration: none; min-width: 0; }
.brand-mark {
    display: grid; place-items: center; flex: 0 0 auto;
    width: 44px; height: 44px; color: #fff; background: var(--brand);
    border-radius: 13px; box-shadow: var(--shadow-sm);
    font-size: 1.25rem; font-weight: 800;
}
.brand-lockup strong, .brand-lockup small { display: block; }
.brand-lockup strong { font-size: 1rem; font-weight: 800; letter-spacing: -0.01em; color: var(--ink); }
.brand-lockup small {
    margin-top: 1px; color: var(--muted); font-size: 0.66rem;
    font-weight: 700; letter-spacing: 0.12em; text-transform: uppercase;
}

.ghost-button {
    min-height: 40px; padding: 8px 14px;
    border: 1px solid var(--line); border-radius: 11px;
    background: var(--surface); color: var(--ink-2);
    font-size: 0.83rem; font-weight: 700; box-shadow: var(--shadow-sm);
    transition: background .15s, border-color .15s;
}
.ghost-button:hover { background: var(--surface-2); border-color: #d7dbe2; }
.account-greeting { font-size: 13px; color: var(--ink-2); font-weight: 600; }

[data-open-cart] {
    color: #fff; background: var(--brand); border-color: transparent;
}
[data-open-cart]:hover { background: var(--brand-ink); }
.cart-count {
    display: inline-grid; place-items: center; min-width: 20px; height: 20px;
    margin-left: 6px; padding: 0 6px; color: var(--brand);
    background: #fff; border-radius: 99px; font-size: 0.72rem; font-weight: 800;
}

/* ---------- layout ---------- */
main { width: min(1140px, calc(100% - 32px)); margin: 0 auto; padding-bottom: 96px; }

.eyebrow {
    display: inline-flex; align-items: center; gap: 8px;
    color: var(--brand); font-size: 0.7rem; font-weight: 800;
    letter-spacing: 0.14em; text-transform: uppercase;
}

/* ---------- cabeçalho de loja (capa + logo + nome + status) ---------- */
.store-header {
    overflow: hidden; margin-top: 18px;
    border: 1px solid var(--line); border-radius: var(--radius);
    background: var(--surface); box-shadow: var(--shadow-sm);
}
.store-cover { position: relative; height: clamp(150px, 24vw, 240px); background: #e9edf2; }
.store-cover img { width: 100%; height: 100%; object-fit: cover; }
.store-cover::after {
    content: ""; position: absolute; inset: 0; pointer-events: none;
    background: linear-gradient(180deg, transparent 45%, rgba(15, 23, 42, 0.34));
}
.store-cover.is-gradient {
    background:
        radial-gradient(80% 130% at 86% -10%, color-mix(in srgb, var(--accent) 32%, transparent), transparent 56%),
        linear-gradient(120deg, var(--brand), color-mix(in srgb, var(--brand) 52%, #0b1322));
}
.store-cover.is-gradient::after { display: none; }

.store-id {
    position: relative; display: flex; align-items: flex-end; gap: 18px;
    padding: 14px 24px 20px;
}
.store-logo {
    flex: 0 0 auto; margin-top: -58px; overflow: hidden;
    display: grid; place-items: center; width: 92px; height: 92px;
    color: #fff; background: var(--brand);
    border: 4px solid var(--surface); border-radius: 22px;
    box-shadow: var(--shadow); font-size: 2.2rem; font-weight: 800;
}
.store-logo img { width: 100%; height: 100%; object-fit: cover; }
.store-id-text { flex: 1; min-width: 0; padding-bottom: 3px; }
.store-id-text h1 {
    margin: 0 0 9px; font-size: clamp(1.45rem, 3vw, 2.05rem);
    font-weight: 800; letter-spacing: -0.025em; line-height: 1.08; color: var(--ink);
}
.store-status { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.status-pill {
    display: inline-flex; align-items: center; gap: 6px;
    padding: 5px 11px; border-radius: 99px; font-size: 0.74rem; font-weight: 800;
}
.status-pill .dot { width: 7px; height: 7px; border-radius: 50%; background: currentColor; }
.status-pill.is-open { color: #15803d; background: #e9f9ef; }
.status-pill.is-closed { color: #b91c1c; background: #fdecec; }
.store-meta-chip {
    display: inline-flex; align-items: center; gap: 5px; padding: 5px 11px;
    color: var(--ink-2); background: var(--surface-2);
    border: 1px solid var(--line); border-radius: 99px;
    font-size: 0.74rem; font-weight: 600;
}
.store-tagline { margin: 11px 0 0; max-width: 74ch; color: var(--muted); font-size: 0.9rem; line-height: 1.5; }

/* ---------- ferramentas do catálogo ---------- */
.catalog-tools {
    display: grid; grid-template-columns: 1fr auto; gap: 12px;
    margin: 26px 0 14px;
}
.search-box {
    display: flex; align-items: center; gap: 10px; min-height: 50px;
    padding: 0 16px; border: 1px solid var(--line); border-radius: 14px;
    background: var(--surface); box-shadow: var(--shadow-sm);
    transition: border-color .15s, box-shadow .15s;
}
.search-box:focus-within { border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft); }
.search-box span { color: var(--muted); font-size: 1.2rem; line-height: 1; }
.search-box input { width: 100%; border: 0; outline: 0; background: transparent; font-size: 0.95rem; }
.search-box input::placeholder { color: #94a3b8; }

.fulfillment-toggle {
    display: flex; padding: 4px; border: 1px solid var(--line);
    border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-sm);
}
.fulfillment-toggle button {
    padding: 9px 16px; border: 0; border-radius: 10px;
    background: transparent; color: var(--muted);
    font-size: 0.82rem; font-weight: 700; transition: .15s;
}
.fulfillment-toggle button.is-active { color: #fff; background: var(--brand); box-shadow: var(--shadow-sm); }

/* ---------- nav de categorias (sticky) ---------- */
.category-nav {
    position: sticky; top: 64px; z-index: 20;
    display: flex; gap: 8px; overflow-x: auto;
    margin: 0 -16px 24px; padding: 12px 16px;
    scrollbar-width: none;
    background: color-mix(in srgb, var(--bg) 88%, transparent);
    backdrop-filter: blur(10px);
}
.category-nav::-webkit-scrollbar { display: none; }
.category-nav a {
    flex: 0 0 auto; display: inline-flex; align-items: center; gap: 7px;
    padding: 9px 15px; color: var(--ink-2);
    border: 1px solid var(--line); border-radius: 99px;
    background: var(--surface); text-decoration: none;
    font-size: 0.82rem; font-weight: 700; white-space: nowrap;
    transition: .15s; box-shadow: var(--shadow-sm);
}
.category-nav a:hover { border-color: #d7dbe2; }
.category-nav a.is-active { color: #fff; background: var(--brand); border-color: transparent; }
.category-nav a.is-active span { background: rgba(255, 255, 255, 0.25); color: #fff; }
.category-nav span {
    display: grid; place-items: center; min-width: 20px; height: 20px;
    padding: 0 5px; color: var(--brand); background: var(--brand-soft);
    border-radius: 99px; font-size: 0.68rem; font-weight: 800;
}

/* ---------- catálogo ---------- */
.catalog-layout { display: grid; grid-template-columns: minmax(0, 1fr) 280px; gap: 30px; align-items: start; }
.category-section { scroll-margin-top: 120px; margin-bottom: 42px; }
.section-heading {
    display: flex; align-items: baseline; justify-content: space-between;
    gap: 12px; margin-bottom: 16px;
}
.section-heading > div { display: flex; align-items: baseline; gap: 10px; }
.section-index {
    color: var(--brand); font-size: 0.72rem; font-weight: 800; letter-spacing: 0.06em;
}
.section-heading h2 {
    margin: 0; font-size: clamp(1.25rem, 2.4vw, 1.6rem);
    letter-spacing: -0.02em; font-weight: 800;
}
.section-heading small { color: var(--muted); font-size: 0.8rem; }

.product-grid { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 14px; }
.product-card {
    overflow: hidden; border: 1px solid var(--line); border-radius: 16px;
    background: var(--surface); box-shadow: var(--shadow-sm);
    transition: transform .18s ease, box-shadow .18s ease, border-color .18s ease;
}
.product-card:hover { transform: translateY(-2px); border-color: #dfe3ea; box-shadow: var(--shadow); }
.product-content {
    display: grid; grid-template-columns: minmax(0, 1fr) 116px; gap: 14px;
    width: 100%; min-height: 150px; padding: 15px; border: 0;
    background: transparent; text-align: left;
}
.product-copy { display: flex; flex-direction: column; align-items: flex-start; min-width: 0; }
.popular-badge {
    margin-bottom: 8px; padding: 3px 8px; color: var(--brand);
    background: var(--brand-soft); border-radius: 99px;
    font-size: 0.6rem; font-weight: 800; letter-spacing: 0.06em; text-transform: uppercase;
}
.product-card h3 {
    margin: 0; font-size: 1rem; font-weight: 700; letter-spacing: -0.01em; color: var(--ink);
}
.product-card p {
    display: -webkit-box; overflow: hidden; margin: 6px 0 10px;
    color: var(--muted); font-size: 0.81rem; line-height: 1.45;
    -webkit-line-clamp: 2; -webkit-box-orient: vertical;
}
.product-card strong { margin-top: auto; color: var(--ink); font-size: 1.02rem; font-weight: 800; }

.product-visual {
    position: relative; overflow: hidden; display: grid; place-items: center;
    border-radius: 12px; min-height: 118px;
    background: linear-gradient(135deg, #f5f7fa, #e9edf2);
    color: rgba(15, 23, 42, 0.085); font-size: 3.1rem; font-weight: 800; line-height: 1;
}
.product-visual img { width: 100%; height: 100%; object-fit: cover; }
.product-visual i {
    position: absolute; right: 8px; bottom: 8px; z-index: 2;
    display: grid; place-items: center; width: 34px; height: 34px;
    color: #fff; background: var(--brand); border: 2px solid #fff; border-radius: 50%;
    font-style: normal; font-size: 1.15rem; line-height: 1;
    box-shadow: var(--shadow-sm);
}

/* ---------- aside (pedido) ---------- */
.desktop-order-note {
    position: sticky; top: 120px; padding: 22px; color: var(--ink);
    border-radius: 18px; border: 1px solid var(--line); box-shadow: var(--shadow-sm);
    background: var(--surface);
}
.desktop-order-note > span {
    color: var(--brand); font-size: 0.66rem; font-weight: 800;
    letter-spacing: 0.12em; text-transform: uppercase;
}
.desktop-order-note h2 { margin: 9px 0; font-size: 1.3rem; line-height: 1.15; letter-spacing: -0.02em; color: var(--ink); }
.desktop-order-note p, .desktop-order-note li { color: var(--muted); font-size: 0.82rem; line-height: 1.55; }
.desktop-order-note ul { margin: 16px 0 0; padding: 16px 0 0; border-top: 1px solid var(--line); list-style: none; }
.desktop-order-note li { margin: 9px 0; padding-left: 24px; position: relative; }
.desktop-order-note li::before {
    content: "✓"; position: absolute; left: 0; top: 0;
    color: var(--brand); font-weight: 800;
}

.empty-search, .empty-cart { padding: 44px 18px; color: var(--muted); text-align: center; font-size: 0.9rem; }

/* ---------- carrinho flutuante ---------- */
.floating-cart {
    position: fixed; z-index: 40; left: 50%; bottom: max(16px, env(safe-area-inset-bottom));
    display: grid; grid-template-columns: 1fr auto 1fr; gap: 16px; align-items: center;
    width: min(560px, calc(100% - 24px)); min-height: 56px; padding: 10px 18px;
    color: #fff; background: var(--brand); border-radius: 16px;
    box-shadow: 0 18px 44px -10px color-mix(in srgb, var(--brand) 60%, rgba(15,23,42,.5));
    transform: translateX(-50%); transition: transform .2s, opacity .2s;
}
.floating-cart:hover { background: var(--brand-ink); }
.floating-cart span { font-size: 0.78rem; opacity: .92; }
.floating-cart span:last-child { text-align: right; }
.floating-cart strong { font-size: 0.92rem; }

/* ---------- diálogos (produto + sacola) ---------- */
dialog {
    width: 100%; max-width: none; height: 100%; max-height: none;
    margin: 0; padding: 0; border: 0; background: transparent;
}
dialog::backdrop { background: rgba(15, 23, 42, 0.55); backdrop-filter: blur(4px); }
.dialog-shell, .cart-shell {
    position: absolute; right: 0; top: 0; bottom: 0;
    overflow-y: auto; width: min(460px, 100%); height: 100%;
    background: var(--surface); box-shadow: var(--shadow-lg);
}
.product-dialog[open] .dialog-shell, .cart-dialog[open] .cart-shell {
    animation: slide-in 260ms cubic-bezier(.2, .8, .2, 1);
}
@keyframes slide-in { from { transform: translateX(36px); opacity: 0; } }
.dialog-close {
    position: absolute; z-index: 4; top: 16px; right: 16px;
    display: grid; place-items: center; width: 38px; height: 38px; padding: 0;
    border: 1px solid var(--line); border-radius: 50%;
    background: var(--surface); font-size: 1.4rem; color: var(--ink-2);
    box-shadow: var(--shadow-sm);
}
.dialog-close:hover { background: var(--surface-2); }
.dialog-product-visual {
    position: relative; overflow: hidden;
    display: grid; place-items: center; height: 260px; color: #fff;
    background: linear-gradient(135deg, color-mix(in srgb, var(--brand) 22%, #e2e8f0), #cbd5e1);
    font-size: 5rem; font-weight: 800;
}
.dialog-product-visual.has-image { background: #e9edf2; }
.dialog-product-visual img { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; }
.dialog-body, .cart-shell { padding: 26px; }
.dialog-body h2, .cart-header h2 { margin: 6px 0; font-size: 1.5rem; font-weight: 800; letter-spacing: -0.02em; }
.dialog-body > p { margin: 0 0 22px; color: var(--muted); line-height: 1.55; }

/* ---------- campos ---------- */
.field { display: grid; gap: 6px; }
.field > span { font-size: 0.72rem; font-weight: 700; color: var(--ink-2); letter-spacing: 0.01em; }
.field input, .field textarea, .field select {
    width: 100%; padding: 11px 13px; border: 1px solid var(--line);
    border-radius: 11px; outline: 0; background: var(--surface);
    transition: border-color .15s, box-shadow .15s;
}
.field input:focus, .field textarea:focus, .field select:focus {
    border-color: var(--brand); box-shadow: 0 0 0 3px var(--brand-soft);
}
.field textarea { min-height: 80px; resize: vertical; }

.dialog-action {
    position: sticky; bottom: 0; z-index: 3;
    display: grid; grid-template-columns: auto 1fr; gap: 12px; align-items: center;
    margin: 22px -26px -26px; padding: 15px 26px max(15px, env(safe-area-inset-bottom));
    background: color-mix(in srgb, var(--surface) 93%, transparent);
    backdrop-filter: saturate(160%) blur(10px); border-top: 1px solid var(--line);
}
.dialog-action .primary-button { display: flex; justify-content: space-between; align-items: center; gap: 10px; width: 100%; }
.dialog-action .primary-button span { font-weight: 800; }
.quantity-stepper {
    display: inline-grid; grid-template-columns: 38px 36px 38px; align-items: center;
    overflow: hidden; border: 1px solid var(--line); border-radius: 11px; background: var(--surface);
}
.quantity-stepper button { height: 44px; padding: 0; border: 0; background: transparent; font-size: 1.15rem; color: var(--ink-2); }
.quantity-stepper button:hover { background: var(--surface-2); }
.quantity-stepper output { text-align: center; font-weight: 800; }
.quantity-stepper.small { grid-template-columns: 30px 28px 30px; }
.quantity-stepper.small button { height: 34px; }

.primary-button, .checkout-button {
    min-height: 48px; padding: 12px 18px; color: #fff;
    border: 0; border-radius: 12px; background: var(--brand);
    font-weight: 800; box-shadow: var(--shadow-sm); transition: background .15s, transform .1s;
}
.primary-button:hover, .checkout-button:hover { background: var(--brand-ink); }
.primary-button:active, .checkout-button:active { transform: translateY(1px); }

/* ---------- sacola ---------- */
.cart-header { position: relative; display: flex; align-items: start; justify-content: space-between; margin-bottom: 14px; }
.cart-header .dialog-close { position: static; }
.cart-items { display: grid; gap: 10px; }
.cart-item {
    display: grid; grid-template-columns: 1fr auto; gap: 12px; align-items: center;
    padding: 13px; border: 1px solid var(--line); border-radius: 13px; background: var(--surface);
}
.cart-item strong, .cart-item small, .cart-item span { display: block; }
.cart-item strong { font-size: 0.92rem; font-weight: 700; }
.cart-item small { margin: 3px 0; color: var(--muted); font-size: 0.72rem; }
.cart-item span { color: var(--ink); font-size: 0.85rem; font-weight: 800; }

.checkout-fields {
    display: grid; gap: 14px; margin: 20px 0; padding: 20px 0;
    border-top: 1px solid var(--line); border-bottom: 1px solid var(--line);
}
.field-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.field-grid-address { grid-template-columns: 2fr 0.7fr 1fr; }
.field-wide { grid-column: span 2; }
.delivery-fields { display: grid; gap: 12px; }

.cart-summary { display: grid; gap: 8px; margin: 16px 0; }
.cart-summary > div { display: flex; justify-content: space-between; color: var(--muted); font-size: 0.84rem; }
.cart-summary .cart-total {
    margin-top: 5px; padding-top: 12px; color: var(--ink);
    border-top: 1px dashed var(--line); font-size: 1.1rem; font-weight: 800;
}
.checkout-button { width: 100%; }
.checkout-button:disabled { cursor: not-allowed; filter: grayscale(.7); opacity: .5; }
.checkout-message { min-height: 20px; margin: 12px 0 0; text-align: center; font-size: 0.8rem; font-weight: 700; }

/* ---------- responsivo ---------- */
@media (max-width: 920px) {
    .catalog-layout { grid-template-columns: 1fr; }
    .desktop-order-note { display: none; }
}
@media (max-width: 700px) {
    body { font-size: 14.5px; }
    main { width: calc(100% - 24px); }
    .site-header { padding: 11px 14px; }
    .brand-mark { width: 40px; height: 40px; }
    .store-header { margin-top: 14px; }
    .store-cover { height: clamp(140px, 40vw, 190px); }
    .store-id { flex-direction: column; align-items: center; text-align: center; gap: 9px; padding: 0 16px 20px; }
    .store-logo { width: 78px; height: 78px; margin-top: -42px; border-radius: 20px; font-size: 1.9rem; border-width: 4px; }
    .store-id-text { padding-bottom: 0; }
    .store-id-text h1 { font-size: clamp(1.35rem, 6vw, 1.75rem); margin-bottom: 9px; }
    .store-status { justify-content: center; }
    .store-tagline { font-size: 0.86rem; margin-left: auto; margin-right: auto; }
    .category-nav { top: 60px; }
    .catalog-tools { grid-template-columns: 1fr; margin-top: 22px; }
    .fulfillment-toggle button { flex: 1; }
    .product-grid { grid-template-columns: 1fr; }
    .product-content { grid-template-columns: minmax(0, 1fr) 104px; min-height: 132px; padding: 13px; }
    .product-visual { min-height: 112px; }
    .dialog-shell, .cart-shell { right: 0; left: 0; top: auto; bottom: 0; width: 100%; height: auto; max-height: 92vh; border-radius: 22px 22px 0 0; }
    .product-dialog[open] .dialog-shell, .cart-dialog[open] .cart-shell { animation: slide-up 260ms cubic-bezier(.2,.8,.2,1); }
    @keyframes slide-up { from { transform: translateY(28px); opacity: 0; } }
    .dialog-body, .cart-shell { padding: 22px 16px max(22px, env(safe-area-inset-bottom)); }
    .dialog-action { grid-template-columns: 1fr; }
    .quantity-stepper { justify-self: stretch; grid-template-columns: 1fr 48px 1fr; }
    .field-grid, .field-grid-address { grid-template-columns: 1fr 1fr; }
    .field-wide { grid-column: 1 / -1; }
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        scroll-behavior: auto !important;
        animation-duration: 0.01ms !important;
        transition-duration: 0.01ms !important;
    }
}
