:root {
    --blue: #1E5EFF;
    --blue-dark: #0f3db3;
    --gold: #D4AF37;
    --gold-light: #f5d66d;
    --white: #FFFFFF;
    --gray-light: #F5F5F5;
    --gray-medium: #E0E0E0;
    --gray-dark: #666666;
    --text-dark: #222222;
    --shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    --border-radius: 12px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Arial, sans-serif;
}

body {
    background-color: var(--gray-light);
    color: var(--text-dark);
    padding-top: 150px;
    padding-bottom: 70px;
    -webkit-font-smoothing: antialiased;
    text-rendering: optimizeLegibility;
}

/* Modifique sua regra existente do header */
header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    background-color: var(--white);
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
    z-index: 1000;
    padding: 8px 20px;
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    /* ADICIONE ESTA LINHA ABAIXO */
    transition: transform 0.3s ease-in-out; 
}

/* ADICIONE ESTA NOVA CLASSE */
.header-hidden {
    transform: translateY(-100%);
}

.logo {
    display: flex;
    align-items: center;
    text-decoration: none;
    gap: 4px; 
    order: 1; 
}

.logo img {
    height: 68px; 
    width: auto;
    object-fit: contain;
}

.logo span {
    background: linear-gradient(135deg, var(--blue), var(--blue-dark));
    color: var(--white);
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 14px; 
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    font-family: 'Montserrat', sans-serif;
    box-shadow: 0 3px 8px rgba(30, 94, 255, 0.25);
    line-height: 1;
}

.header-actions {
    display: flex;
    gap: 25px; 
    align-items: center;
    order: 2; 
}

.icon-btn {
    background: none;
    border: none;
    font-size: 26px; 
    color: var(--text-dark);
    cursor: pointer;
    position: relative;
    display: flex;
    align-items: center;
    height: 100%; 
}

.cart-badge {
    position: absolute;
    top: -5px;
    right: -10px;
    background-color: var(--blue);
    color: var(--white);
    font-size: 11px;
    font-weight: bold;
    height: 18px;
    width: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.search-container {
    position: relative;
    width: 100%;
    order: 3; 
    margin-top: 10px; 
}

.search-container input {
    width: 100%;
    padding: 10px 15px 10px 40px; 
    border: 1px solid var(--gray-medium);
    border-radius: 20px;
    background-color: var(--gray-light);
    font-size: 14px;
    outline: none;
    transition: border-color 0.3s;
}

.search-container input:focus {
    border-color: var(--blue);
}

.search-container > i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-dark);
}

/* MAIN CONTENT */
main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
}

