/* ==========================================================================
   SAATEN - COMPARATEUR AVANT / APRÈS (MODERNE, RÉACTIF & ACCESSIBLE)
   ========================================================================== */

:root {
  --bg-main: #0a0c12;
  --bg-surface: #121622;
  --bg-card: rgba(22, 28, 42, 0.75);
  --bg-card-hover: rgba(30, 38, 58, 0.85);
  --border-subtle: rgba(255, 255, 255, 0.08);
  --border-hover: rgba(255, 255, 255, 0.2);
  --border-focus: #6366f1;

  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --text-dim: #64748b;

  --color-before: #ec4899;     /* Rose / Magenta pour Avant */
  --color-before-glow: rgba(236, 72, 153, 0.25);
  --color-after: #06b6d4;      /* Cyan pour Après */
  --color-after-glow: rgba(6, 182, 212, 0.25);
  --color-accent: #6366f1;     /* Indigo */
  --color-accent-hover: #4f46e5;
  --color-success: #10b981;

  --split-pos: 50%;
  --fade-opacity: 0.5;

  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace;

  --header-height: 68px;
  --toolbar-height: 60px;
  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;
  --radius-full: 9999px;
  
  --shadow-dropdown: 0 12px 36px rgba(0, 0, 0, 0.45);
  --shadow-handle: 0 4px 20px rgba(0, 0, 0, 0.6), 0 0 15px rgba(99, 102, 241, 0.4);
}

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

html, body {
  background-color: var(--bg-main);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 14px;
  line-height: 1.5;
  min-height: 100vh;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   HEADER PRINCIPAL
   ========================================================================== */

.app-header {
  position: sticky;
  top: 0;
  left: 0;
  right: 0;
  height: var(--header-height);
  background: rgba(10, 12, 18, 0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 24px;
  z-index: 1000;
  gap: 16px;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 14px;
  flex-shrink: 0;
}

.brand-badge {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  background: rgba(99, 102, 241, 0.12);
  border: 1px solid rgba(99, 102, 241, 0.3);
  padding: 4px 10px;
  border-radius: var(--radius-full);
}

.brand-dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--color-accent);
  box-shadow: 0 0 8px var(--color-accent);
}

.brand-name {
  font-size: 11px;
  font-weight: 800;
  letter-spacing: 0.12em;
  color: #c7d2fe;
}

.header-title {
  font-size: 15px;
  font-weight: 700;
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--text-main);
}

.badge-tag {
  font-size: 11px;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-muted);
}

.metrics-chips {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-left: 6px;
}

.chip {
  font-family: var(--font-mono);
  font-size: 11px;
  padding: 3px 9px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.chip-before {
  background: rgba(236, 72, 153, 0.12);
  border: 1px solid rgba(236, 72, 153, 0.3);
  color: #f472b6;
}

.chip-after {
  background: rgba(6, 182, 212, 0.12);
  border: 1px solid rgba(6, 182, 212, 0.3);
  color: #38bdf8;
}

.chip-label {
  font-weight: 700;
}

.chip-diff {
  color: #4ade80;
  font-weight: 700;
}

/* ONGLETS DE MODES */

.mode-tabs {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.04);
  padding: 4px;
  border-radius: var(--radius-md);
  border: 1px solid var(--border-subtle);
  gap: 4px;
}

.mode-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 12.5px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 7px;
  transition: all 0.18s cubic-bezier(0.16, 1, 0.3, 1);
}

.mode-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.06);
}

.mode-btn.active {
  background: var(--color-accent);
  color: #ffffff;
  box-shadow: 0 2px 10px rgba(99, 102, 241, 0.35);
}

.mode-icon {
  width: 15px;
  height: 15px;
}

/* OUTILS DROITE */

.header-right {
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}

.tool-group {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tool-label {
  font-size: 11.5px;
  color: var(--text-muted);
  font-weight: 500;
}

.custom-select {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 500;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  outline: none;
  cursor: pointer;
  transition: border-color 0.15s;
}

.custom-select:hover, .custom-select:focus {
  border-color: var(--border-focus);
}

.custom-select option {
  background: var(--bg-surface);
  color: var(--text-main);
}

.icon-tool-btn {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  padding: 5px 10px;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: all 0.15s ease;
}

.icon-tool-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: var(--text-main);
  border-color: var(--border-hover);
}

