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

/* ── LOADING OVERLAY ── */
#loading-overlay {
  position: fixed;
  inset: 0;
  z-index: 999;
  background: #1a1e2a;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.5s ease, visibility 0.5s ease;
}
#loading-overlay.hidden {
  opacity: 0;
  visibility: hidden;
  pointer-events: none;
}
.loading-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.6rem;
  padding: 2.4rem 2.8rem;
  background: rgba(42, 42, 42, 0.92);
  border: 1px solid rgba(78, 140, 225, 0.3);
  border-radius: 18px;
  box-shadow: 0 8px 40px rgba(0,0,0,0.6);
  min-width: 260px;
  max-width: 320px;
  text-align: center;
}
.loading-logo {
  width: 56px;
  height: 56px;
  object-fit: contain;
  border-radius: 10px;
  margin-bottom: 0.2rem;
}
.loading-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: #e0e0e0;
  letter-spacing: 0.04em;
}
.loading-subtitle {
  font-size: 0.8rem;
  color: rgba(224,224,224,0.5);
  letter-spacing: 0.03em;
  margin-bottom: 0.4rem;
}
.loading-bar-track {
  width: 100%;
  height: 4px;
  background: rgba(255,255,255,0.1);
  border-radius: 4px;
  overflow: hidden;
  margin: 0.3rem 0;
}
.loading-bar-fill {
  height: 100%;
  width: 0%;
  background: linear-gradient(90deg, #4e8ce1, #82bfff);
  border-radius: 4px;
  transition: width 0.25s ease;
}
.loading-status {
  font-size: 0.75rem;
  color: rgba(224,224,224,0.45);
  letter-spacing: 0.02em;
  min-height: 1.2em;
}
.loading-powered {
  margin-top: 0.8rem;
  font-size: 0.7rem;
  color: rgba(224,224,224,0.3);
  letter-spacing: 0.03em;
}
.loading-powered strong {
  color: #4e8ce1;
  font-weight: 600;
}

body {
  background: #ffffff;
  color: #1a1a1a;
  font-family: 'Segoe UI', sans-serif;
  overflow: hidden;
  height: 100dvh;
  display: flex;
  flex-direction: column;
}

/* ── VIEWER ── */
#spin-container {
  flex: 1;
  position: relative;
  overflow: hidden;
  cursor: grab;
  touch-action: none;
  user-select: none;
  -webkit-user-select: none;
}
#spin-container.dragging { cursor: grabbing; }

#spin-img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  display: block;
  pointer-events: none;
  will-change: transform;
  transform-origin: center center;
  filter: brightness(1.25);
  transition: opacity 0.16s ease;
}

#spin-img.floor-switching {
  opacity: 0.84;
}

#poly-canvas {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  will-change: transform;
  transform-origin: center center;
  z-index: 5;
}

