/* ==========================================
   Flat Detail (Senso) – /apartamenty/?floor=X&flat=Y
   ========================================== */
.sfd {
  --sfd-accent: #02d5e1;
  --sfd-text:   #1a1a3e;
  --sfd-muted:  #888;
  --sfd-border: #e5e7eb;
  --sfd-bg-soft:#f7f8fa;
  font-family: 'Poppins', sans-serif;
  color: var(--sfd-text);
  padding: 30px 0 180px;
}
.sfd-container {
  max-width: var(--main-width, 1350px);
  width: 100%;
  margin: 0 auto;
  padding: 0;
  box-sizing: border-box;
}
.sfd-empty {
  padding: 60px 30px;
  text-align: center;
  color: var(--sfd-muted);
  background: var(--sfd-bg-soft);
  border-radius: 10px;
}
.sfd-empty a { color: var(--sfd-accent); }

/* ── Tabs ── */
.sfd-tabs {
  display: flex;
  gap: 0;
  flex-wrap: wrap;
  padding: 6px;
  background: rgba(2,213,225,.18);
  border-radius: 14px;
  margin: 0 0 26px;
}
.sfd-tab {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 10px 18px;
  border: none;
  background: transparent;
  border-radius: 10px;
  font-family: inherit;
  font-size: 14px;
  font-weight: 600;
  color: var(--sfd-accent);
  cursor: pointer;
  transition: background .15s, color .15s;
  white-space: nowrap;
}
.sfd-tab svg { width: 16px; height: 16px; flex-shrink: 0; }
.sfd-tab:hover { color: var(--sfd-text); }
.sfd-tab.active { background: var(--sfd-accent); color: #fff !important; }
.sfd-tab[disabled],
.sfd-tab.is-soon {
  opacity: .55;
  cursor: not-allowed;
}
.sfd-panel { display: none; }
.sfd-panel.active { display: block; }

/* ── Lokalizacja panel: nadpisanie stylów z lokalizacja.php aby wpasować w nasz layout ── */
.sfd-panel-location #map-section { padding: 0; }
.sfd-panel-location #map {
  margin-top: 0 !important;
  height: 70vh !important;
  min-height: 500px !important;
  border-radius: 10px !important;
  overflow: hidden !important;
}

/* ── Gallery panel (Zobacz mieszkanie): rotacyjny viewer wnętrza ── */
.sfd-fv {
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.sfd-fv-toolbar {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: rgba(2,213,225,.12);
  border: 1px solid rgba(2,213,225,.35);
  border-radius: 10px;
}
.sfd-fv-info {
  display: flex;
  align-items: center;
  gap: 10px;
  color: var(--sfd-text);
  font-size: 14px;
  font-weight: 500;
  flex: 1;
  min-width: 200px;
}
.sfd-fv-info svg {
  color: var(--sfd-accent);
  flex-shrink: 0;
}
.sfd-fv-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}
.sfd-fv-btn {
  padding: 9px 16px;
  background: #fff;
  border: 1px solid var(--sfd-border);
  border-radius: 6px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  font-family: inherit;
  color: var(--sfd-text);
  transition: background .15s, border-color .15s, color .15s;
}
.sfd-fv-btn:hover { background: var(--sfd-bg-soft); border-color: var(--sfd-accent); }
.sfd-fv-toggle-dim { margin-left: 6px; }
.sfd-fv-toggle-dim.active {
  background: var(--sfd-accent);
  color: #fff !important;
  border-color: var(--sfd-accent);
}
.sfd-fv-stage {
  position: relative;
  width: 100%;
  height: 70vh;
  min-height: 500px;
  background: #1a1a1a;
  border-radius: 10px;
  overflow: hidden;
  cursor: grab;
  user-select: none;
  touch-action: pan-y;
}
.sfd-fv-stage:active { cursor: grabbing; }
.sfd-fv-img {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  object-fit: contain;
  pointer-events: none;
  user-select: none;
  -webkit-user-drag: none;
}
.sfd-fv-beauty-img { z-index: 1; }
.sfd-fv-dim-img    { z-index: 2; }
.sfd-fv-loader {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  color: #fff;
  background: rgba(0,0,0,.55);
  font-size: 14px;
  z-index: 3;
}
.sfd-fv-spinner {
  width: 18px; height: 18px;
  border: 2.5px solid rgba(255,255,255,.2);
  border-top-color: var(--sfd-accent);
  border-radius: 50%;
  animation: sfd-spin .9s linear infinite;
}
@keyframes sfd-spin { to { transform: rotate(360deg); } }
@media (max-width: 768px) {
  .sfd-fv-stage { height: 60vh; min-height: 400px; }
}
@media (max-width: 600px) {
  .sfd-fv-toolbar { padding: 12px 14px; }
  .sfd-fv-info { font-size: 13px; }
  .sfd-fv-btn { padding: 7px 12px; font-size: 13px; }
}

