/* =============================================================
   BienesRaicesOne · Estilos de componentes y layout
   ============================================================= */

/* ---------- Header ---------- */
.app-header {
  position: sticky;
  top: 0;
  z-index: 50;
  height: var(--header-h);
  background: var(--header-bg);
  backdrop-filter: saturate(180%) blur(14px);
  border-bottom: 1px solid var(--border);
}
.app-header .container {
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}
.brand { display: flex; align-items: center; gap: .6rem; font-weight: 800; font-size: 1.15rem; }
.brand-mark {
  width: 34px; height: 34px; border-radius: 9px;
  background: linear-gradient(135deg, var(--a1-green), var(--a1-green-strong));
  color: #04120D; display: grid; place-items: center;
  font-family: var(--font-mono); font-weight: 800;
}
.brand small { color: var(--text-faint); font-weight: 500; font-size: .72rem; }

.nav { display: flex; align-items: center; gap: 1.4rem; }
.nav a { color: var(--text-muted); font-weight: 500; font-size: .95rem; transition: color var(--transition); }
.nav a:hover, .nav a.active { color: var(--text); }
.header-actions { display: flex; align-items: center; gap: .6rem; }

.theme-toggle {
  width: 40px; height: 40px; border-radius: 10px;
  border: 1px solid var(--border-strong);
  background: var(--surface);
  color: var(--text);
  display: grid; place-items: center; cursor: pointer;
  transition: var(--transition);
}
.theme-toggle:hover { background: var(--surface-2); }

.nav-toggle { display: none; background: none; border: none; color: var(--text); cursor: pointer; }

/* ---------- Hero ---------- */
.hero {
  position: relative;
  padding: 88px 0 72px;
  overflow: hidden;
}
.hero::before {
  content: "";
  position: absolute; inset: 0;
  background:
    radial-gradient(60% 80% at 80% -10%, var(--a1-green-soft), transparent 60%),
    radial-gradient(50% 60% at 0% 110%, rgba(76,141,255,.08), transparent 60%);
  pointer-events: none;
}
.hero h1 { font-size: clamp(2.1rem, 5vw, 3.6rem); font-weight: 800; max-width: 15ch; }
.hero h1 .accent { color: var(--a1-green-strong); }
.hero p { color: var(--text-muted); font-size: 1.15rem; max-width: 52ch; margin-top: 1rem; }
.hero-eyebrow {
  font-family: var(--font-mono); font-size: .8rem; letter-spacing: .1em;
  text-transform: uppercase; color: var(--a1-green-strong);
}

/* ---------- Search bar (hero) ---------- */
.search-bar {
  margin-top: 2rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  padding: 10px;
  display: grid;
  grid-template-columns: 1.4fr 1fr 1fr auto;
  gap: 8px;
}
.search-bar .field { display: flex; flex-direction: column; padding: .35rem .7rem; }
.search-bar label { font-size: .68rem; text-transform: uppercase; letter-spacing: .06em; color: var(--text-faint); font-weight: 700; }
.search-bar input, .search-bar select {
  border: none; background: transparent; color: var(--text);
  font-size: .95rem; padding: .2rem 0; outline: none; font-family: var(--font-sans);
}
.search-bar select { cursor: pointer; }

/* ---------- Stats strip ---------- */
.stats { display: flex; gap: 3rem; margin-top: 3rem; flex-wrap: wrap; }
.stat b { font-size: 1.8rem; font-weight: 800; display: block; }
.stat span { color: var(--text-faint); font-size: .85rem; }

/* ---------- Property grid & card ---------- */
.property-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 22px;
}
.property-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  transition: var(--transition);
  display: flex; flex-direction: column;
}
.property-card:hover { transform: translateY(-4px); box-shadow: var(--shadow-lg); border-color: var(--border-strong); }
.property-media { position: relative; aspect-ratio: 16 / 11; overflow: hidden; background: var(--surface-2); }
.property-media img { width: 100%; height: 100%; object-fit: cover; transition: transform 400ms ease; }
.property-card:hover .property-media img { transform: scale(1.06); }
.property-media .badges { position: absolute; top: 12px; left: 12px; display: flex; gap: .4rem; z-index: 3; }

