/* ============================================================================
   DRONE 3D POINT-CLOUD VIEWER — ANONYMIZED DEMO STYLESHEET
   Esthétique Glassmorphism Dark + Mode Plein Soleil & Embed WordPress
   ============================================================================ */

:root {
  --bg-canvas: #090D16;
  --panel-bg: rgba(15, 23, 42, 0.88);
  --panel-bg-solid: #0F172A;
  --panel-surface: rgba(30, 41, 59, 0.85);
  --panel-surface-hover: rgba(51, 65, 85, 0.95);
  --panel-border: rgba(148, 163, 184, 0.26);
  --text-main: #F8FAFC;
  --text-secondary: #CBD5E1;
  --text-muted: #94A3B8;
  --accent: #6366F1;
  --accent-strong: #4F46E5;
  --accent-light: #A5B4FC;
  --accent-glow: rgba(99, 102, 241, 0.45);
  --teal: #14B8A6;
  --amber: #F59E0B;
  --focus-ring: #38BDF8;
  --badge-bg: rgba(15, 23, 42, 0.92);
  --shadow-lg: 0 10px 32px -4px rgba(0, 0, 0, 0.6);
  --radius-lg: 16px;
  --radius-md: 12px;
  --radius-sm: 8px;
  --safe-top: env(safe-area-inset-top, 0px);
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  --safe-left: env(safe-area-inset-left, 0px);
  --safe-right: env(safe-area-inset-right, 0px);
}

[data-theme="light"] {
  --bg-canvas: #E2E8F0;
  --panel-bg: rgba(255, 255, 255, 0.94);
  --panel-bg-solid: #FFFFFF;
  --panel-surface: #F1F5F9;
  --panel-surface-hover: #E2E8F0;
  --panel-border: rgba(71, 85, 105, 0.30);
  --text-main: #0F172A;
  --text-secondary: #1E293B;
  --text-muted: #475569;
  --accent: #4338CA;
  --accent-strong: #3730A3;
  --accent-light: #312E81;
  --accent-glow: rgba(67, 56, 202, 0.25);
  --teal: #0D9488;
  --amber: #D97706;
  --focus-ring: #0284C7;
  --badge-bg: rgba(255, 255, 255, 0.95);
  --shadow-lg: 0 8px 28px -4px rgba(15, 23, 42, 0.18);
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-tap-highlight-color: transparent;
}

html, body {
  width: 100vw;
  height: 100vh;
  height: 100dvh;
  overflow: hidden;
  background-color: var(--bg-canvas);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--text-main);
  font-size: 14px;
  line-height: 1.45;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

:focus-visible {
  outline: 2.5px solid var(--focus-ring) !important;
  outline-offset: 2px !important;
}

.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}

/* ============================================================================
   1. CANEVAS WEBGL
   ============================================================================ */
#webgl-canvas {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  z-index: 1;
  touch-action: none;
  cursor: grab;
}

#webgl-canvas:active {
  cursor: grabbing;
}

html.measure-active #webgl-canvas {
  cursor: crosshair;
}

#webgl-canvas canvas {
  display: block;
  width: 100%;
  height: 100%;
}

.glass-panel {
  background: var(--panel-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
}

/* ============================================================================
   2. BARRE SUPÉRIEURE
   ============================================================================ */
.top-bar {
  position: absolute;
  top: calc(10px + var(--safe-top));
  left: calc(12px + var(--safe-left));
  right: calc(12px + var(--safe-right));
  min-height: 54px;
  padding: 6px 10px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  z-index: 30;
}

.brand-badge {
  display: flex;
  align-items: center;
  gap: 9px;
  min-width: 0;
  flex: 1;
}

.brand-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--teal);
  box-shadow: 0 0 10px var(--teal);
  flex-shrink: 0;
}