/* ── Spacer 360 (Pannellum) ── */
.sfd-panel-walk { width: 100%; }
.sfd-spacer { width: 100%; position: relative; }
#sfd-pano {
  width: 100%;
  height: 70vh;
  min-height: 500px;
  background: #000;
  border-radius: 10px;
  overflow: hidden;
}
@media (max-width: 768px) {
  #sfd-pano { height: 60vh; min-height: 400px; }
}
/* Pannellum hotspoty — duża "tarcza" 64px: turkusowa kropka w środku, biały
   pierścień, półprzezroczysta poświata wokół. Celujemy w SAMĄ .pnlm-hotspot
   (bez wymagania .pnlm-info / .pnlm-scene) bo używamy własnego clickHandler.
   Tło realizujemy przez radial-gradient żeby uniknąć dodatkowych elementów DOM
   (Pannellum re-renderuje pozycję transform:translate3d co frame).
   transition:none — bez lagu podczas panningu kamerą. */
.pnlm-hotspot,
.pnlm-hotspot-base,
.pnlm-render-container .pnlm-hotspot {
  transition: none !important;
  -webkit-transition: none !important;
  /* UWAGA: NIE wymuszamy `visibility: visible` ani `opacity: 1` — Pannellum
     ustawia `style.visibility = 'hidden'` na hotspotach które są poza widocznym
     obszarem (z tyłu sfery) i wtedy nie aktualizuje ich transformu. Wymuszanie
     widoczności powoduje że "ukryte" hotspoty pojawiają się w lewym górnym rogu
     ze starą/zerową translacją. */
  width: 64px !important;
  height: 64px !important;
  margin: 0 !important;
  background: radial-gradient(
    circle at center,
    #02d5e1 0 12px,
    #fff 13px 17px,
    rgba(2, 213, 225, .22) 17px 30px,
    rgba(255, 255, 255, .85) 30px 32px,
    transparent 32px 100%
  ) !important;
  background-image: radial-gradient(
    circle at center,
    #02d5e1 0 12px,
    #fff 13px 17px,
    rgba(2, 213, 225, .22) 17px 30px,
    rgba(255, 255, 255, .85) 30px 32px,
    transparent 32px 100%
  ) !important;
  border: none !important;
  border-radius: 50% !important;
  cursor: pointer !important;
  box-shadow: 0 6px 22px rgba(0, 0, 0, .55) !important;
  box-sizing: border-box !important;
  z-index: 2 !important;
}
/* DWA pulsujące ringi z opóźnieniem (::before + ::after) — bardziej wyrazista
   animacja "wave-out". transform na pseudo NIE koliduje z translate3d Pannellum
   (rodzic ma transform translate(-50%,-50%) translate3d(...), pseudo ma własny
   stacking context). */
.pnlm-hotspot::before,
.pnlm-hotspot::after {
  content: '' !important;
  position: absolute !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  border: 3px solid rgba(2, 213, 225, .95) !important;
  border-radius: 50% !important;
  pointer-events: none !important;
  will-change: transform, opacity;
  animation: sfdHotspotPulse 1.6s ease-out infinite;
}
.pnlm-hotspot::after {
  animation-delay: 0.8s;
}
@keyframes sfdHotspotPulse {
  0%   { transform: scale(0.85); opacity: 1;   }
  60%  { opacity: .35;                          }
  100% { transform: scale(2.4);  opacity: 0;   }
}
.pnlm-hotspot:hover {
  filter: brightness(1.15) saturate(1.2) !important;
}
/* Ukryj wewnętrzny tooltip Pannellum (text na hover w lewym dolnym rogu hotspotu).
   Pannellum tworzy <div class="pnlm-tooltip"><span>...</span></div> wewnątrz hotspotu
   (gdy hotspot ma `text`), albo bezpośrednio <span>/<a>. Ukrywamy WSZYSTKIE dzieci
   DOM — nasze ::before to pseudo-element, nie jest łapany przez `> *`. */
