/* =========================================================================
   DEV-STUDIO NARRATIVE - Vibe Codé, Pro, Agréable & Ultra-Fluide
   Supporte les dialogues avec choix et les dialogues PNJ <-> PNJ
   ========================================================================= */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600;700&display=swap');

:root {
  --bg-deep: #090d16;
  --bg-grid-dot: rgba(56, 189, 248, 0.15);
  --bg-grid-line: rgba(255, 255, 255, 0.03);
  --card-bg: rgba(18, 26, 44, 0.94);
  --card-border: #26354f;
  --card-border-hover: #38bdf8;
  --text-main: #f1f5f9;
  --text-muted: #94a3b8;
  --accent-cyan: #38bdf8;
  --accent-green: #10b981;
  --accent-amber: #f59e0b;
  --accent-purple: #c084fc;
}

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

body {
  font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
  background-color: var(--bg-deep);
  color: var(--text-main);
  overflow: hidden;
  height: 100vh;
  width: 100vw;
  user-select: none;
}

.font-mono {
  font-family: 'JetBrains Mono', monospace;
}

/* =========================================================================
   CANVAS - FOND STUDIO & GRILLE TECHNIQUE
   ========================================================================= */
#canvas-container {
  position: absolute;
  inset: 0;
  overflow: hidden;
  background-color: #070b14;
  background-image: 
    radial-gradient(circle, var(--bg-grid-dot) 1.2px, transparent 1.2px),
    linear-gradient(var(--bg-grid-line) 1px, transparent 1px),
    linear-gradient(90deg, var(--bg-grid-line) 1px, transparent 1px);
  background-size: 24px 24px, 120px 120px, 120px 120px;
  cursor: grab;
}

#canvas-container.panning {
  cursor: grabbing;
}

#canvas-world {
  position: absolute;
  top: 0;
  left: 0;
  width: 10000px;
  height: 10000px;
  transform-origin: 0 0;
  pointer-events: none;
}

/* Connecteurs SVG */
#connections-svg {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  pointer-events: none;
  z-index: 5;
}

.wire-cable {
  fill: none;
  stroke: #0284c7;
  stroke-width: 2.5;
  stroke-linecap: round;
  filter: drop-shadow(0 0 4px rgba(56, 189, 248, 0.4));
  transition: stroke 0.15s;
}

.wire-cable:hover {
  stroke: #38bdf8;
  stroke-width: 3.5;
  filter: drop-shadow(0 0 8px rgba(56, 189, 248, 0.7));
}

/* Câble spécifique pour les liaisons automatiques entre PNJ */
.wire-cable-npc {
  fill: none;
  stroke: #c084fc;
  stroke-width: 2.8;
  stroke-linecap: round;
  filter: drop-shadow(0 0 5px rgba(192, 132, 252, 0.45));
  transition: stroke 0.15s;
}

.wire-cable-npc:hover {
  stroke: #e9d5ff;
  stroke-width: 3.8;
  filter: drop-shadow(0 0 10px rgba(192, 132, 252, 0.8));
}

#nodes-layer {
  position: absolute;
  inset: 0;
  z-index: 10;
  pointer-events: auto;
}

/* =========================================================================
   CARTE DE DIALOGUE DEV-STUDIO (DÉPLAÇABLE FACILEMENT)
   ========================================================================= */
.dev-card {
  position: absolute;
  width: 420px;
  background: var(--card-bg);
  backdrop-filter: blur(16px);
  border: 1px solid var(--card-border);
  border-radius: 12px;
  box-shadow: 0 12px 30px -6px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255, 255, 255, 0.04);
  transition: box-shadow 0.18s, border-color 0.18s;
  user-select: none;
}

.dev-card:hover {
  border-color: rgba(56, 189, 248, 0.5);
  box-shadow: 0 18px 40px -8px rgba(0, 0, 0, 0.8), 0 0 15px rgba(56, 189, 248, 0.2);
}