/* ── FLOOR SELECTOR ── */
#floor-selector {
  position: absolute;
  top: 50%;
  left: 1rem;
  transform: translateY(-50%);
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
  z-index: 30;
  background: rgba(42, 42, 42, 0.92);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(78, 140, 225, 0.25);
  border-radius: 12px;
  padding: 0.4rem 0.3rem;
  max-height: calc(100vh - 8rem);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  scrollbar-width: none;
  box-shadow: 0 4px 24px rgba(0,0,0,0.45);
}
#floor-selector::-webkit-scrollbar { display: none; }
.floor-btn {
  background: transparent;
  border: none;
  color: rgba(224, 224, 224, 0.65);
  border-radius: 8px;
  padding: 0.55rem 1.1rem;
  min-height: 44px;
  font-size: 0.82rem;
  cursor: pointer;
  white-space: nowrap;
  flex-shrink: 0;
  transition: background 0.2s, color 0.2s;
  font-family: inherit;
  letter-spacing: 0.02em;
  -webkit-tap-highlight-color: transparent;
  text-align: center;
}
.floor-btn:hover { color: #e0e0e0; background: rgba(78, 140, 225, 0.15); }
.floor-btn.active {
  background: #4e8ce1;
  color: #fff;
  box-shadow: 0 2px 10px rgba(78, 140, 225, 0.4);
}

.floor-btn-special {
  border: 1px solid rgba(78, 140, 225, 0.45);
  color: #e0e0e0;
  background: rgba(78, 140, 225, 0.08);
}

.floor-btn-special:hover {
  background: rgba(78, 140, 225, 0.22);
}

/* ── PEDESTRIAN 360 INLINE VIEW ── */
.pedestrian-inline {
  position: absolute;
  inset: 0;
  z-index: 22;
  display: none;
  background: rgba(12, 18, 32, 0.92);
}

.pedestrian-inline.active {
  display: block;
}

.pedestrian-inline-title {
  height: 48px;
  display: flex;
  align-items: center;
  padding: 0 1rem;
  color: #e0e0e0;
  font-size: 0.95rem;
  letter-spacing: 0.02em;
  border-bottom: 1px solid rgba(78, 140, 225, 0.25);
  background: rgba(10, 14, 24, 0.55);
}

.pedestrian-inline-viewer {
  width: 100%;
  height: calc(100% - 48px);
}

/* ── COMPASS ── */
#compass {
  position: absolute;
  bottom: 1.2rem;
  right: 1.2rem;
  width: 72px;
  height: 72px;
  z-index: 30;
  pointer-events: none;
  filter: drop-shadow(0 2px 8px rgba(0,0,0,0.55));
}
#compass-svg {
  width: 100%;
  height: 100%;
}

/* ── BOTTOM BAR ── */
.bottom-bar {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(8px);
  gap: 1rem;
  z-index: 10;
}

/* Auto-spin toggle */
#spin-btn {
  background: rgba(255,255,255,0.1);
  border: 1px solid rgba(255,255,255,0.2);
  color: #fff;
  border-radius: 8px;
  padding: 0.6rem 1.4rem;
  min-height: 44px;
  font-size: 0.85rem;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.2s;
  -webkit-tap-highlight-color: transparent;
}
#spin-btn:hover { background: rgba(255,255,255,0.18); }
#spin-btn.active {
  background: rgba(78,140,225,0.2);
  border-color: #4e8ce1;
  color: #4e8ce1;
}

/* Frame counter */
.frame-counter { display: none; }

