/* Apartment inventory — modern rewrite | white/yellow theme */

@font-face {
  font-family: 'Ploni';
  src: url('../fonts/ploni-aaa-400.woff') format('woff');
  font-weight: 400;
  font-display: swap;
}
@font-face {
  font-family: 'Ploni';
  src: url('../fonts/ploni-aaa-600.woff') format('woff');
  font-weight: 600;
  font-display: swap;
}
@font-face {
  font-family: 'Ploni';
  src: url('../fonts/ploni-aaa-800.woff') format('woff');
  font-weight: 800;
  font-display: swap;
}

:root {
  --bg: #ffffff;
  --ink: #1a1a1a;
  --ink-soft: #4a4a4a;
  --accent: #5d5b84;
  --accent-soft: #ecebf4;
  --gray-line: #e4e4e4;
  --gray-bg: #f7f7f5;
  --available: #2f9e63;
  --sold: #c0392b;
  --free: #8a8a85;
  --radius: 14px;
  --shadow: 0 6px 22px rgba(0, 0, 0, 0.1);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

/* the hidden attribute always wins, even over display:flex rules */
[hidden] { display: none !important; }

html { scroll-behavior: smooth; }

body {
  font-family: 'Ploni', 'Assistant', sans-serif;
  background: var(--bg);
  color: var(--ink);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* ---------- loader ---------- */
.loader {
  position: fixed;
  inset: 0;
  background: rgba(255, 255, 255, 0.94);
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  font-size: 1.2rem;
  font-weight: 600;
}
.loader-spinner {
  width: 46px;
  height: 46px;
  border: 4px solid var(--accent-soft);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.9s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
.loader-error { text-align: center; line-height: 1.7; }

/* ---------- header ---------- */
.site-header { text-align: center; padding: 22px 16px 10px; }
.logo { max-width: 220px; width: 55%; height: auto; border-radius: 12px; }
.site-title { font-size: 1.6rem; font-weight: 800; }

/* ---------- toolbar ---------- */
.toolbar {
  position: sticky;
  top: 0;
  z-index: 50;
  padding: 10px 16px 0;
  background: rgba(255, 255, 255, 0.94);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--gray-line);
  transition: box-shadow 0.2s;
}
.toolbar.stuck { box-shadow: var(--shadow); }
.toolbar-inner {
  max-width: 1440px;
  margin: 0 auto;
  display: flex;
  flex-wrap: wrap;
  align-items: flex-end;
  gap: 12px;
}

.views {
  display: flex;
  background: var(--gray-bg);
  border: 1px solid var(--gray-line);
  border-radius: 12px;
  padding: 3px;
  gap: 2px;
}
.view-btn {
  font-family: inherit;
  font-size: 0.9rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border: none;
  border-radius: 9px;
  background: transparent;
  color: var(--ink-soft);
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}
.view-btn:hover { color: var(--ink); }
.view-btn.active { background: var(--accent); color: #fff; }

.filter { display: flex; flex-direction: column; gap: 4px; }
.filter label { font-size: 0.78rem; color: var(--ink-soft); }
.filter select {
  font-family: inherit;
  font-size: 0.95rem;
  padding: 8px 12px;
  border-radius: 10px;
  border: 1px solid var(--gray-line);
  background: #fff;
  color: var(--ink);
  min-width: 140px;
  cursor: pointer;
}
.filter select:focus { outline: 2px solid var(--accent); outline-offset: 1px; }

.filter-check { justify-content: flex-end; padding-bottom: 9px; }
.checkbox-label { display: flex; align-items: center; gap: 8px; cursor: pointer; font-size: 0.92rem; }
.checkbox-label input { width: 18px; height: 18px; accent-color: var(--accent); cursor: pointer; }

.btn-clear, .btn-refresh {
  font-family: inherit;
  font-size: 0.92rem;
  font-weight: 600;
  padding: 9px 16px;
  border-radius: 10px;
  cursor: pointer;
  transition: transform 0.12s;
}
.btn-clear { background: #fff; color: var(--ink); border: 1px solid var(--ink); }
.btn-refresh { background: var(--accent); color: #fff; border: none; margin-inline-start: auto; }
.btn-clear:hover, .btn-refresh:hover { transform: translateY(-1px); }
.btn-refresh:disabled { opacity: 0.5; cursor: wait; }
.refresh-icon { display: inline-block; }
.btn-refresh:disabled .refresh-icon { animation: spin 0.9s linear infinite; }

.result-bar {
  max-width: 1440px;
  margin: 8px auto 0;
  padding: 6px 2px 10px;
  font-size: 0.92rem;
  color: var(--ink-soft);
}

/* ---------- intro ---------- */
.intro { text-align: center; padding: 10px 0 20px; }
.intro-title { font-size: 2rem; font-weight: 800; margin-bottom: 24px; }
.intro-card {
  max-width: 1380px;
  margin: 0 auto;
  border: 1px solid var(--ink);
  border-radius: 4px;
  padding: 28px 40px;
}
.intro-card p { line-height: 2; font-size: 1.15rem; }

/* ---------- layout ---------- */
.container {
  flex: 1;
  width: 100%;
  max-width: 1440px;
  margin: 0 auto;
  padding: 20px 16px 48px;
}

/* ---------- cards view ---------- */
.cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(225px, 1fr));
  gap: 12px;
}

/* ---------- apartment card ---------- */
.apt {
  background: #fff;
  border: 1px solid var(--gray-line);
  color: var(--ink);
  border-radius: 12px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  position: relative;
  transition: transform 0.15s, box-shadow 0.15s;
}
.apt:hover { transform: translateY(-3px); box-shadow: var(--shadow); }

.apt-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 9px 12px;
  background: var(--ink);
  color: #fff;
  font-size: 0.92rem;
}
.apt-badge {
  font-size: 0.7rem;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 20px;
  white-space: nowrap;
}
.badge-available { background: var(--available); color: #fff; }
.badge-sold { background: var(--sold); color: #fff; }
.badge-free { background: var(--free); color: #fff; }

.apt-body { padding: 10px 12px; display: flex; flex-direction: column; gap: 4px; }
.apt-row {
  display: flex;
  justify-content: space-between;
  font-size: 0.88rem;
  border-bottom: 1px dashed var(--gray-line);
  padding-bottom: 3px;
}
.apt-row:last-child { border-bottom: none; }
.apt-row span { color: var(--ink-soft); }

/* prominent price line, like the original design */
.apt-row.apt-price {
  display: flex;
  justify-content: center;
  align-items: baseline;
  gap: 8px;
  background: var(--accent-soft);
  border-radius: 8px;
  border-bottom: none;
  padding: 8px 10px;
  margin-top: 6px;
}
.apt-row.apt-price span { color: var(--ink); font-size: 1rem; font-weight: 600; }
.apt-row.apt-price b { font-size: 1.45rem; font-weight: 800; letter-spacing: -0.5px; }
.apt-id { opacity: 0.7; font-size: 0.78rem; }

.apt-docs { display: flex; gap: 8px; padding: 8px 12px 12px; margin-top: auto; }
.doc-link {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--ink);
  text-decoration: none;
  background: var(--gray-bg);
  border: 1px solid var(--gray-line);
  border-radius: 8px;
  padding: 6px 8px;
  transition: background 0.15s, border-color 0.15s;
}
.doc-link:hover { background: var(--accent-soft); border-color: var(--accent); }
.doc-link svg { flex-shrink: 0; }
.doc-link-sm { flex: 0; padding: 5px 9px; }

/* free-market + sold: card hidden behind an overlay */
.apt-free, .apt-sold { min-height: 170px; }
.apt-body-hidden { flex: 1; }
.apt-overlay {
  position: absolute;
  inset: 0;
  z-index: 2;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.overlay-free { background: #ececea; }
.overlay-sold { background: var(--accent-soft); }
.apt-overlay img { max-width: 78%; max-height: 65%; object-fit: contain; }

/* ---------- table view ---------- */
.table-wrap {
  overflow-x: auto;
  border: 1px solid var(--gray-line);
  border-radius: var(--radius);
  background: #fff;
}
.apt-table { width: 100%; border-collapse: collapse; font-size: 0.92rem; }
.apt-table th {
  background: var(--ink);
  color: #fff;
  text-align: right;
  padding: 10px 12px;
  font-weight: 600;
  white-space: nowrap;
  position: sticky;
  top: 0;
}
.apt-table th.sortable { cursor: pointer; user-select: none; }
.apt-table th.sortable:hover { background: #333; }
.apt-table td { padding: 9px 12px; border-bottom: 1px solid var(--gray-line); }

/* row tint by building */
.apt-table tr.row-b0 { background: #f4f3f9; }
.apt-table tr.row-b1 { background: #f0f6f2; }
.apt-table tr.row-b2 { background: #fdf6ec; }
.apt-table tr.row-b3 { background: #eff5f8; }
.apt-table tr.row-b4 { background: #f9f0f2; }
.apt-table tr.row-b5 { background: #f4f4ef; }

.apt-table tbody tr:hover { background: var(--accent-soft); }
.apt-table tbody tr:last-child td { border-bottom: none; }
.row-sold td { color: #999; }
.row-free td { color: #999; }
.free-cell { font-weight: 600; text-align: center; }

/* ---------- building view ---------- */
.building-section { margin-bottom: 30px; }
.building-name {
  font-size: 1.3rem;
  font-weight: 800;
  margin-bottom: 12px;
  padding-inline-start: 12px;
  border-inline-start: 6px solid var(--accent);
}
.floor-row {
  display: flex;
  align-items: stretch;
  gap: 12px;
  margin-bottom: 12px;
  background: var(--gray-bg);
  border: 1px solid var(--gray-line);
  border-radius: var(--radius);
  padding: 12px;
}
.floor-label {
  flex: 0 0 80px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  background: var(--accent);
  color: #fff;
  border-radius: 10px;
  padding: 10px 6px;
  text-align: center;
}
.floor-label b { font-size: 1.4rem; line-height: 1.1; }
.floor-label span { font-size: 0.75rem; }
.floor-count { opacity: 0.75; }
.floor-apts {
  flex: 1;
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 10px;
}

/* ---------- 3D model view ---------- */
.model3d-wrap {
  height: 560px;
  border-radius: var(--radius);
  overflow: hidden;
  background: linear-gradient(180deg, #cdb9d6 0%, #f0cdb0 70%, #e8dcc8 100%);
  box-shadow: var(--shadow);
  cursor: grab;
}
.model3d-wrap:active { cursor: grabbing; }
.model3d-wrap canvas { display: block; }
@media (max-width: 720px) { .model3d-wrap { height: 420px; } }

/* ---------- model view ---------- */
.model-hint {
  text-align: center;
  font-size: 0.95rem;
  color: var(--ink-soft);
  margin-bottom: 12px;
}
.model-wrap {
  position: relative;
  max-width: 1150px;
  margin: 0 auto;
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.model-wrap img { display: block; width: 100%; height: auto; user-select: none; }
.hotspot {
  position: absolute;
  cursor: pointer;
  border-radius: 3px;
  transition: background 0.12s, box-shadow 0.12s;
}
.hotspot:hover { box-shadow: inset 0 0 0 2px #fff; }
.hs-available:hover { background: rgba(47, 158, 99, 0.45); }
.hs-sold:hover { background: rgba(192, 57, 43, 0.45); }
.hs-free:hover { background: rgba(120, 120, 115, 0.5); }

/* perspective polygon hotspots over the real render */
.hs-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
}
.hs-poly {
  fill: transparent;
  stroke: transparent;
  cursor: pointer;
  transition: fill 0.12s;
  vector-effect: non-scaling-stroke;
}
.hs-poly:hover { stroke: #ffffff; stroke-width: 1.5; }
.hsp-available:hover { fill: rgba(47, 158, 99, 0.45); }
.hsp-sold:hover { fill: rgba(192, 57, 43, 0.45); }
.hsp-free:hover { fill: rgba(120, 120, 115, 0.5); }

.model-tooltip {
  position: fixed;
  z-index: 200;
  background: var(--ink);
  color: #fff;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.85rem;
  pointer-events: none;
  display: flex;
  flex-direction: column;
  gap: 3px;
  box-shadow: var(--shadow);
  max-width: 240px;
}
.model-tooltip b { font-size: 0.95rem; }
.tt-price { color: #ffe58a; font-weight: 700; }
.tt-status { font-weight: 700; }
.tt-sold { color: #ff9d92; }
.tt-free { color: #cfcfc9; }
.tt-hint { font-size: 0.72rem; opacity: 0.7; }

/* ---------- details modal ---------- */
.modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 300;
  background: rgba(0, 0, 0, 0.55);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 16px;
}
.modal {
  position: relative;
  background: #fff;
  border-radius: 16px;
  max-width: 520px;
  width: 100%;
  max-height: 88vh;
  overflow-y: auto;
  padding: 26px 24px 20px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.3);
}
.modal-close {
  position: absolute;
  top: 12px;
  left: 12px;
  border: none;
  background: var(--gray-bg);
  border-radius: 50%;
  width: 32px;
  height: 32px;
  font-size: 0.95rem;
  cursor: pointer;
  color: var(--ink);
}
.modal-close:hover { background: var(--accent-soft); }
.modal-title {
  font-size: 1.25rem;
  font-weight: 800;
  margin-bottom: 16px;
  padding-inline-start: 10px;
  border-inline-start: 5px solid var(--accent);
}
.modal-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 8px 14px;
}
.m-item {
  display: flex;
  justify-content: space-between;
  font-size: 0.92rem;
  border-bottom: 1px dashed var(--gray-line);
  padding-bottom: 4px;
}
.m-item span { color: var(--ink-soft); }
.modal-price {
  margin-top: 14px;
  font-size: 1.1rem;
  background: var(--accent-soft);
  border-radius: 10px;
  padding: 10px 14px;
  text-align: center;
}
.modal-docs .apt-docs { padding: 12px 0 0; }
.modal-disclaimer { margin-top: 12px; font-size: 0.72rem; color: var(--ink-soft); text-align: center; }
.modal-locked { display: flex; justify-content: center; padding: 26px 0 10px; }
.modal-locked img { max-width: 70%; height: auto; }

/* ---------- model time-lock popup ---------- */
.model-lock-wrap {
  min-height: 420px;
  border-radius: var(--radius);
  background: linear-gradient(180deg, var(--accent) 0%, #3d3b5c 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  box-shadow: var(--shadow);
}
.model-lock-card {
  background: #fff;
  border-radius: 18px;
  padding: 38px 42px;
  text-align: center;
  max-width: 420px;
  box-shadow: 0 18px 60px rgba(0, 0, 0, 0.35);
}
.lock-icon { font-size: 2.6rem; margin-bottom: 10px; }
.lock-title { font-size: 1.6rem; font-weight: 800; margin-bottom: 8px; }
.lock-text { font-size: 1.1rem; color: var(--ink-soft); margin-bottom: 20px; }
.lock-cta {
  display: block;
  background: var(--accent);
  color: #fff;
  text-decoration: none;
  font-weight: 700;
  font-size: 1.05rem;
  border-radius: 12px;
  padding: 12px 18px;
  margin-top: 10px;
  transition: transform 0.12s;
}
.lock-cta:hover { transform: translateY(-1px); }
.lock-cta-mail { background: #fff; color: var(--accent); border: 2px solid var(--accent); }

/* ---------- legend / no results ---------- */
.legend {
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 18px;
  margin-top: 22px;
  font-size: 0.85rem;
  color: var(--ink-soft);
}
.legend-item { display: flex; align-items: center; gap: 6px; }
.dot { width: 12px; height: 12px; border-radius: 50%; display: inline-block; }
.dot-available { background: var(--available); }
.dot-sold { background: var(--sold); }
.dot-free { background: var(--free); }

.no-results { text-align: center; padding: 46px 16px; font-size: 1.1rem; color: var(--ink-soft); }

/* ---------- footer ---------- */
.site-footer {
  background: var(--ink);
  color: #fff;
  text-align: center;
  padding: 22px 16px 0;
  margin-top: 40px;
}
.footer-top h4 { font-size: 1.15rem; margin-bottom: 8px; color: #b9b7d8; }
.footer-top a { display: inline-block; color: #fff; text-decoration: none; margin: 0 12px 6px; }
.footer-top a:hover { color: var(--accent); }
.footer-bottom {
  border-top: 1px solid rgba(255, 255, 255, 0.2);
  margin-top: 12px;
  padding: 12px;
  font-size: 0.85rem;
  opacity: 0.85;
}

/* ---------- mobile ---------- */
@media (max-width: 720px) {
  .logo { width: 50%; max-width: 180px; }

  .toolbar-inner { gap: 8px; }
  .views { width: 100%; }
  .view-btn { flex: 1; justify-content: center; }
  .filter { flex: 1 1 45%; }
  .filter select { min-width: 0; width: 100%; }
  .filter-check { flex: 1 1 45%; padding-bottom: 4px; }
  .btn-refresh { margin-inline-start: 0; flex: 1 1 45%; }
  .btn-clear { flex: 1 1 45%; }

  .cards-grid { grid-template-columns: 1fr 1fr; }

  .floor-row { flex-direction: column; gap: 10px; }
  .floor-label { flex-direction: row; justify-content: center; gap: 8px; padding: 8px; }
  .floor-label b { font-size: 1.15rem; }
  .floor-apts { grid-template-columns: 1fr 1fr; }

  .apt-table { font-size: 0.8rem; }
  .apt-table th, .apt-table td { padding: 7px 8px; }
}

@media (max-width: 460px) {
  .cards-grid { grid-template-columns: 1fr; }
  .floor-apts { grid-template-columns: 1fr; }
}