/* BANNER */
.banner {
    background: linear-gradient(135deg, #111 0%, #222 100%);
    border-radius: var(--border-radius);
    padding: 25px 20px;
    color: var(--white);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: relative;
    overflow: hidden;
    margin-bottom: 25px;
    box-shadow: var(--shadow);
}

.banner::before {
    content: '';
    position: absolute;
    right: -20%;
    top: -50%;
    width: 60%;
    height: 200%;
    background: var(--blue);
    transform: rotate(-15deg);
    z-index: 1;
    border-left: 5px solid var(--gold);
}

.banner-content {
    position: relative;
    z-index: 2;
    max-width: 60%;
}

.banner h2 {
    font-size: 18px;
    margin-bottom: 5px;
    font-weight: 600;
}

.banner .highlight {
    color: var(--gold);
    font-size: 24px;
    font-weight: 800;
    display: block;
}

.banner-img-placeholder {
    position: relative;
    z-index: 2;
    width: 80px;
    height: 80px;
    background: rgba(255,255,255,0.1);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 30px;
}

/* CATEGORIES */
.categories {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 15px;
    margin-bottom: 30px;
}

.category-item {
    background-color: var(--white);
    border-radius: var(--border-radius);
    padding: 15px 5px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: var(--text-dark);
    box-shadow: var(--shadow);
    transition: transform 0.2s;
}

.category-item:hover {
    transform: translateY(-3px);
}

.category-item i {
    font-size: 24px;
    margin-bottom: 8px;
    color: var(--text-dark);
}

.category-item span {
    font-size: 12px;
    font-weight: 600;
    text-align: center;
}

/* SECTION TITLES */
.section-title {
    font-size: 20px;
    font-weight: 800;
    margin-bottom: 15px;
    color: var(--text-dark);
    letter-spacing: -0.3px;
}

.flash-deals-container {
    display: flex;
    gap: 12px;
    overflow-x: auto;
    padding: 10px 5px;
    margin-bottom: 25px;
    scrollbar-width: none;
}

.flash-card {
    min-width: 180px;
    background: linear-gradient(135deg, #E0AA3E 0%,#F7EF8A 50%, #E0AA3E 100%);
    border-radius: 10px;
    padding: 8px;
    display: flex;
    flex-direction: row; 
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    text-decoration: none;
}

.flash-img {
    width: 50px;
    height: 50px;
    background-color: #fff;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    color: #333;
    flex-shrink: 0;
    overflow: hidden;
}

.flash-img img {
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 4px;
}

.flash-info {
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.flash-product-name {
    color: #000000;
    font-size: 12px;
    font-weight: 700;
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100px;
}

.timer {
    background: rgba(0, 0, 0, 0.15);
    color: #000000;
    padding: 4px 8px;
    border-radius: 5px;
    font-weight: 800;
    font-size: 11px;
    letter-spacing: 0.5px;
    text-align: center;
    border: 1px solid rgba(255, 255, 255, 0.2);
}

/* PRODUCTS GRID */
.products-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 15px;
    margin-bottom: 30px;
    align-items: stretch; /* garante que todos os cards da mesma linha tenham altura igual */
}

.product-card {
    background-color: var(--white);
    border-radius: var(--border-radius);
    padding: 15px;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow);
    position: relative;
    transition: transform 0.2s, box-shadow 0.2s;
}

.product-img {
    width: 100%;
    padding-top: 100%; /* aspect-ratio 1:1 via padding trick */
    position: relative;
    background-color: var(--white);
    border-radius: 8px;
    margin-bottom: 12px;
    flex-shrink: 0;
    overflow: hidden;
}

.product-img img {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    object-fit: contain;
    padding: 10px;
}

/* Ícone fallback quando não há imagem */
.product-img > i {
    position: absolute;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 50px;
    color: var(--gray-dark);
}

.product-title {
    font-size: 14px;
    font-weight: 600;
    line-height: 20px; /* Padroniza a altura de cada linha */
    
    /* TRAVA ABSOLUTA: 2 linhas exatas (20px * 2) */
    height: 40px; 
    min-height: 40px;
    max-height: 40px; 
    
    margin-bottom: 8px;
    color: var(--text-dark);
    
    /* Limite visual com reticências */
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    text-overflow: ellipsis;
    
    /* Impede que o flexbox tente esticar ou esmagar o título */
    flex-shrink: 0; 
    flex-grow: 0;
    
    /* Quebra palavras muito longas para não vazar pros lados */
    word-break: break-word; 
}

.price-row {
    display: flex;
    flex-direction: column;
    gap: 2px;
    margin-bottom: 12px;
    
    /* ESSA É A MÁGICA: empurra o bloco de preço sempre para o fundo do card */
    margin-top: auto; 
}

/* Preço antigo riscado — linha de cima */
.old-price-grid {
    font-size: 12px;
    font-weight: 500;
    color: var(--gray-dark);
    text-decoration: line-through;
}

/* Linha de baixo: preço atual + badge de desconto lado a lado */
.price-row-top {
    display: flex;
    align-items: center;
    gap: 6px;
}

.price {
    font-size: 18px;
    font-weight: 800;
    color: var(--text-dark);
    letter-spacing: -0.5px;
}

.discount-tag {
    background-color: var(--gold-light);
    color: #4a3800;
    font-size: 10px;
    font-weight: 800;
    padding: 3px 6px;
    border-radius: 4px;
}

.btn-buy {
    background-color: var(--blue);
    color: var(--white);
    border: none;
    border-radius: 20px;
    padding: 10px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    width: 100%;
    transition: background-color 0.3s;
}

.btn-buy:hover {
    background-color: var(--blue-dark);
}

/* BOTTOM NAVIGATION (MOBILE) */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    background-color: var(--white);
    display: flex;
    justify-content: space-around;
    padding: 12px 0;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
    z-index: 1000;
    border-top: 1px solid var(--gray-medium);
}

.nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: var(--gray-dark);
    font-size: 10px;
    gap: 4px;
    transition: color 0.3s;
}

.nav-item.active {
    color: var(--blue);
}

.nav-item i {
    font-size: 20px;
}