/* ── APARTMENT WIDGET ── */
.apt-widget {
  position: fixed;
  z-index: 100;
  min-width: 210px;
  background: rgba(12, 18, 32, 0.88);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(78, 140, 225, 0.45);
  border-radius: 14px;
  padding: 1.1rem 1.2rem 1rem;
  color: #fff;
  box-shadow: 0 8px 32px rgba(0,0,0,0.45);
  pointer-events: auto;
  transition: opacity 0.18s, transform 0.18s;
}
.apt-widget.hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.95);
}
.apt-widget-close {
  position: absolute;
  top: 0.55rem;
  right: 0.65rem;
  background: none;
  border: none;
  color: rgba(255,255,255,0.5);
  font-size: 0.9rem;
  cursor: pointer;
  line-height: 1;
  padding: 0.15rem 0.3rem;
  border-radius: 4px;
  transition: color 0.15s;
}
.apt-widget-close:hover { color: #fff; }
.apt-widget-name {
  font-size: 1rem;
  font-weight: 600;
  letter-spacing: 0.02em;
  margin-bottom: 0.25rem;
  padding-right: 1.4rem;
}
.apt-widget-surface {
  font-size: 0.82rem;
  color: rgba(255,255,255,0.65);
  margin-bottom: 0.85rem;
}
.apt-widget-actions {
  display: flex;
  flex-direction: column;
  gap: 0.45rem;
}
.apt-widget-btn {
  width: 100%;
  padding: 0.55rem 0.8rem;
  border-radius: 8px;
  border: 1px solid rgba(78,140,225,0.5);
  font-size: 0.82rem;
  font-family: inherit;
  cursor: pointer;
  transition: background 0.18s, border-color 0.18s;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
}
.apt-widget-btn--2d {
  background: rgba(78,140,225,0.18);
  color: #90bfff;
}
.apt-widget-btn--2d:hover {
  background: rgba(78,140,225,0.38);
  border-color: #4e8ce1;
  color: #fff;
}
.apt-widget-btn--3d {
  background: rgba(255,255,255,0.07);
  color: rgba(255,255,255,0.8);
}
.apt-widget-btn--3d:hover {
  background: rgba(255,255,255,0.15);
  border-color: rgba(255,255,255,0.4);
  color: #fff;
}
.apt-widget-btn--rt {
  background: rgba(255,215,0,0.12);
  color: #ffd700;
  border-color: rgba(255,215,0,0.45);
}
.apt-widget-btn--rt:hover {
  background: rgba(255,215,0,0.28);
  border-color: #ffd700;
  color: #fff;
}

/* ── VISITE 3D TEMPS RÉEL MODAL ── */
.visitert-frame {
  max-width: min(96vw, 1200px);
  width: 96vw;
  padding: 0.9rem 1rem 1rem;
}
.visitert-iframe {
  width: 100%;
  height: min(78vh, 700px);
  border: none;
  border-radius: 10px;
  display: block;
  background: #0d1b2a;
}

/* ── 2D PLAN MODAL ── */
.plan2d-modal {
  position: fixed;
  inset: 0;
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
}
.plan2d-modal.hidden {
  display: none;
}
.plan2d-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0,0,0,0.72);
  backdrop-filter: blur(4px);
  cursor: pointer;
}
.plan2d-frame {
  position: relative;
  z-index: 1;
  background: #1a1e2a;
  border: 1px solid rgba(78,140,225,0.35);
  border-radius: 16px;
  box-shadow: 0 12px 60px rgba(0,0,0,0.7);
  padding: 1.2rem;
  max-width: min(90vw, 820px);
  width: 100%;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}
.plan2d-close {
  position: absolute;
  top: 0.65rem;
  right: 0.75rem;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.18);
  border-radius: 50%;
  color: rgba(255,255,255,0.8);
  width: 32px;
  height: 32px;
  font-size: 0.85rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  line-height: 1;
}
.plan2d-close:hover {
  background: rgba(224,80,80,0.55);
  border-color: rgba(224,80,80,0.8);
  color: #fff;
}
.plan2d-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: rgba(255,255,255,0.75);
  letter-spacing: 0.03em;
  padding-right: 2rem;
}
.plan2d-img-wrap {
  width: 100%;
  max-height: 75vh;
  overflow: auto;
  border-radius: 10px;
  background: rgba(255,255,255,0.04);
  display: flex;
  align-items: center;
  justify-content: center;
}
.plan2d-img {
  max-width: 100%;
  max-height: 73vh;
  display: block;
  border-radius: 8px;
  object-fit: contain;
}

@media (max-width: 480px) {
  #floor-selector {
    position: fixed;
    top: auto;
    bottom: 1.2rem;
    left: 50%;
    transform: translateX(-50%);
    flex-direction: row;
    max-height: none;
    overflow-x: auto;
    overflow-y: hidden;
    padding: 0.35rem 0.5rem;
    gap: 0.15rem;
    border-radius: 30px;
    max-width: calc(100vw - 2rem);
    width: max-content;
    z-index: 200;
  }
  .floor-btn {
    padding: 0.5rem 0.85rem;
    min-height: 40px;
    font-size: 0.82rem;
  }
  #compass {
    bottom: auto;
    top: 1rem;
    right: 1rem;
  }
  #spin-btn { font-size: 0.8rem; padding: 0.55rem 1.1rem; }
  .apt-widget { min-width: 180px; }
}

/* ── CHATBOT ── */

