/* ============================================================
   LISTINGS PAGE — Ivan Carrillo Realty
   ============================================================ */
:root {
  --ink: #1a1a2e;
  --ink-mid: #3d3d5c;
  --mist: #f7f6f4;
  --border-soft: #e8e6e0;
  --card-shadow: 0 2px 12px rgba(26,26,46,.07);
  --card-shadow-hover: 0 12px 40px rgba(26,26,46,.14);
  --radius-card: 14px;
  --sidebar-w: 280px;
}

.listings-page { min-height: 100vh; background: var(--mist); }

/* ── Layout ── */
.listings-body {
  max-width: 1340px;
  margin: 0 auto;
  padding: 1.5rem 1.25rem 4rem;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  gap: 1.5rem;
  align-items: start;
}

/* ── Sidebar (contenedor flex: scroll interno + footer fijo) ── */
.listings-sidebar {
  background: #fff;
  border: 1px solid var(--border-soft);
  border-radius: 16px;
  padding: 0;
  position: sticky;
  top: 5rem;
  max-height: calc(100vh - 6rem);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}
.sidebar-scroll {
  overflow-y: auto;
  padding: 1.5rem;
  flex: 1;
}
.sidebar-scroll::-webkit-scrollbar { width: 4px; }
.sidebar-scroll::-webkit-scrollbar-thumb { background: var(--border-soft); border-radius: 4px; }

.sidebar-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-soft);
  flex-shrink: 0;
}