.dev-card.dragging {
  opacity: 0.92;
  box-shadow: 0 25px 50px rgba(0, 0, 0, 0.9), 0 0 25px rgba(56, 189, 248, 0.35);
  border-color: #38bdf8;
  z-index: 100 !important;
  cursor: grabbing !important;
}

.dev-card.is-start-node {
  border-color: var(--accent-amber);
  box-shadow: 0 0 0 1px var(--accent-amber), 0 12px 30px rgba(245, 158, 11, 0.15);
}

.dev-card.is-npc-mode {
  border-left: 3px solid var(--accent-purple);
}

/* BARRE DE DRAG & DÉPLACEMENT */
.card-drag-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 12px;
  background: rgba(10, 16, 28, 0.9);
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  border-top-left-radius: 11px;
  border-top-right-radius: 11px;
  cursor: grab;
}

.card-drag-bar:active {
  cursor: grabbing;
}

.drag-grip-icon {
  color: #64748b;
  font-size: 1.1rem;
  letter-spacing: -2px;
  margin-right: 6px;
  cursor: grab;
}

.card-title-field {
  flex: 1;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 2px 6px;
  color: #ffffff;
  font-weight: 700;
  font-size: 0.88rem;
  outline: none;
  transition: all 0.15s;
}

.card-title-field:focus {
  background: rgba(255, 255, 255, 0.08);
  border-color: var(--accent-cyan);
}

/* Barre du locuteur */
.card-speaker-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 6px 12px;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.speaker-tag-label {
  font-size: 0.72rem;
  font-family: 'JetBrains Mono', monospace;
  color: #38bdf8;
  font-weight: 600;
}

.speaker-name-field {
  flex: 1;
  background: rgba(56, 189, 248, 0.08);
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: 6px;
  padding: 3px 8px;
  color: #e0f2fe;
  font-size: 0.82rem;
  font-weight: 600;
  outline: none;
  transition: border-color 0.15s;
}

.speaker-name-field:focus {
  border-color: var(--accent-cyan);
  background: rgba(56, 189, 248, 0.15);
}

/* SÉLECTEUR DE MODE : PNJ DIRECT vs CHOIX DU JOUEUR */
.card-mode-selector {
  display: flex;
  background: rgba(8, 14, 26, 0.7);
  padding: 3px 6px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  gap: 4px;
}

.mode-pill-btn {
  flex: 1;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 6px;
  padding: 4px 6px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  color: #94a3b8;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 5px;
  transition: all 0.15s;
}

.mode-pill-btn:hover {
  color: #ffffff;
  background: rgba(255, 255, 255, 0.04);
}

.mode-pill-btn.active-npc {
  background: rgba(192, 132, 252, 0.18);
  border-color: rgba(192, 132, 252, 0.4);
  color: #f3e8ff;
  font-weight: 700;
}

.mode-pill-btn.active-player {
  background: rgba(56, 189, 248, 0.18);
  border-color: rgba(56, 189, 248, 0.4);
  color: #e0f2fe;
  font-weight: 700;
}

/* Zone de réplique */
.speech-body {
  padding: 10px 12px;
}

.speech-text-area {
  width: 100%;
  min-height: 68px;
  background: #0a0f1d;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 8px 10px;
  color: #f1f5f9;
  font-size: 0.88rem;
  line-height: 1.45;
  resize: vertical;
  outline: none;
  font-family: inherit;
  transition: border-color 0.15s;
}

.speech-text-area:focus {
  border-color: var(--accent-cyan);
  box-shadow: 0 0 0 2px rgba(56, 189, 248, 0.2);
}

/* SECTION PNJ SUITE DIRECTE */
.npc-direct-wrapper {
  padding: 10px 12px 14px 12px;
  border-top: 1px dashed rgba(192, 132, 252, 0.25);
  background: rgba(192, 132, 252, 0.03);
  border-bottom-left-radius: 11px;
  border-bottom-right-radius: 11px;
}

.npc-direct-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 0.72rem;
  color: #c084fc;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
}