.shortcut-badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  background: rgba(255, 255, 255, 0.08);
}

.zoom-controls {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  overflow: hidden;
}

.zoom-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-family: var(--font-sans);
  font-size: 11.5px;
  font-weight: 600;
  padding: 5px 9px;
  cursor: pointer;
  transition: background 0.15s, color 0.15s;
}

.zoom-btn:hover {
  background: rgba(255, 255, 255, 0.08);
  color: var(--text-main);
}

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

/* ==========================================================================
   BANNIÈRE D'ASTUCE CONTEXTUELLE
   ========================================================================== */

.quick-banner {
  background: linear-gradient(90deg, rgba(99, 102, 241, 0.12), rgba(6, 182, 212, 0.08));
  border-bottom: 1px solid rgba(99, 102, 241, 0.2);
  padding: 8px 24px;
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 12.5px;
  color: #cbd5e1;
  position: relative;
}

.hint-icon {
  font-size: 14px;
}

.hint-text {
  flex: 1;
}

.hint-text strong {
  color: #ffffff;
}

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

.hint-close:hover {
  color: var(--text-main);
}

/* ==========================================================================
   ESPACE DE VISUALISATION PRINCIPAL
   ========================================================================== */

.viewer-wrapper {
  position: relative;
  width: 100%;
  display: flex;
  justify-content: center;
  padding: 24px 20px 100px;
  min-height: calc(100vh - var(--header-height));
  background: radial-gradient(circle at 50% 20%, rgba(99, 102, 241, 0.05) 0%, transparent 60%);
}

/* 1. SCÈNE DE COMPARAISON SUPERPOSÉE */

.comparison-stage {
  position: relative;
  width: 1400px;
  max-width: 100%;
  aspect-ratio: 1400 / 5240;
  background: #07090e;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.7), 0 0 0 1px var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  user-select: none;
  transition: width 0.3s cubic-bezier(0.16, 1, 0.3, 1), max-width 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

/* Échelles de zoom */
.comparison-stage.scale-fit {
  width: 100% !important;
  max-width: 1400px;
}
.comparison-stage.scale-75 {
  width: 1050px !important;
  max-width: 100%;
}
.comparison-stage.scale-100 {
  width: 1400px !important;
  max-width: 100%;
}

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

.layer {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
}

.layer-bottom {
  z-index: 1;
}

.layer-top {
  z-index: 2;
  overflow: hidden;
  will-change: clip-path, opacity;
}

.top-content-wrapper {
  position: relative;
  width: 100%;
}

/* Indicateur stylé de fin du visuel Avant */
.end-of-before-indicator {
  width: 100%;
  min-height: 600px;
  background-color: #0c0e17;
  background-image: 
    repeating-linear-gradient(45deg, rgba(236, 72, 153, 0.04) 0, rgba(236, 72, 153, 0.04) 10px, transparent 10px, transparent 20px),
    linear-gradient(180deg, rgba(236, 72, 153, 0.12) 0%, rgba(12, 14, 23, 0.8) 150px);
  border-top: 2px dashed rgba(236, 72, 153, 0.5);
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding: 60px 20px;
}

.end-marker-content {
  text-align: center;
  max-width: 520px;
  background: rgba(18, 22, 34, 0.9);
  backdrop-filter: blur(12px);
  border: 1px solid rgba(236, 72, 153, 0.3);
  padding: 24px 32px;
  border-radius: var(--radius-lg);
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
}

.end-badge {
  display: inline-block;
  background: rgba(236, 72, 153, 0.2);
  color: #f472b6;
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  padding: 4px 12px;
  border-radius: var(--radius-full);
  margin-bottom: 10px;
  letter-spacing: 0.03em;
}

.end-text {
  font-size: 13.5px;
  color: var(--text-muted);
  line-height: 1.6;
}

/* ==========================================================================
   LIGNE DE SÉPARATION & CURSEUR (SPLIT DIVIDER)
   ========================================================================== */

.split-divider {
  position: absolute;
  z-index: 10;
  touch-action: none;
  cursor: grab;
  outline: none;
}

.split-divider:active {
  cursor: grabbing;
}

/* Mode VERTICAL (séparation horizontale glissant haut/bas) */
.comparison-stage.mode-vertical .split-divider {
  left: 0;
  right: 0;
  width: 100%;
  height: 40px;
  margin-top: -20px;
  cursor: ns-resize;
  display: flex;
  align-items: center;
  justify-content: center;
}

.comparison-stage.mode-vertical .split-line-track {
  position: absolute;
  left: 0;
  right: 0;
  top: 50%;
  height: 2px;
  background: #ffffff;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.8), 0 0 20px var(--color-accent);
  pointer-events: none;
}

/* Mode HORIZONTAL (séparation verticale glissant gauche/droite) */
.comparison-stage.mode-horizontal .split-divider {
  top: 0;
  bottom: 0;
  height: 100%;
  width: 40px;
  margin-left: -20px;
  cursor: ew-resize;
  display: flex;
  align-items: center;
  justify-content: center;
}

.comparison-stage.mode-horizontal .split-line-track {
  position: absolute;
  top: 0;
  bottom: 0;
  left: 50%;
  width: 2px;
  background: #ffffff;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.8), 0 0 20px var(--color-accent);
  pointer-events: none;
}

/* POIGNÉE (HANDLE) */
.divider-handle {
  position: relative;
  z-index: 2;
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(14, 18, 28, 0.85);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255, 255, 255, 0.25);
  padding: 6px 14px;
  border-radius: var(--radius-full);
  box-shadow: var(--shadow-handle);
  transition: transform 0.15s cubic-bezier(0.16, 1, 0.3, 1), border-color 0.15s;
  pointer-events: auto;
}

