/* ========================================================================
   1. VARIÁVEIS E RESET (A Identidade Visual)
   ======================================================================== */
:root {
    --primary-color: #005fb9;       /* Azul Forte */
    --primary-dark: #004a94;        /* Azul Mais Escuro */
    --accent-color: #ff6b00;        /* Laranja */
    --accent-hover: #e65100;
    --text-dark: #1a1a1a;
    --text-gray: #666666;
    --background-light: #f4f7fa;
    --white: #ffffff;
    
    --shadow-sm: 0 2px 8px rgba(0,0,0,0.05);
    --shadow-md: 0 5px 15px rgba(0,0,0,0.1);
    --radius: 8px;
    --transition: all 0.3s ease;
}

* { margin: 0; padding: 0; box-sizing: border-box; font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif; }

body {
    background-color: var(--background-light);
    color: var(--text-dark);
    line-height: 1.6;
}

a { text-decoration: none; color: inherit; }
ul { list-style: none; }

/* ========================================================================
   2. CABEÇALHO (HEADER)
   ======================================================================== */
.main-header {
    background-color: var(--white);
    box-shadow: var(--shadow-sm);
    position: sticky;
    top: 0;
    z-index: 900; /* Diminuí um pouco para a barra parceiro ficar acima */
    padding: 15px 0;
}

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

.logo {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary-dark);
    display: flex;
    align-items: center;
    gap: 8px;
}
.logo span { color: var(--accent-color); }
.logo i { font-size: 1.8rem; }

.search-container {
    flex: 1;
    max-width: 600px;
    display: flex;
    align-items: center;
    background: var(--background-light);
    border: 2px solid transparent;
    border-radius: 50px;
    padding: 5px 20px;
    position: relative;
    transition: var(--transition);
}

.search-container:focus-within {
    border-color: var(--primary-color);
    background: var(--white);
    box-shadow: var(--shadow-sm);
}

.search-container input {
    flex: 1;
    border: none;
    background: transparent;
    outline: none;
    padding: 10px;
    font-size: 1rem;
}

.search-button {
    background: none;
    border: none;
    color: var(--primary-color);
    font-size: 1.2rem;
    cursor: pointer;
    padding: 5px;
}

/* Dropdown Categorias */
.search-dropdown-menu {
    display: none;
    position: absolute;
    top: 110%;
    right: 0;
    background: var(--white);
    border-radius: var(--radius);
    box-shadow: var(--shadow-md);
    width: 200px;
    overflow: hidden;
    z-index: 100;
}
.search-dropdown-menu a {
    display: block;
    padding: 10px 15px;
    color: var(--text-dark);
    font-size: 0.95rem;
    transition: background 0.2s;
}
.search-dropdown-menu a:hover { background: var(--background-light); color: var(--primary-color); }

.header-actions { display: flex; gap: 20px; }
.action-button {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 0.85rem;
    color: var(--text-gray);
    position: relative;
    transition: var(--transition);
}
.action-button i { font-size: 1.6rem; margin-bottom: 2px; }
.action-button:hover { color: var(--primary-color); transform: translateY(-2px); }

.cart-button span:last-child {
    position: absolute;
    top: -5px;
    right: -5px;
    background-color: var(--accent-color);
    color: white;
    font-size: 0.75rem;
    font-weight: bold;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ========================================================================
   3. LAYOUT PRINCIPAL
   ======================================================================== */
.main-content { max-width: 1200px; margin: 30px auto; padding: 0 20px; min-height: 80vh; }

h2 { font-size: 1.8rem; margin-bottom: 20px; color: var(--text-dark); position: relative; display: inline-block; }
h2::after { content: ''; display: block; width: 50%; height: 3px; background: var(--accent-color); margin-top: 5px; border-radius: 2px; }

/* ========================================================================
   4. CATEGORIAS (Homepage)
   ======================================================================== */
.category-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(100px, 1fr));
    gap: 20px;
    margin-bottom: 40px;
}

.category-card {
    background: var(--white);
    padding: 20px 10px;
    border-radius: var(--radius);
    text-align: center;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
    border: 1px solid transparent;
    cursor: pointer;
}

.category-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-md);
    border-color: var(--primary-color);
}

.category-card img { width: 50px; height: 50px; margin-bottom: 10px; }
.category-card span { display: block; font-weight: 600; font-size: 0.9rem; color: var(--text-dark); }

