/* 1. RESET BÁSICO */
html, body {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    width: 100%;
    max-width: 100vw;
    overflow-x: hidden; /* Trava mestre contra scroll lateral */
    position: relative;
}

*, *::before, *::after {
    box-sizing: inherit;
}

:root {
    --bg-main: #f9fafb;
    --text-main: #0f172a;
    --text-muted: #64748b;
    --accent: #005f69;
    
    --font-heading: 'Montserrat', sans-serif;
    --font-body: 'Inter', sans-serif;
}

body {
    font-family: var(--font-body);
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    padding-bottom: 200px; 
    scroll-behavior: smooth;
    overflow-x: hidden;
}

.container {
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 24px;
}

/* 2. HEADER E CAPA */
.hero-wrapper {
    background-color: #f1f5f9;
    padding: 40px 24px;
    display: flex;
    justify-content: center;
    border-bottom: 1px solid #e2e8f0;
    width: 100%;
    position: relative;
    overflow: hidden;
}

.hero-wrapper::before,
.hero-wrapper::after {
    content: '';
    position: absolute;
    background-image: url('logos/simbolo-azul.png');
    background-repeat: no-repeat;
    background-size: contain;
    opacity: 0.04;
    pointer-events: none;
    z-index: 1;
}

.hero-wrapper::before {
    width: 1200px;
    height: 1200px;
    top: -350px;
    left: -400px;
    transform: rotate(-35deg);
}

.hero-wrapper::after {
    width: 1200px;
    height: 1200px;
    top: -350px;
    right: -400px;
    transform: rotate(35deg);
}

.hero {
    position: relative;
    z-index: 2;
    background-size: cover;
    background-position: center;
    width: 100%;
    max-width: 1100px;
    aspect-ratio: 16 / 9; /* Respeita o corte que você fez */
    border-radius: 16px;
    box-shadow: 0 30px 60px rgba(0,0,0,0.12);
    cursor: pointer;
    overflow: hidden;
}

/* 3. CONTROLES E FILTROS */
.header-controls-wrapper {
    display: flex; 
    flex-direction: column;
    align-items: center;
    gap: 16px; /* Reduzido de 24px */
    margin: 20px 0 20px 0; /* Reduzido de 40px/32px */
    width: 100%;
}

.catalog-filters {
    display: flex;
    justify-content: center; 
    flex-wrap: wrap; 
    gap: 16px;
    width: 100%;
    scrollbar-width: none; 
    -ms-overflow-style: none; 
}

.catalog-filters::-webkit-scrollbar { display: none; }

.catalog-filters button {
    background: none;
    border: none;
    color: var(--text-muted);
    font-family: var(--font-body);
    font-size: 0.85rem;
    font-weight: 500;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    cursor: pointer;
    padding: 12px 18px;
    position: relative;
    transition: all 0.3s ease;
    white-space: nowrap;
    flex-shrink: 0;
}

.catalog-filters button:hover, 
.catalog-filters button.active {
    color: var(--text-main);
    font-weight: 600;
}

.catalog-filters button.active::after {
    content: '';
    position: absolute;
    bottom: -1px;
    left: 0;
    right: 0;
    height: 2px;
    background-color: var(--accent);
}

/* BUSCA */
.search-wrapper {
    flex-grow: 1;
    max-width: 450px;
    position: relative;
}
.search-wrapper input {
    width: 100%;
    padding: 16px 28px 16px 48px;
    border-radius: 99px; 
    border: 2px solid transparent; 
    font-size: 1.05rem; 
    background-color: #ffffff;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="%2394a3b8" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><circle cx="11" cy="11" r="8"></circle><line x1="21" y1="21" x2="16.65" y2="16.65"></line></svg>');
    background-repeat: no-repeat;
    background-position: 20px center;
    background-size: 18px;
    color: var(--text-main);
    box-shadow: 0 4px 15px rgba(0,0,0,0.06); 
    outline: none;
    transition: all 0.3s;
}