.split-divider:hover .divider-handle,
.split-divider:active .divider-handle {
  transform: scale(1.06);
  border-color: #ffffff;
}

.handle-pill {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: var(--color-accent);
  color: #ffffff;
}

.handle-arrow {
  font-family: var(--font-mono);
  font-size: 10.5px;
  font-weight: 700;
  letter-spacing: 0.05em;
  white-space: nowrap;
}

.before-arrow {
  color: #f472b6;
}

.after-arrow {
  color: #38bdf8;
}

/* Gestion des icônes selon mode */
.comparison-stage.mode-vertical .handle-icon-horiz {
  display: none;
}
.comparison-stage.mode-vertical .handle-icon-vert {
  display: block;
}

.comparison-stage.mode-horizontal .handle-icon-vert {
  display: none;
}
.comparison-stage.mode-horizontal .handle-icon-horiz {
  display: block;
}

/* Orientation du libellé selon mode horizontal */
.comparison-stage.mode-horizontal .before-arrow {
  content: "◀ AVANT";
}
.comparison-stage.mode-horizontal .after-arrow {
  content: "APRÈS ▶";
}

/* Mode Fondu (Fade) */
.comparison-stage.mode-fade .split-divider {
  display: none;
}

/* ==========================================================================
   BADGES FLOTTANTS
   ========================================================================== */

.floating-badge {
  position: absolute;
  z-index: 8;
  display: flex;
  align-items: center;
  gap: 7px;
  background: rgba(10, 12, 18, 0.82);
  backdrop-filter: blur(10px);
  border: 1px solid var(--border-subtle);
  padding: 6px 12px;
  border-radius: var(--radius-full);
  font-family: var(--font-mono);
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-main);
  pointer-events: none;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.4);
}

.badge-top-left {
  top: 16px;
  left: 16px;
}

.badge-bottom-right {
  bottom: 16px;
  right: 16px;
}

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

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

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

/* ==========================================================================
   2. VUE CÔTE À CÔTE
   ========================================================================== */

.side-by-side-stage {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  width: 100%;
  max-width: 1800px;
}

.side-by-side-stage.hidden {
  display: none;
}

.side-column {
  background: var(--bg-surface);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

.side-header {
  padding: 12px 16px;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--border-subtle);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.side-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 13px;
}

.side-meta {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
}

.side-scroll-container {
  overflow-y: auto;
  max-height: calc(100vh - 180px);
  position: relative;
  background: #000000;
}

.side-end-note {
  padding: 40px 20px;
  text-align: center;
  background: repeating-linear-gradient(45deg, rgba(236, 72, 153, 0.03) 0, rgba(236, 72, 153, 0.03) 10px, transparent 10px, transparent 20px);
  border-top: 1px dashed rgba(236, 72, 153, 0.3);
  color: var(--text-dim);
  font-family: var(--font-mono);
  font-size: 12px;
}