/* Toggle button — sits above the compass */
#chatbot-toggle {
  position: fixed;
  bottom: calc(1.2rem + 72px + 0.85rem);
  right: 1.2rem;
  width: 52px;
  height: 52px;
  border-radius: 50%;
  background: #4e8ce1;
  border: none;
  color: #fff;
  cursor: pointer;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(78,140,225,0.55);
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
  -webkit-tap-highlight-color: transparent;
}
#chatbot-toggle:hover {
  background: #6aa3f0;
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(78,140,225,0.7);
}
#chatbot-toggle svg { width: 22px; height: 22px; }

.chatbot-toggle-badge {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 11px;
  height: 11px;
  background: #2ecc71;
  border-radius: 50%;
  border: 2px solid #1a1e2a;
}

/* Panel */
.chatbot-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 340px;
  max-width: 100vw;
  height: 100dvh;
  background: rgba(10, 14, 26, 0.97);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-left: 1px solid rgba(78, 140, 225, 0.3);
  z-index: 400;
  display: flex;
  flex-direction: column;
  transform: translateX(100%);
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: -8px 0 40px rgba(0,0,0,0.55);
}
.chatbot-panel.chatbot-open {
  transform: translateX(0);
}

/* Header */
.chatbot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.9rem 1rem 0.8rem;
  border-bottom: 1px solid rgba(78,140,225,0.2);
  flex-shrink: 0;
}
.chatbot-header-info {
  display: flex;
  align-items: center;
  gap: 0.65rem;
}
.chatbot-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(78,140,225,0.18);
  border: 1px solid rgba(78,140,225,0.45);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #4e8ce1;
  flex-shrink: 0;
}
.chatbot-avatar svg { width: 20px; height: 20px; }
.chatbot-title {
  font-size: 0.88rem;
  font-weight: 600;
  color: #e0e0e0;
  letter-spacing: 0.02em;
}
.chatbot-status {
  font-size: 0.7rem;
  color: #2ecc71;
  letter-spacing: 0.02em;
  margin-top: 0.1rem;
}
.chatbot-close-btn {
  background: rgba(255,255,255,0.07);
  border: 1px solid rgba(255,255,255,0.14);
  border-radius: 50%;
  color: rgba(255,255,255,0.65);
  width: 30px;
  height: 30px;
  font-size: 0.78rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s, color 0.15s;
  flex-shrink: 0;
  line-height: 1;
}
.chatbot-close-btn:hover {
  background: rgba(224,80,80,0.5);
  border-color: rgba(224,80,80,0.7);
  color: #fff;
}

/* Messages */
.chatbot-messages {
  flex: 1;
  overflow-y: auto;
  padding: 0.9rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  scrollbar-width: thin;
  scrollbar-color: rgba(78,140,225,0.3) transparent;
}
.chatbot-messages::-webkit-scrollbar { width: 4px; }
.chatbot-messages::-webkit-scrollbar-track { background: transparent; }
.chatbot-messages::-webkit-scrollbar-thumb { background: rgba(78,140,225,0.3); border-radius: 4px; }

.chat-msg {
  display: flex;
  flex-direction: column;
  max-width: 88%;
  gap: 0.18rem;
}
.chat-msg.user { align-self: flex-end; align-items: flex-end; }
.chat-msg.bot  { align-self: flex-start; align-items: flex-start; }

.chat-bubble {
  padding: 0.58rem 0.82rem;
  border-radius: 14px;
  font-size: 0.82rem;
  line-height: 1.55;
  word-break: break-word;
}
.chat-msg.user .chat-bubble {
  background: #4e8ce1;
  color: #fff;
  border-bottom-right-radius: 4px;
}
.chat-msg.bot .chat-bubble {
  background: rgba(38, 45, 66, 0.95);
  border: 1px solid rgba(78,140,225,0.2);
  color: #cdd8f0;
  border-bottom-left-radius: 4px;
}
.chat-time {
  font-size: 0.63rem;
  color: rgba(255,255,255,0.26);
  padding: 0 0.2rem;
}