.header-summary {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.header-title {
  font-family: 'Outfit', sans-serif;
  font-size: 15px;
  font-weight: 700;
  color: var(--text-main);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-subtitle {
  font-size: 11.5px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.header-metrics {
  display: none;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

.metric-pill {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}

.metric-val {
  font-family: 'Outfit', sans-serif;
  font-size: 13.5px;
  font-weight: 700;
  color: var(--accent-light);
}

.metric-label {
  font-size: 10px;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.4px;
}

.top-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.icon-btn, .fullscreen-link {
  appearance: none;
  background: var(--panel-surface);
  border: 1px solid var(--panel-border);
  color: var(--text-main);
  min-width: 40px;
  min-height: 40px;
  padding: 0 11px;
  border-radius: 10px;
  font-size: 12.5px;
  font-weight: 600;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  text-decoration: none;
  transition: background 0.2s, border-color 0.2s, transform 0.15s;
}

.icon-btn:hover, .fullscreen-link:hover {
  background: var(--panel-surface-hover);
}

.icon-btn[aria-expanded="true"],
.icon-btn[aria-pressed="true"] {
  background: var(--accent);
  color: #FFFFFF;
  border-color: var(--accent-light);
}

.fullscreen-link {
  display: none;
  background: var(--accent);
  color: #FFFFFF;
  border-color: var(--accent-light);
  box-shadow: 0 2px 10px var(--accent-glow);
}

.fullscreen-link:hover {
  background: var(--accent-strong);
}

html[data-embed="1"] .fullscreen-link {
  display: inline-flex;
}

html[data-embed="1"] .top-bar {
  min-height: 46px;
  padding: 4px 8px;
}

html[data-embed="1"] .header-subtitle {
  display: none;
}

/* Boussole dynamique */
.compass-btn {
  position: relative;
  width: 40px;
  height: 40px;
  padding: 0;
  border-radius: 50%;
  background: var(--panel-surface);
  border: 1.5px solid var(--panel-border);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.compass-dial {
  position: relative;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
}

.compass-n {
  position: absolute;
  top: -1px;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Outfit', sans-serif;
  font-size: 9px;
  font-weight: 800;
  color: #EF4444;
}

.compass-s {
  position: absolute;
  bottom: -1px;
  left: 50%;
  transform: translateX(-50%);
  font-family: 'Outfit', sans-serif;
  font-size: 8px;
  font-weight: 700;
  color: #38BDF8;
}

.compass-needle {
  width: 7px;
  height: 18px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.needle-n {
  width: 0; height: 0;
  border-left: 3px solid transparent;
  border-right: 3px solid transparent;
  border-bottom: 8px solid #EF4444;
}

.needle-s {
  width: 0; height: 0;
  border-left: 3px solid transparent;
  border-right: 3px solid transparent;
  border-top: 8px solid #64748B;
}

/* ============================================================================
   3. STATUT DE STREAMING PROGRESSIF & MESURE 3D
   ============================================================================ */
.status-hud {
  position: absolute;
  top: calc(70px + var(--safe-top));
  left: calc(12px + var(--safe-left));
  z-index: 24;
  display: flex;
  flex-direction: column;
  gap: 6px;
  pointer-events: none;
  max-width: calc(100vw - 24px);
}

html[data-embed="1"] .status-hud {
  top: calc(60px + var(--safe-top));
}

.stream-pill {
  pointer-events: auto;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  border-radius: 99px;
  font-size: 12px;
  font-weight: 600;
  color: var(--text-secondary);
}

.stream-spinner {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  border: 2px solid var(--accent-light);
  border-top-color: transparent;
  animation: spin 0.8s linear infinite;
}

.stream-pill.ready .stream-spinner {
  animation: none;
  border: none;
  background: var(--teal);
  width: 8px;
  height: 8px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.measure-hud {
  pointer-events: auto;
  display: none;
  flex-direction: column;
  gap: 6px;
  padding: 10px 12px;
  border-radius: var(--radius-md);
  min-width: 220px;
}

.measure-hud.visible {
  display: flex;
}

.measure-hud-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  font-family: 'Outfit', sans-serif;
  font-size: 12.5px;
  font-weight: 700;
  color: var(--text-main);
}

.measure-hint {
  font-size: 11.5px;
  color: var(--text-muted);
}

.measure-values {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.measure-cell {
  background: var(--panel-surface);
  border: 1px solid var(--panel-border);
  border-radius: 8px;
  padding: 5px 7px;
  display: flex;
  flex-direction: column;
}

.measure-cell span {
  font-size: 10px;
  color: var(--text-muted);
}

.measure-cell strong {
  font-family: 'Outfit', sans-serif;
  font-size: 13px;
  color: var(--accent-light);
}

.btn-mini {
  appearance: none;
  background: var(--panel-surface);
  border: 1px solid var(--panel-border);
  color: var(--text-main);
  padding: 3px 8px;
  border-radius: 6px;
  font-size: 11px;
  font-weight: 600;
  cursor: pointer;
}

.btn-mini:hover {
  background: var(--panel-surface-hover);
}

/* ============================================================================
   4. DOCK DE NAVIGATION INFÉRIEUR
   ============================================================================ */
.bottom-dock {
  position: absolute;
  bottom: calc(10px + var(--safe-bottom));
  left: calc(10px + var(--safe-left));
  right: calc(10px + var(--safe-right));
  z-index: 25;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  pointer-events: none;
}

.quick-tools-bar, .presets-carousel {
  pointer-events: auto;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 5px 8px;
  max-width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
}

.quick-tools-bar::-webkit-scrollbar,
.presets-carousel::-webkit-scrollbar {
  display: none;
}

.tool-pill, .preset-pill {
  appearance: none;
  background: var(--panel-surface);
  border: 1px solid var(--panel-border);
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
  min-height: 38px;
  padding: 0 11px;
  border-radius: 10px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  white-space: nowrap;
  transition: all 0.2s ease;
}

.tool-pill:hover, .preset-pill:hover {
  background: var(--panel-surface-hover);
  color: var(--text-main);
}

.tool-pill[aria-pressed="true"],
.tool-pill[aria-expanded="true"],
.preset-pill.active {
  background: var(--accent);
  color: #FFFFFF;
  border-color: var(--accent-light);
  box-shadow: 0 2px 12px var(--accent-glow);
}

.tool-pill.measure-on[aria-pressed="true"] {
  background: #0D9488;
  border-color: #2DD4BF;
  box-shadow: 0 2px 12px rgba(13, 148, 136, 0.45);
}

/* ============================================================================
   5. TIROIR CONTRÔLES / CALQUES / CLIPPING / QUALITÉ
   ============================================================================ */
.sheet-panel {
  position: absolute;
  z-index: 40;
  left: 10px;
  right: 10px;
  bottom: 0;
  max-height: 76vh;
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
  transform: translateY(110%);
  transition: transform 0.28s cubic-bezier(0.22, 1, 0.36, 1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  pointer-events: none;
}

.sheet-panel.open {
  transform: translateY(0);
  pointer-events: auto;
}

.sheet-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 14px 8px;
  border-bottom: 1px solid var(--panel-border);
}

.sheet-header h2 {
  font-family: 'Outfit', sans-serif;
  font-size: 15px;
  font-weight: 700;
}

.sheet-close-btn {
  appearance: none;
  width: 34px;
  height: 34px;
  border-radius: 8px;
  border: 1px solid var(--panel-border);
  background: var(--panel-surface);
  color: var(--text-main);
  cursor: pointer;
  font-weight: 700;
}

.sheet-body {
  padding: 12px 14px 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.section-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.section-title {
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 12px;
  font-weight: 700;
  color: var(--text-secondary);
}

.segmented-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}

.seg-btn {
  appearance: none;
  background: var(--panel-surface);
  border: 1px solid var(--panel-border);
  color: var(--text-secondary);
  font-size: 11.5px;
  font-weight: 600;
  min-height: 36px;
  padding: 4px 6px;
  border-radius: 9px;
  cursor: pointer;
  text-align: center;
  transition: all 0.18s;
}

.seg-btn.active {
  background: var(--accent);
  color: #FFFFFF;
  border-color: var(--accent-light);
}

.slider-row {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.slider-meta {
  display: flex;
  justify-content: space-between;
  font-size: 11.5px;
  color: var(--text-muted);
}

.slider-meta strong {
  color: var(--accent-light);
}

.range-slider {
  width: 100%;
  accent-color: var(--accent);
  cursor: pointer;
}

.toggle-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.toggle-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 7px 10px;
  border-radius: 10px;
  background: var(--panel-surface);
  border: 1px solid var(--panel-border);
  font-size: 12.5px;
  font-weight: 500;
  cursor: pointer;
}

.toggle-row.disabled {
  opacity: 0.55;
}

.sr-only-input {
  position: absolute;
  opacity: 0;
  width: 1px;
  height: 1px;
  pointer-events: none;
}

.toggle-switch {
  position: relative;
  width: 42px;
  height: 22px;
  background: #475569;
  border-radius: 99px;
  transition: background 0.22s ease;
  flex-shrink: 0;
}

.toggle-switch::after {
  content: '';
  position: absolute;
  top: 2px;
  left: 2px;
  width: 18px;
  height: 18px;
  background: #FFFFFF;
  border-radius: 50%;
  transition: transform 0.22s ease;
}

.sr-only-input:checked + .toggle-switch {
  background: var(--accent);
}

.sr-only-input:checked + .toggle-switch::after {
  transform: translateX(20px);
}

/* ============================================================================
   6. REPÈRES POI 3D
   ============================================================================ */
#markersContainer {
  position: absolute;
  inset: 0;
  pointer-events: none;
  z-index: 15;
  overflow: hidden;
}

.poi-pin {
  position: absolute;
  appearance: none;
  background: var(--badge-bg);
  border: 1.5px solid var(--accent-light);
  border-radius: 99px;
  padding: 4px 10px 4px 6px;
  font-size: 11.5px;
  font-weight: 700;
  color: var(--text-main);
  pointer-events: auto;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.5);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transform: translate(-50%, -100%);
  white-space: nowrap;
  transition: transform 0.16s ease, background 0.16s ease;
}

.poi-pin:hover {
  background: var(--accent);
  color: #FFFFFF;
  border-color: #FFFFFF;
  transform: translate(-50%, -100%) scale(1.06);
  z-index: 20;
}

.poi-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--teal);
  flex-shrink: 0;
}

/* Toast */
.toast-banner {
  position: absolute;
  top: calc(70px + var(--safe-top));
  left: 50%;
  transform: translateX(-50%) translateY(-10px);
  z-index: 50;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  color: var(--text-main);
  padding: 6px 14px;
  border-radius: 99px;
  font-size: 12.5px;
  font-weight: 600;
  box-shadow: var(--shadow-lg);
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.25s ease, transform 0.25s ease;
  white-space: nowrap;
}

.toast-banner.visible {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Desktop adaptation */
@media (min-width: 768px) {
  .header-metrics {
    display: flex;
  }

  .sheet-panel {
    left: auto;
    right: calc(12px + var(--safe-right));
    top: calc(74px + var(--safe-top));
    bottom: auto;
    width: 340px;
    max-height: calc(100dvh - 180px);
    border-radius: var(--radius-lg);
    transform: translateX(115%);
  }

  .sheet-panel.open {
    transform: translateX(0);
  }

  html[data-embed="1"] .sheet-panel {
    top: calc(60px + var(--safe-top));
  }
}

@media (max-width: 640px) {
  .header-subtitle {
    display: none;
  }
}
