/* ==========================================================================
   1. CONFIGURAÇÕES GERAIS E RESETS
   ========================================================================== */
:root {
    --borda: #e2e8f0;
    --texto-suave: #718096;
    --azul-meli: #007bff;
    --azul-escuro: #1a202c;
    --azul-hover: #0056b3;
    --verde-sucesso: #10b981;
    --fundo-cards: #f8fafc;
}

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

body {
    background-color: #f4f6f9;
    color: #333;
    line-height: 1.6;
    /* Espaçador obrigatório para o conteúdo não sumir atrás da navbar fixa */
    padding-top: 85px; 
}

img {
    max-width: 100%;
    display: block;
}

a {
    transition: all 0.2s ease;
}

h1:not(.header-wrap h1) {
    text-align: center;
    margin: 30px 0 10px 0;
    font-size: 1.8rem;
    color: #222;
}

/* ==========================================================================
   2. TOPO / HEADER (NAVBAR STICKY AUTO-AJUSTÁVEL)
   ========================================================================== */
header {
    background-color: var(--azul-escuro);
    color: #fff;
    padding: 12px 20px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    width: 100%;
    
    /* MUDANÇA COGNITIVA: Sticky evita o vazamento de botões no mobile */
    position: sticky !important;
    top: 0;
    z-index: 1000;
}

/* Remove o padding-top antigo do body para não duplicar espaço */
body {
    background-color: #f4f6f9;
    color: #333;
    line-height: 1.6;
    padding-top: 0 !important; 
}

/* Ajuste das barras para o novo comportamento do topo */
.sidebar-esquerda, 
.sidebar-direita,
.sidebar-veiculos {
    position: sticky !important;
    top: 20px !important; 
}



/* ==========================================================================
   3. BARRA DE FILTROS / BUSCA
   ========================================================================== */
.container-filtros {
    position: fixed;
    top: 165px; /* Aumentado para 135px para descer e sair de trás da barra escura */
    left: 50%;
    transform: translateX(-50%);
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 15px 20px;
    z-index: 999; /* Fica logo atrás da navbar, mas à frente dos carros */
    background-color: #ffffff;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.08); /* Sombra leve para destacar dos cards */
    box-sizing: border-box;
    border-radius: 0 0 8px 8px; /* Cantos arredondados suaves embaixo */
}

.form-filtros {
    background: #fff;
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
    display: flex;
    align-items: flex-end;
    gap: 15px;
    flex-wrap: wrap;
}

.campo-filtro {
    flex: 1;
    min-width: 200px;
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.campo-filtro label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #4a5568;
}

.campo-filtro input, 
.campo-filtro select {
    width: 100%;
    padding: 10px;
    border: 1px solid #cbd5e0;
    border-radius: 6px;
    font-size: 0.9rem;
    outline: none;
    background-color: #fff;
}

.campo-filtro input:focus, 
.campo-filtro select:focus {
    border-color: var(--azul-meli);
    box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.15);
}

.btn-filtrar {
    background-color: var(--azul-meli);
    color: white;
    border: none;
    padding: 11px 24px;
    border-radius: 6px;
    font-weight: bold;
    cursor: pointer;
    font-size: 0.95rem;
}

.btn-filtrar:hover {
    background-color: var(--azul-hover);
}

.btn-limpar {
    background-color: #e2e8f0;
    color: #4a5568;
    text-decoration: none;
    padding: 11px 20px;
    border-radius: 6px;
    font-weight: bold;
    font-size: 0.95rem;
    text-align: center;
}

.btn-limpar:hover {
    background-color: #cbd5e0;
}

/* ==========================================================================
   4. ESTRUTURA BASE DO LAYOUT (COMPUTADOR / PC)
   ========================================================================== */
.layout-portal-container,
.portal-grid {
    display: flex !important;
    flex-direction: row !important;
    justify-content: space-between !important;
    align-items: flex-start !important;
    max-width: 1200px !important;
    
    /* CORREÇÃO AQUI: Mudado de 20px para 230px para empurrar os anúncios para baixo das barras fixas */
    margin: 50px auto 20px auto !important; 
    
    padding: 0 15px !important;
    gap: 20px !important;
    width: 100% !important;
}


