/* ==========================================================================
   Diff PLU — Comparateur Haute Résolution
   Styles CSS épurés, réactifs et optimisés GPU
   ========================================================================== */

:root {
  --bg-color: #0b0f19;
  --panel-bg: rgba(15, 23, 42, 0.90);
  --panel-border: rgba(255, 255, 255, 0.14);
  --text-main: #f8fafc;
  --text-muted: #94a3b8;
  --accent-color: #38bdf8;
  --accent-hover: #0284c7;
  --badge-old: #f59e0b;
  --badge-new: #10b981;
  --handle-shadow: 0 4px 20px rgba(0, 0, 0, 0.5), 0 0 10px rgba(56, 189, 248, 0.6);
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 14px;
  --radius-full: 9999px;
  --transition-fast: 0.15s ease;
}

*, *::before, *::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  -webkit-font-smoothing: antialiased;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: var(--bg-color);
  color: var(--text-main);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  user-select: none;
  -webkit-user-select: none;
  touch-action: none;
}

/* ==========================================================================
   Viewport & Stages
   ========================================================================== */

.viewport {
  position: relative;
  width: 100vw;
  height: 100vh;
  overflow: hidden;
  background-color: var(--bg-color);
  cursor: grab;
}

.viewport.is-dragging {
  cursor: grabbing;
}

.viewport.is-sliding {
  cursor: ew-resize;
}

.stage {
  position: absolute;
  top: 0;
  left: 0;
  width: 2302px;
  height: 3246px;
  transform-origin: 0 0;
  will-change: transform;
  pointer-events: none;
}

.stage img {
  display: block;
  width: 100%;
  height: 100%;
  image-rendering: auto;
  pointer-events: none;
}

/* Calque supérieur découpé */
.clipped-wrapper {
  position: absolute;
  top: 0;
  left: 0;
  bottom: 0;
  width: 50%;
  overflow: hidden;
  z-index: 2;
  pointer-events: none;
  will-change: width, opacity;
  transition: opacity 0.08s ease;
}

.blink-hide-old .clipped-wrapper {
  opacity: 0 !important;
}

/* ==========================================================================
   Rideau vertical (Split line & Handle)
   ========================================================================== */

.split-line {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  background: rgba(255, 255, 255, 0.9);
  box-shadow: 0 0 12px rgba(56, 189, 248, 0.8), 0 0 2px rgba(0, 0, 0, 0.5);
  z-index: 10;
  pointer-events: none;
  transform: translateX(-50%);
}

.split-handle {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: #ffffff;
  color: #0f172a;
  box-shadow: var(--handle-shadow);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: ew-resize;
  pointer-events: auto;
  transition: transform var(--transition-fast), box-shadow var(--transition-fast);
}

.split-handle:hover,
.split-handle:active {
  transform: translate(-50%, -50%) scale(1.12);
  box-shadow: 0 6px 24px rgba(0, 0, 0, 0.7), 0 0 16px rgba(56, 189, 248, 0.9);
}

.handle-icon {
  pointer-events: none;
}

.handle-grip {
  width: 2px;
  height: 16px;
  background: #cbd5e1;
  margin: 0 2px;
  border-radius: 1px;
}

.split-line::before {
  content: "";
  position: absolute;
  top: 0;
  bottom: 0;
  left: -24px;
  right: -24px;
  pointer-events: auto;
  cursor: ew-resize;
}

/* ==========================================================================
   Badges flottants (PLU PADD / PLU 2026)
   ========================================================================== */

.plu-badge {
  position: absolute;
  top: 20px;
  z-index: 20;
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 14px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: var(--radius-md);
  font-size: 13px;
  font-weight: 600;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.35);
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.badge-left {
  left: 20px;
}

.badge-right {
  right: 20px;
}

.badge-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
}

.dot-old {
  background-color: var(--badge-old);
  box-shadow: 0 0 8px var(--badge-old);
}

.dot-new {
  background-color: var(--badge-new);
  box-shadow: 0 0 8px var(--badge-new);
}

.badge-tag {
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  opacity: 0.75;
  padding: 2px 6px;
  border-radius: 4px;
  background: rgba(255, 255, 255, 0.08);
}