@media (max-width: 768px) {
    .catalog-filters {
        display: flex !important;
        justify-content: center !important;
        flex-wrap: wrap !important;
        gap: 5px 15px; /* Mais espaço horizontal, menos vertical */
        padding: 0 10px 10px 10px; /* Zerado o topo (padding-top: 0) */
        width: 100%;
        text-align: center;
        overflow-x: visible;
    }
    .catalog-filters button {
        background: none !important;
        border: none !important;
        box-shadow: none !important;
        font-size: 0.85rem;
        padding: 10px 5px; /* Reduzido o topo para 10px para alinhar com a busca */
        color: var(--text-muted);
        text-transform: uppercase;
        border-radius: 0;
    }
    .catalog-filters button.active {
        color: var(--text-main);
        font-weight: 700;
        background: none !important;
    }
    .catalog-filters button.active::after { 
        display: block !important; 
        content: '';
        position: absolute;
        bottom: 2px;
        left: 5px;
        right: 5px;
        height: 2px;
        background-color: var(--accent);
    }

    .search-wrapper { 
        max-width: 100%; 
        order: -1; 
        margin-bottom: 12px; /* Reduzido de 25px para compactar */
    } 
    .catalog-filters {
        gap: 0px 8px !important; /* Gap mínimo para caber mais itens sem bagunçar */
        padding: 0 5px 5px 5px !important; /* Zerado o topo no bloco ultra-compacto */
    }
    .catalog-filters button {
        padding: 16px 4px !important; /* Aumentado para 16px para igualar o respiro superior */
        font-size: 0.75rem !important; 
    }
}

/* 4. GRID DE PRODUTOS */
.products-section { padding-bottom: 120px; }

.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 32px;
    align-items: stretch; /* Garante que todas as cartas tenham a mesma altura por linha */
}

.product-card {
    background-color: #ffffff;
    padding: 32px 24px;
    text-align: center;
    border: 1px solid #f1f5f9;
    border-radius: 12px;
    transition: all 0.4s ease;
    display: flex;
    flex-direction: column; /* Necessário para alinhar controles no fundo */
    height: 100%;
    position: relative;
}

.product-card:hover {
    box-shadow: 0 20px 40px rgba(0,0,0,0.05);
    transform: translateY(-5px);
}

.product-card img {
    max-width: 100%;
    height: 220px;
    object-fit: contain;
    margin-bottom: 20px;
    mix-blend-mode: multiply;
}

.categoria-tag {
    display: block;
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1.5px;
    margin-bottom: 8px;
}

.product-card h3 {
    font-family: var(--font-heading);
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 20px;
    
    /* Nova lógica para evitar texto fantasma */
    height: 2.8em; 
    line-height: 1.4em;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-align: center;
}

