/* ==========================================================================
   EMDR NATIVE MACOS THEME - REPRODUCTION EXACTE PIXEL-PERFECT
   ========================================================================== */

:root {
  --mac-titlebar-bg: #2b2b2d;
  --mac-titlebar-border: #1d1d1f;
  --mac-seg-bg: rgba(0, 0, 0, 0.28);
  --mac-seg-border: rgba(255, 255, 255, 0.08);
  --mac-seg-active: rgba(255, 255, 255, 0.22);
  --mac-text-primary: #ffffff;
  --mac-text-muted: #a1a1a6;
  --mac-accent: #007aff;
  --mac-sheet-bg: #262628;
  --mac-sheet-border: rgba(255, 255, 255, 0.14);
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  user-select: none;
  -webkit-user-select: none;
  font-family: -apple-system, BlinkMacSystemFont, "SF Pro Text", "SF Pro Display", "Helvetica Neue", sans-serif;
}

html, body {
  width: 100%;
  height: 100%;
  overflow: hidden;
  background-color: #000000;
  color: var(--mac-text-primary);
}

#macWindow {
  display: flex;
  flex-direction: column;
  width: 100vw;
  height: 100vh;
  position: relative;
  background: #000000;
}

/* Mode patient (?patient=1) : vue distante pour le patient — aucune interface,
   uniquement le canvas plein écran piloté à distance par le thérapeute. */
body.patient-mode .mac-toolbar,
body.patient-mode .center-play-btn {
  display: none !important;
}

/* ==========================================================================
   1. BARRE D'OUTILS NATIVE MACOS (HAUT)
   ========================================================================== */
.mac-toolbar {
  height: 52px;
  background: var(--mac-titlebar-bg);
  border-bottom: 1px solid var(--mac-titlebar-border);
  display: flex;
  align-items: center;
  padding: 0 16px;
  gap: 12px;
  z-index: 20;
  flex-shrink: 0;
}

/* Traffic light (utilisé uniquement pour le bouton fermer des sheets/modaux) */
.traffic-light {
  width: 12px;
  height: 12px;
  border-radius: 50%;
  display: inline-block;
  cursor: pointer;
}

.traffic-light.close { background: #ff5f56; border: 1px solid #e0443e; }

/* Segmented Controls macOS */
.mac-segmented {
  display: inline-flex;
  align-items: center;
  background: var(--mac-seg-bg);
  border: 1px solid var(--mac-seg-border);
  border-radius: 6px;
  padding: 2px;
  gap: 1px;
}

.seg-btn {
  background: transparent;
  border: none;
  color: var(--mac-text-muted);
  font-size: 0.82rem;
  font-weight: 500;
  padding: 3px 10px;
  border-radius: 4px;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 22px;
  transition: all 0.12s ease;
}

.seg-btn:hover {
  color: #fff;
}

.seg-btn.active {
  background: var(--mac-seg-active);
  color: #ffffff;
  font-weight: 600;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
}

/* Outils droite */
.toolbar-tools {
  margin-left: auto;
  display: flex;
  align-items: center;
  gap: 6px;
}

.tool-btn {
  background: transparent;
  border: none;
  color: var(--mac-text-muted);
  width: 32px;
  height: 32px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.15s ease;
}

.tool-btn:hover, .tool-btn.active {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.12);
}

/* ==========================================================================
   2. ZONE CENTRALE & CANVAS
   ========================================================================== */
.canvas-container {
  flex: 1;
  position: relative;
  background: #000000;
  overflow: hidden;
}

canvas#emdrCanvas {
  display: block;
  width: 100%;
  height: 100%;
}

/* Gros bouton rond central Play */
.center-play-btn {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 68px;
  height: 68px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.16);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: #ffffff;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  transition: transform 0.2s ease, opacity 0.25s ease, background 0.2s ease;
  z-index: 10;
}

.center-play-btn svg {
  margin-left: 3px;
}

.center-play-btn:hover {
  transform: translate(-50%, -50%) scale(1.06);
  background: rgba(255, 255, 255, 0.24);
}

.center-play-btn.hidden {
  opacity: 0;
  pointer-events: none;
  transform: translate(-50%, -50%) scale(0.8);
}

/* Badge matériel en bas */
/* Badge gamepad - maintenant dans le panneau Contrôle local */
.gamepad-status-card {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 0.8rem;
  color: #8e8e93;
  transition: all 0.2s ease;
}

.gamepad-status-card.gamepad-connected {
  border-color: rgba(34, 197, 94, 0.45);
  background: rgba(34, 197, 94, 0.08);
  color: #86efac;
}

