/* selettore.css — pagina integrata del configuratore, nello stile della direzione A.
   Usa i token di css/sito-progetto.css; qui solo il layout a tutta altezza. */

body.sel-page { overflow: hidden; }
[hidden] { display: none !important; }

.app { position: fixed; inset: var(--header-h) 0 0 0; display: grid; grid-template-columns: 360px minmax(0, 1fr); background: var(--bg); }

/* Pannello sinistro */
.side { background: var(--surface); border-right: 1px solid var(--line); overflow-y: auto; padding: 24px 24px 32px; display: flex; flex-direction: column; gap: 20px; min-width: 0; }
.stats-line { display: flex; flex-wrap: wrap; gap: 6px 16px; font-size: 14px; color: var(--muted); }
.stats-line .stat { display: inline-flex; align-items: center; gap: 6px; }
.stats-line b { color: var(--ink); font-weight: 600; }
.blk { display: flex; flex-direction: column; gap: 16px; padding-top: 20px; border-top: 1px solid var(--line); }
.blk .label { margin: 0; }

/* Interruttori: input nascosto + traccia del design system */
.switch { position: relative; }
.switch input { position: absolute; opacity: 0; pointer-events: none; }
.switch input:checked + .switch__track { background: var(--ink); }
.switch input:checked + .switch__track::after { left: 19px; }
.switch input:focus-visible + .switch__track { outline: 2px solid var(--accent); outline-offset: 2px; }