/* DESKTOP RESPONSIVENESS */
@media (min-width: 768px) {
    body {
        padding-top: 115px; 
        padding-bottom: 30px;
    }

    header {
        flex-wrap: nowrap;
        height: 85px; 
        padding: 0 40px; 
    }

    .search-container {
        order: 2; 
        margin: 0 40px; 
        flex-grow: 1; 
        max-width: 600px; 
        margin-top: 0; 
    }

    .header-actions {
        order: 3; 
        gap: 30px; 
    }

    .banner {
        padding: 40px;
        border-radius: 20px;
    }

    .banner h2 {
        font-size: 28px;
    }

    .banner .highlight {
        font-size: 42px;
    }

    .banner-img-placeholder {
        width: 150px;
        height: 150px;
        font-size: 60px;
    }

    .categories {
        grid-template-columns: repeat(8, 1fr);
    }

    .products-grid {
        grid-template-columns: repeat(4, 1fr);
        gap: 20px;
    }


}

@media (min-width: 1024px) {
    .products-grid {
        grid-template-columns: repeat(5, 1fr);
    }
}

.icon-btn img {
    height: 32px; 
    width: auto;
    object-fit: contain;
}

/* Substituiu a antiga .icon-btnn img */
.profile-btn img {
    height: 38px; 
    width: auto;
    object-fit: contain;
}
/* --- MENU DROPDOWN DE PERFIL NA NAVBAR --- */
.profile-dropdown-container {
    position: relative;
    display: flex;
    align-items: center;
    height: 100%;
}

.profile-dropdown {
    position: absolute;
    top: 100%; /* Posiciona logo abaixo do header */
    right: -10px; /* Alinha mais próximo da borda direita */
    margin-top: 15px;
    background-color: var(--white);
    border-radius: var(--border-radius);
    box-shadow: 0 8px 25px rgba(0,0,0,0.15);
    width: 220px;
    display: none; /* Escondido por padrão */
    flex-direction: column;
    z-index: 1001; /* Fica por cima de tudo */
    border: 1px solid var(--gray-medium);
}

.profile-dropdown.show {
    display: flex; /* O JS adiciona essa classe para mostrar a aba */
    animation: slideDown 0.2s ease-out forwards;
}

