:root {
    --ink: #111827;
    --muted: #6b7280;
    --line: #e5e7eb;
    --soft: #f6f7f9;
    --brand: #2563eb;
    --brand-dark: #1d4ed8;
    --brand-2: #38bdf8;
    --ok: #16a34a;
    --card: #ffffff;
}

*, *::before, *::after { box-sizing: border-box; letter-spacing: 0; }

html { width: 100%; overflow-x: hidden; }

body {
    font-family: -apple-system, "Segoe UI", Roboto, "Helvetica Neue", sans-serif;
    background: var(--soft);
    color: var(--ink);
    width: 100%;
    min-width: 0;
    overflow-x: hidden;
}

img, video, canvas, svg { max-width: 100%; }

.container { max-width: min(1120px, 100%); }

/* ============================================================
   HEADER
   ============================================================ */
.catalog-header {
    background: rgba(255,255,255,.97);
    border-bottom: 1px solid rgba(17,24,39,.08);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    padding: 14px 0;
    /* height para cálculo correto do offset sticky */
    min-height: 84px;
}

.brand-link {
    display: inline-flex;
    align-items: center;
    gap: 10px;
    color: var(--ink);
    text-decoration: none;
    min-width: 0;
}

.brand-mark {
    width: 64px; height: 64px;
    display: grid; place-items: center;
    border-radius: 14px;
    color: #fff;
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    flex-shrink: 0;
}