/* Carrusel de la tarjeta */
.property-media .media-link { display: block; width: 100%; height: 100%; }
.carousel-nav {
    position: absolute; top: 50%; transform: translateY(-50%);
    width: 34px; height: 34px; border-radius: 50%;
    border: none; background: rgba(255,255,255,.85); color: #0b0f14;
    font-size: 1.4rem; line-height: 1; cursor: pointer;
    display: grid; place-items: center; opacity: 0; transition: opacity var(--transition), background var(--transition);
    z-index: 4; box-shadow: 0 2px 8px rgba(0,0,0,.25);
}
.carousel-nav.prev { left: 10px; }
.carousel-nav.next { right: 10px; }
.property-card:hover .carousel-nav { opacity: 1; }
.carousel-nav:hover { background: #fff; }
.carousel-dots {
    position: absolute; bottom: 10px; left: 0; right: 0; z-index: 3;
    display: flex; gap: 5px; justify-content: center; pointer-events: none;
}
.carousel-dots .dot { width: 6px; height: 6px; border-radius: 50%; background: rgba(255,255,255,.55); box-shadow: 0 0 2px rgba(0,0,0,.4); }
.carousel-dots .dot.active { background: #fff; width: 7px; height: 7px; }
/* En pantallas táctiles, mostrar siempre las flechas */
@media (hover: none) { .carousel-nav { opacity: 1; } }
.fav-btn {
  position: absolute; top: 12px; right: 12px;
  width: 38px; height: 38px; border-radius: 50%;
  background: var(--overlay); color: #fff; border: none;
  display: grid; place-items: center; cursor: pointer;
  backdrop-filter: blur(4px); transition: var(--transition);
}
.fav-btn:hover { transform: scale(1.08); }
.fav-btn.is-fav { color: #ff5d73; }
.property-body { padding: 16px; display: flex; flex-direction: column; gap: .5rem; flex: 1; }
.property-price { font-size: 1.3rem; font-weight: 800; }
.property-price .per { font-size: .8rem; font-weight: 500; color: var(--text-faint); }
.property-title { font-weight: 600; font-size: 1rem; }
.property-loc { color: var(--text-muted); font-size: .88rem; display: flex; align-items: center; gap: .3rem; }
.property-meta {
  margin-top: auto; padding-top: .75rem; border-top: 1px solid var(--border);
  display: flex; gap: 1.1rem; color: var(--text-muted); font-size: .85rem;
}
.property-meta span { display: inline-flex; align-items: center; gap: .35rem; }

/* ---------- Layout de búsqueda (filtros + resultados) ---------- */
.search-layout { display: grid; grid-template-columns: 280px 1fr; gap: 28px; align-items: start; }
.filters {
  position: sticky; top: calc(var(--header-h) + 16px);
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 20px;
}
.filters h3 { font-size: .95rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-faint); }
.filter-group { margin-bottom: 1.25rem; }
.filter-group > label { display: block; font-weight: 600; font-size: .85rem; margin-bottom: .45rem; }
.filter-group select, .filter-group input {
  width: 100%; padding: .55rem .7rem; border-radius: var(--radius-sm);
  border: 1px solid var(--border-strong); background: var(--bg-elevated); color: var(--text);
  font-size: .9rem; outline: none;
}
.range-row { display: flex; gap: .5rem; }
.results-head { display: flex; justify-content: space-between; align-items: center; margin-bottom: 1.2rem; flex-wrap: wrap; gap: .6rem; }
.results-head .count { font-weight: 700; }
.view-tabs { display: flex; gap: .3rem; background: var(--surface-2); padding: 4px; border-radius: 10px; }
.view-tabs button { border: none; background: transparent; color: var(--text-muted); padding: .4rem .8rem; border-radius: 8px; cursor: pointer; font-weight: 600; font-size: .85rem; }
.view-tabs button.active { background: var(--surface); color: var(--text); box-shadow: var(--shadow-sm); }

/* ---------- Búsqueda estilo Zillow (mapa + tarjetas) ---------- */
.search-page { display: flex; flex-direction: column; }
.search-toolbar {
    background: var(--bg-elevated);
    border-bottom: 1px solid var(--border);
    padding: 12px 20px;
    display: flex; gap: .6rem; flex-wrap: wrap; align-items: flex-end;
    position: sticky; top: var(--header-h); z-index: 20;
}
.tb-field { display: flex; flex-direction: column; gap: .2rem; }
.tb-field label { font-size: .66rem; text-transform: uppercase; letter-spacing: .05em; color: var(--text-faint); font-weight: 700; }
.tb-field input, .tb-field select {
    padding: .5rem .6rem; border-radius: 8px; border: 1px solid var(--border-strong);
    background: var(--surface); color: var(--text); font-size: .88rem; outline: none;
}
.tb-grow { flex: 1 1 220px; min-width: 180px; }
.tb-grow input { width: 100%; }
.tb-narrow input, .tb-narrow select { width: 92px; }
.search-toolbar .btn { align-self: flex-end; }

.split-view { display: grid; grid-template-columns: 1.05fr 1fr; align-items: start; }
.map-panel { position: sticky; top: calc(var(--header-h) + 66px); height: calc(100vh - var(--header-h) - 66px); }
.search-map { width: 100%; height: 100%; border: 0; border-radius: 0; }
.results-panel { padding: 18px 22px; min-width: 0; }
.property-grid.cards-2 { grid-template-columns: repeat(auto-fill, minmax(240px, 1fr)); gap: 18px; }
.pager { display: flex; gap: .6rem; justify-content: center; align-items: center; margin: 2rem 0; }
.btn-sm { padding: .35rem .7rem; font-size: .82rem; }

@media (max-width: 900px) {
    .map-panel { display: none; }
    .split-view { grid-template-columns: 1fr; }
    .search-toolbar { top: var(--header-h); }
}

/* ---------- Mapa ---------- */
#map, .map-view { width: 100%; height: 640px; border-radius: var(--radius); overflow: hidden; border: 1px solid var(--border); z-index: 1; }
.leaflet-popup-content { font-family: var(--font-sans); }
.map-popup img { width: 200px; height: 120px; object-fit: cover; border-radius: 8px; }
.map-popup .price { font-weight: 800; margin-top: 6px; }

/* ---------- Detalle de propiedad ---------- */
.detail-gallery {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: 10px;
    height: 460px;
    overflow: hidden;
}
/* min-width/height:0 evita el "grid blowout" (que las imágenes ignoren la altura del grid). */
.detail-gallery img { width: 100%; height: 100%; min-width: 0; min-height: 0; object-fit: cover; border-radius: var(--radius-sm); }
.detail-gallery img:first-child { grid-column: span 2; grid-row: span 2; }
.detail-layout { display: grid; grid-template-columns: 1fr 340px; gap: 32px; margin-top: 32px; align-items: start; }
.spec-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(120px, 1fr)); gap: 14px; }
.spec { background: var(--surface-2); border-radius: var(--radius-sm); padding: 14px; }
.spec b { display: block; font-size: 1.15rem; }
.spec span { color: var(--text-muted); font-size: .8rem; }
.feature-list { display: flex; flex-wrap: wrap; gap: .5rem; }
.feature-pill { background: var(--surface-2); border: 1px solid var(--border); border-radius: 999px; padding: .4rem .8rem; font-size: .85rem; }
.agent-card { position: sticky; top: calc(var(--header-h) + 16px); }
.agent-card .avatar { width: 60px; height: 60px; border-radius: 50%; object-fit: cover; }

