/* =============================================================
   KS Immobile Single Template — ks-imm.css
   Versione: 1.7.7  |  Refactored & Fixed
   Autore:   Keyspace
   ============================================================= */

/* ─────────────────────────────────────────────────────────────
   1. VARIABILI & RESET DI BASE
   ───────────────────────────────────────────────────────────── */

:root {
  --ks-color-primary:   #1A2A4F;
  --ks-color-blue:      #0b3aa2;
  --ks-color-text:      #111;
  --ks-color-muted:     #475467;
  --ks-color-border:    rgba(0,0,0,.08);
  --ks-color-bg:        #fff;
  --ks-color-bg-light:  rgba(0,0,0,.02);
  --ks-radius-sm:       12px;
  --ks-radius-md:       14px;
  --ks-radius-lg:       16px;
  --ks-radius-xl:       18px;
  --ks-radius-pill:     999px;
}

/* Utility: nasconde elementi */
body.ks-imm-template .hidden { display: none !important; }

/* ─────────────────────────────────────────────────────────────
   2. LAYOUT PAGINA (Salient overrides)
   ───────────────────────────────────────────────────────────── */

/* Desktop: max-width del #primary */
@media (min-width: 1450px) {
  #primary {
    max-width: 1450px !important;
    width: 100%;
    margin: 0 auto;
    padding: 0 45px;
  }
}

@media (min-width: 1000px) and (max-width: 1449px) {
  #primary {
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 0 45px;
  }
}

@media (max-width: 450px){
  #primary, body input[type=text] {
  text-align: center;
  }

  body.ks-imm-template .ks-imm-tags__list {
    justify-content: center;
}
}

/* Desktop: sfondo e larghezza main-content */
@media (min-width: 1000px) {
  body.ks-imm-template .container-wrap {
    background-color: #FAF7F3 !important;
  }
  body.ks-imm-template .main-content {
    max-width: 1200px !important;
    padding: 0 75px !important;
    background-color: #fdfcf9;
  }
}

/* Breadcrumb: nasconde se il tema lo stampa */
body.ks-imm-template .woocommerce-breadcrumb,
body.ks-imm-template .breadcrumbs,
body.ks-imm-template .breadcrumb {
  display: none !important;
  margin: 0 !important;
  font-size: 0 !important;
}

/* ─────────────────────────────────────────────────────────────
   3. ROOT & SEZIONI PRINCIPALI
   ───────────────────────────────────────────────────────────── */

body.ks-imm-template .ks-imm-top,
body.ks-imm-template .ks-imm-summary {
  width: 100% !important;
}

.ks-imm-top    { margin: 0; }
.ks-imm-summary { margin: 1em 0; }

/* CTA esterna scroll */
body .nectar-cta.ks-scroll-lead { margin: 40px 0 !important; }

/* ─────────────────────────────────────────────────────────────
   4. GRIGLIA SUMMARY (2 colonne → 1 colonna su mobile)
   ───────────────────────────────────────────────────────────── */

.ks-imm-summary__grid {
  display: grid;
  grid-template-columns: 1.6fr .9fr;
  gap: 18px;
  align-items: start;
}

/* PUNTO CRITICO: breakpoint unificato a 1000px */
@media (max-width: 1000px) {
  .ks-imm-summary__grid {
    grid-template-columns: 1fr;
  }
  body.ks-imm-template .ks-imm-summary {
    margin: 1em 0 !important;
    padding: 0 1em;
    /* rimosso text-align:center che rompeva il layout */
  }
}

/* Colonna sinistra */
.ks-imm-left {
  background: var(--ks-color-bg);
  border: 1px solid var(--ks-color-border);
  border-radius: var(--ks-radius-lg);
  padding: 18px !important;
  min-width: 0; /* evita overflow in grid */
}

.single-immobile .ks-imm-left section { margin: 2.5em 1em; }
.single-immobile .ks-imm-head { margin: 1em; }

/* Colonna destra */
.ks-imm-right {
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0; /* evita overflow in grid */
}

.ks-imm-right > * {
  background: var(--ks-color-bg);
  border: 1px solid var(--ks-color-border);
  border-radius: var(--ks-radius-lg);
  padding: 18px;
}

/* .card nella sidebar ha stili propri */
.ks-imm-right .card {
  border: 1px solid var(--ks-color-border);
  border-radius: var(--ks-radius-md);
  background: var(--ks-color-bg);
  padding: 16px;
  margin: 0;
}

/* ─────────────────────────────────────────────────────────────
   5. HEADER IMMOBILE (titolo, prezzo, badge)
   ───────────────────────────────────────────────────────────── */

.ks-imm-title {
  margin: 0 0 6px 0;
  line-height: 1.15;
}