.conteudo-principal-galeria,
.feed-noticias {
    flex: 1 !important;
    min-width: 0 !important;
    width: auto !important;
    order: 2 !important; /* Joga o conteúdo principal para o meio */
}

.sidebar-esquerda {
    flex: 0 0 180px !important;
    width: 180px !important;
    max-width: 180px !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 20px !important;
    position: sticky !important;
    top: 105px !important; /* Altura da navbar fixa + margem */
    z-index: 10 !important;
    order: 1 !important;
}

.sidebar-direita,
.sidebar-veiculos {
    flex: 0 0 180px !important;
    width: 180px !important;
    max-width: 180px !important;
    display: flex !important;
    flex-direction: column !important;
    gap: 20px !important;
    position: sticky !important;
    top: 105px !important;
    z-index: 10 !important;
    order: 3 !important;
}

.sidebar-veiculos {
    flex: 0 0 280px !important;
    width: 280px !important;
    max-width: 280px !important;
}

.sem-anuncios,
.feed-vazio {
    background: #fff;
    padding: 40px 20px;
    text-align: center;
    border-radius: 12px;
    border: 1px solid #e2e8f0;
    color: var(--texto-suave);
    font-style: italic;
    width: 100%;
    margin: 0 auto;
}
/* ==========================================================================
   5. GALERIA E CARTÕES DE VEÍCULOS (DESIGN PREMIUM)
   ========================================================================== */
.galeria {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    gap: 24px;
    padding: 16px;
}

.cartao {
    display: flex;
    flex-direction: column;
    background-color: #fff;
    border-radius: 12px;
    border: 1px solid #e0e0e0;
    overflow: hidden;
    position: relative; /* Essencial para o posicionamento do selo-ouro */
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.cartao:hover {
    transform: translateY(-4px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
}


.cartao.ouro_pago {
    border: 2px solid #ffc107;
}

.selo-ouro {
    position: absolute;
    top: 10px;
    left: 10px;
    background-color: #ffc107;
    color: #000;
    font-size: 0.7rem;
    font-weight: 800;
    padding: 4px 8px;
    border-radius: 4px;
    letter-spacing: 0.5px;
    z-index: 2;
}

.cartao-link-img {
    display: block;
    width: 100%;
    aspect-ratio: 16 / 9; /* Força todas as fotos a terem a mesma proporção de tela cheia */
    overflow: hidden;
    background-color: #f7f7f7; /* Fundo cinza caso o carro tenha fundo transparente ou demore a carregar */
}

.cartao-link-img img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Recorta a imagem proporcionalmente sem distorcer o carro */
    object-position: center; /* Mantém o foco no centro do veículo */
    transition: transform 0.3s ease;
}
.cartao:hover .cartao-link-img img {
    transform: scale(1.04); /* Efeito sutil de zoom ao passar o mouse no cartão */
}



.cartao .conteudo {
    padding: 5px;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.cartao .titulo {
    font-size: 1.05rem;
    font-weight: 700;
    line-height: 1.3;
    margin-bottom: 10px;
    color: #05090f;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    height: 2.7rem;
}

.cartao .detalhes {
    font-size: 0.8rem;
    color: #05090f;
    margin-bottom: 14px;
    border-bottom: 1px dashed #e2e8f0;
    padding-bottom: 12px;
}

.detalhe-item {
    display: inline-block;
    margin-right: 12px;
    font-weight: 500;
}

.localizacao {
    margin-top: 6px;
    font-size: 0.78rem;
    color: #05090f;
}

.preco-container {
    margin-top: auto;
    margin-bottom: 14px;
}

.preco-label {
    font-size: 0.7rem;
    text-transform: uppercase;
    color: #05090f;
    letter-spacing: 0.5px;
    font-weight: bold;
    display: block;
}

.cartao .preco {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--verde-sucesso);
    line-height: 1;
}

.btn-ver-mais {
    background-color: var(--azul-meli);
    color: #ffffff;
    text-align: center;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 0.9rem;
    box-shadow: 0 4px 6px -1px rgba(0, 123, 255, 0.2);
}

.btn-ver-mais:hover {
    background-color: var(--azul-hover);
    box-shadow: 0 4px 12px rgba(0, 123, 255, 0.35);
}

.btn-ver-mais svg {
    transition: transform 0.2s ease;
}

.btn-ver-mais:hover svg {
    transform: translateX(3px);
}

/* ==========================================================================
   6. FEED DE NOTÍCIAS (PÁGINA NOTICIAS.PHP)
   ========================================================================== */
.noticia-card {
    background: #fff;
    border-radius: 12px;
    border: 1px solid var(--borda);
    display: flex;
    gap: 20px;
    padding: 20px;
    margin-bottom: 20px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.02);
}