.badges-hidden .plu-badge {
  opacity: 0;
  transform: translateY(-10px);
}

/* ==========================================================================
   Indicateur Zoom & Infos
   ========================================================================== */

.info-overlay {
  position: absolute;
  top: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 20;
  padding: 6px 16px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 500;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.25);
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.info-overlay span {
  color: var(--text-main);
}

.info-sep {
  opacity: 0.4;
}

.res-badge {
  color: var(--accent-color) !important;
  font-weight: 600;
  transition: color 0.3s ease;
}

.res-badge.is-loading {
  color: #f59e0b !important;
  animation: pulse-res 1.4s ease-in-out infinite;
}

.res-badge.is-ultrahd {
  color: #10b981 !important;
}

@keyframes pulse-res {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.5; }
}

/* ==========================================================================
   Fenêtre Flottante Déplaçable & Redimensionnable (Drag & Drop + Resize)
   ========================================================================== */

.floating-window {
  position: absolute;
  width: 330px;
  height: 520px;
  min-width: 250px;
  min-height: 180px;
  max-width: 94vw;
  max-height: 90vh;
  background: rgba(15, 23, 42, 0.94);
  border: 1px solid rgba(255, 255, 255, 0.18);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: var(--radius-lg);
  box-shadow: 0 16px 40px rgba(0, 0, 0, 0.65), 0 0 16px rgba(56, 189, 248, 0.25);
  z-index: 45;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  resize: both;
  transition: opacity 0.2s ease, transform 0.2s ease;
}

.floating-window.is-collapsed {
  height: auto !important;
  min-height: unset;
  resize: none !important;
  width: 240px !important;
}

.floating-window.is-collapsed .floating-body,
.floating-window.is-collapsed .resize-handle {
  display: none !important;
}

.floating-window.hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.95);
}

.floating-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 10px 14px;
  background: rgba(30, 41, 59, 0.85);
  border-bottom: 1px solid rgba(255, 255, 255, 0.10);
  cursor: grab;
  user-select: none;
  flex-shrink: 0;
}

.floating-header:active {
  cursor: grabbing;
}

.floating-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-main);
  pointer-events: none;
}

.floating-title svg {
  color: var(--accent-color);
}

.floating-controls {
  display: flex;
  align-items: center;
  gap: 3px;
}

.win-zoom-val {
  font-size: 11px;
  font-weight: 700;
  color: var(--accent-color);
  min-width: 36px;
  text-align: center;
  user-select: none;
}

.win-sep {
  width: 1px;
  height: 14px;
  background: rgba(255, 255, 255, 0.15);
  margin: 0 4px;
}

.win-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  width: 26px;
  height: 26px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  outline: none;
  transition: background-color var(--transition-fast), color var(--transition-fast);
}

.win-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
}

.win-btn:active {
  transform: scale(0.92);
}

/* Corps déroulant avec barre de défilement verticale visible */
.floating-body {
  flex: 1 1 auto;
  min-height: 0;
  padding: 10px;
  overflow-y: auto;
  overflow-x: auto;
  scrollbar-width: thin;
  scrollbar-color: rgba(56, 189, 248, 0.5) rgba(15, 23, 42, 0.5);
}

.floating-body::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

.floating-body::-webkit-scrollbar-track {
  background: rgba(15, 23, 42, 0.6);
  border-radius: 4px;
}

.floating-body::-webkit-scrollbar-thumb {
  background: rgba(56, 189, 248, 0.5);
  border-radius: 4px;
}

.floating-body::-webkit-scrollbar-thumb:hover {
  background: rgba(56, 189, 248, 0.85);
}

.legend-scroll-container {
  background: #ffffff;
  border-radius: var(--radius-sm);
  padding: 10px;
  box-shadow: inset 0 0 6px rgba(0, 0, 0, 0.2);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  min-height: 100%;
}

.legend-img {
  display: block;
  width: 100%;
  max-width: none;
  height: auto;
  pointer-events: none;
  transition: width 0.15s ease;
}

/* Poignée tactile de redimensionnement */
.resize-handle {
  position: absolute;
  right: 2px;
  bottom: 2px;
  width: 22px;
  height: 22px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  cursor: nwse-resize;
  z-index: 10;
  pointer-events: auto;
  touch-action: none;
  transition: color var(--transition-fast), transform var(--transition-fast);
}