.product-controls {
    margin-top: auto;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.quantity-selector {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    background: #f8fafc;
    padding: 6px;
    border-radius: 8px;
}

.qty-btn {
    width: 32px;
    height: 32px;
    border: none;
    background: white;
    border-radius: 6px;
    font-size: 1.2rem;
    cursor: pointer;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.qty-input {
    width: 45px;
    height: 38px; /* Aumentado para melhor toque */
    text-align: center;
    border: 1px solid #e2e8f0;
    background: #ffffff;
    border-radius: 6px;
    font-weight: 700;
    font-size: 1.1rem;
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0; /* Remove padding que desloca o número */
    outline: none;
}

/* Remove as setinhas padrão do navegador para o número ficar centralizado */
.qty-input::-webkit-outer-spin-button,
.qty-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.buy-button, .btn-add-cart {
    background-color: var(--accent);
    color: white;
    border: none;
    padding: 12px;
    border-radius: 8px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: opacity 0.3s;
}

.buy-button {
    background-color: transparent;
    color: var(--accent);
    border: 1px solid var(--accent);
    margin-bottom: 12px;
}

.buy-button:hover { background: #f0fdfa; }
.btn-add-cart:hover { opacity: 0.9; }

/* PRICING */
.product-pricing {
    margin-top: 16px;
    padding-top: 16px;
    border-top: 1px solid #f1f5f9;
}

.price-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.75rem;
    margin-bottom: 4px;
}

.price-condition { color: var(--text-muted); }
.price-value { font-weight: 700; color: var(--text-main); }

/* MOBILE GRID */
@media (max-width: 480px) {
    .products-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .product-card { padding: 16px 12px; }
    .product-card img { height: 140px; }
    .product-card h3 { font-size: 0.85rem; }
    .qty-btn { width: 44px; height: 44px; }
}

/* 5. GAVETA */
.modal-backdrop {
    position: fixed;
    top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s;
}
.modal-backdrop.active { opacity: 1; pointer-events: auto; }

.product-drawer {
    position: fixed;
    bottom: 0; left: 0; width: 100%;
    height: 85vh;
    background: white;
    border-radius: 24px 24px 0 0;
    z-index: 10000;
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
}
@media (min-width: 768px) {
    .product-drawer { width: 450px; height: 100%; right: 0; left: auto; border-radius: 20px 0 0 20px; transform: translateX(100%); }
    .product-drawer.active { transform: translateX(0); }
}
.product-drawer.active { transform: translateY(0); }

.drawer-header { padding: 20px; display: flex; justify-content: flex-end; }
.drawer-content { padding: 0 32px 32px 32px; overflow-y: auto; flex-grow: 1; }

.cart-widget {
    position: fixed;
    bottom: 25px; left: 50%;
    transform: translateX(-50%) translateY(150%);
    width: 92%; 
    max-width: 380px; /* Largura otimizada para mobile */
    background: #0f172a;
    color: white;
    padding: 0 8px 0 24px;
    height: 65px;
    border-radius: 50px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 20px 40px rgba(0,0,0,0.25);
    z-index: 9999;
    transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}
.cart-widget.active { transform: translateX(-50%) translateY(0); }
.btn-view-cart {
    background: white; color: var(--text-main);
    border: none; padding: 8px 16px; border-radius: 20px;
    font-weight: 700; cursor: pointer;
}

/* CHECKOUT MODAL */
.checkout-modal {
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 92%; max-width: 500px; /* Levemente menor para respiro lateral */
    background: white; border-radius: 20px;
    padding: 20px; z-index: 10001;
    display: none; 
    max-height: 90vh; /* Máximo de altura do modal */
    flex-direction: column; 
    overflow: hidden; /* O modal em si NUNCA rola, apenas o meio dele */
}
.checkout-modal.active { display: flex; }
#checkout-order-details {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-height: 0; /* Essencial para permitir o scroll interno no Flexbox */
}
.order-items {
    flex: 1;
    min-height: 0; /* Permite que a lista encolha e ative o scroll */
    overflow-y: auto;
    -webkit-overflow-scrolling: touch; /* Melhora o scroll no iPhone */
    padding-right: 8px;
    margin: 15px 0;
}
.order-items::-webkit-scrollbar {
    width: 6px;
}
.order-items::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 10px;
}
.order-items::-webkit-scrollbar-thumb {
    background: #94a3b8; /* Cor um pouco mais escura para ser mais visível */
    border-radius: 10px;
}
.order-item-row {
    display: flex;
    justify-content: space-between;
    align-items: flex-start; /* Alinha pelo topo para nomes longos */
    padding: 12px 0;
    border-bottom: 1px solid #f1f5f9;
    gap: 15px; /* Espaço entre nome e preço */
}
.order-item-row:last-child { border-bottom: none; }

.item-info {
    flex: 1; /* Nome ocupa o espaço que sobrar */
    min-width: 0;
}
.item-price-area {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-shrink: 0; /* Impede que o preço quebre para baixo */
    text-align: right;
    font-weight: 700;
}

.item-name {
    display: block;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-main);
}
.item-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.order-summary {
    background: #f8fafc;
    padding: 20px;
    border-radius: 12px;
    margin: 20px 0;
}
.summary-row {
    display: flex;
    justify-content: space-between;
    margin-bottom: 8px;
    font-size: 0.85rem;
}
.summary-total { 
    font-weight: 800; 
    font-size: 1.4rem; 
    color: var(--accent); 
    margin-top: 15px; 
    border-top: 2px solid #e2e8f0; 
    padding-top: 15px; 
}
.tier-badge { 
    background: var(--accent); 
    color: white; 
    padding: 2px 8px; 
    border-radius: 4px; 
    font-size: 0.7rem; 
    font-weight: 700;
}

.btn-clear-cart {
    display: block;
    width: 100%;
    background: none;
    border: none;
    color: #ef4444;
    font-size: 0.8rem;
    font-weight: 600;
    text-decoration: underline;
    cursor: pointer;
    margin-top: 12px;
    text-align: center;
    transition: opacity 0.2s;
}
.btn-clear-cart:hover { opacity: 0.7; }

.salesperson-section {
    margin-top: 24px;
    text-align: center;
}
.salesperson-section h3 {
    font-size: 1rem;
    margin-bottom: 16px;
    color: var(--text-main);
    width: 100%;
    text-align: center;
}