/* ---------- Footer ---------- */
.app-footer { border-top: 1px solid var(--border); background: var(--bg-elevated); padding: 48px 0 28px; margin-top: 64px; }
.footer-grid { display: grid; grid-template-columns: 2fr 1fr 1fr 1fr; gap: 32px; }
.app-footer h5 { text-transform: uppercase; font-size: .78rem; letter-spacing: .08em; color: var(--text-faint); margin-bottom: 1rem; }
.app-footer a { display: block; color: var(--text-muted); padding: .25rem 0; font-size: .9rem; }
.app-footer a:hover { color: var(--text); }
.footer-bottom { margin-top: 32px; padding-top: 20px; border-top: 1px solid var(--border); color: var(--text-faint); font-size: .82rem; display: flex; justify-content: space-between; flex-wrap: wrap; gap: .6rem; }

/* ---------- Estados ---------- */
.empty-state { text-align: center; padding: 64px 20px; color: var(--text-muted); }
.skeleton { background: linear-gradient(90deg, var(--surface-2) 25%, var(--border) 50%, var(--surface-2) 75%); background-size: 200% 100%; animation: shimmer 1.4s infinite; border-radius: var(--radius); }
@keyframes shimmer { to { background-position: -200% 0; } }

/* Blazor error UI */
#blazor-error-ui {
  background: #ffe6e6; color: #7a0000; bottom: 0; left: 0; right: 0;
  display: none; padding: .8rem 1.2rem; position: fixed; z-index: 1000; box-shadow: var(--shadow);
}
#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 1rem; top: .6rem; }

/* ---------- Responsive ---------- */
@media (max-width: 940px) {
  .nav { display: none; }
  .nav-toggle { display: grid; place-items: center; }
  .search-bar { grid-template-columns: 1fr 1fr; }
  .search-layout { grid-template-columns: 1fr; }
  .filters { position: static; }
  .detail-layout { grid-template-columns: 1fr; }
  .detail-gallery { grid-template-columns: 1fr; grid-template-rows: 1fr; height: 300px; }
  .detail-gallery img:not(:first-child) { display: none; }
  .footer-grid { grid-template-columns: 1fr 1fr; }
}
@media (max-width: 560px) {
  .search-bar { grid-template-columns: 1fr; }
  .footer-grid { grid-template-columns: 1fr; }
  .stats { gap: 1.5rem; }
}
