/* =====================================================================
   Interaktywna wizualizacja (domuly-tab-wiz3d.php) + widok lokalu (.aptview)
   ===================================================================== */

.wiz { margin-block: 8px 16px; }
.wiz__layout { display: grid; grid-template-columns: 1.6fr 1fr; gap: 26px; align-items: start; }

.wiz__planwrap { position: relative; }
.wiz__hint { font-size: .9rem; color: var(--muted-2); margin-bottom: 10px; }
.wiz__plan {
	width: 100%; height: auto; display: block;
	background: #eef4e6; border: 1px solid var(--line); border-radius: var(--radius-lg);
	overflow: hidden;
}

/* Budynki na planie */
.wiz-bld { cursor: pointer; }
.wiz-bld__shape {
	fill: #b9c8a6; stroke: #fff; stroke-width: 2.5;
	transition: fill .15s ease, filter .15s ease;
}
.wiz-bld--free .wiz-bld__shape { fill: #72cb20; }
.wiz-bld--reserved .wiz-bld__shape { fill: #e1c281; }
.wiz-bld--sold .wiz-bld__shape { fill: #c9c9c9; }

.wiz-bld:hover .wiz-bld__shape,
.wiz-bld:focus-visible .wiz-bld__shape { filter: url(#wiz-glow); }
.wiz-bld:focus { outline: none; }

.wiz-bld.is-active .wiz-bld__shape { stroke: #1d2a16; stroke-width: 3.5; }

.wiz-bld__label {
	font-family: var(--font-head); font-weight: 800; font-size: 30px; fill: #1d2a16;
	pointer-events: none; dominant-baseline: middle;
}
.wiz-bld--sold .wiz-bld__label { fill: #6a6a6a; }
.wiz-bld__pin-text { font-family: var(--font-head); font-weight: 800; font-size: 13px; fill: #2c352a; }
.wiz-bld__pin rect { stroke: #72cb20; stroke-width: 1.5; }

/* Legenda */
.wiz__legend { display: flex; flex-wrap: wrap; gap: 8px 22px; margin-top: 14px; font-size: .9rem; color: var(--text); }
.wiz__legend span { display: inline-flex; align-items: center; gap: 8px; }
.wiz-dot { width: 16px; height: 16px; border-radius: 5px; border: 2px solid rgba(0,0,0,.12); display: inline-block; }
.wiz-dot--free { background: #72cb20; }
.wiz-dot--reserved { background: #e1c281; }
.wiz-dot--sold { background: #c9c9c9; }

/* Panel boczny */
.wiz__panel {
	position: sticky; top: calc(var(--header-h) + 16px);
	background: #fff; border: 1px solid var(--line); border-radius: var(--radius-lg);
	box-shadow: var(--shadow-sm); padding: 24px; min-height: 280px;
}
.wiz__panel-empty { text-align: center; color: var(--muted-2); padding: 24px 8px; }
.wiz__panel-icon { width: 64px; height: 64px; margin: 0 auto 14px; color: var(--green); }
.wiz__panel-empty h3 { color: var(--ink); }

.wiz__panel-head { margin-bottom: 16px; }
.wiz__panel-type { font-family: var(--font-head); font-weight: 700; letter-spacing: .1em; text-transform: uppercase; font-size: .72rem; color: var(--green-700); }
.wiz__panel-head h3 { margin: 4px 0 0; }

.wiz__stats { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 18px; }
.wiz__stat { background: var(--bg-soft); border: 1px solid var(--line); border-radius: var(--radius); padding: 14px 8px; text-align: center; }
.wiz__stat b { display: block; font-family: var(--font-head); font-size: 1.7rem; color: var(--ink); line-height: 1; }
.wiz__stat span { font-size: .78rem; color: var(--muted-2); }
.wiz__stat--accent { background: var(--green-soft); border-color: #cfe8b0; }
.wiz__stat--accent b { color: var(--green-700); }

.wiz__rows { display: flex; flex-direction: column; gap: 8px; }
.wiz-row {
	display: grid; grid-template-columns: 1fr auto; grid-template-areas: "nr tag" "facts price";
	gap: 2px 10px; padding: 12px 14px; border: 1px solid var(--line); border-radius: var(--radius);
	color: var(--text); transition: .15s;
}
.wiz-row:hover { border-color: var(--green); background: var(--bg-soft); }
.wiz-row.is-disabled { opacity: .55; pointer-events: none; }
.wiz-row__nr { grid-area: nr; font-family: var(--font-head); font-weight: 700; color: var(--ink); }
.wiz-row__facts { grid-area: facts; font-size: .85rem; color: var(--muted-2); }
.wiz-row__price { grid-area: price; align-self: end; font-family: var(--font-head); font-weight: 700; color: var(--green-700); }
.wiz-tag { grid-area: tag; justify-self: end; padding: 3px 10px; border-radius: var(--radius-pill); font-size: .72rem; font-weight: 700; font-family: var(--font-head); }
.wiz-tag--free { background: var(--green-soft); color: var(--green-700); }
.wiz-tag--reserved { background: #f6ecd4; color: #8a6a18; }
.wiz-tag--sold { background: #ededed; color: #6a6a6a; }

@media (max-width: 900px) {
	.wiz__layout { grid-template-columns: 1fr; }
	.wiz__panel { position: static; }
}

/* =====================================================================
   Widok pojedynczego lokalu (.aptview – plugin single template)
   ===================================================================== */
.aptview { padding-block: clamp(24px, 4vw, 48px); }
.aptview__crumbs { font-size: .85rem; color: var(--muted-2); margin-bottom: 12px; }
.aptview__crumbs a { color: var(--muted-2); }
.aptview__crumbs a:hover { color: var(--green-700); }
.aptview__head { display: flex; flex-wrap: wrap; justify-content: space-between; gap: 16px; align-items: flex-start; margin-bottom: 26px; }
.aptview__badge { display: inline-block; padding: 5px 14px; border-radius: var(--radius-pill); font-weight: 700; font-family: var(--font-head); font-size: .8rem; background: var(--green); color: #fff; }
.aptview__topmargin { margin-top: 6px; }
.aptview__title { margin: 8px 0 0; font-size: clamp(1.8rem, 4vw, 2.8rem); }

.aptview__grid { display: grid; grid-template-columns: 360px 1fr; gap: 28px; align-items: start; }
.box.card { background: #fff; border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 22px; box-shadow: var(--shadow-sm); }
.meta3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 10px; margin-bottom: 16px; }
.meta3 > div { background: var(--bg-soft); border-radius: var(--radius); padding: 12px 10px; text-align: center; font-family: var(--font-head); font-weight: 700; color: var(--ink); }
.meta3 span { display: block; font-size: .72rem; font-weight: 600; color: var(--muted-2); text-transform: uppercase; letter-spacing: .04em; margin-bottom: 4px; }
.row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; margin-bottom: 16px; }
.cell { background: var(--bg-soft); border-radius: var(--radius); padding: 12px 14px; }
.cell small { display: block; color: var(--muted-2); font-size: .75rem; margin-bottom: 4px; }
.cell b { font-family: var(--font-head); }

.pricebar { border-top: 1px solid var(--line); padding-top: 16px; margin-bottom: 14px; }
.pricebar__label { color: var(--muted-2); font-size: .85rem; }
.pricebar__value { font-family: var(--font-head); font-weight: 800; font-size: 1.35rem; color: var(--ink); line-height: 1.2; }
.pricebar__hint { font-size: .78rem; color: var(--muted-2); margin-top: 4px; }
.pricebar__btn { margin-top: 14px; width: 100%; justify-content: center; }
.pricebar__btn svg { width: 18px; height: 18px; }

/* Stackowanie .row gdy chcemy w jednej kolumnie */
.row--stack { grid-template-columns: 1fr; }

/* Modal Historia cen */
.history[hidden] { display: none; }
.history { position: fixed; inset: 0; z-index: 1000; display: flex; align-items: center; justify-content: center; padding: 20px; opacity: 0; pointer-events: none; transition: opacity .2s ease; margin: 0; border: 0; background: transparent; border-radius: 0; }
.history.is-open { opacity: 1; pointer-events: auto; }
.history__backdrop { position: absolute; inset: 0; background: rgba(15,22,10,.55); backdrop-filter: blur(2px); cursor: pointer; }
.history__inner { position: relative; z-index: 2; width: 100%; max-width: 480px; max-height: calc(100vh - 60px); overflow: auto; background: #fff; border-radius: 12px; padding: 22px 24px 24px; box-shadow: 0 20px 60px rgba(0,0,0,.32); transform: translateY(8px); transition: transform .25s ease; }
.history.is-open .history__inner { transform: translateY(0); }
.history__close { position: absolute; top: 10px; right: 10px; width: 36px; height: 36px; border-radius: 50%; border: 0; background: var(--bg-soft); cursor: pointer; display: inline-flex; align-items: center; justify-content: center; color: var(--ink); transition: background .15s ease; }
.history__close:hover { background: var(--line); }
.history__close svg { width: 18px; height: 18px; }
.history__row { display: flex; justify-content: space-between; gap: 12px; padding: 10px 0; border-bottom: 1px dashed var(--line-2); }
.history__row:last-child { border-bottom: 0; }
.history__price { font-family: var(--font-head); font-weight: 700; color: var(--ink); }
.history__dates { font-size: .8rem; color: var(--muted-2); }
.history__trend--down { color: var(--green-700); font-family: var(--font-head); font-weight: 700; }
.history__trend--up { color: #c0392b; font-family: var(--font-head); font-weight: 700; }
body.modal-open { overflow: hidden; }

/* „Zobacz inne mieszkania" + .sale wewnątrz widoku oferty */
.other-flats { margin-top: 36px; }
.other-flats__title { margin-bottom: 18px; }
.offer-detail .sale,
.other-flats + .sale { padding-block: 0; padding-top: 0; }

.cta { display: flex; flex-direction: column; gap: 10px; margin-top: 18px; }
.cta .gbtn, .cta .gbtn--ghost { justify-content: center; }
.cta svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; }

.tabs { display: flex; gap: 4px; border-bottom: 1px solid var(--line); margin-bottom: 18px; overflow-x: auto; }
.tabs .tab, .plan__switch .tab { padding: 12px 16px; border: 0; background: transparent; border-bottom: 3px solid transparent; font-family: var(--font-head); font-weight: 600; color: var(--muted-2); cursor: pointer; white-space: nowrap; }
.tabs .tab.is-active, .plan__switch .tab.is-active { color: var(--green-700); border-bottom-color: var(--green); }
.canvas { background: #fff; border: 1px solid var(--line); border-radius: var(--radius-lg); padding: 18px; min-height: 420px; }
.zoomwrap { position: relative; height: clamp(540px, 78vh, 820px); overflow: hidden; background: var(--bg-soft); border-radius: var(--radius); }
.zoomstage { position: absolute; left: 50%; top: 50%; }
/* Plugin podaje rzut jako <img> – musi mieć intrinsic size, żeby transform scale liczył się z prawdziwych wymiarów */
#planImg, #mPlanImg, .plan-img-fixed {
	max-width: none !important;
	max-height: none !important;
	width: auto !important;
	height: auto !important;
	display: block;
}
.zoomctrls, .modal__ctrls { position: absolute; right: 16px; bottom: 16px; display: flex; flex-direction: column; gap: 8px; z-index: 4; }
.zoomctrls button, .modal__ctrls button { width: 44px; height: 44px; padding: 0; border-radius: 50%; border: 0; background: rgba(29,42,22,.85); color: #fff; cursor: pointer; display: inline-flex; align-items: center; justify-content: center; box-shadow: 0 6px 14px rgba(0,0,0,.18); transition: background .15s ease, transform .15s ease; }
.zoomctrls button:hover, .modal__ctrls button:hover { background: var(--green-700); transform: translateY(-1px); }
.zoomctrls button:active, .modal__ctrls button:active { transform: translateY(0); }
.zoomctrls button svg, .modal__ctrls button svg { width: 22px; height: 22px; pointer-events: none; }
.modal__ctrls button { font-size: 22px; font-family: var(--font-head); font-weight: 700; line-height: 1; }
#unitMap { height: 480px; border-radius: var(--radius); overflow: hidden; }

.rooms__list { display: grid; grid-template-columns: 1fr auto; gap: 6px 20px; }
.rooms__name { color: var(--text); }
.rooms__size { font-family: var(--font-head); font-weight: 600; color: var(--ink); text-align: right; }

.modal { position: fixed; inset: 0; z-index: 999; background: rgba(15,22,10,.85); display: none; }
.modal.is-open { display: block; }
.modal__inner { position: absolute; inset: 3vh 3vw; background: #fff; border-radius: var(--radius-lg); display: flex; flex-direction: column; overflow: hidden; }
.modal__close { align-self: flex-end; margin: 12px; display: inline-flex; align-items: center; gap: 6px; padding: 8px 14px; border: 0; background: var(--bg-soft); border-radius: var(--radius-pill); cursor: pointer; }
.modal__close svg { width: 18px; height: 18px; fill: none; stroke: currentColor; stroke-width: 2; }
.modal__stage { flex: 1; }

/* Formularz zapytania */
.askform { margin-top: 6px; }
.askgrid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field { display: flex; flex-direction: column; gap: 6px; }
.field > span { font-size: .85rem; font-weight: 600; color: var(--muted-2); }
.field--full { grid-column: 1 / -1; }
.field input, .field textarea, .field select { padding: 12px 14px; border: 1px solid var(--line-2); border-radius: 12px; font: inherit; background: #fff; }
.field input:focus, .field textarea:focus { outline: none; border-color: var(--green); }
.phonewrap { display: flex; gap: 8px; }
.check { display: flex; gap: 10px; align-items: flex-start; font-size: .85rem; color: var(--muted-2); }
.askform__legal { color: var(--muted-2); font-size: .78rem; }
.askform__msg { margin-top: 8px; font-weight: 600; }
.askform__msg.is-ok { color: var(--green-700); }
.askform__msg.is-error { color: #c0392b; }

@media (max-width: 880px) {
	.aptview__grid { grid-template-columns: 1fr; }
	.askgrid { grid-template-columns: 1fr; }
}