/* ==========================================================================
   BARRE D'OUTILS INFÉRIEURE FLOTTANTE
   ========================================================================== */

.floating-toolbar {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  z-index: 1000;
  max-width: 90vw;
}

.toolbar-inner {
  display: flex;
  align-items: center;
  gap: 14px;
  background: rgba(14, 18, 28, 0.88);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border: 1px solid var(--border-subtle);
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.55);
  padding: 8px 18px;
  border-radius: var(--radius-full);
}

.toolbar-separator {
  width: 1px;
  height: 20px;
  background: var(--border-subtle);
}

.slider-control-group, .fade-control-group {
  display: flex;
  align-items: center;
  gap: 10px;
}

.fade-control-group.hidden {
  display: none;
}

.slider-label {
  font-size: 11.5px;
  font-weight: 600;
  color: var(--text-muted);
  white-space: nowrap;
}

.position-value {
  font-family: var(--font-mono);
  font-size: 12px;
  font-weight: 700;
  color: var(--text-main);
  min-width: 40px;
}

/* Styled Range Input */
.styled-range {
  -webkit-appearance: none;
  appearance: none;
  width: 140px;
  height: 6px;
  border-radius: var(--radius-full);
  background: rgba(255, 255, 255, 0.12);
  outline: none;
  cursor: pointer;
}

.styled-range::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 16px;
  height: 16px;
  border-radius: 50%;
  background: var(--color-accent);
  box-shadow: 0 0 10px var(--color-accent);
  cursor: pointer;
  transition: transform 0.1s;
}

.styled-range::-webkit-slider-thumb:hover {
  transform: scale(1.2);
}

/* Bouton Flash Aperçu */
.flash-btn {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid var(--border-subtle);
  color: var(--text-main);
  font-family: var(--font-sans);
  font-size: 12px;
  font-weight: 600;
  padding: 6px 14px;
  border-radius: var(--radius-full);
  display: inline-flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.15s ease;
  user-select: none;
}

.flash-btn:hover {
  background: rgba(255, 255, 255, 0.14);
  border-color: var(--border-hover);
}

.flash-btn:active, .flash-btn.active {
  background: var(--color-before);
  color: #ffffff;
  border-color: var(--color-before);
  box-shadow: 0 0 15px var(--color-before-glow);
}

.quick-reset-btn {
  background: transparent;
  border: 1px solid var(--border-subtle);
  color: var(--text-muted);
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  padding: 4px 8px;
  border-radius: var(--radius-full);
  cursor: pointer;
  transition: all 0.15s;
}

.quick-reset-btn:hover {
  color: var(--text-main);
  background: rgba(255, 255, 255, 0.06);
}

/* ==========================================================================
   MODAL ROUX RACCOURCIS CLAVIER
   ========================================================================== */

.help-dialog {
  margin: auto;
  border: none;
  background: transparent;
  outline: none;
}

.help-dialog::backdrop {
  background: rgba(0, 0, 0, 0.65);
  backdrop-filter: blur(8px);
}

.help-content {
  background: var(--bg-surface);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-lg);
  padding: 24px;
  width: 440px;
  max-width: 90vw;
  box-shadow: var(--shadow-dropdown);
  color: var(--text-main);
}

.help-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 20px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border-subtle);
}

.help-header h3 {
  font-size: 16px;
  font-weight: 700;
}

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

.close-btn:hover {
  color: var(--text-main);
}

.help-grid {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.help-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
  font-size: 13px;
}

.help-row kbd {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  padding: 2px 7px;
  font-family: var(--font-mono);
  font-size: 11px;
  font-weight: 600;
  box-shadow: 0 2px 0 rgba(255, 255, 255, 0.1);
  white-space: nowrap;
}

/* ==========================================================================
   RESPONSIVE DESIGN
   ========================================================================== */

@media (max-width: 1080px) {
  .metrics-chips {
    display: none;
  }
}

@media (max-width: 820px) {
  .app-header {
    height: auto;
    padding: 12px 16px;
    flex-wrap: wrap;
  }
  .mode-tabs {
    order: 3;
    width: 100%;
    justify-content: space-around;
  }
  .side-by-side-stage {
    grid-template-columns: 1fr;
  }
}