.npc-nav-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.direct-dest-dropdown {
  flex: 1;
  background: #14162e;
  border: 1px solid rgba(192, 132, 252, 0.35);
  border-radius: 6px;
  color: #e9d5ff;
  padding: 5px 8px;
  font-size: 0.76rem;
  font-weight: 600;
  outline: none;
  cursor: pointer;
}

.btn-create-npc-reply {
  background: linear-gradient(135deg, rgba(192, 132, 252, 0.25), rgba(168, 85, 247, 0.35));
  color: #f3e8ff;
  border: 1px solid rgba(192, 132, 252, 0.5);
  border-radius: 6px;
  padding: 5px 10px;
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.btn-create-npc-reply:hover {
  background: #c084fc;
  color: #090d16;
  box-shadow: 0 0 10px rgba(192, 132, 252, 0.5);
}

.direct-custom-action-input {
  width: 100%;
  background: rgba(15, 23, 42, 0.9);
  border: 1px dashed rgba(245, 158, 11, 0.4);
  border-radius: 6px;
  padding: 4px 8px;
  color: #fde047;
  font-size: 0.78rem;
  outline: none;
  margin-top: 6px;
}

/* SECTION CHOIX DU JOUEUR */
.choices-wrapper {
  padding: 0 12px 12px 12px;
  border-top: 1px dashed rgba(56, 189, 248, 0.2);
  padding-top: 8px;
}

.choice-item-card {
  background: #0a0f1d;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 8px;
  padding: 8px;
  margin-bottom: 8px;
  transition: border-color 0.15s;
}

.choice-item-card:hover {
  border-color: rgba(56, 189, 248, 0.4);
}

.choice-reply-input {
  width: 100%;
  background: transparent;
  border: none;
  color: #ffffff;
  font-size: 0.84rem;
  font-weight: 500;
  outline: none;
  margin-bottom: 6px;
}

.choice-reply-input::placeholder {
  color: #64748b;
  font-style: italic;
}

.choice-nav-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.choice-dest-dropdown {
  flex: 1;
  background: #141c2e;
  border: 1px solid rgba(56, 189, 248, 0.25);
  border-radius: 6px;
  color: #38bdf8;
  padding: 4px 6px;
  font-size: 0.76rem;
  font-weight: 600;
  outline: none;
  cursor: pointer;
}

.btn-create-suite {
  background: linear-gradient(135deg, rgba(56, 189, 248, 0.2), rgba(2, 132, 199, 0.3));
  color: #ffffff;
  border: 1px solid rgba(56, 189, 248, 0.4);
  border-radius: 6px;
  padding: 4px 8px;
  font-size: 0.74rem;
  font-weight: 700;
  cursor: pointer;
  white-space: nowrap;
  transition: all 0.15s;
}

.btn-create-suite:hover {
  background: #38bdf8;
  color: #090d16;
  box-shadow: 0 0 10px rgba(56, 189, 248, 0.4);
}

.custom-consequence-field {
  width: 100%;
  background: rgba(15, 23, 42, 0.9);
  border: 1px dashed rgba(245, 158, 11, 0.4);
  border-radius: 6px;
  padding: 4px 8px;
  color: #fde047;
  font-size: 0.78rem;
  outline: none;
  margin-top: 6px;
}

.btn-add-choice-row {
  width: 100%;
  background: rgba(255, 255, 255, 0.04);
  border: 1px dashed rgba(255, 255, 255, 0.18);
  border-radius: 8px;
  color: #94a3b8;
  padding: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.btn-add-choice-row:hover {
  background: rgba(56, 189, 248, 0.1);
  border-color: #38bdf8;
  color: #ffffff;
}

/* =========================================================================
   BARRE FLOTTANTE EN BAS
   ========================================================================= */
.floating-dev-bar {
  position: absolute;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 8px;
  background: rgba(13, 20, 36, 0.92);
  backdrop-filter: blur(16px);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 40px;
  padding: 6px 14px;
  box-shadow: 0 16px 36px rgba(0, 0, 0, 0.6);
  z-index: 50;
}

.tool-button {
  background: transparent;
  color: #94a3b8;
  border: none;
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.15s;
}

.tool-button:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.tool-button.btn-primary-cyan {
  background: #0284c7;
  color: #ffffff;
  font-weight: 700;
}

.tool-button.btn-primary-cyan:hover {
  background: #38bdf8;
  color: #090d16;
}

.tool-button.btn-primary-purple {
  background: #8b5cf6;
  color: #ffffff;
  font-weight: 700;
}

.tool-button.btn-primary-purple:hover {
  background: #c084fc;
  color: #090d16;
}

/* =========================================================================
   SIMULATEUR DE DIALOGUE (PLAYTEST)
   ========================================================================= */
#playtest-view {
  position: absolute;
  inset: 0;
  background: rgba(7, 11, 20, 0.96);
  backdrop-filter: blur(14px);
  z-index: 80;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
}

.playtest-window {
  width: 100%;
  max-width: 680px;
  background: #11192b;
  border: 1px solid #26354f;
  border-radius: 16px;
  padding: 30px;
  box-shadow: 0 25px 60px rgba(0, 0, 0, 0.7);
}

.playtest-observer-badge {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 0.72rem;
  font-family: 'JetBrains Mono', monospace;
  font-weight: 700;
  background: rgba(192, 132, 252, 0.15);
  border: 1px solid rgba(192, 132, 252, 0.4);
  color: #e9d5ff;
  margin-bottom: 12px;
}

.playtest-title-line {
  font-size: 1.15rem;
  font-weight: 700;
  color: #38bdf8;
  display: flex;
  align-items: center;
  gap: 8px;
}

.playtest-body-text {
  font-size: 1.15rem;
  line-height: 1.6;
  color: #ffffff;
  min-height: 70px;
  margin: 14px 0 24px 0;
}

.playtest-btn-choice {
  display: block;
  width: 100%;
  text-align: left;
  background: #090e1a;
  border: 1px solid #26354f;
  border-radius: 10px;
  color: #f1f5f9;
  padding: 12px 16px;
  font-size: 0.92rem;
  margin-bottom: 8px;
  cursor: pointer;
  transition: all 0.15s;
}

.playtest-btn-choice:hover {
  background: rgba(56, 189, 248, 0.15);
  border-color: #38bdf8;
  transform: translateX(4px);
}

.playtest-btn-next-direct {
  width: 100%;
  background: linear-gradient(135deg, #8b5cf6, #6366f1);
  color: #ffffff;
  border: none;
  border-radius: 10px;
  padding: 14px 20px;
  font-size: 1rem;
  font-weight: 700;
  cursor: pointer;
  transition: all 0.15s;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
}

.playtest-btn-next-direct:hover {
  background: #a855f7;
  transform: translateY(-1px);
  box-shadow: 0 6px 20px rgba(139, 92, 246, 0.45);
}

/* =========================================================================
   MODALES (EXPORTATION & NOUVEAU DIALOGUE)
   ========================================================================= */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.75);
  backdrop-filter: blur(8px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
}

.modal-box {
  width: 90%;
  max-width: 640px;
  background: #11192b;
  border: 1px solid #26354f;
  border-radius: 18px;
  padding: 30px;
  box-shadow: 0 30px 60px rgba(0, 0, 0, 0.8);
}

.export-tile-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #090e1a;
  border: 1px solid #26354f;
  border-radius: 12px;
  padding: 15px 18px;
  margin-bottom: 10px;
  cursor: pointer;
  transition: all 0.15s;
}

.export-tile-item:hover {
  border-color: #38bdf8;
  background: rgba(56, 189, 248, 0.08);
  transform: translateY(-2px);
}

/* Toasts */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 999;
}

.dev-toast {
  background: #11192b;
  border: 1px solid #38bdf8;
  color: #ffffff;
  padding: 10px 18px;
  border-radius: 10px;
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.6);
  font-size: 0.85rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
}
