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

body {
    font-family: 'Montserrat', 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Arial, sans-serif;
    color: #333;
    line-height: 1.6;
    padding-top: var(--header-h);
}

/* =========================
   CONTEÚDO PRINCIPAL
========================= */
.main-container {
    max-width: 1300px;
    margin: 0 auto;
    padding: 1.5rem 1.5rem 2rem;
}

/* =========================
   LAYOUT COMPRAR (SIDEBAR + RESULTADOS)
========================= */
.comprar-layout {
    display: grid;
    grid-template-columns: 340px 1fr;
    align-items: start;
    gap: 2rem;
}

/* =========================
   SIDEBAR DE FILTROS
========================= */
.filters-sidebar {
    background: #f8f8f8;
    padding: 1.5rem;
    border-radius: 6px;
    position: sticky;
    top: 96px;
    max-height: calc(100vh - 116px);
    overflow-y: auto;
}

.filters-sidebar-header {
    display: none;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}

.filters-sidebar-header h2 {
    font-size: 1.2rem;
    color: #2a2a2a;
}

.filters-close-btn {
    background: none;
    border: none;
    font-size: 1.6rem;
    line-height: 1;
    cursor: pointer;
    color: #666;
    width: 44px;
    height: 44px;
}

.filters-overlay {
    display: none;
}

.btn-filters-toggle {
    display: none;
    align-items: center;
    gap: 0.5rem;
    min-height: 44px;
    padding: 0.6rem 1rem;
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-weight: 500;
    font-size: 0.9rem;
    cursor: pointer;
    font-family: inherit;
    color: #333;
    transition: background 0.2s;
}

.btn-filters-toggle:hover {
    background: #f5f5f5;
}

.filters {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.filter-group {
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.filter-group label {
    font-weight: 500;
    font-size: 0.9rem;
    color: #555;
}

.filter-group input,
.filter-group select {
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 1rem;
    width: 100%;
    transition: border-color 0.2s;
    font-family: inherit;
}

.filter-group input:focus,
.filter-group select:focus {
    outline: none;
    border-color: #C5B358;
}

.filter-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

/* Na sidebar, os pares de filtros (Preço, Área, Divisões) ficam
   lado a lado; o texto reduz ligeiramente para não cortar */
.filters-sidebar .filter-row {
    grid-template-columns: 1fr 1fr;
    gap: 0.6rem;
}

.filters-sidebar .filter-row .filter-group {
    padding: 0.5rem 0.6rem 0.55rem;
    min-width: 0;
}

.filters-sidebar .filter-row .filter-group select {
    font-size: 0.85rem;
    text-overflow: ellipsis;
    white-space: nowrap;
    overflow: hidden;
}

/* Título de secção (ex: "Preço", "Área Útil", "Divisões") */
.filters-sidebar .filter-section {
    margin-bottom: 0;
}

.filters-sidebar .filter-section-title {
    font-size: 0.85rem;
    font-weight: 700;
    color: #2a2a2a;
    margin-bottom: 0.6rem;
}

/* Caixa arredondada com label pequeno dentro, no estilo das grandes
   plataformas imobiliárias */
.filters-sidebar .filter-group {
    flex-direction: column;
    gap: 0.1rem;
    background: white;
    border: 1px solid #e2e2e2;
    border-radius: 6px;
    padding: 0.5rem 0.75rem 0.55rem;
    transition: border-color 0.2s;
}

.filters-sidebar .filter-group:focus-within {
    border-color: #C5B358;
}

.filters-sidebar .filter-group label {
    font-size: 0.7rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    color: #6b7280;
}

.filters-sidebar .filter-group input,
.filters-sidebar .filter-group select {
    border: none;
    padding: 0.1rem 0 0;
    font-size: 0.95rem;
    color: #2a2a2a;
    background: transparent;
}

.filters-sidebar .filter-group input:focus,
.filters-sidebar .filter-group select:focus {
    outline: none;
    border-color: transparent;
}

.filters-sidebar .filter-group input::placeholder {
    color: #6b7280;
}

.filter-actions {
    display: flex;
    gap: 1rem;
    margin-top: 0.5rem;
}

.btn-search {
    flex: 2;
    padding: 0.9rem;
    background: #C5B358;
    color: var(--navy);
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    text-transform: uppercase;
    transition: background 0.2s;
    font-family: inherit;
}

.btn-search:hover {
    background: #a89a48;
}

.btn-reset {
    flex: 1;
    padding: 0.9rem;
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
    font-family: inherit;
}

.btn-reset:hover {
    background: #f5f5f5;
}

/* =========================
   SECÇÃO DE IMÓVEIS
========================= */
.properties-section {
    margin-bottom: 3rem;
}

.properties-section h2 {
    margin-bottom: 1.5rem;
    font-size: 1.5rem;
    color: #2a2a2a;
}

.properties-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
}

.property-card {
    color: inherit;
    text-decoration: none;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    transition: transform 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
    height: 100%;
}

.property-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 20px rgba(0,0,0,0.15);
}