.brand-logo {
    width: 64px; height: 64px;
    object-fit: cover;
    border-radius: 14px;
    border: 1px solid var(--line);
    background: #fff;
    flex-shrink: 0;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

.brand-link strong {
    display: block;
    line-height: 1.15;
    font-size: 1.1rem;
    max-width: min(58vw, 360px);
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.brand-link small {
    display: block;
    color: var(--muted);
    font-size: .75rem;
}

.cart-link {
    flex: 0 0 auto;
    width: 44px; height: 44px;
    display: grid; place-items: center;
    position: relative;
    color: var(--ink);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    text-decoration: none;
    box-shadow: 0 8px 24px rgba(17,24,39,.08);
    transition: box-shadow .15s ease, transform .15s ease;
}

.cart-link:hover { transform: translateY(-1px); box-shadow: 0 12px 28px rgba(17,24,39,.12); }
.cart-link i { font-size: 1.25rem; }

.cart-badge {
    position: absolute;
    top: -7px; right: -7px;
    min-width: 20px; height: 20px;
    padding: 0 5px;
    display: grid; place-items: center;
    color: #fff;
    background: #ef4444;
    border: 2px solid #fff;
    border-radius: 999px;
    font-size: .7rem;
    font-weight: 800;
}

/* ============================================================
   FOOTER
   ============================================================ */
.catalog-footer {
    color: var(--muted);
    font-size: .85rem;
    padding: 36px 16px 40px;
    border-top: 1px solid rgba(0,0,0,.06);
    margin-top: 28px;
    background: #fff;
}

.catalog-footer-inner {
    max-width: 980px;
    margin: 0 auto 14px;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    gap: 24px;
    flex-wrap: wrap;
}

.catalog-footer-brand { display: flex; align-items: center; gap: 12px; }
.catalog-footer-brand strong { display: block; color: #111; font-size: .95rem; margin-bottom: 2px; }
.catalog-footer-brand span { font-size: .78rem; color: var(--muted); }
.catalog-footer-logo { width: 56px; height: 56px; border-radius: 12px; object-fit: cover; border: 1px solid rgba(0,0,0,.06); flex-shrink: 0; }
.catalog-footer-contact { text-align: right; font-size: .82rem; line-height: 1.55; color: var(--muted); }
.catalog-footer-contact div { margin-bottom: 2px; }
.catalog-footer-contact i { color: var(--brand); margin-right: 4px; }
.catalog-footer-contact a { color: inherit; text-decoration: none; }
.catalog-footer-contact a:hover { color: var(--brand); }
.catalog-footer small { display: block; text-align: center; margin-top: 14px; color: var(--muted); }

@media (max-width: 640px) {
    .catalog-footer-inner { flex-direction: column; gap: 14px; }
    .catalog-footer-contact { text-align: left; }
}

/* ============================================================
   PAGE HEADING
   ============================================================ */
.page-heading { margin-bottom: 16px; }
.page-heading .eyebrow { display: block; color: var(--brand); font-size: .75rem; font-weight: 800; text-transform: uppercase; }
.page-heading h1 { margin: 0; font-size: 1.55rem; font-weight: 800; }

/* ============================================================
   CATALOG INTRO
   ============================================================ */
.catalog-intro {
    display: grid;
    grid-template-columns: 1fr auto;
    align-items: center;
    gap: 16px;
    margin: 6px 0 18px;
    padding: 16px;
    background: linear-gradient(180deg, #fff, #fbfdff);
    border: 1px solid rgba(17,24,39,.08);
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(17,24,39,.06);
    min-width: 0;
}

.catalog-intro h1 {
    margin: 0;
    font-size: 1.35rem;
    font-weight: 900;
    overflow-wrap: anywhere;
}

.catalog-intro p { margin: 4px 0 0; color: var(--muted); font-size: .92rem; }

.eyebrow { color: var(--brand); font-size: .72rem; font-weight: 850; text-transform: uppercase; }

.intro-count {
    flex: 0 0 auto;
    min-width: 78px;
    padding: 10px;
    text-align: center;
    color: #fff;
    background: linear-gradient(135deg, var(--brand), var(--brand-2));
    border-radius: 14px;
}

.intro-count strong { display: block; font-size: 1.25rem; line-height: 1; }
.intro-count span { display: block; margin-top: 3px; font-size: .72rem; color: rgba(255,255,255,.72); }

/* ============================================================
   SEARCH
   ============================================================ */
.catalogo-header { max-width: 680px; margin: 0 auto 18px; }

.search-input-wrapper {
    position: relative;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 14px;
    box-shadow: 0 10px 30px rgba(17,24,39,.06);
    transition: box-shadow .15s ease;
}

.search-input-wrapper:focus-within {
    box-shadow: 0 0 0 3px color-mix(in srgb, var(--brand) 18%, transparent), 0 10px 30px rgba(17,24,39,.06);
    border-color: color-mix(in srgb, var(--brand) 42%, #fff);
}

.search-input-wrapper i.bi-search {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--muted);
    font-size: 1.05rem;
    pointer-events: none;
}

.search-input-wrapper .form-control {
    border: none;
    padding: .85rem 1rem .85rem 3rem;
    border-radius: 14px;
    background: transparent;
    font-size: 1rem;
}

.search-input-wrapper .form-control:focus { box-shadow: none; }

.clear-search {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: #9ca3af;
    text-decoration: none;
    display: flex;
    align-items: center;
}

.clear-search:hover { color: #6b7280; }

/* ============================================================
   CATEGORY CHIPS — sticky corretamente
   ============================================================ */
.categorias-scroll {
    margin-left: -12px;
    margin-right: -12px;
    padding: 8px 12px;
    overflow-x: auto;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
    position: sticky;
    top: 60px; /* altura do header */
    z-index: 10;
    background: rgba(246,247,249,.95);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.categorias-scroll::-webkit-scrollbar { display: none; }

.categorias-row {
    display: flex;
    gap: 8px;
    width: max-content;
    min-width: 100%;
}

.cat-chip {
    display: inline-flex;
    align-items: center;
    gap: 7px;
    color: var(--ink);
    background: #fff;
    text-decoration: none;
    padding: 9px 14px;
    border: 1px solid var(--line);
    border-radius: 999px;
    font-size: .86rem;
    font-weight: 700;
    white-space: nowrap;
    box-shadow: 0 5px 14px rgba(17,24,39,.04);
    transition: color .14s ease, border-color .14s ease;
}

.cat-chip:hover { color: var(--brand); border-color: color-mix(in srgb, var(--brand) 38%, #fff); }

.cat-count {
    color: var(--brand);
    background: color-mix(in srgb, var(--brand-2) 20%, #fff);
    border-radius: 999px;
    padding: 1px 7px;
    font-size: .72rem;
}

/* ============================================================
   CATEGORY SECTIONS
   ============================================================ */
.categoria-section {
    margin-bottom: 34px;
    scroll-margin-top: 110px; /* header + chips sticky */
}

.categoria-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 13px;
    gap: 10px;
}

.categoria-titulo { font-size: 1.05rem; font-weight: 850; margin: 0; min-width: 0; overflow-wrap: anywhere; }

.categoria-count {
    color: var(--muted);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 4px 10px;
    font-size: .75rem;
    font-weight: 700;
    white-space: nowrap;
}

/* ============================================================
   PRODUCT GRID
   ============================================================ */
.produtos-grid {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 10px;
}

@media (max-width: 359px) { .produtos-grid { grid-template-columns: 1fr; } }
@media (min-width: 576px)  { .produtos-grid { grid-template-columns: repeat(3, 1fr); gap: 14px; } }
@media (min-width: 768px)  { .produtos-grid { grid-template-columns: repeat(4, 1fr); } }
@media (min-width: 1200px) { .produtos-grid { grid-template-columns: repeat(5, 1fr); } }
@media (min-width: 1400px) { .produtos-grid { grid-template-columns: repeat(6, 1fr); } }

/* ============================================================
   PRODUCT CARD
   ============================================================ */
.produto-card {
    display: flex;
    flex-direction: column;
    height: 100%;
    color: inherit;
    background: var(--card);
    border: 1px solid rgba(17,24,39,.07);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 14px rgba(17,24,39,.05);
    transition: transform .18s ease, box-shadow .18s ease;
}

.produto-card-main,
.produto-title-link {
    color: inherit;
    text-decoration: none;
}

.produto-card:hover {
    color: inherit;
    transform: translateY(-2px);
    box-shadow: 0 14px 32px rgba(17,24,39,.10);
}

.produto-card-image {
    position: relative;
    aspect-ratio: 1/1.08;
    overflow: hidden;
    background: #eef1f4;
}

.produto-card-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform .28s ease;
}

.produto-card:hover .produto-card-image img { transform: scale(1.04); }

.produto-card-image .no-image {
    width: 100%;
    height: 100%;
    display: grid;
    place-items: center;
    color: #cbd5e1;
    font-size: 2.25rem;
}

.produto-badge {
    position: absolute;
    top: 8px; left: 8px;
    color: #111827;
    background: #facc15;
    border-radius: 999px;
    padding: 4px 9px;
    font-size: .68rem;
    font-weight: 850;
}

.produto-badge.badge-danger { color: #fff; background: #dc2626; }

.produto-card-body { padding: 9px 10px 11px; display: flex; flex-direction: column; flex: 1; }

.produto-nome {
    min-height: 2.25em;
    margin-bottom: 8px;
    color: var(--ink);
    font-size: .84rem;
    font-weight: 800;
    line-height: 1.25;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    overflow-wrap: anywhere;
}

.produto-precos {
    border-top: 1px solid #f1f5f9;
    padding-top: 9px;
    margin-top: auto;
}

.preco-pacote { display: flex; flex-direction: column; gap: 1px; }

.preco-unitario {
    display: block;
    color: var(--muted);
    font-size: .74rem;
    font-weight: 750;
    margin-bottom: 3px;
}

.preco-label { color: var(--muted); font-size: .72rem; font-weight: 750; text-transform: uppercase; }
.preco-valor { color: var(--brand); font-size: 1.12rem; font-weight: 900; }

.produto-cta {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex: 1;
    margin-top: 8px;
    color: #fff;
    background: var(--brand);
    border-radius: 8px;
    padding: 7px 8px;
    font-size: .76rem;
    font-weight: 800;
    text-decoration: none;
    transition: background .14s ease;
}

.produto-cta:hover { color: #fff; background: var(--brand-dark); }

.produto-actions { display: flex; align-items: center; gap: 8px; }

.quick-add-btn {
    flex: 0 0 38px;
    width: 38px; height: 38px;
    display: grid; place-items: center;
    margin-top: 8px;
    color: #fff;
    background: var(--ok);
    border: none;
    border-radius: 10px;
    font-weight: 900;
    box-shadow: 0 6px 16px rgba(22,163,74,.22);
    transition: transform .15s ease, background .15s ease, box-shadow .15s ease;
    cursor: pointer;
}

.quick-add-btn:hover { transform: translateY(-1px); box-shadow: 0 10px 22px rgba(22,163,74,.28); }
.quick-add-btn.added { background: var(--brand-2); }
.quick-add-btn:disabled {
    cursor: not-allowed;
    background: #9ca3af;
    box-shadow: none;
    opacity: .75;
    transform: none;
}

/* ============================================================
   PRODUCT DETAIL
   ============================================================ */
.main-image-wrapper {
    position: relative;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 14px;
    overflow: hidden;
    aspect-ratio: 1/1;
    box-shadow: 0 12px 30px rgba(17,24,39,.08);
}

.main-image { width: 100%; height: 100%; object-fit: contain; background: #fff; user-select: none; }

.gallery-nav {
    position: absolute;
    top: 50%;
    transform: translateY(-50%);
    width: 42px; height: 42px;
    display: grid; place-items: center;
    color: var(--ink);
    background: rgba(255,255,255,.94);
    border: 1px solid rgba(17,24,39,.08);
    border-radius: 999px;
    box-shadow: 0 8px 18px rgba(17,24,39,.15);
    cursor: pointer;
    text-decoration: none;
    transition: transform .15s ease, box-shadow .15s ease;
}

.gallery-nav:hover { box-shadow: 0 12px 24px rgba(17,24,39,.2); }
.gallery-nav.prev { left: 12px; }
.gallery-nav.next { right: 12px; }

.image-counter {
    position: absolute;
    right: 12px; bottom: 12px;
    color: #fff;
    background: rgba(17,24,39,.74);
    border-radius: 999px;
    padding: 4px 11px;
    font-size: .78rem;
    font-weight: 700;
}

.thumbnails-row { display: flex; gap: 8px; overflow-x: auto; padding: 4px 0; }

.thumb-item {
    flex: 0 0 68px;
    aspect-ratio: 1/1;
    padding: 0;
    background: #fff;
    border: 2px solid transparent;
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    transition: border-color .14s ease;
}

.thumb-item img { width: 100%; height: 100%; object-fit: cover; }
.thumb-item.active { border-color: var(--brand); }
.thumb-item:hover:not(.active) { border-color: color-mix(in srgb, var(--brand) 38%, #fff); }

.product-info { padding: 0 2px; }

.product-code {
    display: inline-flex;
    color: var(--muted);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 999px;
    padding: 4px 10px;
    font-size: .75rem;
    font-weight: 800;
    margin-bottom: 10px;
}

.product-title { color: var(--ink); font-size: 1.55rem; font-weight: 900; line-height: 1.15; }

.price-block,
.purchase-box,
.checkout-form,
.checkout-summary,
.total-card,
.cart-item {
    background: #fff;
    border: 1px solid rgba(17,24,39,.08);
    border-radius: 14px;
    box-shadow: 0 10px 30px rgba(17,24,39,.06);
}

.price-block { padding: 16px; }

.unit-price-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    color: var(--muted);
    border-bottom: 1px solid var(--line);
    padding-bottom: 10px;
    margin-bottom: 12px;
    font-size: .9rem;
}

.unit-price-info strong { color: var(--ink); white-space: nowrap; }

.price-package {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.price-label { color: var(--muted); font-size: .9rem; font-weight: 750; }
.price-value { color: var(--brand); font-size: 1.65rem; font-weight: 950; white-space: nowrap; }

.purchase-box { padding: 16px; }

.package-summary {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    background: #f8fafc;
    border: 1px solid var(--line);
    border-radius: 12px;
    padding: 12px;
    margin-bottom: 12px;
    align-items: center;
}

.qty-controls {
    display: flex;
    align-items: stretch;
    max-width: 180px;
}

.qty-controls input {
    border-left: none;
    border-right: none;
    font-weight: 800;
    -moz-appearance: textfield;
    text-align: center;
}

.qty-controls input::-webkit-outer-spin-button,
.qty-controls input::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

.total-preview {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 0 0;
    border-top: 1px dashed var(--line);
    font-size: 1.05rem;
}

/* Buttons */
.btn-success { background: var(--ok); border-color: var(--ok); font-weight: 800; box-shadow: 0 12px 24px rgba(22,163,74,.22); }
.btn-primary { background: var(--brand); border-color: var(--brand); font-weight: 800; }

/* Empty state */
.empty-state {
    text-align: center;
    color: var(--muted);
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 16px;
    padding: 44px 18px;
}

.empty-state i { color: #cbd5e1; font-size: 4rem; }
.empty-state h5 { margin-top: 14px; color: var(--ink); font-weight: 850; }

/* Cart */
.cart-item { padding: 12px; margin-bottom: 10px; }

.cart-thumb {
    width: 66px; height: 66px;
    object-fit: cover;
    border-radius: 10px;
}

.total-card {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
}

.total-card span { color: var(--muted); font-weight: 750; }
.total-card strong { color: var(--brand); font-size: 1.35rem; }

.checkout-form { padding: 16px; }
.checkout-summary { padding: 14px; }
.checkout-summary h6 { color: var(--ink); font-weight: 850; margin-bottom: 10px; }

.summary-line,
.summary-total {
    display: flex;
    justify-content: space-between;
    gap: 12px;
    padding: 8px 0;
}

.summary-line span,
.cart-item .fw-bold {
    min-width: 0;
    overflow-wrap: anywhere;
}

.summary-line span {
    display: flex;
    flex-direction: column;
    line-height: 1.25;
}

.summary-line small { color: var(--muted); margin-top: 2px; }

.summary-total {
    border-top: 1px dashed var(--line);
    margin-top: 8px;
    padding-top: 12px;
    font-size: 1.08rem;
}

.summary-total strong { color: var(--brand); }

/* ============================================================
   TABLET (≥768px)
   ============================================================ */
@media (min-width: 768px) {
    main.container { max-width: 1120px; }
    .product-title { font-size: 1.9rem; }
    .categorias-scroll { top: 62px; }
}

/* ============================================================
   MOBILE (<576px)
   ============================================================ */
@media (max-width: 575.98px) {
    .catalog-header { padding: 10px 0; min-height: 70px; }

    main.container { padding-left: 12px; padding-right: 12px; }

    .brand-mark, .brand-logo { width: 52px; height: 52px; border-radius: 12px; }
    .brand-link { gap: 8px; }
    .brand-link strong { font-size: .92rem; max-width: 54vw; }
    .brand-link small { font-size: .69rem; }

    .cart-link { width: 40px; height: 40px; }

    /* Intro card em coluna */
    .catalog-intro {
        grid-template-columns: 1fr;
        gap: 10px;
        padding: 14px;
    }

    .catalog-intro h1 { font-size: 1.2rem; }
    .catalog-intro p { font-size: .85rem; }

    .intro-count {
        width: 100%;
        display: flex;
        justify-content: center;
        align-items: baseline;
        gap: 6px;
        padding: 9px;
    }

    .intro-count strong,
    .intro-count span { display: inline; margin: 0; }

    /* Sticky offset para o header menor */
    .categorias-scroll { top: 56px; margin-left: -12px; margin-right: -12px; }
    .categoria-section { scroll-margin-top: 120px; }

    .categoria-header { align-items: flex-start; flex-direction: column; }
    .categoria-count { align-self: flex-start; }

    .produto-card-image { aspect-ratio: 1/1.03; }
    .produto-card-body { padding: 8px 8px 10px; }
    .produto-nome { font-size: .82rem; }
    .preco-valor { font-size: 1.02rem; }
    .produto-cta { padding: 7px 6px; }
    .quick-add-btn { flex-basis: 36px; width: 36px; height: 36px; }

    .product-title { font-size: 1.32rem; }

    .price-package,
    .package-summary,
    .total-preview,
    .summary-line,
    .summary-total {
        align-items: flex-start;
        flex-direction: column;
    }

    .price-value { font-size: 1.45rem; white-space: normal; }
    .qty-controls { width: 100%; max-width: none; }

    .cart-item { padding: 10px; }
    .cart-thumb { width: 58px; height: 58px; }
    .total-card { gap: 8px; }

    .checkout-form .btn,
    .purchase-box .btn,
    #cart-content > .btn { min-height: 48px; }
}

@media (max-width: 420px) {
    main.container { padding-left: 10px; padding-right: 10px; }
    .produtos-grid { gap: 8px; }
    .preco-label { font-size: .68rem; }
    .preco-unitario { font-size: .69rem; }
    .preco-valor { font-size: .98rem; }
    .produto-cta { font-size: .72rem; }
}

@media (max-width: 319px) {
    .brand-link small, .intro-count { display: none; }
    .brand-link strong { max-width: 48vw; }
}

/* Sem hover em touch */
@media (hover: none) {
    .produto-card:hover { transform: none; }
    .cart-link:hover { transform: none; }
    .quick-add-btn:hover { transform: none; }
}