/* Apartment cards inside chat */
.chat-apt-cards { display: flex; flex-direction: column; gap: 0.5rem; margin-top: 0.35rem; }
.chat-apt-card {
  background: rgba(16, 22, 42, 0.96);
  border: 1px solid rgba(78,140,225,0.32);
  border-radius: 10px;
  padding: 0.6rem 0.75rem 0.55rem;
}
.chat-apt-id {
  font-size: 0.82rem;
  font-weight: 700;
  color: #6aaeff;
  margin-bottom: 0.15rem;
  letter-spacing: 0.03em;
}
.chat-apt-detail {
  font-size: 0.74rem;
  color: rgba(190, 205, 235, 0.82);
  line-height: 1.65;
}
.chat-apt-status {
  display: inline-block;
  font-size: 0.67rem;
  font-weight: 600;
  padding: 0.08rem 0.45rem;
  border-radius: 20px;
  margin-top: 0.28rem;
  letter-spacing: 0.05em;
  text-transform: uppercase;
}
.status-available { background: rgba(46,204,113,0.15); color: #2ecc71; border: 1px solid rgba(46,204,113,0.3); }
.status-reserved  { background: rgba(241,196,15,0.15);  color: #f1c40f; border: 1px solid rgba(241,196,15,0.3); }
.status-sold      { background: rgba(231,76,60,0.15);   color: #e74c3c; border: 1px solid rgba(231,76,60,0.3); }

/* Typing indicator */
.chat-typing {
  display: flex;
  gap: 5px;
  padding: 0.58rem 0.82rem;
  align-items: center;
}
.chat-typing span {
  width: 7px;
  height: 7px;
  background: rgba(78,140,225,0.75);
  border-radius: 50%;
  animation: chatbotBounce 1.2s infinite;
}
.chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.chat-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes chatbotBounce {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.55; }
  30%            { transform: translateY(-5px); opacity: 1; }
}

/* Quick-reply chips */
.chatbot-suggestions {
  padding: 0.5rem 0.8rem 0.45rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.38rem;
  border-top: 1px solid rgba(78,140,225,0.15);
  flex-shrink: 0;
}
.chatbot-chip {
  background: rgba(78,140,225,0.1);
  border: 1px solid rgba(78,140,225,0.32);
  color: #90bfff;
  border-radius: 20px;
  padding: 0.28rem 0.72rem;
  font-size: 0.74rem;
  cursor: pointer;
  transition: background 0.18s, color 0.18s;
  white-space: nowrap;
  -webkit-tap-highlight-color: transparent;
  font-family: inherit;
}
.chatbot-chip:hover {
  background: rgba(78,140,225,0.26);
  color: #fff;
}

/* Input row */
.chatbot-input-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.7rem 0.9rem;
  border-top: 1px solid rgba(78,140,225,0.18);
  flex-shrink: 0;
}
.chatbot-input {
  flex: 1;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(78,140,225,0.28);
  border-radius: 22px;
  color: #e0e0e0;
  font-size: 0.82rem;
  padding: 0.52rem 1rem;
  outline: none;
  font-family: inherit;
  transition: border-color 0.18s;
}
.chatbot-input::placeholder { color: rgba(224,224,224,0.28); }
.chatbot-input:focus { border-color: #4e8ce1; }

.chatbot-send-btn {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: #4e8ce1;
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.18s, transform 0.15s;
  -webkit-tap-highlight-color: transparent;
}
.chatbot-send-btn:hover { background: #6aa3f0; transform: scale(1.08); }
.chatbot-send-btn svg  { width: 17px; height: 17px; }

@media (max-width: 480px) {
  .chatbot-panel { width: 100vw; }
  #chatbot-toggle {
    bottom: calc(1.2rem + 40px + 3rem);
    right: 1rem;
    width: 46px;
    height: 46px;
  }
}