.property-image {
    position: relative;
    height: 200px;
    overflow: hidden;
}

.property-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

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

.property-tag {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #C5B358;
    color: var(--navy);
    padding: 0.25rem 0.75rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
}

.property-info {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    flex: 1;
}

.property-info h3 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    color: #2a2a2a;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.property-location {
    color: #666;
    font-size: 0.9rem;
    margin-bottom: 0.75rem;
}

.property-features {
    display: flex;
    flex-wrap: wrap;
    gap: 1rem;
    font-size: 0.85rem;
    color: #555;
    margin-bottom: 0.75rem;
}

.property-price {
    font-size: 1.2rem;
    margin-top: auto;
    color: #2a2a2a;
}

/* =========================
   PAGINAÇÃO
========================= */
.pagination {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 2rem;
}

.page-link {
    min-width: 44px;
    height: 44px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 1px solid #ddd;
    border-radius: 50%;
    background: #fff;
    text-decoration: none;
    color: #333;
    font-weight: 500;
    font-size: 1rem;
    cursor: pointer;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
    font-family: inherit;
}

.page-link:hover {
    background: #f5f5f5;
}

.page-link.active,
.page-link[aria-current="page"] {
    background: #C5B358;
    color: var(--navy);
    border-color: #C5B358;
}

span.page-link {
    border-color: transparent;
    cursor: default;
}

span.page-link:hover {
    background: transparent;
}

/* =========================
   SECÇÃO CTA
========================= */
.cta-section {
    background: #f8f8f8;
    padding: 4rem 2rem;
    text-align: center;
}

.cta-section h2 {
    margin-bottom: 0.5rem;
    font-size: 1.5rem;
    color: #2a2a2a;
}

.cta-section p {
    margin-bottom: 1.5rem;
    color: #555;
    font-size: 1.1rem;
}

.btn-cta {
    background: #C5B358;
    color: var(--navy);
    border: none;
    padding: 1rem 2.5rem;
    font-size: 1rem;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
    font-family: inherit;
}

.btn-cta:hover {
    background: #a89a48;
}

/* =========================
   RESULTADOS (cabeçalho da lista)
========================= */
.results-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.results-count {
    margin-right: auto;
    color: #666;
    font-size: 0.95rem;
}

.results-count strong {
    color: #333;
}

.results-sort {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.results-sort label {
    font-size: 0.9rem;
    color: #666;
}

.results-sort select {
    min-height: 44px;
    padding: 0.5rem 1rem;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 0.9rem;
    font-family: inherit;
    background: #fff;
}

/* =========================
   RESPONSIVE - COMPRAR
========================= */

/* Sidebar vira drawer a partir daqui */
@media (max-width: 1100px) {
    .properties-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 900px) {
    .comprar-layout {
        grid-template-columns: 1fr;
    }

    .filters-sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        height: 100dvh;
        width: min(320px, 85vw);
        max-height: none;
        border-radius: 0;
        z-index: 3000;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: 4px 0 20px rgba(0,0,0,0.15);
    }

    .filters-sidebar.active {
        transform: translateX(0);
    }

    .filters-sidebar-header {
        display: flex;
    }

    .filters-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0,0,0,0.55);
        z-index: 2999;
    }

    .filters-overlay.active {
        display: block;
    }

    .btn-filters-toggle {
        display: inline-flex;
    }
}

@media (max-width: 768px) {
    body {
        padding-top: var(--header-h);
    }
    
    .main-container {
        padding: 1rem;
    }
    
    .filter-row {
        grid-template-columns: 1fr;
    }
    
    .filter-actions {
        flex-direction: column;
    }
    
    .properties-grid {
        grid-template-columns: 1fr;
    }

    .results-info {
        flex-direction: column;
        align-items: flex-start;
    }

    .property-image {
        height: 180px;
    }
    
    .cta-section {
        padding: 3rem 1rem;
    }
    
    .cta-section h2 {
        font-size: 1.3rem;
    }
    
}

@media (max-width: 480px) {
    body {
        padding-top: var(--header-h);
    }
    
    .main-container {
        padding: 0.75rem;
    }
    
    .filters-sidebar {
        padding: 1rem;
        width: 100vw;
    }
    
    .property-info {
        padding: 1rem;
    }
    
    .pagination {
        gap: 0.3rem;
    }
    
    .page-link {
        min-width: 40px;
        height: 44px;
        font-size: 0.9rem;
    }
}