.noticia-img-box {
    flex: 0 0 240px;
    max-width: 240px;
    height: 160px;
    border-radius: 8px;
    overflow: hidden;
}

.noticia-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.noticia-conteudo {
    flex: 1;
    display: flex;
    flex-direction: column;
}

.noticia-meta {
    font-size: 0.75rem;
    color: var(--texto-suave);
    margin-bottom: 6px;
}

.noticia-titulo {
    font-size: 1.25rem;
    color: #1a202c;
    margin-bottom: 8px;
    line-height: 1.3;
}

.noticia-scroll-texto {
    max-height: 75px;
    overflow-y: auto;
    margin-bottom: 10px;
    padding-right: 5px;
}

.noticia-texto {
    font-size: 0.9rem;
    color: #4a5568;
    line-height: 1.5;
}

.btn-ler-mais {
    color: var(--azul-meli);
    text-decoration: none;
    font-weight: bold;
    font-size: 0.85rem;
}

/* ==========================================================================
   7. BLOCOS DE ANÚNCIOS DUPLOS (MERCADO LIVRE)
   ========================================================================== */
.container-anuncios-duplos {
    display: flex;
    gap: 15px;
    margin-bottom: 25px;
    width: 100%;
}

.container-anuncios-duplos .card-oferta-recomendada {
    flex: 1;
    border: 2px dashed var(--azul-meli);
    background-color: var(--fundo-cards);
    border-radius: 12px;
    padding: 15px;
    display: flex;
    gap: 15px;
    align-items: center;
    margin: 0;
}

.wrapper-imagem-oferta {
    flex: 0 0 120px;
    width: 120px;
    height: 100px;
    background: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    overflow: hidden;
}

.wrapper-imagem-oferta img {
    max-width: 100%;
    max-height: 100px;
    object-fit: contain;
}