@media (min-width: 1000px) {
  body.ks-imm-template .ks-imm-title {
    font-size: 1.2em !important;
    line-height: 1.1 !important;
  }
}

@media (max-width: 999px) {
  body.ks-imm-template .ks-imm-title {
    font-size: 18px !important;
    line-height: 1.1 !important;
  }
}

/* Prezzo */
.ks-imm-price {
  font-size: 22px;
  font-weight: 600;
  color: var(--ks-color-blue);
}

@media (min-width: 1000px) {
  body.ks-imm-template .ks-imm-price {
    font-size: 1.1em !important;
  }
}

@media (max-width: 999px) {
  body.ks-imm-template .ks-imm-price {
    font-size: 1em !important;
  }
}

/* Riga prezzo + badge */
.ks-imm-head__top {
  display: grid;
  grid-template-columns: 1fr auto;
  align-items: center;
  gap: 14px;
}

@media (max-width: 520px) {
  .ks-imm-head__top { gap: 8px; }
}

.ks-imm-head__badges {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  flex-wrap: nowrap;
  white-space: nowrap;
}

/* Badge disponibilità */
.ks-imm-availability {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0 10px 0;
  padding: 6px 10px;
  border: 1px solid var(--ks-color-border);
  border-radius: var(--ks-radius-pill);
  background: var(--ks-color-bg);
  font-weight: 800;
  font-size: .85rem;
  text-transform: capitalize;
}

.ks-imm-availability__dot {
  width: 10px;
  height: 10px;
  border-radius: var(--ks-radius-pill);
  display: inline-block;
}

/* Pill contratto */
.ks-imm-contract-pill {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  margin: 8px 0 10px 0;
  padding: 6px 10px;
  border: 1px solid var(--ks-color-border);
  border-radius: var(--ks-radius-pill);
  background: var(--ks-color-bg);
  font-weight: 800;
  font-size: .85rem;
  text-transform: capitalize;
}

.ks-imm-contract-pill__ico {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: .9;
}