.gamepad-status-icons {
  display: flex;
  align-items: center;
  gap: 6px;
  color: #6e6e73;
  flex-shrink: 0;
}

.gamepad-status-card.gamepad-connected .gamepad-status-icons {
  color: #22c55e;
}

/* ==========================================================================
   3. FEUILLE MODALE NATIVE (AJUSTEMENTS / PRÉRÉGLAGES)
   ========================================================================== */
.sheet-backdrop {
  position: absolute;
  top: 52px;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.45);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
  z-index: 50;
  display: flex;
  justify-content: center;
  align-items: flex-start;
  padding-top: 30px;
  transition: opacity 0.2s ease;
}

.sheet-backdrop.hidden {
  display: none;
}

.mac-sheet {
  width: 480px;
  background: var(--mac-sheet-bg);
  border: 1px solid var(--mac-sheet-border);
  border-radius: 14px;
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.75);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  animation: sheetDrop 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes sheetDrop {
  from { transform: translateY(-20px); opacity: 0; }
  to { transform: translateY(0); opacity: 1; }
}

.sheet-titlebar {
  display: flex;
  align-items: center;
  padding: 12px 16px 6px 16px;
  position: relative;
}

.sheet-traffic-lights {
  position: absolute;
  left: 16px;
}

.sheet-title {
  width: 100%;
  text-align: center;
  font-size: 0.88rem;
  font-weight: 600;
  color: #d1d1d6;
}

/* Onglets de la feuille */
.sheet-tabs {
  display: flex;
  justify-content: center;
  gap: 8px;
  padding: 8px 16px 12px 16px;
}

.sheet-tab {
  background: transparent;
  border: none;
  color: var(--mac-text-muted);
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 4px;
  padding: 6px 10px;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.72rem;
  font-weight: 500;
  min-width: 80px;
  transition: all 0.15s ease;
}

.sheet-tab:hover {
  color: #fff;
}

.sheet-tab.active {
  background: rgba(255, 255, 255, 0.12);
  color: #ffffff;
  font-weight: 600;
}

.sheet-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.1);
}

.tab-pane {
  padding: 20px 24px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  max-height: 480px;
  overflow-y: auto;
}

.tab-pane.hidden {
  display: none;
}

.pane-section {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.patient-preview-frame {
  width: 100%;
  aspect-ratio: 16 / 10;
  border-radius: 8px;
  overflow: hidden;
  border: 1px solid var(--mac-sheet-border);
  background: #000000;
}

.patient-preview-frame iframe {
  width: 100%;
  height: 100%;
  border: none;
  display: block;
}

.pane-section h4 {
  font-size: 0.88rem;
  font-weight: 600;
  color: #ffffff;
}

.pane-divider {
  height: 1px;
  background: rgba(255, 255, 255, 0.08);
}

/* Formulaires & Sélecteurs */
.form-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.form-row label {
  font-size: 0.82rem;
  color: #d1d1d6;
  min-width: 100px;
}

.mac-select {
  background: rgba(255, 255, 255, 0.12);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 0.82rem;
  outline: none;
  min-width: 240px;
  cursor: pointer;
}

.mac-select option {
  background: #2b2b2d;
  color: #fff;
}

/* Échantillons de couleurs */
.swatches-row {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: wrap;
  max-width: 260px;
}

.swatch {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid transparent;
  transition: transform 0.12s;
}

.swatch:hover {
  transform: scale(1.2);
}

.swatch.active {
  border-color: #007aff;
  box-shadow: 0 0 0 2px rgba(0, 122, 255, 0.4);
}

/* Sliders avec crans / Ticks */
.slider-tick-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.slider-tick-row label {
  font-size: 0.82rem;
  color: #d1d1d6;
  min-width: 90px;
}

.tick-slider {
  flex: 1;
  accent-color: #007aff;
  cursor: pointer;
}

.slider-val {
  font-size: 0.82rem;
  font-weight: 500;
  color: #fff;
  min-width: 50px;
  text-align: right;
}

/* Inputs répétitions */
.input-text-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
}

.input-text-row label {
  font-size: 0.82rem;
  color: #d1d1d6;
}

.mac-input-small {
  width: 80px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #fff;
  padding: 4px 8px;
  border-radius: 6px;
  font-size: 0.82rem;
  outline: none;
}

.input-hint {
  font-size: 0.74rem;
  color: #8e8e93;
  margin-top: -4px;
}

/* Cartes d'animations (exactement comme Préréglages 2) */
.animation-cards-row {
  display: flex;
  gap: 10px;
  justify-content: space-between;
  margin-top: 4px;
}

.anim-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.15);
  border-radius: 10px;
  padding: 8px 6px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  width: 72px;
  transition: all 0.15s ease;
}