.pnlm-hotspot > * { display: none !important; }
/* Boczne / dolne info-boxy Pannellum (title, autor, panorama-info, loading bar) */
.pnlm-panorama-info,
.pnlm-title-box,
.pnlm-author-box,
.pnlm-load-box { display: none !important; }

/* ── Locate panel: viewer360 edge-to-edge bez nav-panela ── */
.sfd-panel-locate { min-height: 500px; width: 100%; }
.sfd-panel-locate .v360-outer { margin-top: 0; }
.sfd-panel-locate .v360-np-container,
.sfd-panel-locate #v360-navPanel { display: none !important; }
.sfd-panel-locate #v360-app {
  height: 70vh !important;
  min-height: 500px !important;
  border-radius: 10px !important;
  overflow: hidden !important;
}

@media (max-width: 768px) {
  .sfd-panel-location #map {
    height: 60vh !important;
    min-height: 400px !important;
  }
  .sfd-panel-locate { min-height: 400px; }
  .sfd-panel-locate #v360-app {
    height: 60vh !important;
    min-height: 400px !important;
  }
}

.sfd-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 16px;
  font-size: 13px;
  color: var(--sfd-muted) !important;
  text-decoration: none !important;
}
.sfd-back:hover { color: var(--sfd-accent) !important; }

/* ── Header (nad zakładkami) ── */
.sfd-header { display: flex; flex-direction: column; gap: 10px; margin-bottom: 26px; }
.sfd-header-row { display: flex; justify-content: space-between; gap: 20px; align-items: flex-start; }
.sfd-header-left { display: flex; flex-direction: column; gap: 4px; }
.sfd-title {
  font-size: 32px;
  font-weight: 800;
  margin: 0;
  color: var(--sfd-text);
  line-height: 1.1;
}
.sfd-status {
  font-size: 18px;
  font-weight: 600;
}
.sfd-status.is-free     { color: #008e5a; }
.sfd-status.is-reserved { color: #c46514; }
.sfd-status.is-sold     { color: #b21f1f; }

/* ── Stack akcji w prawej kolumnie headera (Karta / Historia / Prospekt + Viewers CTA) ── */
.sfd-actions-stack {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 8px;
  min-width: 240px;
}
.sfd-action-btn {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 11px 16px;
  border: 1px solid var(--sfd-border);
  border-radius: 8px;
  text-align: left;
  text-decoration: none !important;
  color: var(--sfd-text) !important;
  font-family: inherit;
  font-size: 14px;
  font-weight: 500;
  white-space: nowrap;
  background: #fff;
  cursor: pointer;
  transition: background .15s, border-color .15s, color .15s, transform .12s;
}
.sfd-action-btn:hover { background: var(--sfd-bg-soft); border-color: var(--sfd-accent); color: var(--sfd-accent) !important; }
.sfd-action-btn:active { transform: translateY(1px); }
.sfd-action-btn svg { width: 17px; height: 17px; flex-shrink: 0; }
.sfd-action-btn span { flex: 1; }
.sfd-action-history { color: var(--sfd-text) !important; }

/* ── Live viewers CTA ── */
.sfd-viewers {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  margin-top: 4px;
  background: linear-gradient(135deg, rgba(0, 142, 90, .08) 0%, rgba(2, 213, 225, .08) 100%);
  border: 1px solid rgba(0, 142, 90, .25);
  border-radius: 8px;
  font-size: 13px;
  line-height: 1.35;
  color: var(--sfd-text);
}
.sfd-viewers-dot {
  position: relative;
  width: 10px;
  height: 10px;
  flex-shrink: 0;
  background: #19c37d;
  border-radius: 50%;
  box-shadow: 0 0 0 0 rgba(25, 195, 125, .7);
  animation: sfdViewerDotPulse 1.6s ease-out infinite;
}
@keyframes sfdViewerDotPulse {
  0%   { box-shadow: 0 0 0 0 rgba(25, 195, 125, .7); }
  70%  { box-shadow: 0 0 0 12px rgba(25, 195, 125, 0); }
  100% { box-shadow: 0 0 0 0 rgba(25, 195, 125, 0); }
}
.sfd-viewers-text { display: inline-block; }
.sfd-viewers-count {
  font-weight: 700;
  color: #008e5a;
  font-size: 14px;
  display: inline-block;
  transition: transform .25s;
}
.sfd-viewers-count.is-bump { transform: scale(1.25); }
.sfd-viewers-suffix { color: var(--sfd-text); }

/* ── Modal: Historia cen (i ewentualne kolejne) ── */
.sfd-modal {
  position: fixed;
  inset: 0;
  z-index: 99999;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .22s ease;
}
.sfd-modal.is-open {
  opacity: 1;
  pointer-events: auto;
}
.sfd-modal[hidden] { display: none; }
.sfd-modal-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(15, 18, 35, .65);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  cursor: pointer;
}
.sfd-modal-window {
  position: relative;
  z-index: 1;
  background: #fff;
  border-radius: 14px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, .35);
  max-width: 720px;
  width: 100%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  transform: translateY(10px) scale(.98);
  transition: transform .25s ease;
}
.sfd-modal.is-open .sfd-modal-window { transform: translateY(0) scale(1); }
.sfd-modal-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--sfd-muted);
  cursor: pointer;
  border-radius: 8px;
  transition: background .15s, color .15s;
}
.sfd-modal-close:hover { background: var(--sfd-bg-soft); color: var(--sfd-text); }
.sfd-modal-close svg { width: 18px; height: 18px; }
.sfd-modal-title {
  margin: 0;
  padding: 22px 60px 12px 28px;
  font-size: 22px;
  font-weight: 700;
  color: var(--sfd-text);
}
.sfd-modal-body {
  padding: 6px 28px 28px;
  overflow: auto;
  flex: 1;
}
/* w modalu panel jest już otwarty, bez ramki/tła */
.sfd-modal-body .sfd-history-panel {
  display: block;
  margin: 0;
  padding: 0;
  background: transparent;
  border: none;
  border-radius: 0;
}
body.sfd-modal-locked { overflow: hidden; }