.ks-imm-contract-pill__ico svg {
  width: 18px;
  height: 18px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

/* Testo complementare header */
.ks-imm-sub      { color: var(--ks-color-muted); font-size: 14px; margin: 0 0 10px 0; }
.ks-imm-contract { font-size: 12px; color: var(--ks-color-muted); margin: 0 0 4px 0; }
.ks-imm-brief    { margin: 14px 0 0 0; color: var(--ks-color-text); }
.ks-imm-section  { margin: 18px 0 0 0; }
.ks-imm-section h2 { margin: 0 0 10px 0; font-size: 1.1em; }

/* Descrizione breve */
.ks-imm-shortdesc { margin: 10px 0; opacity: .9; }
.ks-imm-shortdesc p { margin: 0; padding: 0; }

/* ─────────────────────────────────────────────────────────────
   6. SCARCITY BADGE
   ───────────────────────────────────────────────────────────── */

body.ks-imm-template .ks-imm-scarcity {
  position: absolute;
  right: 14px;
  bottom: 10px;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  border-radius: var(--ks-radius-pill);
  background: rgba(255,255,255,.92);
  backdrop-filter: saturate(1.2) blur(2px);
  border: 1px solid var(--ks-color-border);
  font-size: 14px;
  font-weight: 800;
  color: inherit;
  user-select: none;
  pointer-events: none;
}

body.ks-imm-template .ks-imm-scarcity[hidden] { display: none !important; }

/* ─────────────────────────────────────────────────────────────
   7. KPI ROW (sotto prezzo)
   ───────────────────────────────────────────────────────────── */

body.ks-imm-template .ks-imm-kpi { margin: 10px 0 6px 0; }

body.ks-imm-template .ks-imm-kpi__row {
  display: grid;
  grid-template-columns: repeat(6, minmax(0, 1fr));
  gap: 10px;
  align-items: stretch;
}

body.ks-imm-template .ks-imm-kpi__item {
  display: grid;
  grid-template-columns: 22px 1fr;
  grid-template-rows: auto auto;
  column-gap: 10px;
  row-gap: 2px;
  align-items: center;
  padding: 10px 12px;
  border-radius: var(--ks-radius-md);
  border: 1px solid var(--ks-color-border);
  background: var(--ks-color-bg-light);
}

body.ks-imm-template .ks-imm-kpi__ico {
  grid-column: 1;
  grid-row: 1 / span 2;
  width: 22px;
  height: 22px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  opacity: .9;
}

body.ks-imm-template .ks-imm-kpi__ico svg {
  width: 22px;
  height: 22px;
  display: block;
  fill: none;
  stroke: currentColor;
  stroke-width: 2;
  stroke-linecap: round;
  stroke-linejoin: round;
}

body.ks-imm-template .ks-imm-kpi__val {
  grid-column: 2;
  grid-row: 1;
  font-weight: 900;
  font-size: 14px;
  line-height: 1.1;
  color: inherit;
}

body.ks-imm-template .ks-imm-kpi__lab {
  grid-column: 2;
  grid-row: 2;
  font-weight: 800;
  font-size: 12px;
  line-height: 1.1;
  color: var(--ks-color-muted);
}

/* Anche il vecchio helper "kpis" (inline legacy) */
.ks-imm-kpis { display: flex; flex-wrap: wrap; gap: 8px 10px; font-size: 13px; color: var(--ks-color-muted); }
.ks-imm-kpis span { background: rgba(0,0,0,.04); border-radius: var(--ks-radius-pill); padding: 6px 10px; }

/* KPI responsive */
@media (max-width: 1024px) {
  body.ks-imm-template .ks-imm-kpi__row { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (max-width: 820px) {
  body.ks-imm-template .ks-imm-kpi__row { grid-template-columns: repeat(3, minmax(0, 1fr)); }
}
@media (max-width: 520px) {
  body.ks-imm-template .ks-imm-kpi__row { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  body.ks-imm-template .ks-imm-kpi__item { padding: 10px; border-radius: var(--ks-radius-sm); }
}

/* ─────────────────────────────────────────────────────────────
   8. TAGS / PILLS (Highlights + Dotazioni)
   ───────────────────────────────────────────────────────────── */

body.ks-imm-template .ks-imm-tags__inner  { display: flex; flex-direction: column; gap: 10px; }
body.ks-imm-template .ks-imm-tags__block  { display: flex; flex-direction: column; gap: 8px; }
body.ks-imm-template .ks-imm-tags__title  { font-size: 15px; font-weight: 700; letter-spacing: .2px; color: inherit; }
body.ks-imm-template .ks-imm-tags__list   { display: flex; flex-wrap: wrap; gap: 8px; }

body.ks-imm-template .ks-imm-tag {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  font-weight: 600;
  padding: 8px 12px;
  border-radius: var(--ks-radius-pill);
  border: 1px solid rgba(0,0,0,.10);
  background: rgba(0,0,0,.03);
  color: inherit;
  font-size: 14px;
  line-height: 1;
  user-select: none;
  -webkit-tap-highlight-color: transparent;
}

@media (hover: hover) {
  body.ks-imm-template .ks-imm-tag:hover {
    background: rgba(0,0,0,.05);
    border-color: rgba(0,0,0,.16);
  }
}

/* ─────────────────────────────────────────────────────────────
   9. GRIGLIA ACF (Caratteristiche / Energetiche / Superfici)
   ───────────────────────────────────────────────────────────── */

/* Titoli sezioni */
body.ks-imm-template .ks-imm-section--principali > h2,
body.ks-imm-template .ks-imm-section--energetiche > h2,
body.ks-imm-template .ks-imm-section--superfici > h2 {
  margin: 0 0 10px 0;
  color: inherit;
}

body.ks-imm-template .ks-imm-section--principali .ks-imm-acf-grid,
body.ks-imm-template .ks-imm-section--energetiche .ks-imm-acf-grid,
body.ks-imm-template .ks-imm-section--superfici .ks-imm-acf-grid {
  margin-top: 10px;
}

/* Grid ACF */
.ks-imm-acf-grid {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px 16px;
  margin-top: 10px;
}

/* Singola cella */
.ks-imm-acf-item {
  padding: 10px 12px;
  border: 1px solid var(--ks-color-border);
  border-radius: var(--ks-radius-sm);
  background: var(--ks-color-bg);
}

body.ks-imm-template .ks-imm-acf-item {
  border-radius: var(--ks-radius-md);
  border: 1px solid rgba(0,0,0,.08);
  background: var(--ks-color-bg);
  padding: 11px 12px;
}

.ks-imm-acf-label {
  font-weight: 800;
  font-size: .92rem;
  opacity: .9;
  letter-spacing: .2px;
  color: inherit;
}

.ks-imm-acf-value {
  margin-top: 3px;
  font-size: .95rem;
  opacity: .9;
  text-transform: capitalize;
  color: var(--ks-color-muted);
  font-weight: 500;
}

/* Responsive */
@media (max-width: 1000px) { .ks-imm-acf-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); } }
@media (max-width: 520px)  { .ks-imm-acf-grid { grid-template-columns: 1fr; } }

/* ─────────────────────────────────────────────────────────────
   10. DOCUMENTI / LINK
   ───────────────────────────────────────────────────────────── */

.ks-imm-docs { display: flex; gap: 10px; flex-wrap: wrap; }
.ks-imm-doc {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 10px 12px;
  border-radius: var(--ks-radius-sm);
  border: 1px solid rgba(0,0,0,.10);
  text-decoration: none;
  font-weight: 700;
  color: var(--ks-color-text);
}

/* ─────────────────────────────────────────────────────────────
   11. MAPPA
   ───────────────────────────────────────────────────────────── */

.ks-imm-map { width: 100%; height: 360px; border-radius: var(--ks-radius-md); background: rgba(0,0,0,.04); }

.ks-imm-map-embed {
  border-radius: var(--ks-radius-md);
  overflow: hidden;
  border: 1px solid var(--ks-color-border);
  background: var(--ks-color-bg);
}
.ks-imm-map-embed iframe {
  width: 100%;
  height: 360px;
  border: 0;
  display: block;
}

/* ─────────────────────────────────────────────────────────────
   12. PLANIMETRIA
   ───────────────────────────────────────────────────────────── */

.ks-imm-plan.card { padding: 16px; margin-top: 14px; }

.ks-imm-plan__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  margin-bottom: 8px;
}

.ks-imm-plan__title { font-weight: 700; font-size: 16px; }

.ks-imm-plan__dl {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 8px 10px;
  border-radius: var(--ks-radius-sm);
  border: 1px solid rgba(0,0,0,.10);
  text-decoration: none;
  font-weight: 800;
  color: var(--ks-color-text);
}

.ks-imm-plan__desc {
  color: var(--ks-color-muted);
  line-height: 1.35;
  margin-bottom: 10px;
  font-size: .95rem;
}

/* Anteprima planimetria (unica definizione, era duplicata) */
.ks-imm-plan__preview {
  position: relative;
  display: block;
  text-decoration: none;
  border-radius: var(--ks-radius-md);
  overflow: hidden;
  border: 1px solid rgba(0,0,0,.08);
  background: rgba(0,0,0,.02);
}

.ks-imm-plan__img {
  width: 100%;
  height: 500px;
  object-fit: cover;
  display: block;
  background: rgba(0,0,0,.03);
}

@media (max-width: 520px) { .ks-imm-plan__img { height: 200px; } }

/* Shimmer attesa */
.ks-imm-plan__img[src^="data:image/gif"] {
  background: linear-gradient(90deg, rgba(0,0,0,.03), rgba(0,0,0,.06), rgba(0,0,0,.03));
  background-size: 200% 100%;
  animation: ksPlanShimmer 1.2s linear infinite;
}

@keyframes ksPlanShimmer {
  0%   { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.ks-imm-plan__file {
  display: flex;
  gap: 12px;
  align-items: center;
  padding: 14px;
}

.ks-imm-plan__fileIcon {
  width: 44px;
  height: 44px;
  border-radius: var(--ks-radius-md);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 1px solid rgba(0,0,0,.10);
  background: var(--ks-color-bg);
  color: var(--ks-color-primary);
}

.ks-imm-plan__fileName { font-weight: 900; color: var(--ks-color-text); }
.ks-imm-plan__fileHint { opacity: .8; font-size: .92rem; margin-top: 2px; color: var(--ks-color-muted); }

/* ─────────────────────────────────────────────────────────────
   13. GALLERY — GRIGLIA DESKTOP
   ───────────────────────────────────────────────────────────── */

.ks-gallery { position: relative; margin: 0; }
.ks-gallery * { box-sizing: border-box; }

/* Padding legacy slider (compat) */
body.ks-imm-template .ks-imm-gallery .ks-imm-gallery__track { padding-left: 25px !important; }

/* Desktop ≥ 1001px: griglia 4 colonne */
@media (min-width: 1001px) {
  body.ks-imm-template .ks-gallery__grid {
    display: grid !important;
    grid-template-columns: repeat(4, 1fr);
    grid-template-rows: repeat(2, 1fr);
    gap: .75rem;
    border-radius: var(--ks-radius-xl);
    overflow: hidden;
    background: #f6f6f6;
    margin: 0 auto;
    height: 400px;
    max-height: 600px;
  }
}

/* Su schermi molto larghi: altezza maggiore */
@media (min-width: 2001px) {
  body.ks-imm-template .ks-gallery__grid { height: 600px; }
}

/* Celle */
@media (min-width: 1001px) {
  body.ks-imm-template .ks-gallery__cell { position: relative; overflow: hidden; }
  body.ks-imm-template .ks-gallery__cell a {
    display: block;
    width: 100%;
    height: 100%;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
  }
  body.ks-imm-template .ks-gallery__img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: center;
    display: block;
    transform: translateZ(0);
  }
  /* Hero: 2 colonne × 2 righe (layout normale con thumbs) */
  body.ks-imm-template .ks-gallery__cell--hero {
    grid-column: 1 / span 2;
    grid-row: 1 / span 2;
    min-height: 0;
  }

  body.ks-imm-template .ks-gallery__cell--thumb { min-height: 0; }

  /*
   * Layout intermedi (1–4 foto)
   * La griglia base è sempre 4 col × 2 righe.
   * In base al numero di foto mostriamo colonne diverse.
   *
   *  n1 → 1 col (full width)
   *  n2 → 2 col: hero (span2 sx) + 1 thumb (span2 dx, full height)
   *  n3 → 3 col: hero (span2 sx) + 2 thumbs in colonna destra (1 per riga)
   *  n4 → 4 col: hero (span2 sx) + 3 thumbs: 2 in col3 + 1 grande in col4
   *  5+ → 4 col: layout completo (regole base, nessun modificatore)
   */

  /* ── n1: foto singola ── */
  body.ks-imm-template .ks-gallery--n1 .ks-gallery__grid {
    grid-template-columns: 1fr;
  }
  body.ks-imm-template .ks-gallery--n1 .ks-gallery__cell--hero {
    grid-column: 1 / -1;
    grid-row: 1 / -1;
  }

  /* ── n2: 2 foto ── */
  body.ks-imm-template .ks-gallery--n2 .ks-gallery__grid {
    grid-template-columns: 1fr 1fr;
  }
  body.ks-imm-template .ks-gallery--n2 .ks-gallery__cell--hero {
    grid-column: 1;
    grid-row: 1 / -1;
  }
  body.ks-imm-template .ks-gallery--n2 .ks-gallery__cell--thumb:nth-of-type(2) {
    grid-column: 2;
    grid-row: 1 / -1;
  }

  /* ── n3: 3 foto ── */
  body.ks-imm-template .ks-gallery--n3 .ks-gallery__grid {
    grid-template-columns: 1fr 1fr;
  }
  body.ks-imm-template .ks-gallery--n3 .ks-gallery__cell--hero {
    grid-column: 1;
    grid-row: 1 / -1;
  }
  body.ks-imm-template .ks-gallery--n3 .ks-gallery__cell--thumb {
    grid-column: 2;
  }

  /* ── n4: 4 foto ── */
  body.ks-imm-template .ks-gallery--n4 .ks-gallery__grid {
    grid-template-columns: repeat(3, 1fr);
  }
  body.ks-imm-template .ks-gallery--n4 .ks-gallery__cell--hero {
    grid-column: 1 / span 2;
    grid-row: 1 / -1;
  }
  body.ks-imm-template .ks-gallery--n4 .ks-gallery__cell--thumb:nth-of-type(2) {
    grid-column: 3;
    grid-row: 1;
  }
  body.ks-imm-template .ks-gallery--n4 .ks-gallery__cell--thumb:nth-of-type(3) {
    grid-column: 3;
    grid-row: 2;
  }
  body.ks-imm-template .ks-gallery--n4 .ks-gallery__cell--thumb:nth-of-type(4) {
    display: none;
  }

  /* Nascondi swipe su desktop */
  body.ks-imm-template .ks-gallery__swipe { display: none; }
}

/* ─────────────────────────────────────────────────────────────
   14. GALLERY — BADGE FOTO (count)
   ───────────────────────────────────────────────────────────── */

body.ks-imm-template .ks-gallery__count {
  position: absolute;
  left: 14px;
  bottom: 14px;
  z-index: 5;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-radius: var(--ks-radius-pill);
  background: rgba(255,255,255,.92);
  backdrop-filter: saturate(1.2) blur(2px);
  border: 1px solid var(--ks-color-border);
  font-size: 14px;
  font-weight: 800;
  color: var(--ks-color-text);
  text-decoration: none;
  user-select: none;
}

body.ks-imm-template .ks-gallery__count svg {
  width: 18px;
  height: 18px;
  display: block;
  stroke: currentColor;
  opacity: .85;
}

body.ks-imm-template .ks-gallery__count strong { font-weight: 900; line-height: 1; }

@media (hover: hover) {
  body.ks-imm-template .ks-gallery__count:hover {
    background: var(--ks-color-bg);
    box-shadow: 0 8px 22px rgba(0,0,0,.14);
  }
}

@media (max-width: 1000px) {
  body.ks-imm-template .ks-gallery__count {
    left: 25px;
    bottom: 10px;
    padding: 9px 11px;
    font-size: 13px;
  }
  .ks-imm-top { padding-top: 3px; }
}

/* ─────────────────────────────────────────────────────────────
   15. GALLERY — OVERLAY "+N" sull'ultima thumb
   ───────────────────────────────────────────────────────────── */

body.ks-imm-template .ks-gallery__cell--thumb a { position: relative; }

body.ks-imm-template .ks-gallery__cell--hasMore .ks-gallery__img {
  filter: blur(2px);
  transform: scale(1.02);
}

body.ks-imm-template .ks-gallery__more {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgba(0,0,0,.30);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  color: #fff;
  z-index: 3;
}

body.ks-imm-template .ks-gallery__moreInner {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 12px 14px;
  border-radius: var(--ks-radius-md);
  background: rgba(0,0,0,.35);
  border: 1px solid rgba(255,255,255,.18);
  box-shadow: 0 10px 30px rgba(0,0,0,.28);
  font-weight: 900;
  font-size: 22px;
  line-height: 1;
}

body.ks-imm-template .ks-gallery__moreInner svg { display: block; stroke: currentColor; }

/* Su mobile: overlay non serve */
@media (max-width: 1000px) {
  body.ks-imm-template .ks-gallery__cell--hasMore .ks-gallery__img { filter: none; }
}

/* ─────────────────────────────────────────────────────────────
   16. GALLERY — SWIPE MOBILE
   ───────────────────────────────────────────────────────────── */

@media (max-width: 1000px) {
  body.ks-imm-template .ks-gallery__cell--hero,
  body.ks-imm-template .ks-gallery__cell--thumb { display: none !important; }

  body.ks-imm-template .ks-gallery__swipe {
    display: block;
    width: 100vw;
    overflow: hidden;
  }

  body.ks-imm-template .ks-gallery__swipeTrack {
    list-style: none;
    margin: 0;
    padding: 0 16px;
    display: flex;
    flex-wrap: nowrap;
    gap: 12px;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scroll-snap-type: x mandatory;
    scroll-snap-stop: always;
    scroll-behavior: smooth;
    scrollbar-width: none;
  }
  body.ks-imm-template .ks-gallery__swipeTrack::-webkit-scrollbar { height: 0; }

  body.ks-imm-template .ks-gallery__swipeItem {
    flex: 0 0 86%;
    scroll-snap-align: center;
    border-radius: var(--ks-radius-lg);
    overflow: hidden;
    line-height: 0;
  }

  /* Foto singola (n1): riempie tutta la larghezza senza bordi laterali */
  body.ks-imm-template .ks-gallery--n1 .ks-gallery__swipeItem {
    flex: 0 0 100%;
    border-radius: 0;
  }

  body.ks-imm-template .ks-gallery__swipeItem > a {
    display: block;
    width: 100%;
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
    line-height: 0; /* idem: nessun gap sopra/sotto l'immagine */
  }

  body.ks-imm-template .ks-gallery__swipeItem img {
    width: 100%;
    height: 56vw;
    max-height: 420px;
    object-fit: cover;
    object-position: center;
    display: block;   /* block rimuove il gap baseline inline */
    flex-shrink: 0;
    border-radius: 15px;
  }
}

@media (max-width: 520px) {
  body.ks-imm-template .ks-gallery__swipeItem { flex-basis: 92%; }
  body.ks-imm-template .ks-gallery__swipeItem img { height: 62vw; max-height: 380px; }
}

/* ─────────────────────────────────────────────────────────────
   17. LIGHTBOX
   ───────────────────────────────────────────────────────────── */

/* Nascosto di default */
body.ks-imm-template .ks-gallery__lightbox {
  position: fixed;
  inset: 0;
  background: rgba(2,3,41,.594);
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
  transition: opacity .18s ease, visibility .18s ease;
  z-index: 999999;
}

body.ks-imm-template .ks-gallery__lightbox[hidden] { display: none !important; }

/* Aperto via :target (fallback CSS) */
body.ks-imm-template .ks-gallery__lightbox:target {
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* Aperto via JS */
body.ks-imm-template .ks-gallery__lightbox.is-open {
  display: block !important;
  opacity: 1;
  visibility: visible;
  pointer-events: auto;
}

/* Blocca scroll pagina quando lightbox aperta */
body.ks-imm-template.ks-lb-open { overflow: hidden; }

/* Backdrop */
body.ks-imm-template .ks-gallery__lbBackdrop {
  position: absolute;
  inset: 0;
  background: rgba(2,3,41,.594);
  z-index: 1;
  pointer-events: auto;
  backdrop-filter: blur(8px);
}

/* Dialog sopra al backdrop */
body.ks-imm-template .ks-gallery__lbInner {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  padding: 18px;
}

/* Top bar (close) */
.ks-gallery__lbTop {
  margin: 3em 0 0 0;
  text-align: right;
  color: #fff;
}

a.ks-gallery__lbClose { font-size: 35px; }

.ks-gallery__lbClose,
.ks-gallery__lbCounter,
.ks-gallery__lbTitle { color: #fff; }

/* Stage */
body.ks-imm-template .ks-gallery__lbStage {
  position: relative;
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 0;
  padding: 8px 54px;
}

/* Figure */
body.ks-imm-template .ks-gallery__lbFigure {
  margin: 0;
  width: auto;
  height: auto;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 10px;
}

/* Immagine */
body.ks-imm-template .ks-gallery__lbImg {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  border-radius: var(--ks-radius-lg);
  background: rgba(255,255,255,.02);
  box-shadow: 0 20px 60px rgba(0,0,0,.35);
  user-select: none;
  -webkit-user-drag: none;
}

/* Navigazione frecce */
body.ks-imm-template .ks-gallery__lbNav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 46px;
  height: 46px;
  border-radius: var(--ks-radius-lg);
  border: 1px solid rgba(255,255,255,.14);
  background: rgba(0,0,0,.35);
  color: #fff;
  font-size: 34px;
  line-height: 1;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 5;
  -webkit-tap-highlight-color: transparent;
}

body.ks-imm-template .ks-gallery__lbNav--prev { left: 12px; }
body.ks-imm-template .ks-gallery__lbNav--next { right: 12px; }

@media (hover: hover) {
  body.ks-imm-template .ks-gallery__lbNav:hover,
  body.ks-imm-template .ks-gallery__lbClose:hover { background: rgba(0,0,0,.48); }
}

@media (max-width: 520px) {
  body.ks-imm-template .ks-gallery__lbStage { padding: 5px 30px; }
  body.ks-imm-template .ks-gallery__lbNav { width: 42px; height: 42px; border-radius: 14px; font-size: 30px; }
}

/* ─────────────────────────────────────────────────────────────
   18. LEAD FORM
   ───────────────────────────────────────────────────────────── */

.ks-imm-lead-card {
  margin: 0 0 16px 0;
  border-radius: var(--ks-radius-md);
  overflow: hidden;
  border: 1px solid rgba(0,0,0,.08);
  background: var(--ks-color-bg);
  color: var(--ks-color-primary);
}

select#ks_imm_lead_reason {
    width: fit-content !important;
}

.ks-imm-lead-field[hidden] { display: none !important; }

.ks-imm-lead-card__inner {
  padding: 22px 20px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.ks-imm-lead-card__title {
  font-weight: 800;
  font-size: 1.05rem;
  line-height: 1.15;
  margin: 0;
}

.ks-imm-lead-card__desc {
  opacity: .88;
  font-size: .95rem;
  line-height: 1.3;
  margin: 0 0 6px 0;
}

.ks-imm-lead-field { display: flex; flex-direction: column; gap: 6px; }

/* Label: nascosta (a livello visivo, c'è già sopra) */
.ks-imm-lead-label { display: none !important; }

.ks-imm-lead-input {
  width: 100% !important;
  height: 64px !important;
  border: solid !important;
  padding: 10px 12px !important;
  border-radius: 5px !important;
  border: 1px solid rgba(0,0,0,.10) !important;
  background: var(--ks-color-bg) !important;
  color: inherit !important;
  outline: none !important;
}
.ks-imm-lead-input:focus { border-color: rgba(0,0,0,.22); }

.ks-imm-lead-hint { font-size: .75rem; opacity: .7; line-height: 1.2; margin-bottom: 1em; }

.ks-imm-lead-privacy {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: .9rem;
  line-height: 1.25;
  opacity: .92;
}
.ks-imm-lead-privacy input { margin-top: 3px; }

.ks-imm-lead-submit {
  width: 100%;
  padding: 12px 14px;
  border-radius: var(--ks-radius-sm);
  border: 0;
  cursor: pointer;
  background-color: var(--ks-color-primary);
  color: #fff;
  font-weight: 800;
}

/* Specifico override padding del submit (tema) */
button.ks-imm-lead-submit { padding: 25px 0; }

.ks-imm-lead-msg       { font-size: .92rem; line-height: 1.25; }
.ks-imm-lead-msg.is-ok { opacity: .9; }
.ks-imm-lead-msg.is-err{ opacity: .9; }

.ks-imm-lead-reassurance { text-align: center; }

/* Layout 2 colonne su desktop */
@media (min-width: 1001px) {
  body.ks-imm-template .ks-imm-lead-form {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 12px;
    align-items: start;
  }
  body.ks-imm-template .ks-imm-lead-form > .ks-imm-lead-privacy,
  body.ks-imm-template .ks-imm-lead-form > .ks-imm-lead-submit,
  body.ks-imm-template .ks-imm-lead-form > .ks-imm-lead-msg,
  body.ks-imm-template .ks-imm-lead-form > [data-ks-date-wrap] { grid-column: 1 / -1; }
}

@media (max-width: 1000px) {
  .ks-imm-lead-form { display: flex; flex-direction: column; gap: 12px; margin-top: 4px; }
}

/* ─────────────────────────────────────────────────────────────
   19. LEAD FORM — HEADER CON FOTO AGENTE
   ───────────────────────────────────────────────────────────── */

.ks-imm-lead-head {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  margin-bottom: 12px;
}

.ks-imm-lead-head__photo {
  width: 65px;
  height: 65px;
  border-radius: var(--ks-radius-pill);
  object-fit: cover;
  flex: 0 0 auto;
}

.ks-imm-lead-head__copy { min-width: 0; }

.ks-imm-lead-head .ks-imm-lead-card__title { margin: 0; line-height: 1.15; }
.ks-imm-lead-head .ks-imm-lead-card__desc  { margin-top: 4px; line-height: 1.3; opacity: .9; }

.ks-imm-lead-head__photo-wrap {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  line-height: 0;
}
.ks-imm-lead-head__photo-wrap > .ks-imm-lead-head__photo { display: block; }

/* Attention badge (punto verde pulsante) */
.ks-agent-attention {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: #2ecc71;
  color: #fff;
  font-size: 13px;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 0 rgba(46,204,113,.6);
  animation: ksAgentPulse 2.2s ease-out infinite;
  will-change: transform, box-shadow;
}

@media (prefers-reduced-motion: reduce) { .ks-agent-attention { animation: none; } }

@keyframes ksAgentPulse {
  0%   { transform: scale(1);    box-shadow: 0 0 0 0 rgba(46,204,113,.55); }
  70%  { transform: scale(1.06); box-shadow: 0 0 0 10px rgba(46,204,113,0); }
  100% { transform: scale(1);    box-shadow: 0 0 0 0 rgba(46,204,113,0); }
}

/* ─────────────────────────────────────────────────────────────
   20. SIDEBAR — AGENTE, WHATSAPP, ALLEGATI
   ───────────────────────────────────────────────────────────── */

/* Agente */
.ks-imm-agent__row   { display: flex; gap: 12px; align-items: center; }
.ks-imm-agent__photo { width: 56px; height: 56px; border-radius: var(--ks-radius-md); object-fit: cover; }
.ks-imm-agent__name  { font-weight: 900; }
.ks-imm-agent__role,
.ks-imm-agent__zone  { opacity: .8; font-size: .92rem; margin: 2px 0 6px; }
.ks-imm-agent__link  { display: block; font-weight: 800; font-size: .95rem; }

/* WhatsApp CTA */
.ks-imm-wa__title { font-weight: 900; margin-bottom: 6px; }
.ks-imm-wa__desc  { opacity: .85; margin-bottom: 10px; }
.ks-imm-wa__btn {
  display: block;
  text-align: center;
  padding: 12px 14px;
  border-radius: var(--ks-radius-sm);
  background: var(--ks-color-primary);
  color: #fff;
  font-weight: 900;
  text-decoration: none;
}
.ks-imm-wa__btn:hover {
  background: var(--ks-color-primary);
  color: #fff;
}

/* WhatsApp CTA */
.ks-imm-valuta__title { font-weight: 900; margin-bottom: 6px; }
.ks-imm-valuta__desc  { opacity: .85; margin-bottom: 10px; }
.ks-imm-valuta__btn {
  display: block;
  text-align: center;
  padding: 22px 14px;
  border-radius: 5px;
  background: var(--ks-color-primary);
  color: #fff;
  font-weight: 900;
  text-decoration: none;
}
.ks-imm-valuta__btn:hover {
  background: var(--ks-color-primary);
  color: #fff;
}

/* CTA generica */
.ks-imm-cta__title { font-weight: 700; font-size: 16px; margin: 0 0 6px 0; }
.ks-imm-cta__desc  { color: var(--ks-color-muted); margin: 0 0 12px 0; line-height: 1.35; }
.ks-imm-cta__btn {
  display: inline-flex;
  width: 100%;
  align-items: center;
  justify-content: center;
  padding: 12px 14px;
  border-radius: var(--ks-radius-md);
  background: var(--ks-color-primary);
  color: #fff;
  text-decoration: none;
  font-weight: 900;
}

.ks-imm-contact-box__placeholder { color: #667085; font-size: 13px; }

/* ─────────────────────────────────────────────────────────────
   21. SMOOTH SCROLL (JS helper, nessun CSS specifico)
   ───────────────────────────────────────────────────────────── */

/* Nessuna regola CSS necessaria — gestito da ks-imm.js */