/* Animação suave ao abrir */
@keyframes slideDown {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.dropdown-header {
    padding: 15px;
    display: flex;
    flex-direction: column;
}

.dropdown-header strong {
    font-size: 14px;
    color: var(--text-dark);
}

.dropdown-header span {
    font-size: 12px;
    color: var(--gray-dark);
    margin-top: 4px;
}

.profile-dropdown hr {
    border: none;
    border-top: 1px solid var(--gray-medium);
    margin: 0;
}

.dropdown-item {
    padding: 12px 15px;
    text-decoration: none;
    color: var(--text-dark);
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: background-color 0.2s;
}

.dropdown-item:hover {
    background-color: var(--gray-light);
}

.dropdown-item i {
    width: 16px;
    text-align: center;
    color: var(--gray-dark);
    font-size: 16px;
    transition: color 0.2s;
}

.dropdown-item:hover i {
    color: var(--blue);
}

/* Estilo específico para o botão de Sair */
.dropdown-item.text-danger {
    color: #e74c3c;
}

.dropdown-item.text-danger i {
    color: #e74c3c;
}

.dropdown-item.text-danger:hover {
    background-color: #fdf0ef;
}
/* --- RESULTADOS DA SUPER BUSCA (CORRIGIDO) --- */
.search-results-dropdown {
    position: absolute;
    /* Faz a aba nascer EXATAMENTE abaixo do container, com 8px de respiro (espaço) */
    top: calc(100% + 8px); 
    left: 0;
    width: 100%;
    background-color: var(--white);
    /* Borda arredondada em todos os cantos para criar um efeito de "Card Flutuante" elegante */
    border-radius: 16px; 
    box-shadow: 0 10px 30px rgba(0,0,0,0.12);
    z-index: 2000;
    display: none; 
    flex-direction: column;
    overflow: hidden;
    border: 1px solid var(--gray-medium);
    max-height: 400px;
    overflow-y: auto;
}

.search-results-dropdown.show {
    display: flex;
    /* Pequena animação suave ao aparecer */
    animation: slideDownSearch 0.2s ease-out; 
}

@keyframes slideDownSearch {
    from { opacity: 0; transform: translateY(-10px); }
    to { opacity: 1; transform: translateY(0); }
}

.search-result-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 15px 20px;
    text-decoration: none;
    color: var(--text-dark);
    border-bottom: 1px solid var(--gray-light);
    transition: background-color 0.2s;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item:hover {
    background-color: var(--gray-light);
}

/* Container da Imagem Corrigido - Mais Robusto (Nuke Distorção) */
.sr-img {
    width: 45px;
    height: 45px;
    background-color: var(--gray-light);
    border-radius: 8px;
    display: flex;
    align-items: center; /* Centraliza verticalmente se a imagem for menor */
    justify-content: center; /* Centraliza horizontalmente se a imagem for menor */
    color: var(--gray-dark);
    font-size: 18px;
    flex-shrink: 0;
    overflow: hidden; /* Garante que a foto não vaze para fora das bordas arredondadas */
    border: 1px solid var(--gray-medium); /* Adiciona uma borda sutil ao quadrado */
}

/* Regra de ouro corrigida: Garante o FIM TOTAL da imagem esticada */
.sr-img img {
    /* Primeiro, garantimos que ela não possa se esticar além do container */
    max-width: 100%;
    max-height: 100%;
    
    /* Reseta qualquer largura/altura forçada que possa estar vindo de regras globais antigas */
    width: auto !important; 
    height: auto !important;

    /* Por fim, garantimos que ela cubra todo o espaço, mas sem distorcer */
    object-fit: cover; 
    object-position: center;
}

.sr-info {
    display: flex;
    flex-direction: column;
}

.sr-title {
    font-size: 14px;
    font-weight: 600;
    color: var(--text-dark);
    display: -webkit-box;
    -webkit-line-clamp: 2; /* Permite até 2 linhas para o nome não cortar tão rápido */
    -webkit-box-orient: vertical;
    overflow: hidden;
    line-height: 1.3;
}

.sr-price {
    font-size: 14px;
    font-weight: 800;
    color: var(--blue);
    margin-top: 4px;
}

.search-empty {
    padding: 25px 20px;
    text-align: center;
    font-size: 14px;
    color: var(--gray-dark);
}
/* Garante que o ícone do resultado não herde as posições da lupa */
.sr-img i {
    position: static !important;
    transform: none !important;
    margin: 0 !important;
}
/* Atualizado para a lupa funcionar como botão dentro do form */
.search-container button {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--gray-dark);
    z-index: 10;
}

.search-container button i {
    font-size: 16px;
    color: inherit;
}
/* Botão de favorito dentro da Grid */
.btn-fav-grid {
    position: absolute;
    top: 15px;
    right: 15px;
    z-index: 5;
    background: white;
    border: none;
    width: 35px;
    height: 35px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    cursor: pointer;
    color: #ccc;
    transition: all 0.3s ease;
}

.btn-fav-grid:hover {
    transform: scale(1.1);
    color: #e53935;
}

.btn-fav-grid.active {
    color: #e53935;
}

/* Destaque para categoria ativa */
.category-item.active {
    background-color: var(--blue);
    color: white !important;
    border-color: var(--blue);
}
.category-item.active i, .category-item.active span {
    color: white;
}
/* ===== CORREÇÃO DOS CARDS DE PRODUTO ===== */

.product-card-wrapper {
    position: relative;
    background-color: var(--white);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
    height: 100%; /* preenche a célula do grid → todos os cards da linha ficam com a mesma altura */
}

.product-card-wrapper:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0,0,0,0.10);
}

/* Link interno: ocupa todo o espaço disponível */
.product-card-link {
    display: flex;
    flex-direction: column;
    flex: 1;
    padding: 15px 15px 10px;
    text-decoration: none;
    color: var(--text-dark);
}

.product-card-link .product-title {
    flex-grow: 1;
}

/* Botão Comprar fica na parte inferior, fora do <a> */
.product-card-wrapper .btn-buy {
    display: block;
    margin: 0 15px 15px;
    width: calc(100% - 30px);
    text-align: center;
    text-decoration: none;
    background-color: var(--blue);
    color: var(--white);
    border: none;
    border-radius: 20px;
    padding: 10px;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.3s;
}

.product-card-wrapper .btn-buy:hover {
    background-color: var(--blue-dark);
}

/* Favorito posicionado em relação ao wrapper */
.product-card-wrapper .btn-fav-grid {
    position: absolute;
    top: 12px;
    right: 12px;
    z-index: 5;
}

/* Neutraliza o .product-card antigo que conflitava */
.product-card { all: unset; }