.sfd-area, .sfd-price { font-size: 18px; line-height: 1.4; margin: 0; color: var(--sfd-text); }
.sfd-area strong, .sfd-price strong {
  color: var(--sfd-accent);
  font-weight: 700;
}
.sfd-price-sqm { color: var(--sfd-text); font-weight: 400; }
.sfd-price-low { font-size: 13px; color: var(--sfd-muted); margin: 0; }
.sfd-price-low b { color: var(--sfd-text); font-weight: 600; }

/* Historia cen — komponenty wewnątrz modala. AJAX wraca <div class="container archiveList">
   gdzie globalna `.container` (Bootstrap-like) ma fixed-width i marginy — rozsadza modal.
   Resetujemy ją w obrębie modala plus stylizujemy nasz list of price rows. */
.sfd-history-panel { font-size: 14px; }
.sfd-history-loading,
.sfd-history-error { color: var(--sfd-muted); padding: 8px 0; }
.sfd-history-error { color: #b21f1f; }
/* Reset globalnego .container w obrębie modala */
.sfd-modal-body .container,
.sfd-history-panel .container,
.sfd-history-panel .archiveList {
  width: 100% !important;
  max-width: 100% !important;
  min-width: 0 !important;
  margin: 0 !important;
  padding: 0 !important;
  box-sizing: border-box !important;
}
/* Backend renderuje #backToFlat oraz duplikat <h3>Historia cen</h3>+<hr> — ukryj
   (modal ma już własny tytuł, a zamykanie idzie przez X/backdrop/Escape) */
.sfd-history-panel #backToFlat,
.sfd-history-panel .archiveList > h3,
.sfd-history-panel .archiveList > h3 + hr { display: none !important; }

/* Stylizacja wierszy cenowych */
.sfd-history-panel .price-row {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  padding: 14px 0;
  border-bottom: 1px solid var(--sfd-border);
  flex-wrap: wrap;
}
.sfd-history-panel .price-row:last-child { border-bottom: none; }
.sfd-history-panel .price-row .left { min-width: 0; flex: 1; }
.sfd-history-panel .price-row .amount {
  font-size: 18px;
  font-weight: 700;
  color: var(--sfd-text);
  margin-bottom: 4px;
  word-break: break-word;
}
.sfd-history-panel .price-row .dates {
  font-size: 13px;
  color: var(--sfd-muted);
}
.sfd-history-panel .price-row .right { flex-shrink: 0; }
.sfd-history-panel .trend {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 999px;
  white-space: nowrap;
}
.sfd-history-panel .trend.up   { background: rgba(178, 31, 31, .1);  color: #b21f1f; }
.sfd-history-panel .trend.down { background: rgba(0, 142, 90, .1);   color: #008e5a; }
.sfd-history-panel .trend.up::before   { content: '▲'; font-size: 10px; }
.sfd-history-panel .trend.down::before { content: '▼'; font-size: 10px; }

.sfd-cta-row { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 18px; }
.sfd-cta {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 22px;
  background: var(--sfd-accent);
  color: #fff !important;
  text-decoration: none !important;
  border: none;
  border-radius: 6px;
  font-family: inherit;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}
.sfd-cta:hover { background: #38393b; color: #fff !important; }
.sfd-cta svg { width: 18px; height: 18px; }

/* ── Plan tab content ── */
.sfd-plan {
  background: #fff;
  border: 1px solid var(--sfd-border);
  border-radius: 10px;
  padding: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 460px;
}
.sfd-plan img,
.sfd-plan svg,
.sfd-plan object { max-width: 100%; height: auto; display: block; }
.sfd-plan-empty {
  color: var(--sfd-muted);
  font-size: 14px;
  text-align: center;
  padding: 40px 20px;
}
.sfd-walls-info { font-size: 14px; color: var(--sfd-muted); margin-top: 14px; }
.sfd-walls-info span { color: #ff8c00; font-weight: 600; }

/* ── Rooms table (Lista pomieszczeń tab) ── */
.sfd-rooms-full {
  background: #fff;
  border: 1px solid var(--sfd-border);
  border-radius: 10px;
  overflow: hidden;
  width: 100%;
}
.sfd-rooms-head,
.sfd-rooms-row {
  display: grid;
  grid-template-columns: 1fr auto;
  padding: 14px 22px;
  font-size: 15px;
  border-bottom: 1px solid var(--sfd-border);
}
.sfd-rooms-row:last-child { border-bottom: none; }
.sfd-rooms-head {
  background: var(--sfd-accent);
  color: #fff;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .04em;
  font-size: 13px;
  border-bottom: 0;
}
.sfd-rooms-row span:first-child { color: var(--sfd-text); }
.sfd-rooms-row span:last-child  { color: var(--sfd-text); font-weight: 600; }

/* ── Placeholder panele ── */
.sfd-soon {
  padding: 80px 30px;
  text-align: center;
  color: var(--sfd-muted);
  background: var(--sfd-bg-soft);
  border-radius: 10px;
}
.sfd-soon-title { font-size: 18px; font-weight: 600; color: var(--sfd-text); margin: 0 0 8px; }

@media (max-width: 768px) {
  .sfd { padding: 20px 0 120px; }
  /* Mobile: container z paddingiem żeby treść nie kleiła się do krawędzi ekranu */
  .sfd-container { padding: 0 16px; }
  /* Zakładki jedna pod drugą */
  .sfd-tabs {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    flex-wrap: nowrap;
    width: 100%;
  }
  .sfd-tab {
    width: 100%;
    justify-content: flex-start;
    padding: 11px 14px;
    font-size: 14px;
  }
  .sfd-title { font-size: 24px; }
  .sfd-header-row { flex-direction: column; align-items: stretch; }
  .sfd-actions-stack { min-width: 0; width: 100%; }
  .sfd-action-btn { white-space: normal; }
  .sfd-viewers { font-size: 12px; padding: 9px 12px; }
  .sfd-area, .sfd-price { font-size: 16px; }
  .sfd-plan { min-height: 320px; padding: 16px; }
  /* Modal: na komórce mniejsze marginesy, większy max-height */
  .sfd-modal { padding: 12px; }
  .sfd-modal-window { max-height: 92vh; border-radius: 10px; }
  .sfd-modal-title { padding: 18px 50px 10px 18px; font-size: 18px; }
  .sfd-modal-body { padding: 4px 18px 22px; }
}