/* =======================================================
   CARDS DE PRODUTO
   ======================================================= */
#promocoes-track, #search-track {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 25px;
    padding: 10px;
}

.product-card {
    background: #ffffff;
    border: 1px solid #e1e1e1;
    border-radius: 12px;
    padding: 15px;
    text-decoration: none;
    color: #333;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.product-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 10px 25px rgba(0,0,0,0.1);
    border-color: #3498db;
}

.product-card .product-image {
    height: 180px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 15px;
    background: #f9f9f9;
    border-radius: 8px;
}

.product-card .product-image img {
    max-height: 100%;
    max-width: 100%;
    object-fit: contain;
    transition: transform 0.3s;
}

.product-card:hover .product-image img { transform: scale(1.05); }

.product-card h3 {
    font-size: 1rem;
    font-weight: 600;
    color: #2c3e50;
    margin-bottom: 10px;
    line-height: 1.4;
    height: 40px;
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.product-card .price-new {
    font-size: 1.4rem;
    font-weight: 800;
    color: #27ae60;
    margin-bottom: 15px;
}

.btn-card-action {
    display: block;
    width: 100%;
    padding: 10px;
    background-color: #f1f2f6;
    color: #2c3e50;
    text-align: center;
    border-radius: 6px;
    font-weight: 700;
    font-size: 0.9rem;
    transition: 0.2s;
}

.product-card:hover .btn-card-action {
    background-color: #3498db;
    color: white;
}

/* ========================================================================
   6. PÁGINA DE PRODUTO (Detalhes)
   ======================================================================== */
.product-detail-container {
    max-width: 1200px;
    margin: 40px auto;
    padding: 20px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 40px;
    background: #fff;
    border-radius: 12px;
    box-shadow: 0 5px 20px rgba(0,0,0,0.05);
}

.detail-image {
    display: flex;
    justify-content: center;
    align-items: center;
    background: #f8f9fa;
    border-radius: 12px;
    padding: 20px;
    max-height: 500px;
}
.detail-image img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    transition: transform 0.3s;
}

