/* =========================================================================
   Viviendas — componentes públicos
   Colores ajustables desde el tema con --viv-navy / --viv-orange.
   ========================================================================= */
.viv-search, .viv-card, .viv-filters, .viv-contact, .viv-gallery, .viv-order {
  --vn: var(--viv-navy, #0c2b5e);
  --vo: var(--viv-orange, #ff5a1f);
  --vi: var(--viv-ink, #14213d);
  --vm: var(--viv-muted, #5b6475);
  --vl: var(--viv-line, #e4e8ef);
  box-sizing: border-box;
}
.viv-search *, .viv-card *, .viv-filters *, .viv-contact *, .viv-gallery * { box-sizing: border-box; }

.viv-ico { width: 20px; height: 20px; flex: none; fill: none; stroke: currentColor; stroke-width: 1.8; stroke-linecap: round; stroke-linejoin: round; display: block; }
.viv-ico-fill { width: 22px; height: 22px; fill: currentColor; display: block; }

/* Botones */
.viv-btn { display: inline-flex; align-items: center; justify-content: center; gap: 9px; height: 46px; padding: 0 22px; border: 1.5px solid transparent; border-radius: 8px; font: 600 15px/1 inherit; font-family: inherit; cursor: pointer; text-decoration: none; transition: background .2s, transform .1s; }
.viv-btn-orange { background: var(--vo, #ff5a1f); color: #fff; }
.viv-btn-orange:hover { background: #e94c12; color: #fff; }
.viv-btn:active { transform: translateY(1px); }
.viv-btn[disabled] { opacity: .7; cursor: wait; }
.viv-block { width: 100%; }

/* ---------- Buscador ---------- */
.viv-search { position: relative; }
.viv-tabs { display: inline-flex; gap: 6px; background: #fff; padding: 12px 12px 0; border-radius: 12px 12px 0 0; }
.viv-tab { position: relative; cursor: pointer; }
.viv-tab input { position: absolute; opacity: 0; pointer-events: none; }
.viv-tab span { display: flex; align-items: center; height: 38px; padding: 0 24px; border-radius: 6px; font-size: 14px; font-weight: 600; color: var(--vi); transition: background .2s; }
.viv-tab:hover span { background: #f2f4f8; }
.viv-tab input:checked + span { background: var(--vo); color: #fff; }
.viv-tab input:focus-visible + span { outline: 2px solid var(--vn); outline-offset: 2px; }
.viv-search-box { background: #fff; border-radius: 12px; padding: 14px; display: grid; grid-template-columns: 1fr 1fr 1fr 182px; gap: 14px; box-shadow: 0 18px 40px rgba(12, 35, 80, .16); }
.viv-tabs + .viv-search-box { border-top-left-radius: 0; }

.viv-field { position: relative; display: flex; align-items: center; gap: 14px; border: 1px solid var(--vl); border-radius: 8px; height: 58px; padding: 0 16px; cursor: pointer; background: #fff; color: var(--vi); }
.viv-field:focus-within { border-color: var(--vo); box-shadow: 0 0 0 3px rgba(255, 90, 31, .12); }
.viv-field > .viv-ico { width: 22px; height: 22px; }
.viv-field-txt { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.viv-field-txt b { font-size: 13px; font-weight: 600; line-height: 1.2; }
.viv-field select { appearance: none; -webkit-appearance: none; border: 0; background: transparent; padding: 0 22px 0 0; margin: 3px 0 0; font: 400 13px/1.2 inherit; font-family: inherit; color: var(--vm); width: 100%; cursor: pointer; outline: none; text-overflow: ellipsis; position: relative; z-index: 1; }
.viv-field .viv-chev { position: absolute; right: 14px; width: 18px; height: 18px; pointer-events: none; }
.viv-search-btn { height: 58px; font-size: 17px; }
.viv-search-btn .viv-ico { width: 21px; height: 21px; }

/* ---------- Tarjetas ---------- */
.viv-cards { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: 22px; }
.viv-card { position: relative; background: #fff; border: 1px solid #eef0f4; border-radius: 10px; overflow: hidden; box-shadow: 0 4px 18px rgba(12, 35, 80, .10); transition: box-shadow .2s, transform .2s; color: var(--vi); }
.viv-card:hover { box-shadow: 0 10px 28px rgba(12, 35, 80, .16); transform: translateY(-2px); }
.viv-card-img { position: relative; display: block; aspect-ratio: 331 / 146; background: #e9edf3; overflow: hidden; }
.viv-card-img img { width: 100%; height: 100%; object-fit: cover; display: block; transition: transform .4s; }
.viv-card:hover .viv-card-img img { transform: scale(1.03); }
.viv-noimg { display: grid; place-items: center; width: 100%; height: 100%; color: #b3bccb; }
.viv-noimg .viv-ico { width: 48px; height: 48px; }
.viv-badge { position: absolute; top: 10px; left: 10px; z-index: 2; height: 30px; padding: 0 14px; display: inline-flex; align-items: center; border-radius: 6px; color: #fff; font-size: 13.5px; font-weight: 600; }
.viv-badge-orange { background: var(--vo, #ff5a1f); }
.viv-badge-dark { background: #2b3442; }
.viv-badge-sold { background: #6b7280; letter-spacing: .3px; }
.viv-card.is-sold .viv-card-img img { filter: grayscale(.55); opacity: .9; }
.viv-card.is-sold .viv-price { color: #6b7280; }
.viv-fav { position: absolute; top: 10px; right: 10px; z-index: 3; width: 36px; height: 36px; border: 0; border-radius: 7px; background: #fff; color: var(--vi, #14213d); display: grid; place-items: center; cursor: pointer; padding: 0; }
.viv-fav .viv-ico { width: 20px; height: 20px; }
.viv-fav[aria-pressed="true"] { color: var(--vo, #ff5a1f); }
.viv-fav[aria-pressed="true"] .viv-ico { fill: currentColor; }
.viv-card-body { position: relative; padding: 14px 18px 16px; }
.viv-card-title { margin: 0; font-size: 17px; font-weight: 600; line-height: 1.3; font-family: inherit; }
.viv-card-title a { color: inherit; text-decoration: none; }
.viv-card-title a::after { content: ""; position: absolute; inset: 0; z-index: 1; } /* toda la tarjeta es clicable */
.viv-price { font-size: 24px; font-weight: 700; margin: 6px 0 10px; color: var(--vi); }
.viv-specs { display: flex; flex-wrap: wrap; gap: 8px 26px; font-size: 14px; color: #333c4d; }
.viv-specs span { display: inline-flex; align-items: center; gap: 8px; }
.viv-specs .viv-ico, .viv-loc .viv-ico { width: 17px; height: 17px; }
.viv-loc { display: flex; align-items: center; gap: 8px; font-size: 14px; color: #333c4d; margin-top: 12px; padding-right: 30px; }
.viv-go { position: absolute; right: 16px; bottom: 16px; color: var(--vo); z-index: 2; }
.viv-go .viv-ico { width: 22px; height: 22px; stroke-width: 2.4; }

/* Tarjeta horizontal (listado) */
.viv-card-list { display: grid; grid-template-columns: 240px minmax(0, 1fr); }
.viv-card-list .viv-card-img { aspect-ratio: auto; height: 100%; min-height: 170px; }
.viv-card-list .viv-fav { left: auto; right: 12px; top: 12px; }
.viv-card-list .viv-card-body { padding: 16px 20px; }
.viv-card-list .viv-badge { top: 10px; left: 10px; }

/* ---------- Filtros del listado ---------- */
.viv-filters { background: #fff; border: 1px solid var(--vl); border-radius: 10px; padding: 18px; font-size: 14px; color: var(--vi); }
.viv-filters-title { display: flex; align-items: center; gap: 8px; font-weight: 700; font-size: 16px; margin-bottom: 8px; }
.viv-filters fieldset { border: 0; border-top: 1px solid var(--vl); padding: 14px 0 6px; margin: 8px 0 0; }
.viv-filters legend { font-weight: 600; padding: 0; margin-bottom: 10px; float: left; width: 100%; }
.viv-check { display: flex; align-items: center; gap: 8px; margin: 6px 0; cursor: pointer; clear: both; }
.viv-check input { accent-color: var(--vo); width: 16px; height: 16px; margin: 0; }
.viv-check span { color: var(--vm); }
.viv-range { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; clear: both; }
.viv-range input, .viv-contact input[type=text], .viv-contact input[type=email], .viv-contact input[type=tel], .viv-contact textarea {
  width: 100%; height: 40px; border: 1px solid var(--vl); border-radius: 7px; padding: 0 12px; font: inherit; font-size: 14px; color: var(--vi); background: #fff; }
.viv-range input:focus, .viv-contact input:focus, .viv-contact textarea:focus { outline: none; border-color: var(--vo); box-shadow: 0 0 0 3px rgba(255, 90, 31, .12); }
.viv-pills { display: flex; gap: 8px; clear: both; }
.viv-pill { cursor: pointer; }
.viv-pill input { position: absolute; opacity: 0; pointer-events: none; }
.viv-pill span { display: grid; place-items: center; width: 42px; height: 36px; border: 1px solid var(--vl); border-radius: 7px; font-weight: 600; }
.viv-pill input:checked + span { background: var(--vo); border-color: var(--vo); color: #fff; }
.viv-pill input:focus-visible + span { outline: 2px solid var(--vn); outline-offset: 2px; }
.viv-filters .viv-btn { margin-top: 18px; }
.viv-clear { display: block; text-align: center; margin-top: 12px; color: var(--vm); font-size: 13px; }

.viv-order { font-size: 14px; color: var(--vm); }
.viv-order select { margin-left: 6px; height: 38px; border: 1px solid var(--vl); border-radius: 7px; padding: 0 10px; font: inherit; color: var(--vi); background: #fff; }

/* ---------- Galería de la ficha ---------- */
.viv-gallery-main { position: relative; border-radius: 10px; overflow: hidden; background: #e9edf3; aspect-ratio: 14 / 8.6; }
.viv-gallery-main img { width: 100%; height: 100%; object-fit: cover; display: block; }
.viv-gallery-main .viv-badge { top: 14px; left: 14px; }
.viv-gallery-main .viv-fav { top: 14px; right: 14px; }
.viv-gallery-count { position: absolute; right: 14px; bottom: 14px; background: rgba(12, 22, 40, .7); color: #fff; font-size: 13px; padding: 5px 10px; border-radius: 6px; }
.viv-gallery-thumbs { display: grid; grid-template-columns: repeat(5, 1fr); gap: 10px; margin-top: 10px; }
.viv-gallery-thumbs button { padding: 0; border: 2px solid transparent; border-radius: 7px; overflow: hidden; cursor: pointer; background: none; aspect-ratio: 26 / 17; }
.viv-gallery-thumbs button.is-active { border-color: var(--vo); }
.viv-gallery-thumbs img { width: 100%; height: 100%; object-fit: cover; display: block; }

/* ---------- Formulario de contacto ---------- */
.viv-contact { display: grid; gap: 10px; color: var(--vi); }
.viv-contact-title { margin: 0 0 4px; font-size: 16px; font-weight: 700; font-family: inherit; }
.viv-contact .viv-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }
.viv-contact textarea { height: auto; padding: 10px 12px; resize: vertical; min-height: 96px; }
.viv-contact .viv-privacy { font-size: 12.5px; align-items: flex-start; }
.viv-contact .viv-privacy span { color: var(--vm); }
.viv-contact .viv-privacy a { color: var(--vn); }
.viv-contact-msg { padding: 10px 12px; border-radius: 7px; font-size: 14px; }
.viv-contact-msg[data-state="ok"] { background: #e8f6ec; color: #17642f; }
.viv-contact-msg:not([data-state="ok"]) { background: #fdeceb; color: #a1261c; }
.viv-hp { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; overflow: hidden; }

/* ---------- Responsive ---------- */
@media (max-width: 960px) {
  .viv-search-box { grid-template-columns: 1fr 1fr; }
  .viv-cards { grid-template-columns: repeat(2, minmax(0, 1fr)); }
}
@media (max-width: 760px) {
  .viv-has-tabs { background: #fff; border-radius: 12px; padding: 10px; box-shadow: 0 14px 30px rgba(12, 35, 80, .18); }
  .viv-search .viv-tabs { display: grid; grid-template-columns: repeat(3, 1fr); width: 100%; padding: 0 0 10px; background: transparent; }
  .viv-search .viv-tab span { justify-content: center; height: 36px; padding: 0; font-size: 13px; background: #f1f3f7; }
  .viv-search-box { grid-template-columns: 1fr; gap: 8px; }
  .viv-tabs + .viv-search-box { padding: 0; box-shadow: none; border-radius: 0; }
  .viv-field { height: 52px; }
  .viv-search-btn { height: 50px; }
  .viv-cards { grid-template-columns: 1fr; gap: 14px; }
  .viv-card-list { grid-template-columns: 1fr; }
  .viv-card-list .viv-card-img { aspect-ratio: 331 / 146; min-height: 0; }
  .viv-contact .viv-row { grid-template-columns: 1fr; }
  .viv-gallery-thumbs { grid-template-columns: repeat(4, 1fr); }
}