/* Fascia di prezzo a due cursori (stile .range) */
.dual { position: relative; height: 26px; }
.dual .rail { position: absolute; left: 10px; right: 10px; top: 12px; height: 2px; background: var(--line); }
.dual .fill { position: absolute; top: 12px; height: 2px; background: var(--ink); }
.dual input { position: absolute; left: 0; top: 0; width: 100%; height: 26px; margin: 0; background: none; pointer-events: none; -webkit-appearance: none; appearance: none; }
.dual input::-webkit-slider-runnable-track { background: none; height: 26px; }
.dual input::-moz-range-track { background: none; }
.dual input::-webkit-slider-thumb { -webkit-appearance: none; pointer-events: auto; width: 20px; height: 20px; margin-top: 3px; border-radius: 50%; background: #fff; border: 2px solid var(--ink); cursor: pointer; }
.dual input::-moz-range-thumb { pointer-events: auto; width: 16px; height: 16px; border-radius: 50%; background: #fff; border: 2px solid var(--ink); cursor: pointer; }
.dual input:disabled::-webkit-slider-thumb { border-color: var(--control); }

/* Elenco unità */
#unitList { list-style: none; margin: 0 -10px; padding: 0; display: flex; flex-direction: column; }
.unit-row { grid-template-columns: 12px 30px minmax(0, 1fr) auto; }
.empty { margin: 0; padding: 12px 10px; font-size: 14px; color: var(--muted); }
.st--nd { background: var(--control); border: 1px solid var(--muted); }

/* Visore */
.viewer { position: relative; min-width: 0; overflow: hidden; background: #c9d6df; user-select: none; -webkit-user-select: none; }
.blur { position: absolute; inset: 0; width: 100%; height: 100%; object-fit: cover; filter: blur(22px) saturate(1.1); transform: scale(1.15); opacity: .9; pointer-events: none; }
#bg, #c { position: absolute; inset: 0; width: 100%; height: 100%; display: block; }
#c { touch-action: pan-y; cursor: grab; }
#c.dragging { cursor: grabbing; }
.topbar { position: absolute; top: 16px; left: 16px; right: 16px; display: flex; flex-wrap: wrap; gap: 10px; pointer-events: none; }
.topbar > * { pointer-events: auto; }
.legend { display: flex; gap: 16px; padding: 10px 14px; font-size: 13px; flex-wrap: wrap; }
.legend span { display: inline-flex; align-items: center; gap: 7px; }
.tip { position: absolute; padding: 6px 10px; font-size: 13px; pointer-events: none; white-space: nowrap; z-index: 3; }
.tip b { font-weight: 600; }
.orbit { position: absolute; left: 50%; bottom: 16px; transform: translateX(-50%); display: flex; align-items: center; gap: 4px; padding: 6px; }
.orbit button { width: 44px; height: 44px; border: 0; border-radius: var(--r-1); background: transparent; font-size: 22px; line-height: 1; cursor: pointer; color: var(--ink); }
.orbit button:hover { background: var(--line-soft); }
.orbit .ang { min-width: 6ch; text-align: center; font: 500 14px var(--font-text); }
.hint { position: absolute; left: 50%; bottom: 82px; transform: translateX(-50%); padding: 8px 14px; font-size: 13px; color: var(--muted); white-space: nowrap; pointer-events: none; }
.loading { position: absolute; inset: 0; display: grid; place-items: center; align-content: center; gap: 14px; color: var(--muted); background: var(--bg); z-index: 5; padding-inline: 16px; text-align: center; }
.bar { width: min(280px, 70vw); height: 2px; background: var(--line); overflow: hidden; }
.bar i { display: block; height: 100%; width: 0; background: var(--ink); transition: width .2s; }

/* Scheda appartamento (flottante a destra) */
.card { position: absolute; top: 16px; right: 16px; width: 340px; max-height: calc(100% - 32px); overflow-y: auto; display: flex; flex-direction: column; z-index: 4; }
.card-head { display: flex; align-items: flex-start; gap: 10px; padding: 20px 20px 14px; }
.card-head .grow { flex: 1; min-width: 0; }
.card-head #cStatus { margin-top: 2px; }
.x { width: 34px; height: 34px; border: 1px solid var(--control); border-radius: var(--r-1); background: transparent; cursor: pointer; font-size: 20px; line-height: 1; flex: none; color: var(--ink); }
.x:hover { border-color: var(--ink); }
.tabs { display: flex; gap: 2px; padding: 0 12px; border-bottom: 1px solid var(--line-soft); overflow-x: auto; }
.tab { padding: 11px 8px; border: 0; border-bottom: 2px solid transparent; background: none; font: 500 14px var(--font-text); color: var(--muted); cursor: pointer; white-space: nowrap; }
.tab[aria-selected="true"] { color: var(--ink); border-bottom-color: var(--accent); }
.cpanel { padding: 20px; display: flex; flex-direction: column; gap: 16px; }
.card-price { display: flex; justify-content: space-between; align-items: baseline; padding-top: 16px; border-top: 1px solid var(--line-soft); }
.card-price .price { font-size: 28px; }
.card-cta { display: flex; flex-direction: column; gap: 8px; }
.thumbs { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.thumb { padding: 0; border: 1px solid var(--line); border-radius: var(--r-1); overflow: hidden; background: var(--sunken); cursor: pointer; aspect-ratio: 16 / 10; }
.thumb img { width: 100%; height: 100%; object-fit: cover; }
.media { display: block; width: 100%; border: 1px solid var(--line); background: var(--paper); }
.placeholder { margin: 0; padding: 16px; border: 1px dashed var(--control); border-radius: var(--r-1); font-size: 14px; color: var(--muted); }

/* Mobile: render in alto, poi scheda e filtri; la pagina scorre normalmente */
@media (max-width: 900px) {
  body.sel-page { overflow: auto; }
  .app { position: static; display: block; margin-top: var(--header-h); }
  .viewer { height: 62vh; min-height: 380px; }
  .card { position: static; width: auto; max-height: none; margin: 16px; box-shadow: none; border: 1px solid var(--line); }
  .side { border-right: 0; overflow: visible; }
  .hint { display: none; }
  .orbit { bottom: 12px; }
}

/* ritocchi scheda */
.card-head { flex-wrap: wrap; row-gap: 10px; }
.card-head .unit-card__code { font-size: 34px; }
.card-head #cStatus { order: 3; flex-basis: 100%; margin-top: 0; }
.card-head #cStatus { width: fit-content; }
.card-head .x { order: 2; }
.tabs { scrollbar-width: none; }
.tabs::-webkit-scrollbar { display: none; }
.tab { padding: 11px 7px; font-size: 13.5px; }

/* mobile: ordine render → scheda → filtri */
@media (max-width: 900px) {
  .app { display: flex; flex-direction: column; }
  .viewer { order: 0; flex: none; width: 100%; }
  .card { order: 1; }
  .side { order: 2; }
}

/* animazioni selettore */
@keyframes cardIn { from { opacity: 0; transform: translateX(18px); } to { opacity: 1; transform: none; } }
@keyframes rise { from { opacity: 0; transform: translateY(10px); } to { opacity: 1; transform: none; } }
.card:not([hidden]) { animation: cardIn .35s cubic-bezier(.2,.6,.2,1) both; }
.cpanel > * { animation: rise .4s both; }
.cpanel > *:nth-child(2) { animation-delay: .05s; } .cpanel > *:nth-child(3) { animation-delay: .1s; } .cpanel > *:nth-child(4) { animation-delay: .15s; }
.unit-row { transition: background-color .2s; }
.switch__track, .switch__track::after { transition: background-color .2s, left .2s; }
.chip { transition: background-color .2s, color .2s, border-color .2s; }
.legend { animation: rise .6s .3s both; }
@media (max-width: 900px) { .card:not([hidden]) { animation-name: rise; } }
@media (prefers-reduced-motion: reduce) { *, *::before, *::after { animation: none !important; transition: none !important; } }

/* Scheda: testata e schede restano sempre visibili, scorre solo il contenuto */
.card { overflow: hidden; }
.card-head, .tabs { flex: none; background: var(--surface); }
.cpanel { flex: 1 1 auto; min-height: 0; overflow-y: auto; overscroll-behavior: contain; }
.tabs { display: grid; grid-template-columns: repeat(3, 1fr); padding: 0 12px; overflow: visible; }
.tab { text-align: center; padding: 12px 6px; }
@media (max-width: 900px) {
  /* su telefono la scheda scorre con la pagina: le schede restano agganciate sotto l'header */
  .card { overflow: visible; }
  .tabs { position: sticky; top: var(--header-h); z-index: 3; }
  .cpanel { overflow: visible; }
}

/* Bersagli di tocco da 44 px: filtri piano, chiusura scheda, cursori del prezzo */
@media (max-width: 900px), (pointer: coarse) {
  .chip { min-width: 44px; height: 44px; font-size: 15px; }
  .x { width: 44px; height: 44px; }
  .dual { height: 44px; }
  .dual .rail, .dual .fill { top: 21px; }
  .dual input { height: 44px; }
  .dual input::-webkit-slider-runnable-track { height: 44px; }
  .dual input::-webkit-slider-thumb { width: 28px; height: 28px; margin-top: 8px; }
  .dual input::-moz-range-thumb { width: 24px; height: 24px; }
  .dual .rail { left: 14px; right: 14px; }
}
.tab { min-height: 44px; }

/* appartamento venduto: riga spenta e non cliccabile */
.unit-row:disabled { cursor: not-allowed; opacity: .6; }
.unit-row:disabled:hover { background: none; }

/* zoom */
.orbit__sep { width: 1px; height: 24px; background: var(--line); margin: 0 4px; }
.orbit button:disabled { opacity: .35; cursor: default; }
.orbit button:disabled:hover { background: transparent; }
.orbit .orbit__reset { width: auto; padding: 0 10px; font: 600 12px var(--font-text); letter-spacing: .04em; }
.orbit button[hidden] { display: none; }
