:root {
    --primary-color: #1e3a8a;
    --secondary-color: #f50a0a;
    --bg-color: #f8fafc;
    --text-color: #0f172a;
    --border-color: #e2e8f0;
    --card-bg: #ffffff;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    line-height: 1.5;
}

.header { background-color: var(--primary-color); color: #fff; padding: 1rem; }
.btn-primary { background-color: var(--primary-color); color: #fff; border: none; padding: 0.5rem 1rem; border-radius: 4px; cursor: pointer; }
.btn-secondary { background-color: var(--secondary-color); color: #fff; border: none; padding: 0.5rem 1rem; border-radius: 4px; cursor: pointer; }
.price-tag { color: var(--secondary-color); font-weight: bold; }

/* Layout Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem 1rem;
}

/* Header & Navegação */
.site-header {
    background-color: #ffffff;
    border-bottom: 1px solid var(--border-color);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.header-top {
    max-width: 1200px;
    margin: 0 auto;
    padding: 1rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1.5rem;
}

.logo a {
    text-decoration: none;
    color: var(--primary-color);
}

.logo h1 {
    text-decoration: none;
    font-size: 1.5rem;
    font-weight: 800;
}

.header-search {
    flex: 1;
    max-width: 500px;
}

.header-search form {
    display: flex;
    gap: 0.5rem;
}

.header-search input {
    width: 100%;
    padding: 0.6rem 1rem;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    outline: none;
}

.main-nav {
    background-color: var(--primary-color);
}

/* Aplica flexbox apenas no primeiro nível (categorias principais) */
.main-nav > ul {
    max-width: 1200px;
    margin: 0 auto;
    list-style: none;
    display: flex;
    padding: 0 1rem;
}

.main-nav a {
    color: #ffffff;
    text-decoration: none;
    padding: 0.8rem 1.2rem;
    display: block;
    font-size: 0.95rem;
    font-weight: 500;
}

.main-nav a:hover {
    background-color: rgba(255,255,255,0.1);
}

/* Dropdown Subcategorias */
.nav-item {
    position: relative;
}

.nav-item:hover > .dropdown {
    display: block;
}

.dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    background: #ffffff;
    min-width: 220px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border-radius: 0 0 6px 6px;
    z-index: 100;
    padding: 0;
    margin: 0;
    list-style: none;
}

/* Garante a disposição vertical dos itens do submenu */
.dropdown li {
    display: block;
    width: 100%;
}

.dropdown a {
    color: var(--text-color);
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--border-color);
    display: block;
    white-space: nowrap;
}

.dropdown li:last-child a {
    border-bottom: none;
}

.dropdown a:hover {
    background-color: var(--bg-color);
    color: var(--primary-color);
}

/* Grids e Cards */
.grid-4 {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 1.5rem;
}

.hero {
    background: linear-gradient(135deg, var(--primary-color), #3b82f6);
    color: #ffffff;
    padding: 3rem 2rem;
    border-radius: 8px;
    text-align: center;
    margin-bottom: 2rem;
}

.product-card {
    background-color: var(--card-bg);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.product-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 15px -3px rgba(0,0,0,0.1);
}

.product-card img {
    width: 100%;
    height: 180px;
    object-fit: cover;
    border-radius: 6px;
    margin-bottom: 0.8rem;
}

.product-card h4 {
    font-size: 1rem;
    margin-bottom: 0.4rem;
}

.product-card .code {
    font-size: 0.8rem;
    color: #64748b;
    margin-bottom: 0.5rem;
}

.product-card .price-atacado {
    font-size: 0.9rem;
    color: var(--secondary-color);
    margin-bottom: 1rem;
}

/* Botões */
.btn-primary {
    background-color: var(--primary-color);
    color: #ffffff;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    font-weight: 600;
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: #ffffff;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    cursor: pointer;
    text-decoration: none;
    text-align: center;
    font-weight: 600;
}

.btn-danger {
    background-color: #ef4444;
    color: #ffffff;
    border: none;
    padding: 0.4rem 0.8rem;
    border-radius: 4px;
    cursor: pointer;
}

/* Tabelas e Carrinho */
.cart-table {
    width: 100%;
    border-collapse: collapse;
    background: #ffffff;
    border-radius: 8px;
    overflow: hidden;
    margin: 1.5rem 0;
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.cart-table th, .cart-table td {
    padding: 1rem;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
}

.cart-table th {
    background-color: #f1f5f9;
}

.checkout-form {
    background: #ffffff;
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    margin-top: 2rem;
    max-width: 500px;
}

.checkout-form input {
    width: 100%;
    padding: 0.75rem;
    margin-bottom: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

.checkout-form textarea {
    width: 100%;
    padding: 0.75rem;
    margin-bottom: 1rem;
    border: 1px solid var(--border-color);
    border-radius: 4px;
}

/* Footer */
.site-footer {
    background-color: #0f172a;
    color: #94a3b8;
    text-align: center;
    padding: 2rem 1rem;
    margin-top: 4rem;
}

/* --- ESTILOS GERAIS DO TOPO --- */
.site-header {
    background-color: #ffffff;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.08);
    position: sticky;
    top: 0;
    z-index: 1000;
    width: 100%;
}

.header-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 10px 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand-logo img {
    max-height: 45px;
    width: auto;
    display: block;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

/* Busca */
.search-form {
    display: flex;
    align-items: center;
    border: 1px solid #e0e0e0;
    border-radius: 20px;
    padding: 4px 10px;
    background-color: #f9f9f9;
}

.search-form input {
    border: none;
    background: transparent;
    outline: none;
    padding: 5px;
    font-size: 14px;
}

.search-form button {
    background: transparent;
    border: none;
    cursor: pointer;
    color: #555;
    display: flex;
    align-items: center;
}

/* Ícone Carrinho com contador */
.cart-btn {
    position: relative;
    color: #333;
    display: flex;
    align-items: center;
    text-decoration: none;
}

.cart-badge {
    position: absolute;
    top: -6px;
    right: -8px;
    background-color: #e63946;
    color: #fff;
    font-size: 11px;
    font-weight: bold;
    border-radius: 50%;
    padding: 2px 6px;
    min-width: 18px;
    text-align: center;
}

/* Menu de Navegação Desktop */
.nav-menu {
    background-color: #f8f9fa;
    border-top: 1px solid #eee;
}

.nav-menu ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    justify-content: center;
    gap: 20px;
}

.nav-menu a {
    display: block;
    padding: 12px 15px;
    color: #333;
    text-decoration: none;
    font-weight: 500;
    transition: color 0.2s;
}

.nav-menu a:hover {
    color: #007bff;
}

/* Botão Hambúrguer (Escondido no Desktop) */
.mobile-toggle {
    display: none;
    flex-direction: column;
    justify-content: space-around;
    width: 28px;
    height: 24px;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
}

.mobile-toggle span {
    width: 100%;
    height: 3px;
    background-color: #333;
    border-radius: 2px;
    transition: all 0.3s ease;
}

/* --- REGRAS RESPONSIVAS (MOBILE) --- */
@media (max-width: 768px) {
    .mobile-toggle {
        display: flex;
    }

    /* Oculta busca no topo para poupar espaço em telas muito pequenas */
    .search-form {
        display: none;
    }

    /* Transforma a navegação em menu gaveta colapsável */
    .nav-menu {
        display: none;
        position: absolute;
        top: 100%;
        left: 0;
        width: 100%;
        background-color: #ffffff;
        box-shadow: 0 5px 15px rgba(0, 0, 0, 0.1);
        border-top: 1px solid #eee;
    }

    .nav-menu.active {
        display: block;
    }

    .nav-menu ul {
        flex-direction: column;
        gap: 0;
    }

    .nav-menu a {
        padding: 15px 20px;
        border-bottom: 1px solid #f0f0f0;
    }

    /* Animação simples no hambúrguer quando ativo */
    .mobile-toggle.active span:nth-child(1) {
        transform: translateY(8px) rotate(45deg);
    }
    .mobile-toggle.active span:nth-child(2) {
        opacity: 0;
    }
    .mobile-toggle.active span:nth-child(3) {
        transform: translateY(-8px) rotate(-45deg);
    }
}

/* --- BUSCA RESPONSIVA --- */
.search-form {
    display: flex;
    align-items: center;
    border: 1px solid #d0d0d0;
    border-radius: 20px;
    padding: 4px 12px;
    background-color: #f9f9f9;
    width: 100%;
}

.search-form input {
    border: none;
    background: transparent;
    outline: none;
    padding: 6px;
    font-size: 14px;
    width: 100%;
}

.search-form button {
    background: transparent;
    border: none;
    cursor: pointer;
    color: #555;
    display: flex;
    align-items: center;
    padding: 0 4px;
}

/* Comportamento da busca em Telas Grandes (Desktop) */
@media (min-width: 769px) {
    .header-search-desktop {
        flex: 1;
        max-width: 450px;
        margin: 0 20px;
    }

    .header-search-mobile {
        display: none; /* Esconde o container mobile no desktop */
    }
}

/* Comportamento da busca em Dispositivos Móveis (Mobile) */
@media (max-width: 768px) {
    .header-search-desktop {
        display: none; /* Esconde a busca do topo no mobile */
    }

    .header-search-mobile {
        display: block;
        padding: 0 15px 10px 15px; /* Exibe a busca logo abaixo do logo e carrinho */
    }
}