.detalhes-oferta {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.selo-oferta {
    background: var(--azul-meli);
    color: white;
    font-size: 10px;
    font-weight: bold;
    padding: 2px 6px;
    border-radius: 4px;
    align-self: flex-start;
    margin-bottom: 5px;
}

.detalhes-oferta h3 {
    font-size: 15px;
    color: #333;
    margin-bottom: 3px;
    line-height: 1.2;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.preco-link {
    font-size: 18px;
    color: #218838;
    font-weight: bold;
    margin-bottom: 5px;
}

.btn-meli {
    background: #218838;
    color: white;
    text-align: center;
    font-size: 12px;
    padding: 6px 10px;
    width: 100%;
    text-decoration: none;
    border-radius: 4px;
    font-weight: bold;
    display: block;
}

/* ==========================================================================
   8. SIDEBAR LATERAL: DESTAQUES (ANÚNCIOS OURO)
   ========================================================================== */
.card-destaques-lateral {
    background: white;
    border: 1px solid var(--borda);
    border-radius: 12px;
    padding: 15px;
    box-shadow: 0 4px 6px -1px rgba(0,0,0,0.05);
}

.card-destaques-lateral h3 {
    font-size: 18px;
    color: #1e293b;
    border-bottom: 2px solid var(--borda);
    padding-bottom: 10px;
    margin-bottom: 15px;
}

.sem-destaques-texto {
    color: var(--texto-suave);
    font-style: italic;
    font-size: 14px;
    text-align: center;
    padding: 20px 0;
}

.mini-card-carro {
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 12px;
    margin-bottom: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.mini-card-carro:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.mini-card-carro img {
    width: 100%;
    height: 140px;
    object-fit: cover;
    border-radius: 8px;
}

.mini-card-conteudo h4 {
    font-size: 15px;
    color: #1e293b;
    font-weight: bold;
    margin: 0 0 4px 0;
}

.mini-card-dados {
    font-size: 13px;
    color: #64748b;
    margin-bottom: 6px;
}

.mini-card-rodape {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.mini-card-preco {
    font-size: 16px;
    color: var(--verde-sucesso);
    font-weight: bold;
}

.mini-card-link {
    font-size: 12px;
    color: var(--azul-meli);
    text-decoration: none;
    font-weight: bold;
}

/* PAGINAÇÃO */
.paginacao {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 15px;
    margin: 25px 0;
}

.btn-pag {
    text-decoration: none;
    color: var(--azul-meli);
    font-weight: bold;
    font-size: 0.95rem;
    padding: 5px 10px;
}

.btn-pag.desativated {
    color: #ccc;
    pointer-events: none;
}

.texto-pag {
    font-size: 0.9rem;
    color: var(--texto-suave);
}

/* ==========================================================================
   9. MEDIA QUERIES (RESPONSIVIDADE MOBILE E TABLET CORRIGIDA)
   ========================================================================== */

/* 📱 TABLETS E CELULARES (Telas de até 992px) */
@media (max-width: 992px) {
    .layout-portal-container,
    .portal-grid {
        flex-direction: column !important;
        gap: 15px !important;
    }

    /* PRIORIDADE ABSOLUTA 1: Galeria de veículos sempre no topo */
    .conteudo-principal-galeria {
        order: 1 !important;
        width: 100% !important;
        margin-bottom: 20px !important;
    }

    /* PRIORIDADE 2: Notícias (se houver na página) */
    .feed-noticias {
        order: 2 !important;
        width: 100% !important;
        margin-bottom: 20px !important;
    }

    /* PRIORIDADE 3: Afiliados da Esquerda abaixo do conteúdo */
    .sidebar-esquerda {
        order: 3 !important;
        width: 100% !important;
        max-width: 100% !important;
        position: static !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        justify-content: center !important;
        gap: 15px !important;
    }

    /* PRIORIDADE 4: Afiliados da Direita / Destaques por último no fim da tela */
    .sidebar-direita,
    .sidebar-veiculos {
        order: 4 !important;
        width: 100% !important;
        max-width: 100% !important;
        position: static !important;
        flex-direction: row !important;
        flex-wrap: wrap !important;
        justify-content: center !important;
        gap: 15px !important;
    }

    .sidebar-esquerda > *, 
    .sidebar-direita > * {
        flex: 1 !important;
        min-width: 140px !important;
        max-width: 250px !important;
    }

    .container-anuncios-duplos {
        flex-direction: column;
    }

    .noticia-card {
        flex-direction: column;
    }

    .noticia-img-box {
        max-width: 100%;
        width: 100%;
        height: 220px;
    }

    .mini-card-carro {
        flex-direction: row;
        align-items: center;
        gap: 15px;
        padding-bottom: 15px;
    }

    .mini-card-carro img {
        width: 140px;
        height: 95px;
    }

    .form-filtros {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }

    .campo-filtro {
        width: 100%;
        min-width: 100%;
    }

    .btn-filtrar, 
    .btn-limpar {
        width: 100%;
        text-align: center;
        padding: 12px;
    }
}

/* 📱 SMARTPHONES (Telas de até 600px) */
@media (max-width: 600px) {
    /* Reseta o espaçamento do topo já que a barra agora cresce dinamicamente */
    body {
        padding-top: 0 !important; 
    }

    .header-wrap {
        flex-direction: column;
        text-align: center;
        gap: 10px;
    }

    .header-botoes {
        width: 100%;
        justify-content: center;
        gap: 8px;
    }

    .btn-header-login {
        flex: 1;
        min-width: 45%; /* Organiza os botões em blocos de 2 por linha no celular */
        justify-content: center;
        font-size: 0.75rem;
        padding: 10px 6px;
    }

    .galeria {
        display: grid !important;
        grid-template-columns: 1fr !important;
        width: 100% !important;
        gap: 15px;
    }

    .cartao {
        max-width: 100% !important;
    }

    .cartao img {
        height: 190px;
    }

    .card-oferta-recomendada {
        flex-direction: column;
        text-align: center;
    }

    .wrapper-imagem-oferta {
        width: 100%;
    }

    .selo-oferta {
        align-self: center;
    }

    .mini-card-carro {
        flex-direction: column;
    }

    .mini-card-carro img {
        width: 100%;
        height: 150px;
    }
}
