/* Estilos gerais para a página de resultados da pesquisa */
.main-search-results-page {
    display: flex;
    background-color: transparent;
    gap: 10px;
    align-items: flex-start;
    max-width: 1180px;
    margin: 65px auto 0 auto;
    padding: 20px 20px !important;
}

/* Área de conteúdo principal (lado direito da sidebar) */
.content-area {
    flex-grow: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

/* Contêiner para o cabeçalho da área de resultados, incluindo o select de ordenação */
.results-header {
    display: flex;
    justify-content: flex-end; /* Alinha o conteúdo à direita */
    align-items: center;
    margin-bottom: 20px;
    padding: 5px 0;
    width: 100%; /* Garante que ocupe a largura total do content-area */
    box-sizing: border-box;
}

/* --- ESTILO: Botão para abrir/fechar filtros (Mobile) com ÍCONE FA --- */
.filter-toggle-button {
    /* CORRIGIDO: Oculta por padrão em desktop, o 'display: flex' foi movido para o @media */
    display: none;
    padding: 10px 15px;
    background-color: var(--azul-selecao);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    transition: background-color 0.2s ease;
    margin-right: auto; /* Empurra o botão de ordenação para a direita */
    position: relative;
    /* As regras de alinhamento devem ir para o @media, ou ele aparecerá */
}

.filter-toggle-button:hover {
    background-color: #0056b3;
}

/* Estilo para o ícone Font Awesome dentro do botão */
.filter-toggle-button .fas.fa-filter {
    font-size: 1.1rem; /* Tamanho do ícone de funil */
    color: white; /* Garante a cor branca */
    transition: transform 0.3s ease;
}

/* Rotação do ícone quando o painel de filtros está aberto */
.filter-toggle-button.active .fas.fa-filter {
    transform: rotate(180deg); /* Gira o ícone do funil 180 graus */
}

/* --- FIM ESTILO BOTÃO FA --- */

.search-results-title {
    display: none;
}

/* --- ESTILOS DO SELECT CUSTOMIZADO (MANTIDOS) --- */
.custom-select {
    position: relative;
    display: flex;
    align-items: center;
    font-size: 1rem;
    color: #555;
    cursor: pointer;
}

.custom-select .select-label {
    margin-right: 5px;
}

.custom-select .select-selected {
    background-color: transparent;
    border: none;
    padding: 0 20px 0 0;
    cursor: pointer;
    color: inherit;
    white-space: nowrap;
    position: relative;
    transition: color 0.2s ease;
}

.custom-select .select-selected:after {
    content: '\276F';
    font-size: 0.8rem;
    color: #555;
    position: absolute;
    right: 0;
    top: 50%;
    transform: translateY(-50%) rotate(90deg);
    transition: color 0.2s ease;
}

.custom-select:hover .select-selected {
    color: var(--azul-padrao);
}

.custom-select:hover .select-selected:after {
    color: var(--azul-padrao);
}

.custom-select.active .select-selected:after {
    transform: translateY(-50%) rotate(-90deg);
}

.select-items {
    position: absolute;
    background-color: #fff;
    top: 100%;
    left: 0;
    right: 0;
    z-index: 99;
    border: 1px solid #ccc;
    border-top: none;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    border-radius: 0 0 5px 5px;
    min-width: max-content;
}

.select-items div {
    color: #333;
    padding: 8px 20px;
    cursor: pointer;
    border-bottom: 1px solid #eee;
    white-space: nowrap;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.select-items div:last-child {
    border-bottom: none;
}

.select-items div:hover, .select-items .same-as-selected {
    background-color: var(--azul-padrao);
    color: #fff;
}

.select-hide {
    display: none;
}
/* --- FIM DOS ESTILOS DO SELECT CUSTOMIZADO --- */


.search-results-container {
    width: 100%;
    background-color: transparent;
    padding: 0;
    border-radius: 0;
    box-shadow: none;
    margin: 0;
}

#search-term {
    color: var(--azul-padrao);
    font-weight: bold;
}

/* Grid para exibir os produtos */
.product-grid {
    display: flex;
    flex-direction: column;
    align-items: center;
}

/* Estilos para cada item de produto no grid, aprimorados (MANTIDOS) */
.product-item {
    flex-shrink: 0;
    width: 100%;
    max-width: 885px;
    height: auto;
    background: #fff;
    border-radius: 0;
    overflow: hidden;
    text-align: left;
    box-shadow: none;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    flex-direction: row;
    align-items: flex-start;
    cursor: pointer;
    box-sizing: border-box;
    padding: 0;
    border-bottom: 1px solid #e0e0e0;
    margin-bottom: 0;
}

/* Remove a borda inferior do último item para não ter uma linha extra no final */
.product-grid .product-item:last-child {
    border-bottom: none;
}

.product-item:hover {
    box-shadow: 0px 4px 8px rgba(0, 0, 0, 0.08);
}

.product-link {
    text-decoration: none;
    color: inherit;
    display: flex;
    flex-direction: row;
    width: 100%;
    padding: 15px;
}

.product-image-wrapper {
    width: 196px;
    height: 196px;
    overflow: hidden;
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #f8f8f8;
    border-radius: 0;
    margin-right: 15px;
    flex-shrink: 0;
}

.product-image {
    width: 100%;
    height: 100%;
    object-fit: contain;
    display: block;
}

.product-details {
    padding: 0;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
}

.product-name {
    font-size: 18px;
    margin: 0 0 8px 0;
    line-height: 1.4;
    max-height: 2.8em;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    font-weight: 500;
    color: var(--azul-padrao);
}

.product-item:hover .product-name {
    color: #3483fa;
}

.product-old-price {
    font-size: 14px;
    color: #666;
    margin-bottom: 2px;
}

.product-old-price s {
    text-decoration: line-through;
}

.product-current-price-container {
    display: flex;
    align-items: baseline;
    margin-bottom: 5px;
    flex-wrap: wrap;
}

.product-current-price {
    font-size: 28px;
    font-weight: 400;
    color: #333;
    font-family: 'Roboto', sans-serif;
    white-space: nowrap;
}

.product-current-price .integer {
    margin-left: 2px;
}

.product-current-price .centavos {
    font-size: 14px;
    vertical-align: super;
}

.product-discount {
    font-size: 14px;
    color: #00a650;
    font-weight: bold;
    margin-left: 10px;
    flex-shrink: 0;
}

.product-installments {
    font-size: 15px;
    color: #000000e6;
    margin-bottom: 3px;
}

.product-installments-value {
    color: #00a650;
    font-weight: bold;
}

.product-installments-info {
    color: #00a650;
}

.product-shipping {
    font-size: 15px;
    color: #00a650;
    font-weight: 600;
    margin-top: 5px;
}

/* --- ESTILOS SIDEBAR (MANTIDOS) --- */
.sidebar {
    width: 300px;
    padding: 0 1rem;
    background-color: transparent;
    border-right: none;
    box-shadow: none;
    flex-shrink: 0;
    border-radius: 0;
    align-self: flex-start;
    position: sticky;
    top: 10px;
    height: fit-content;
    /* Adicionado para transição suave */
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

/* NOVO: Estilo para o botão de fechar a sidebar em mobile */
.close-sidebar-button {
    display: none; /* Oculto em desktop */
    position: absolute;
    top: 15px;
    right: 15px;
    background: transparent;
    color: var(--azul-selecao); /* Cor azul para o 'X' */
    font-size: 1.5rem;
    font-weight: bold;
    border: none;
    cursor: pointer;
    z-index: 101;
    padding: 5px;
}


.sidebar h2 {
    display: none;
}

.filter-section {
    margin-bottom: 2rem;
    margin-top: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid #eee;
}

.filter-section:last-of-type {
    border-bottom: none;
    margin-bottom: 0;
}

.filter-section:first-of-type {
    margin-top: 50px !important;
}

.filter-section h3 {
    color: #555;
    margin-top: 0;
    margin-bottom: 1.2rem;
    font-size: 1.2rem;
}

.breadcrumb {
    font-size: 0.95rem;
    color: #777;
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
}

.breadcrumb a {
    text-decoration: none;
    color: #007bff;
    padding: 0 3px;
}

.breadcrumb a:hover {
    text-decoration: underline;
}

.breadcrumb span {
    color: #bbb;
}

.breadcrumb .active {
    font-weight: bold;
    color: #333;
    pointer-events: none;
}

.price-range {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.price-range label {
    font-size: 0.9rem;
    color: #666;
}

.price-range input[type="number"] {
    width: 90px;
    padding: 0.6rem;
    border: 1px solid #ccc;
    border-radius: 5px;
    -moz-appearance: textfield;
}

.price-range input[type="number"]::-webkit-outer-spin-button,
.price-range input[type="number"]::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.price-range button {
    display: none;
}

.brand-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.brand-list li {
    margin-bottom: 0.8rem;
    display: flex;
    align-items: center;
}

.brand-list input[type="checkbox"] {
    margin-right: 10px;
    transform: scale(1.2);
    cursor: pointer;
}

.brand-list label {
    color: #444;
    cursor: pointer;
}

.update-button-container {
    display: flex;
    justify-content: center;
    margin-top: 2rem;
    padding-bottom: 1rem;
}

.update-button {
    padding: 0.8rem 2rem;
    background-color: var(--azul-selecao);
    color: white;
    border: none;
    border-radius: 5px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: bold;
    transition: background-color 0.2s ease;
    width: 100%;
}

.update-button:hover {
    background-color: #0056b3;
}


/* --- RESPONSIVIDADE ATUALIZADA --- */

@media (max-width: 900px) {
    /* Exibir o botão em mobile */
    .close-sidebar-button {
        display: block;
    }

    .main-search-results-page {
        flex-direction: column;
        padding: 5px 15px;
        gap: 15px;
        max-width: 100%;
        margin-top: 65px;
        position: relative; /* Necessário para a sidebar se posicionar corretamente */
    }

    /* 1. Sidebar escondida por padrão em mobile */
    .sidebar {
        width: 100%;
        position: fixed; /* Fixa no topo para funcionar como overlay */
        top: 0;
        left: 0;
        z-index: 100; /* Garante que fique acima de todo o conteúdo */
        height: 100vh;
        overflow-y: auto; /* Permite scroll no conteúdo dos filtros */
        background-color: #fff; /* Fundo branco completo para o painel */
        box-shadow: 0 0 20px rgba(0,0,0,0.2);
        padding: 60px 20px 20px 20px; /* Espaço para o botão fechar */

        /* Oculta a sidebar para a esquerda */
        transform: translateX(-100%);
    }

    /* 2. Classe para MOSTRAR a sidebar quando o botão é clicado (via JS) */
    .sidebar-open .sidebar {
        transform: translateX(0);
    }

    /* 3. Retorna o display do botão de filtro no header em mobile */
    .filter-toggle-button {
        /* CORRIGIDO: Agora o display: flex só aparece em telas menores */
        display: flex;
        align-items: center;
        gap: 8px;
    }

    .results-header {
        /* Garante que o botão de filtro e o select de ordenação fiquem lado a lado */
        justify-content: space-between;
        flex-direction: row;
        align-items: center;
    }

    /* Ajustes menores para produtos */
    .content-area {
        max-width: 100%;

    }
    .product-grid {
        gap: 0;
    }
    .product-item {
        max-width: 100%;
    }
    .product-link {
        padding: 10px;
    }
    .product-image-wrapper {
        width: 150px;
        height: 150px;
        margin-right: 10px;
    }
    .product-name {
        font-size: 16px;
    }
    .product-current-price {
        font-size: 24px;
    }
    .product-old-price, .product-discount, .product-installments, .product-shipping {
        font-size: 13px;
    }
}

@media (max-width: 500px) {
    .results-header {
        flex-direction: row; /* Mantém na linha para o botão e select */
        justify-content: space-between;
    }

    /* Garante que o painel de filtro ocupe toda a largura */
    .sidebar {
        width: 100vw;
    }

    /* Quebra o produto em coluna para telas muito pequenas */
    .product-item {
        flex-direction: column;
        align-items: center;
        text-align: center;
        padding: 0;
    }

    .product-image-wrapper {
        width: 120px;
        height: 120px;
        margin-right: 0;
        margin-bottom: 10px;
    }
    .product-link {
        flex-direction: row;
    }
    .product-details {
        text-align: left;
        align-items: flex-start;
    }
    .product-current-price-container {
        justify-content: center;
    }
}