.detail-info h1 { font-size: 2rem; color: #2c3e50; margin-bottom: 10px; }
.detail-code { color: #7f8c8d; font-size: 0.9rem; margin-bottom: 20px; display: block; }

.detail-price-box {
    margin: 20px 0;
    padding: 20px;
    background: #f8f9fa;
    border-radius: 8px;
    border-left: 5px solid #27ae60;
}
.detail-old-price { text-decoration: line-through; color: #95a5a6; font-size: 1rem; }
.detail-price { font-size: 2.5rem; color: #27ae60; font-weight: 800; }

.action-group { display: flex; gap: 15px; margin-top: 25px; }
.qty-selector { display: flex; align-items: center; border: 1px solid #ddd; border-radius: 6px; }
.qty-selector button { background: none; border: none; padding: 10px 15px; font-size: 1.2rem; cursor: pointer; }
.qty-selector input { width: 50px; text-align: center; border: none; font-weight: bold; font-size: 1.1rem; }

.btn-buy-now, .btn-add-cart {
    flex: 1;
    background: linear-gradient(135deg, #e67e22, #d35400);
    color: white;
    border: none;
    padding: 15px;
    border-radius: 8px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    box-shadow: 0 4px 15px rgba(230, 126, 34, 0.4);
    transition: transform 0.2s;
    display: block;
}
.btn-buy-now:hover, .btn-add-cart:hover { transform: translateY(-2px); }

/* ========================================================================
   7. CARRINHO (VERSÃO DESKTOP PADRÃO)
   ======================================================================== */
.cart-page-container { display: grid; grid-template-columns: 2fr 1fr; gap: 30px; max-width: 1200px; margin: 40px auto; padding: 0 20px; }
.cart-items-list { background: var(--white); border-radius: var(--radius); padding: 20px; box-shadow: var(--shadow-sm); }

/* Tabela Padrão (Desktop) */
.cart-table { border-collapse: collapse; width: 100%; }
.cart-table th { text-align: left; padding: 15px; border-bottom: 2px solid #eee; color: #666; font-size: 0.9rem; }
.cart-table td { padding: 15px; border-bottom: 1px solid #eee; vertical-align: middle; }
.cart-table td img { border: 1px solid #eee; border-radius: 4px; }

/* Resumo do Pedido */
.order-summary-box {
    background: var(--white);
    padding: 25px;
    border-radius: var(--radius);
    box-shadow: var(--shadow-sm);
    height: fit-content;
}
.summary-row { display: flex; justify-content: space-between; margin-bottom: 15px; font-size: 1.1rem; }
.summary-row.total { font-weight: 800; font-size: 1.4rem; color: var(--text-dark); border-top: 2px solid #eee; padding-top: 15px; }

.btn-place-order {
    width: 100%;
    background: var(--accent-color);
    color: white;
    padding: 15px;
    border: none;
    border-radius: 5px;
    font-size: 1.1rem;
    font-weight: bold;
    cursor: pointer;
    margin-top: 20px;
    transition: var(--transition);
    text-align: center;
    text-decoration: none;
    display: block;
}
.btn-place-order:hover { background: var(--accent-hover); }

/* ========================================================================
   8. RODAPÉ
   ======================================================================== */
.main-footer {
    background: var(--text-dark);
    color: #bbb;
    text-align: center;
    padding: 40px 20px;
    margin-top: 60px;
}

/* ========================================================================
   9. CARROSSEL (Hero Banner)
   ======================================================================== */
.hero-banner { position: relative; width: 100%; height: 400px; overflow: hidden; margin-bottom: 40px; background: #000; }
.slide { position: absolute; top: 0; left: 0; width: 100%; height: 100%; background-size: cover; background-position: center; opacity: 0; transition: opacity 1s ease-in-out; display: flex; align-items: center; justify-content: center; }
.slide.active { opacity: 1; }
.slide::before { content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 100%; background: rgba(0, 0, 0, 0.5); }
.slide-content { position: relative; z-index: 2; text-align: center; color: white; max-width: 800px; padding: 20px; }
.slide-content h2 { font-size: 3rem; margin-bottom: 15px; text-shadow: 0 2px 4px rgba(0,0,0,0.5); color: white; }
.slide-content p { font-size: 1.3rem; margin-bottom: 25px; }
.btn-banner { display: inline-block; padding: 12px 30px; background: var(--accent-color); color: white; font-weight: bold; border-radius: 50px; transition: transform 0.2s; }
.btn-banner:hover { transform: scale(1.05); }

/* ========================================================================
   📱 MOBILE FINAL (CARDS + HEADER + BOTÃO FIXED)
   ======================================================================== */

.mobile-only { display: none !important; } /* Esconde mobile no PC */

@media (max-width: 768px) {

    /* --- 1. CONSERTO DO CABEÇALHO (FIXO E ORGANIZADO) --- */
    
    /* Espaço para o cabeçalho duplo não cobrir o conteúdo */
    body {
        padding-top: 170px !important; 
        padding-bottom: 50px !important;
    }

    /* Barra Verde/Escura do Parceiro (Fica no topo absoluto) */
    #barra-parceiro {
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: auto;
        min-height: 40px;
        z-index: 2000; /* Fica acima de tudo */
        padding: 5px 10px !important;
        display: flex;
        flex-wrap: wrap;
        justify-content: center;
        gap: 10px;
        box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    }

    /* Cabeçalho Branco (Logo e Busca) - Fica logo abaixo da barra parceiro */
    .main-header {
        position: fixed;
        top: 50px; /* Altura estimada da barra do parceiro */
        left: 0;
        width: 100%;
        z-index: 1900;
        background: white;
        padding: 10px 15px;
        box-shadow: 0 5px 15px rgba(0,0,0,0.05);
        display: flex;
        flex-direction: column;
        gap: 10px;
    }

    /* Organiza os itens do cabeçalho */
    .header-container { flex-direction: column; gap: 5px; width: 100%; padding: 0; }
    .logo { justify-content: center; margin-bottom: 5px; }
    .search-container { width: 100%; max-width: 100%; order: 3; }
    


    /* --- 2. LAYOUT DA PÁGINA --- */
    .cart-page-container {
        display: flex !important;
        flex-direction: column !important;
        width: 100% !important;
        padding: 10px !important;
        gap: 20px !important;
    }

    /* Esconde tabela PC / Mostra Cards Mobile */
    .desktop-only { display: none !important; }
    .mobile-only { display: block !important; width: 100% !important; }


    /* --- 3. ESTILO DOS CARDS (JÁ ESTAVA BOM, MANTIVE) --- */
    .mobile-cart-card {
        background: white;
        border: 1px solid #eee;
        border-radius: 12px;
        padding: 15px;
        margin-bottom: 15px;
        box-shadow: 0 4px 12px rgba(0,0,0,0.05);
        display: flex;
        flex-direction: column;
        align-items: center;
        text-align: center;
    }

    .mobile-cart-img { width: 120px; height: 120px; object-fit: contain; margin-bottom: 10px; }
    
    .mobile-cart-title { 
        font-size: 1rem; font-weight: bold; color: #005fb9; margin-bottom: 8px; line-height: 1.4;
    }

    .mobile-lucro-box {
        background: #fff8e1; border: 1px dashed #e67e22; padding: 5px 15px;
        border-radius: 8px; margin-bottom: 10px; display: flex; align-items: center; gap: 10px;
    }
    .mobile-lucro-box input {
        width: 50px; padding: 5px; text-align: center; border: 1px solid #ccc; border-radius: 4px;
    }

    .mobile-cart-details {
        width: 100%; display: flex; justify-content: space-between; align-items: center;
        border-top: 1px solid #f0f0f0; padding-top: 10px; margin-top: 5px;
    }
    
    .mobile-qty-box {
        display: flex; align-items: center; gap: 10px; background: #f5f5f5;
        padding: 5px 10px; border-radius: 6px;
    }

    .mobile-remove-btn {
        width: 100%; margin-top: 15px; background: #ffebee; color: #c0392b;
        border: none; padding: 10px; border-radius: 6px; font-weight: bold; cursor: pointer;
    }


    /* --- 4. CONSERTO DO BOTÃO FINALIZAR (O Resgate!) --- */
    
    .cart-total-box {
        width: 100% !important;
        background: white;
        padding: 20px;
        border-radius: 12px;
        box-shadow: 0 -2px 10px rgba(0,0,0,0.05);
        margin-top: 10px;
    }

    /* Container onde o JS coloca o botão */
    #afiliado-cart-actions {
        display: block !important;
        width: 100% !important;
        margin-top: 20px;
    }

    /* Estilo forçado para o botão (caso esteja invisível) */
    #afiliado-cart-actions button, .btn-place-order {
        display: block !important;
        width: 100% !important;
        background-color: #2c3e50 !important; /* Azul Escuro */
        color: white !important;
        padding: 15px !important;
        font-size: 1.1rem !important;
        font-weight: bold !important;
        border: none !important;
        border-radius: 8px !important;
        cursor: pointer !important;
        opacity: 1 !important;
        visibility: visible !important;
        text-align: center;
    }
    
    /* Hover do botão */
    #afiliado-cart-actions button:active {
        background-color: #1a252f !important;
        transform: scale(0.98);
    }

    

}

/* FORÇA O BOTÃO DO CARRINHO A APARECER SEMPRE */
.header-actions {
    display: flex !important;
    opacity: 1 !important;
    visibility: visible !important;
}

/* ========================================================================
   CORREÇÃO CIRÚRGICA DO MOBILE (Mantendo seu Design)
   ======================================================================== */

@media (max-width: 768px) {

    /* 1. Ajusta o corpo para o cabeçalho não cobrir o conteúdo */
    body {
        padding-top: 180px !important; /* Espaço para as 3 linhas do cabeçalho */
    }

    /* 2. Solta o Header para ele crescer conforme necessário */
    .main-header {
        height: auto !important;
        padding-bottom: 10px;
    }

    /* 3. Organiza os itens em COLUNA (Um embaixo do outro) */
    .header-container {
        display: flex;
        flex-direction: column; /* O SEGREDO: Coluna vertical */
        align-items: center;
        gap: 15px; /* Espaço entre Logo, Busca e Botões */
    }

    /* 4. Centraliza a Logo */
    .logo {
        width: 100%;
        justify-content: center;
        margin: 0;
    }

    /* 5. A Busca ocupa a largura toda */
    .search-container {
        width: 100%;
        max-width: 100%;
        margin: 0;
        order: 2; /* Garante que fique no meio */
    }

    /* 6. Arruma os botões (Sino, Entrar, Carrinho) */
    .header-actions {
        width: 100%;
        display: flex;
        justify-content: center; /* Centraliza na tela */
        gap: 25px; /* Afasta um ícone do outro */
        margin: 0 !important; /* Remove margens negativas antigas */
        padding: 0;
        order: 3; /* Garante que fique por último */
        position: static; /* Remove posições absolutas que causam sobreposição */
    }

    /* 7. Limpeza visual: Esconde o texto "Carrinho/Entrar" no mobile, mantém só ícone */
    /* Se você quiser que o texto apareça, apague as 3 linhas abaixo */
    .header-actions .action-button span:not(.badge) {
        display: none;
    }
    
    /* Aumenta um pouco os ícones para facilitar o toque */
    .header-actions i {
        font-size: 1.5rem;
    }
}

/* } <--- ESSA CHAVE É UMA SEGURANÇA CASO TENHA FICADO ALGUMA ABERTA ANTES */

/* ========================================================================
   CORREÇÃO DE EMERGÊNCIA (FORCE MOBILE)
   ======================================================================== */

/* 1. Esconde o menu de notificações que está vazando na tela */
.notif-dropdown {
    display: none !important; /* Só deve aparecer quando clicar */
}

/* Quando clicar (via JS), ele deve flutuar e não empurrar nada */
.notif-dropdown.show, .notif-dropdown.active {
    display: block !important;
    position: absolute !important;
    top: 40px !important;
    right: 0 !important;
    z-index: 9999 !important;
    background: white !important;
    box-shadow: 0 5px 15px rgba(0,0,0,0.2) !important;
    width: 250px !important;
}

/* 2. Força BRUTAL do layout em Coluna no Mobile */
@media screen and (max-width: 900px) { /* Aumentei para 900px para pegar celulares grandes */
    
    .header-container {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        height: auto !important;
        padding-bottom: 15px !important;
    }

    /* Linha 1: Logo */
    .logo {
        width: 100% !important;
        justify-content: center !important;
        margin-bottom: 10px !important;
        display: flex !important;
    }

    /* Linha 2: Busca */
    .search-container {
        width: 100% !important;
        max-width: 95% !important; /* Um pouco menos que 100% pra não colar na borda */
        margin: 0 auto 15px auto !important;
        order: 2 !important;
    }

    /* Linha 3: Ícones */
    .header-actions {
        width: 100% !important;
        justify-content: center !important;
        margin: 0 !important;
        order: 3 !important;
        display: flex !important;
        gap: 20px !important;
        position: static !important; /* Remove qualquer posição fixa que esteja atrapalhando */
    }

    /* Ajuste para o botão "Acessar Meu Painel" não quebrar o topo */
    #barra-parceiro {
        flex-wrap: wrap !important;
        height: auto !important;
        padding: 5px !important;
    }
}

/* ========================================================================
   CORREÇÃO FINAL: BARRA DO AFILIADO + CABEÇALHO
   ======================================================================== */

@media (max-width: 768px) {

    /* 1. ARRUMA A BARRA PRETA (PARCEIRO) */
    #barra-parceiro {
        height: auto !important;       /* Deixa a altura crescer conforme precisa */
        min-height: 80px !important;   /* Garante tamanho para 2 linhas */
        flex-wrap: wrap !important;    /* Permite quebrar linha */
        justify-content: center !important;
        padding: 10px 5px !important;
        gap: 8px !important;
        align-content: center !important;
    }

    /* Ajuste fino dos itens dentro da barra preta */
    #barra-parceiro > div {
        width: 100%;                  /* Força o Nome+Status a ocupar a linha de cima */
        justify-content: center;      /* Centraliza */
        margin-bottom: 5px;
    }

    #barra-parceiro > a {
        width: 90%;                   /* Botão "Acessar Painel" quase largura total */
        justify-content: center;      /* Centraliza texto do botão */
    }

    /* 2. EMPURRA O CABEÇALHO BRANCO PRA BAIXO */
    /* Como a barra preta ficou maior (aprox 80px), o cabeçalho branco tem que descer */
    .main-header {
        top: 85px !important;         /* Desce para não ficar embaixo da barra preta */
    }

    /* 3. EMPURRA O CORPO DO SITE PRA BAIXO */
    /* Soma: 85px (barra preta) + 140px (cabeçalho branco) = ~225px */
    body {
        padding-top: 230px !important; 
    }

    /* 4. AJUSTE FINO NO CARRINHO (CART) */
    /* Dá um espaço extra no final do card para o botão não ficar colado */
    .mobile-cart-card {
        padding-bottom: 20px;
    }
}