/* ==============================================================================
   BPV-XR 4-in-1 Public Viewer System Styles (viewer.html, scan.html, vr.html)
   Tối ưu Spatial UI nút chạm lớn cho Kính AR/MR (Vision Pro, Quest Passthrough)
   & Điện thoại Android/iOS
   ============================================================================== */

body.viewer-body {
  margin: 0;
  padding: 0;
  overflow: hidden;
  width: 100vw;
  height: 100vh;
  background: #050912;
  user-select: none;
}

.viewer-canvas-wrap {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
}

.viewer-canvas-wrap model-viewer {
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 50% 40%, #152238 0%, #050912 85%);
  --poster-color: transparent;
}

/* Top White-label Header + Mode Switcher */
.viewer-topbar {
  position: fixed;
  top: 14px;
  left: 14px;
  right: 14px;
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  pointer-events: none;
}

.viewer-topbar > * {
  pointer-events: auto;
}

.viewer-brand-pill {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 8px 14px;
  border-radius: 16px;
  background: rgba(8, 13, 25, 0.82);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(var(--bpv-brand-rgb), 0.35);
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.45);
}

.viewer-brand-pill img {
  height: 30px;
  max-width: 110px;
  object-fit: contain;
  border-radius: 6px;
}

.viewer-model-meta {
  display: flex;
  flex-direction: column;
  line-height: 1.2;
}

.viewer-model-title {
  font-weight: 700;
  font-size: 0.92rem;
  color: #f8fafc;
}

.viewer-model-sub {
  font-size: 0.72rem;
  color: #94a3b8;
}

/* 3-Mode Quick Switcher Bar */
.mode-switcher {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 5px;
  border-radius: 16px;
  background: rgba(8, 13, 25, 0.86);
  backdrop-filter: blur(14px);
  -webkit-backdrop-filter: blur(14px);
  border: 1px solid rgba(148, 163, 184, 0.22);
  box-shadow: 0 8px 26px rgba(0, 0, 0, 0.45);
}

.mode-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 14px;
  border-radius: 11px;
  font-size: 0.82rem;
  font-weight: 600;
  color: #cbd5e1;
  transition: all 0.16s ease;
}

.mode-tab:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.08);
}

.mode-tab.active {
  background: linear-gradient(135deg, var(--bpv-brand), var(--bpv-accent));
  color: #ffffff;
  box-shadow: 0 4px 14px rgba(var(--bpv-brand-rgb), 0.35);
}

/* Loading Progress Bar (%) */
.viewer-progress-overlay {
  position: fixed;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  z-index: 45;
  width: min(340px, 86vw);
  padding: 20px 22px;
  border-radius: 18px;
  background: rgba(8, 13, 25, 0.92);
  border: 1px solid rgba(var(--bpv-brand-rgb), 0.4);
  text-align: center;
  box-shadow: 0 18px 48px rgba(0, 0, 0, 0.65);
  transition: opacity 0.28s ease;
}

.viewer-progress-overlay.hidden {
  opacity: 0;
  pointer-events: none;
}

/* Spatial UI Control Panel (Large Touch Targets for AR/MR Headsets) */
.spatial-dock {
  position: fixed;
  bottom: 18px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 40;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-wrap: wrap;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 22px;
  background: rgba(8, 13, 25, 0.86);
  backdrop-filter: blur(18px);
  -webkit-backdrop-filter: blur(18px);
  border: 1px solid rgba(148, 163, 184, 0.25);
  box-shadow: 0 14px 40px rgba(0, 0, 0, 0.55);
  max-width: calc(100vw - 24px);
}

.spatial-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 48px;
  min-width: 52px;
  padding: 10px 16px;
  border-radius: 14px;
  border: 1px solid rgba(148, 163, 184, 0.26);
  background: rgba(30, 41, 59, 0.72);
  color: #f8fafc;
  font-size: 0.86rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.16s ease;
}

.spatial-btn:hover {
  border-color: var(--bpv-brand);
  background: rgba(var(--bpv-brand-rgb), 0.18);
}

.spatial-btn.active {
  background: linear-gradient(135deg, var(--bpv-brand), var(--bpv-accent));
  border-color: transparent;
  color: #ffffff;
  box-shadow: 0 0 18px rgba(var(--bpv-brand-rgb), 0.45);
}

.spatial-btn.ar-cta {
  background: linear-gradient(135deg, #10b981, #06b6d4);
  border-color: transparent;
  color: #ffffff;
  font-weight: 700;
}

/* Measurement Overlay SVG + Banner */
.measure-svg-layer {
  position: fixed;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 25;
}

.measure-banner {
  position: fixed;
  top: 84px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 42;
  padding: 10px 18px;
  border-radius: 14px;
  background: rgba(6, 182, 212, 0.18);
  backdrop-filter: blur(12px);
  border: 1px solid var(--bpv-brand);
  color: #e0f2fe;
  font-size: 0.88rem;
  font-weight: 600;
  display: none;
  align-items: center;
  gap: 12px;
}

.measure-banner.show {
  display: inline-flex;
}

/* Hotspot Annotation Bubble inside <model-viewer> */
.mv-hotspot {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  border: 2.5px solid #ffffff;
  background: var(--bpv-brand);
  color: #ffffff;
  font-weight: 800;
  font-size: 12px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 16px rgba(var(--bpv-brand-rgb), 0.85);
}

.mv-hotspot-card {
  position: absolute;
  bottom: 36px;
  left: 50%;
  transform: translateX(-50%);
  width: 210px;
  padding: 10px 12px;
  border-radius: 12px;
  background: rgba(8, 13, 25, 0.94);
  border: 1px solid var(--border-brand);
  color: #f8fafc;
  text-align: left;
  font-size: 0.78rem;
  line-height: 1.4;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.18s ease;
}

.mv-hotspot:hover .mv-hotspot-card,
.mv-hotspot:focus .mv-hotspot-card,
.mv-hotspot.pinned .mv-hotspot-card {
  opacity: 1;
}

/* Password Protection Gate */
.password-gate {
  position: fixed;
  inset: 0;
  z-index: 120;
  background: rgba(4, 8, 16, 0.94);
  backdrop-filter: blur(16px);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.password-gate.open {
  display: flex;
}

/* Floating side panel for VR / Scan HUD */
.viewer-side-hud {
  position: fixed;
  right: 14px;
  top: 84px;
  z-index: 40;
  width: 260px;
  padding: 14px;
  border-radius: 16px;
  background: rgba(8, 13, 25, 0.86);
  backdrop-filter: blur(14px);
  border: 1px solid rgba(148, 163, 184, 0.24);
  display: flex;
  flex-direction: column;
  gap: 10px;
}

@media (max-width: 760px) {
  .viewer-topbar {
    top: 10px;
    left: 10px;
    right: 10px;
  }
  .mode-tab {
    padding: 8px 10px;
    font-size: 0.74rem;
  }
  .spatial-btn {
    min-height: 44px;
    padding: 8px 12px;
    font-size: 0.78rem;
  }
  .viewer-side-hud {
    top: auto;
    bottom: 92px;
    right: 10px;
    width: 225px;
  }
}