.sidebar-title {
  font-size: 1rem;
  font-weight: 700;
  color: var(--ink);
  margin-bottom: 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.btn-clear-all {
  font-size: .78rem;
  color: var(--brand);
  background: none;
  border: none;
  cursor: pointer;
  text-decoration: underline;
  display: none;
}
.btn-clear-all.visible { display: inline; }

/* ── Meta: contador + país (dentro del sidebar) ── */
.sidebar-meta {
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: .5rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1.25rem;
  border-bottom: 1px solid var(--border-soft);
}
.sidebar-count { font-size: .85rem; color: var(--ink-mid); }
.sidebar-count strong { color: var(--ink); }
.sidebar-country {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .3rem .7rem;
  background: var(--mist);
  border: 1px solid var(--border-soft);
  border-radius: 20px;
  font-size: .76rem;
  font-weight: 600;
  color: var(--ink-mid);
  text-decoration: none;
}
.sidebar-country:hover { border-color: var(--brand); color: var(--brand); }

/* ── Sort + view (dentro del sidebar) ── */
.sidebar-sort-row { display: flex; gap: .5rem; }
.sort-select {
  flex: 1;
  padding: .55rem 2rem .55rem .9rem;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  font-size: .85rem;
  background: var(--mist) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 24 24'%3E%3Cpath fill='%23888' d='M7 10l5 5 5-5z'/%3E%3C/svg%3E") no-repeat right .7rem center;
  -webkit-appearance: none;
  appearance: none;
  color: var(--ink);
  cursor: pointer;
}
.sort-select:focus { outline: none; border-color: var(--brand); }

.view-toggle { display: flex; border: 1px solid var(--border-soft); border-radius: 8px; overflow: hidden; flex-shrink: 0; }
.view-btn {
  padding: .55rem .65rem;
  background: #fff;
  border: none;
  cursor: pointer;
  color: #999;
  font-size: .95rem;
  transition: all .2s;
}
.view-btn.active, .view-btn:hover { background: var(--brand-ligh); color: var(--brand); }

/* ── Botón flotante mobile para abrir el sidebar ── */
.btn-filter-toggle-mobile {
  display: none;
  position: fixed;
  bottom: 1.25rem;
  left: 50%;
  transform: translateX(-50%);
  z-index: 250;
  align-items: center;
  gap: .5rem;
  padding: .8rem 1.4rem;
  background: var(--ink);
  color: #fff;
  border: none;
  border-radius: 30px;
  font-size: .85rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: 0 6px 20px rgba(0,0,0,.25);
}
.btn-filter-toggle-mobile .badge-count {
  background: var(--brand);
  color: #fff;
  border-radius: 20px;
  font-size: .7rem;
  padding: .1rem .45rem;
  font-weight: 700;
  display: none;
}
.btn-filter-toggle-mobile .badge-count.has-filters { display: inline-block; }

/* ── Filter groups ── */
.filter-group {
  margin-bottom: 1.5rem;
  border-bottom: 1px solid var(--border-soft);
  padding-bottom: 1.25rem;
}
.filter-group:last-child { border-bottom: none; margin-bottom: 0; padding-bottom: 0; }
.filter-group-label {
  font-size: .8rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: #999;
  margin-bottom: .75rem;
}

.filter-pills { display: flex; flex-wrap: wrap; gap: .4rem; }
.filter-pill {
  padding: .38rem .85rem;
  border: 1.5px solid var(--border-soft);
  border-radius: 20px;
  font-size: .82rem;
  color: var(--ink-mid);
  cursor: pointer;
  background: #fff;
  transition: all .18s;
  white-space: nowrap;
}
.filter-pill:hover { border-color: var(--brand); color: var(--brand); }
.filter-pill.active { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 600; }

.price-range-wrap { display: flex; flex-direction: column; gap: .6rem; }
.price-inputs { display: grid; grid-template-columns: 1fr 1fr; gap: .5rem; }
.price-input {
  padding: .55rem .7rem;
  border: 1px solid var(--border-soft);
  border-radius: 8px;
  font-size: .85rem;
  color: var(--ink);
  background: var(--mist);
  width: 100%;
  box-sizing: border-box;
}
.price-input:focus { outline: none; border-color: var(--brand); background: #fff; }

.stepper-wrap { display: flex; align-items: center; gap: .4rem; flex-wrap: wrap; }
.stepper-btn {
  width: 34px; height: 34px;
  border: 1.5px solid var(--border-soft);
  border-radius: 8px;
  background: #fff;
  color: var(--ink);
  font-size: .9rem;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all .18s;
  flex-shrink: 0;
}
.stepper-btn:hover { border-color: var(--brand); color: var(--brand); }
.stepper-btn.active { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 700; }

.filter-checks { display: flex; flex-direction: column; gap: .55rem; }
.filter-check-item {
  display: flex;
  align-items: center;
  gap: .6rem;
  cursor: pointer;
  font-size: .88rem;
  color: var(--ink-mid);
  transition: color .15s;
}
.filter-check-item:hover { color: var(--ink); }
.filter-check-item input[type="checkbox"] { accent-color: var(--brand); width: 16px; height: 16px; cursor: pointer; }

/* ── Apply button (vive en sidebar-footer, fuera del scroll) ── */
.btn-apply-filters {
  width: 100%;
  padding: .85rem;
  background: var(--ink);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: .9rem;
  font-weight: 700;
  cursor: pointer;
  letter-spacing: .03em;
  transition: background .2s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
}
.btn-apply-filters:hover { background: var(--brand); }

/* ── Active filter chips ── */
.active-filters-bar { display: flex; flex-wrap: wrap; gap: .5rem; margin-bottom: 1.25rem; }
.active-filter-chip {
  display: flex;
  align-items: center;
  gap: .35rem;
  padding: .35rem .75rem;
  background: var(--brand-ligh);
  border: 1px solid rgba(201,168,76,.3);
  border-radius: 20px;
  font-size: .8rem;
  color: var(--ink);
}
.active-filter-chip button {
  background: none; border: none; cursor: pointer;
  color: #aaa; font-size: .85rem; padding: 0; line-height: 1; display: flex;
}
.active-filter-chip button:hover { color: var(--ink); }

/* ── Grid view ── */
.prop-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1.25rem;
}

/* ── List view ── */
.prop-list { display: flex; flex-direction: column; gap: 1rem; }

/* ── Property card (grid) ── */
.prop-card-g {
  background: #fff;
  border-radius: var(--radius-card);
  overflow: hidden;
  border: 1px solid var(--border-soft);
  box-shadow: var(--card-shadow);
  transition: box-shadow .25s, transform .2s;
  text-decoration: none;
  color: inherit;
  display: flex;
  flex-direction: column;
}
.prop-card-g:hover { box-shadow: var(--card-shadow-hover); transform: translateY(-3px); }

.card-img {
  position: relative;
  height: 210px;
  overflow: hidden;
  background: #f0ede8;
}
.card-img img {
  width: 100%; height: 100%;
  object-fit: cover;
  transition: transform .4s ease;
  display: block;
}
.prop-card-g:hover .card-img img { transform: scale(1.05); }
.card-img-fallback {
  width: 100%; height: 100%;
  display: flex; align-items: center; justify-content: center;
  color: #ccc; font-size: 3rem;
}
.card-badge {
  position: absolute;
  top: .75rem; left: .75rem;
  padding: .3rem .8rem;
  border-radius: 20px;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .04em;
  backdrop-filter: blur(6px);
}
.card-badge.sale { background: rgba(22,163,74,.9); color: #fff; }
.card-badge.rent { background: rgba(37,99,235,.9); color: #fff; }
.card-badge.comm { background: rgba(30,30,50,.85); color: #fff; }

.card-photo-count {
  position: absolute;
  bottom: .6rem; right: .7rem;
  background: rgba(0,0,0,.55);
  color: #fff;
  font-size: .72rem;
  padding: .2rem .55rem;
  border-radius: 6px;
  display: flex; align-items: center; gap: .3rem;
  backdrop-filter: blur(4px);
}

.card-body { padding: 1.1rem 1.2rem; flex: 1; display: flex; flex-direction: column; gap: .5rem; }
.card-price { font-size: 1.3rem; font-weight: 800; color: var(--ink); letter-spacing: -.01em; }
.card-name  { font-size: .88rem; color: var(--ink-mid); font-weight: 500; }
.card-addr  {
  font-size: .82rem; color: #aaa;
  display: flex; align-items: center; gap: .3rem;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.card-addr i { flex-shrink: 0; }
.card-stats {
  display: flex; gap: .9rem;
  padding-top: .4rem;
  border-top: 1px solid var(--border-soft);
  flex-wrap: wrap;
}
.card-stat { display: flex; align-items: center; gap: .3rem; font-size: .82rem; color: var(--ink-mid); }
.card-stat i { color: var(--brand); font-size: .8rem; }

/* ── Property card (list) ── */
.prop-card-l {
  background: #fff;
  border-radius: var(--radius-card);
  border: 1px solid var(--border-soft);
  box-shadow: var(--card-shadow);
  display: grid;
  grid-template-columns: 280px 1fr auto;
  overflow: hidden;
  text-decoration: none;
  color: inherit;
  transition: box-shadow .25s, transform .2s;
  align-items: stretch;
}
.prop-card-l:hover { box-shadow: var(--card-shadow-hover); transform: translateY(-2px); }

.card-l-img { position: relative; overflow: hidden; height: 200px; }
.card-l-img img { width: 100%; height: 100%; object-fit: cover; transition: transform .4s; display: block; }
.prop-card-l:hover .card-l-img img { transform: scale(1.04); }

.card-l-body { padding: 1.25rem 1.5rem; display: flex; flex-direction: column; justify-content: center; gap: .5rem; }
.card-l-price { font-size: 1.5rem; font-weight: 800; color: var(--ink); }
.card-l-name  { font-size: .95rem; color: var(--ink-mid); }
.card-l-addr  { font-size: .85rem; color: #aaa; display: flex; align-items: center; gap: .3rem; }
.card-l-stats { display: flex; gap: 1.25rem; flex-wrap: wrap; }
.card-l-stat  { display: flex; align-items: center; gap: .35rem; font-size: .85rem; color: var(--ink-mid); }
.card-l-stat i { color: var(--brand); }

.card-l-cta {
  display: flex; flex-direction: column;
  justify-content: center; align-items: center;
  gap: .6rem; padding: 1.25rem 1.5rem;
  border-left: 1px solid var(--border-soft);
  min-width: 140px;
}
.btn-view-prop {
  padding: .65rem 1.2rem;
  background: var(--ink); color: #fff;
  border: none; border-radius: 8px;
  font-size: .85rem; font-weight: 600;
  cursor: pointer; white-space: nowrap;
  transition: background .2s;
  text-decoration: none; display: inline-block; text-align: center;
}
.btn-view-prop:hover { background: var(--brand); }
.card-l-dom { font-size: .75rem; color: #bbb; text-align: center; }

/* ── Empty state ── */
.empty-state { grid-column: 1/-1; text-align: center; padding: 5rem 2rem; color: var(--ink-mid); }
.empty-state i { font-size: 4rem; color: var(--border-soft); display: block; margin-bottom: 1rem; }
.empty-state h3 { font-size: 1.3rem; margin-bottom: .5rem; color: var(--ink); }
.empty-state p { color: #aaa; }

/* ── Pagination ── */
.pagination {
  display: flex; align-items: center; justify-content: center;
  gap: .5rem; margin-top: 2.5rem; flex-wrap: wrap;
}
.page-btn {
  width: 38px; height: 38px;
  border: 1.5px solid var(--border-soft);
  border-radius: 8px; background: #fff;
  color: var(--ink-mid); font-size: .88rem;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  transition: all .18s; text-decoration: none;
}
.page-btn:hover { border-color: var(--brand); color: var(--brand); }
.page-btn.active { background: var(--brand); border-color: var(--brand); color: #fff; font-weight: 700; }
.page-btn[disabled] { opacity: .3; pointer-events: none; }

/* ── Mobile sidebar overlay ── */
.sidebar-overlay {
  display: none; position: fixed; inset: 0;
  background: rgba(26,26,46,.45); z-index: 200;
  backdrop-filter: blur(2px);
}
.sidebar-overlay.open { display: block; }

/* ── Responsive ── */
@media (max-width: 960px) {
  .listings-body { grid-template-columns: 1fr; padding-top: 1rem; }
  .listings-sidebar {
    position: fixed; left: 0; top: 0; bottom: 0;
    width: 300px; z-index: 1300;
    border-radius: 0 16px 16px 0;
    transform: translateX(-105%);
    transition: transform .3s cubic-bezier(.4,0,.2,1);
    max-height: 100vh;
  }
  .listings-sidebar.open { transform: translateX(0); }
  .btn-filter-toggle-mobile { display: flex; }
}
@media (max-width: 640px) {
  .prop-card-l { grid-template-columns: 1fr; }
  .card-l-img  { height: 180px; }
  .card-l-cta  { flex-direction: row; border-left: none; border-top: 1px solid var(--border-soft); justify-content: space-between; }
  .prop-grid   { grid-template-columns: 1fr; }
  .sidebar-sort-row { flex-direction: column; }
}