.salesperson-grid {
    display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-top: 20px;
}
.btn-salesperson {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px; /* Espaço entre o ícone e o nome */
    border: 1px solid #e2e8f0;
    background: white;
    padding: 12px 8px;
    border-radius: 12px;
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s;
    font-size: 0.9rem;
}
.btn-salesperson:hover { 
    border-color: var(--accent); 
    background-color: #f0fdfa;
}
.wa-icon { 
    width: 20px; 
    height: 20px;
    color: #25d366; 
}
@media (max-width: 768px) {
    .container { padding: 0 10px; }
    .hero-wrapper { 
        padding-top: 5px !important; 
        padding-bottom: 8px !important; /* Aumentado para dar mais respiro ao banner */
    }
    .hero {
        aspect-ratio: 16 / 9;
        min-height: 200px; /* Garante que a capa apareça mesmo em navegadores antigos */
        margin-bottom: 0; 
    }
    .header-controls-wrapper {
        margin: 8px 0 8px 0 !important; /* Aumentado para 8px para totalizar 16px com o banner */
        gap: 0 !important; 
    }
    .products-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
        padding: 0 12px;
        width: 100%;
        margin: 0;
        box-sizing: border-box; 
    }
    .search-wrapper {
        width: calc(100% - 24px); 
        margin: 0 auto 0 !important; 
    }
}
@media (max-width: 480px) {
    .products-grid {
        padding: 0 8px; 
        gap: 8px;
    }
    .search-wrapper {
        width: calc(100% - 16px);
    }
    .product-card { 
        padding: 12px 8px !important; 
    }
    .product-card h3 { 
        font-size: 0.95rem !important; 
        height: 2.6em !important;
        line-height: 1.3em !important;
        -webkit-line-clamp: 2 !important;
        display: -webkit-box !important;
        -webkit-box-orient: vertical !important;
        overflow: hidden !important;
        margin-bottom: 12px !important;
    }
    .qty-btn { 
        width: 32px !important; /* Ligeiramente mais compacto */
        height: 32px !important; 
        font-size: 0.9rem !important;
    }
    .qty-input { 
        width: 30px !important; 
        height: 32px !important; 
        font-size: 0.9rem !important;
    }
    .quantity-selector {
        gap: 4px !important;
        padding: 2px !important;
    }
    .btn-add-cart, .buy-button {
        padding: 8px 4px !important;
        font-size: 0.7rem !important;
    }
    .price-row {
        font-size: 0.65rem !important;
    }

    /* Restaura os vendedores em linha */
    .salesperson-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 5px;
        margin-top: 15px;
    }
    .btn-salesperson {
        flex-direction: row !important;
        padding: 12px 2px !important;
        font-size: 1.1rem !important; /* For\u00e7ado no bloco mobile */
        gap: 6px !important;
        justify-content: center;
        font-weight: 800 !important;
    }
    .wa-icon { width: 22px !important; height: 22px !important; }
}

.min-order-alert { background: #fef2f2; color: #dc2626; padding: 10px; border-radius: 8px; text-align: center; margin-top: 15px; display: none; }
.min-order-alert.active { display: block; }

/* 6. DETALHES INTERNOS DA GAVETA (RESTAURAÇÃO) */
.drawer-product-hero {
    text-align: center;
    margin-bottom: 30px;
    padding-top: 20px;
}
.drawer-product-hero img {
    max-width: 220px;
    height: auto;
    margin-bottom: 20px;
}
.drawer-product-hero span {
    display: block;
    font-size: 0.7rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 2px;
}
.drawer-product-hero h2 {
    font-size: 1.5rem;
    font-weight: 700;
    font-family: var(--font-heading);
}

.drawer-pricing {
    background: #f8fafc;
    padding: 20px;
    border-radius: 12px;
    margin-bottom: 30px;
}
.drawer-pricing h4 {
    font-size: 0.8rem;
    margin-bottom: 12px;
    color: var(--text-muted);
}

.nutrition-facts {
    border: 1px solid #e2e8f0;
    padding: 20px;
    border-radius: 8px;
    font-size: 0.85rem;
}
.nutrition-facts h3 {
    border-bottom: 4px solid #000;
    padding-bottom: 4px;
    margin-bottom: 8px;
    font-size: 1.1rem;
}
.nutrition-table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
}
.nutrition-table th, .nutrition-table td {
    padding: 6px 0;
    border-bottom: 1px solid #e2e8f0;
    text-align: left;
}
.nutrition-table th { font-weight: 700; }
.nutrition-table td { text-align: right; }

.close-drawer-btn {
    background: #f1f5f9;
    border: none;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--text-main);
    transition: background 0.2s;
}
.close-drawer-btn:hover { background: #e2e8f0; }

.checkout-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid #f1f5f9;
}