.anim-card:hover {
  background: rgba(255, 255, 255, 0.08);
}

.anim-card.active {
  border-color: #007aff;
  background: rgba(0, 122, 255, 0.14);
  box-shadow: 0 0 0 1px #007aff;
}

.anim-screen {
  width: 52px;
  height: 32px;
  border: 1.5px solid rgba(255, 255, 255, 0.35);
  border-radius: 6px;
  position: relative;
  background: rgba(0, 0, 0, 0.4);
}

.anim-dot {
  position: absolute;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  border: 1.5px solid #ffffff;
}

.dot-h { top: 12px; left: 34px; }
.dot-diag-up { top: 6px; left: 34px; }
.dot-diag-down { top: 18px; left: 34px; }
.dot-v { top: 12px; left: 22px; }
.dot-rand { top: 8px; left: 36px; }

.anim-arrow {
  font-size: 0.88rem;
  color: #d1d1d6;
}

.mac-checkbox-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 0.82rem;
  color: #d1d1d6;
  cursor: pointer;
}

.mac-checkbox-label input {
  accent-color: #007aff;
  width: 15px;
  height: 15px;
}

/* Footer et boutons */
.pane-footer {
  padding-top: 8px;
  display: flex;
  justify-content: center;
}

.mac-btn-default {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.14);
  color: #d1d1d6;
  border-radius: 6px;
  padding: 6px 14px;
  font-size: 0.8rem;
  cursor: pointer;
  transition: all 0.15s ease;
}

.mac-btn-default:hover {
  background: rgba(255, 255, 255, 0.18);
  color: #fff;
}

.mac-input-full {
  width: 100%;
  background: rgba(0, 0, 0, 0.35);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: #38bdf8;
  padding: 8px 10px;
  border-radius: 6px;
  font-family: monospace;
  font-size: 0.78rem;
}

.share-text {
  font-size: 0.82rem;
  color: #a1a1a6;
  margin-bottom: 8px;
}

/* Cartes et fenêtres d'information et dialogues additionnels */
.dialog-card {
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 12px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.dialog-notice-yellow {
  background: rgba(120, 100, 30, 0.3);
  border: 1px solid rgba(245, 190, 40, 0.35);
  border-radius: 8px;
  padding: 12px 14px;
  font-size: 0.82rem;
  line-height: 1.45;
  color: #fbbf24;
}

.info-card-row {
  display: flex;
  align-items: center;
  gap: 10px;
  background: rgba(255, 255, 255, 0.05);
  border: 1px solid rgba(255, 255, 255, 0.1);
  padding: 10px 14px;
  border-radius: 10px;
}

.badge-check {
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: #eab308;
  color: #000;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: bold;
}

.info-nav-card {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 10px;
  padding: 12px 14px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  cursor: pointer;
  transition: all 0.15s ease;
}

.info-nav-card:hover {
  background: rgba(255, 255, 255, 0.09);
  border-color: rgba(255, 255, 255, 0.2);
}

.info-nav-card strong {
  font-size: 0.85rem;
  color: #ffffff;
}

.info-nav-card small {
  font-size: 0.78rem;
  color: #8e8e93;
}

/* ==========================================================================
   PRÉRÉGLAGES DYNAMIQUES — Boutons + et × dans le panneau Ajustements
   ========================================================================== */

/* Bouton + Ajouter un préréglage */
.preset-add-btn {
  background: transparent;
  border: 1px dashed rgba(255, 255, 255, 0.2);
  color: #8e8e93;
  border-radius: 6px;
  padding: 5px 12px;
  font-size: 0.78rem;
  cursor: pointer;
  margin-top: 6px;
  width: 100%;
  text-align: center;
  transition: all 0.15s ease;
}

.preset-add-btn:hover {
  border-color: rgba(0, 122, 255, 0.5);
  color: #007aff;
  background: rgba(0, 122, 255, 0.06);
}

/* Bouton × Supprimer un préréglage */
.preset-del-btn {
  background: transparent;
  border: none;
  color: #6e6e73;
  font-size: 1rem;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: all 0.12s ease;
  padding: 0;
  line-height: 1;
}

.preset-del-btn:hover {
  background: rgba(255, 59, 48, 0.18);
  color: #ff3b30;
}

/* Ligne slider avec bouton delete */
.slider-tick-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.slider-tick-row label {
  font-size: 0.82rem;
  color: #d1d1d6;
  min-width: 88px;
  flex-shrink: 0;
}

/* Ligne input avec bouton delete */
.input-text-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}

.input-text-row label {
  font-size: 0.82rem;
  color: #d1d1d6;
  flex: 1;
}