.resize-handle:hover,
.resize-handle:active {
  color: var(--accent-color);
  transform: scale(1.15);
}

/* ==========================================================================
   Barre d'outils flottante (Toolbar)
   ========================================================================== */

.toolbar {
  position: absolute;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 30;
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--panel-bg);
  border: 1px solid var(--panel-border);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-radius: var(--radius-full);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
  transition: opacity 0.25s ease, transform 0.25s ease;
}

.btn-tool {
  background: transparent;
  border: none;
  color: var(--text-main);
  width: 38px;
  height: 38px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  outline: none;
  transition: background-color var(--transition-fast), color var(--transition-fast), transform var(--transition-fast);
}

.btn-tool:hover {
  background: rgba(255, 255, 255, 0.12);
  color: var(--accent-color);
  transform: translateY(-2px);
}

.btn-tool:active {
  transform: translateY(0) scale(0.94);
}

.btn-tool.active {
  background: rgba(56, 189, 248, 0.2);
  color: var(--accent-color);
  border: 1px solid rgba(56, 189, 248, 0.4);
}

.btn-text {
  width: auto;
  padding: 0 10px;
  border-radius: var(--radius-full);
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 0.5px;
}

.toolbar-sep {
  width: 1px;
  height: 20px;
  background: rgba(255, 255, 255, 0.15);
  margin: 0 2px;
}

.hud-hidden .toolbar,
.hud-hidden .info-overlay,
.hud-hidden .plu-badge,
.hud-hidden .floating-window {
  opacity: 0;
  pointer-events: none;
}

/* ==========================================================================
   Loader
   ========================================================================== */

.loader {
  position: absolute;
  inset: 0;
  background: rgba(11, 15, 25, 0.88);
  backdrop-filter: blur(8px);
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  transition: opacity 0.4s ease;
}

.loader.loaded {
  opacity: 0;
  pointer-events: none;
}

.spinner {
  width: 44px;
  height: 44px;
  border: 3px solid rgba(56, 189, 248, 0.2);
  border-top-color: var(--accent-color);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

#loader-text {
  font-size: 14px;
  color: var(--text-muted);
}

/* ==========================================================================
   Modal d'aide
   ========================================================================== */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(6px);
  z-index: 200;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.modal-backdrop.show {
  display: flex;
}

.modal-card {
  background: #111827;
  border: 1px solid var(--panel-border);
  border-radius: var(--radius-md);
  max-width: 480px;
  width: 100%;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.6);
  animation: popIn 0.2s ease-out;
}

@keyframes popIn {
  from { opacity: 0; transform: scale(0.95); }
  to { opacity: 1; transform: scale(1); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 4px;
}

.modal-close:hover {
  color: #fff;
}

.modal-body {
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 18px;
}

.help-section h4 {
  font-size: 13px;
  color: var(--accent-color);
  margin-bottom: 8px;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.help-section ul {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.help-section li {
  font-size: 13px;
  line-height: 1.5;
  color: #cbd5e1;
}

kbd {
  display: inline-block;
  padding: 2px 6px;
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  font-family: monospace;
  font-size: 11px;
  color: #fff;
}

/* ==========================================================================
   Responsive Mobile / Écrans tactiles
   ========================================================================== */

@media (max-width: 768px) {
  .plu-badge {
    top: 12px;
    padding: 6px 10px;
    font-size: 11px;
  }
  .badge-left { left: 10px; }
  .badge-right { right: 10px; }

  .info-overlay {
    top: 56px;
    padding: 4px 10px;
    font-size: 11px;
  }

  .floating-window {
    top: auto !important;
    bottom: 80px !important;
    right: 12px !important;
    left: auto !important;
    width: 270px;
    height: 380px;
  }

  .floating-body {
    max-height: 300px;
  }

  .toolbar {
    bottom: 16px;
    padding: 4px 8px;
    gap: 4px;
    max-width: 95vw;
    overflow-x: auto;
  }

  .btn-tool {
    width: 34px;
    height: 34px;
  }

  .split-handle {
    width: 48px;
    height: 48px;
  }
}
