/* --- ESTILOS GENERALES Y VARIABLES --- */

html {
    scroll-behavior: smooth; /* <--- ESTO ES LA CLAVE */
}

:root {
    --primary-color: #2c3e50; /* Azul oscuro elegante */
    --secondary-color: #3498db; /* Azul brillante para botones */
    --accent-color: #e74c3c; /* Rojo para ofertas o cerrar */
    --bg-light: #f4f7f6; /* Fondo gris muy suave */
    --text-dark: #333;
    --card-shadow: 0 10px 20px rgba(0,0,0,0.08);
}

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

body {
    font-family: 'Segoe UI', sans-serif;
    background-color: var(--bg-light);
    color: var(--text-dark);
    line-height: 1.6;
}

.container { width: 90%; max-width: 1200px; margin: 0 auto; }

/* HEADER */
.header { background: white; box-shadow: 0 2px 10px rgba(0,0,0,0.1); position: sticky; top: 0; z-index: 100; }
.header-content { display: flex; justify-content: space-between; align-items: center; padding: 15px 0; }
.logo h1 { color: var(--primary-color); font-size: 1.5rem; }
.logo span { color: var(--secondary-color); }
.nav-menu { list-style: none; display: flex; gap: 20px; }
.nav-menu a { text-decoration: none; color: var(--text-dark); font-weight: 600; }

/* HERO SECTION (PORTADA) */
.hero {
    /* Imagen de fondo genérica de una ciudad o casa */
    background: linear-gradient(rgba(0,0,0,0.6), rgba(0,0,0,0.6)), url('https://images.unsplash.com/photo-1560518883-ce09059eeffa?ixlib=rb-4.0.3&auto=format&fit=crop&w=1920&q=80');
    background-size: cover;
    background-position: center;
    padding: 80px 0;
    text-align: center;
    color: white;
}

.hero h1 { font-size: 2.5rem; margin-bottom: 10px; }
.search-form { background: white; padding: 20px; border-radius: 8px; max-width: 900px; margin: 30px auto 0; box-shadow: 0 5px 15px rgba(0,0,0,0.2); }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 15px; }
.form-group input, .form-group select { width: 100%; padding: 10px; border: 1px solid #ddd; border-radius: 4px; }
.btn-search { background: var(--secondary-color); color: white; border: none; padding: 10px; border-radius: 4px; cursor: pointer; font-weight: bold; }
.btn-search:hover { background: #2980b9; }

/* --- REJILLA DE PROPIEDADES (Grid System) --- */
.properties-section { padding: 50px 0; }
.section-title { text-align: center; margin-bottom: 40px; color: var(--primary-color); font-size: 2rem; }

.properties-grid {
    display: grid;
    /* Esto crea columnas automáticas de mínimo 300px */
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 30px;
    align-items: start;
}

/* TARJETA DE PROPIEDAD */
.property-card {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: var(--card-shadow);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
    border: 1px solid rgba(0,0,0,0.05);
    cursor: pointer;
}

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

.property-image {
    height: 200px;
    width: 100%;
    position: relative;
}

.property-image img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Ajusta la imagen sin deformarla */
}

.property-badge {
    position: absolute;
    top: 15px; left: 15px;
    background: var(--primary-color);
    color: white;
    padding: 5px 10px;
    font-size: 0.8rem;
    font-weight: bold;
    border-radius: 4px;
    text-transform: uppercase;
}

.property-info { padding: 20px; }
.property-info h3 { font-size: 1.2rem; margin-bottom: 5px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.property-price { font-size: 1.5rem; color: var(--secondary-color); font-weight: 800; margin-bottom: 10px; }
.property-location { color: #777; font-size: 0.9rem; margin-bottom: 15px; }

.property-features {
    display: flex;
    justify-content: space-between;
    border-top: 1px solid #eee;
    padding-top: 15px;
    color: #666;
    font-size: 0.9rem;
}
.property-features i { color: var(--secondary-color); margin-right: 5px; }

.btn-details {
    display: block;
    width: 100%;
    background: var(--primary-color);
    color: white;
    text-align: center;
    padding: 10px;
    margin-top: 15px;
    border-radius: 6px;
    text-decoration: none;
    transition: background 0.3s;
}
.btn-details:hover { background: #34495e; }

/* MODAL (VENTANA DETALLE) */
.modal {
    display: none; position: fixed; z-index: 1000; left: 0; top: 0;
    width: 100%; height: 100%; overflow: auto;
    background-color: rgba(0,0,0,0.8); backdrop-filter: blur(4px);
}

.modal-content {
    background-color: #fff; margin: 5% auto; padding: 0;
    border-radius: 10px; width: 90%; max-width: 800px;
    box-shadow: 0 25px 50px rgba(0,0,0,0.5);
    position: relative; animation: slideDown 0.4s;
}

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

.modal-body { padding: 30px; }
.modal-close {
    position: absolute; top: 15px; right: 20px;
    font-size: 30px; font-weight: bold; color: white;
    background: rgba(0,0,0,0.5); width: 40px; height: 40px;
    border-radius: 50%; display: flex; align-items: center; justify-content: center;
    cursor: pointer; z-index: 10;
}
.modal-close:hover { background: var(--accent-color); }

.modal-img { width: 100%; height: 350px; object-fit: cover; }
.modal-info-grid { display: grid; grid-template-columns: 2fr 1fr; gap: 20px; margin-top: 20px; }

/* RESPONSIVE */
@media (max-width: 768px) {
    .modal-info-grid { grid-template-columns: 1fr; }
    .hero h1 { font-size: 1.8rem; }
}