/* ═══════════════════════════════════════════════════════════════════════════
   Pistachio plugin — Solarpunk Dark Theme (port focused depuis source mobile)
   Palette : pistachio green + deep forest + warm gold accents
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Frame de la fenêtre flottante (créée par Eden.shell.createFloatingWindow) ── */
.pistachio-window {
  position: fixed;
  display: flex;
  flex-direction: column;
  background: rgba(10, 15, 13, 0.97);
  border: 1px solid rgba(147, 196, 125, 0.12);
  border-radius: 14px;
  box-shadow:
    0 18px 60px rgba(0, 0, 0, 0.55),
    0 0 24px rgba(147, 196, 125, 0.10);
  overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: #e8f0ea;
  animation: pist-win-in 0.18s ease-out;

  --pist-bg: #0a0f0d;
  --pist-bg-card: #111a15;
  --pist-bg-input: #152019;
  --pist-bg-hover: #1a2b21;
  --pist-border: #243a2e;
  --pist-border-light: #3a5a48;
  --pist-text: #e8f0ea;
  --pist-text-muted: #8fa898;
  --pist-text-dim: #5c7a68;
  --pist-accent: #93c47d;
  --pist-accent-dark: #6b9a56;
  --pist-accent-glow: rgba(147, 196, 125, 0.12);
  --pist-red: #e85d4a;
  --pist-gold: #d4a84b;
  --pist-radius: 14px;
  --pist-radius-sm: 10px;
}
@keyframes pist-win-in { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; } }
.pistachio-window.pistachio-window-maximized { border-radius: 0; box-shadow: none; }

.pistachio-window-titlebar {
  display: flex;
  align-items: center;
  height: 32px;
  padding: 0 12px;
  background: rgba(255, 255, 255, 0.03);
  border-bottom: 1px solid var(--pist-border);
  cursor: grab;
  user-select: none;
  flex-shrink: 0;
}
.pistachio-window-titlebar:active { cursor: grabbing; }
.pistachio-window-titlebar-left {
  display: flex; align-items: center; gap: 8px;
  min-width: 0; flex: 1;
}
.pistachio-window-title {
  font-size: 13px; font-weight: 600;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  margin-left: 6px;
  color: var(--pist-text);
}

/* Body : flex column qui remplit l'espace restant */
.pistachio-window-body {
  display: flex; flex-direction: column;
  flex: 1;
  overflow: hidden;
  position: relative;
  background: var(--pist-bg);
  outline: none;
}

/* ── Mon container interne (innerHTML dans body) ─────────────────────────── */
.pistachio-window .pist-body {
  display: flex; flex-direction: column;
  flex: 1;
  width: 100%;
  background: var(--pist-bg);
  color: var(--pist-text);
  font: 14px -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  overflow: hidden;
}

/* ═══ Sub-nav (3 tabs : Models / Trainings / Editor) ═══ */
.pistachio-window .pist-sub-nav {
  display: flex; gap: 4px; padding: 12px 16px 8px;
  border-bottom: 1px solid var(--pist-border);
  background: var(--pist-bg-card);
}
.pistachio-window .pist-sub-btn {
  flex: 1; padding: 9px 14px; background: transparent; border: 1px solid var(--pist-border);
  color: var(--pist-text-muted); border-radius: 8px; cursor: pointer; font-size: 13px;
  font-weight: 500; transition: all 0.15s;
}
.pistachio-window .pist-sub-btn:hover { background: var(--pist-bg-hover); color: var(--pist-text); }
.pistachio-window .pist-sub-btn.active {
  background: var(--pist-accent-glow); color: var(--pist-accent);
  border-color: var(--pist-accent-dark);
}

/* ═══ Sub-pages ═══ */
.pistachio-window .pist-page { display: none; flex: 1; overflow-y: auto; padding: 16px 18px; }
.pistachio-window .pist-page.active { display: block; }
.pistachio-window .pist-page-header {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 14px;
}
.pistachio-window .pist-page-header h3 {
  font-size: 14px; font-weight: 600; color: var(--pist-text);
  text-transform: uppercase; letter-spacing: 0.5px;
}
.pistachio-window .pist-icon-btn {
  width: 32px; height: 32px; border-radius: 8px; border: 1px solid var(--pist-border);
  background: var(--pist-bg-card); color: var(--pist-text-muted); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; font-size: 14px;
  transition: all 0.15s;
}
.pistachio-window .pist-icon-btn:hover { color: var(--pist-accent); border-color: var(--pist-accent-dark); }

/* ═══ Cards (model / training) ═══ */
.pistachio-window .pist-card-list { display: flex; flex-direction: column; gap: 10px; }
.pistachio-window .pist-card {
  background: var(--pist-bg-card); border: 1px solid var(--pist-border);
  border-radius: var(--pist-radius); padding: 14px 16px; cursor: pointer;
  transition: all 0.15s;
}
.pistachio-window .pist-card:hover { border-color: var(--pist-accent-dark); background: var(--pist-bg-hover); }
.pistachio-window .pist-card-title {
  display: flex; align-items: center; justify-content: space-between;
  margin-bottom: 6px;
}
.pistachio-window .pist-card-title h4 { font-size: 14px; font-weight: 600; color: var(--pist-text); }
.pistachio-window .pist-badge {
  font-size: 11px; padding: 2px 8px; border-radius: 999px;
  background: var(--pist-accent-glow); color: var(--pist-accent);
  border: 1px solid var(--pist-accent-dark);
}
.pistachio-window .pist-badge.gold { background: rgba(212, 168, 75, 0.1); color: var(--pist-gold); border-color: var(--pist-gold); }
.pistachio-window .pist-badge.red  { background: rgba(232, 93, 74, 0.1); color: var(--pist-red);  border-color: var(--pist-red); }
.pistachio-window .pist-card-meta {
  font-size: 12px; color: var(--pist-text-muted); display: flex; gap: 12px; flex-wrap: wrap;
}
.pistachio-window .pist-card-meta span { display: inline-flex; align-items: center; gap: 4px; }

.pistachio-window .pist-empty {
  padding: 40px 20px; text-align: center; color: var(--pist-text-dim); font-size: 13px;
}

/* ═══ Editor : config grid ═══ */
.pistachio-window .pist-config-grid {
  display: grid; grid-template-columns: repeat(3, 1fr); gap: 12px; margin-bottom: 14px;
}
.pistachio-window .pist-input-group { display: flex; flex-direction: column; gap: 4px; }
.pistachio-window .pist-input-group label {
  font-size: 11px; color: var(--pist-text-muted); text-transform: uppercase;
  letter-spacing: 0.5px; font-weight: 500;
}
.pistachio-window .pist-input-group input,
.pistachio-window .pist-input-group select {
  padding: 8px 10px; background: var(--pist-bg-input); border: 1px solid var(--pist-border);
  border-radius: 8px; color: var(--pist-text); font-size: 13px; outline: none;
  transition: border-color 0.15s;
}
.pistachio-window .pist-input-group input:focus,
.pistachio-window .pist-input-group select:focus { border-color: var(--pist-accent); }

/* ═══ Mode switch CPU / GPU / Server ═══ */
.pistachio-window .pist-mode-switch { display: flex; gap: 6px; margin-bottom: 14px; }
.pistachio-window .pist-mode-btn {
  flex: 1; padding: 8px; background: var(--pist-bg-input); border: 1px solid var(--pist-border);
  color: var(--pist-text-muted); border-radius: 8px; cursor: pointer; font-size: 12px;
  font-weight: 500; transition: all 0.15s;
}
.pistachio-window .pist-mode-btn:hover { color: var(--pist-text); }
.pistachio-window .pist-mode-btn.active {
  background: var(--pist-accent-glow); color: var(--pist-accent);
  border-color: var(--pist-accent-dark);
}

/* ═══ Action buttons ═══ */
.pistachio-window .pist-actions { display: flex; gap: 8px; margin-bottom: 14px; }
.pistachio-window .pist-btn {
  padding: 10px 18px; border-radius: 8px; border: 1px solid transparent;
  font-size: 13px; font-weight: 500; cursor: pointer; transition: all 0.15s;
}
.pistachio-window .pist-btn-primary {
  background: var(--pist-accent); color: var(--pist-bg);
  border-color: var(--pist-accent);
}
.pistachio-window .pist-btn-primary:hover:not(:disabled) { background: var(--pist-accent-dark); }
.pistachio-window .pist-btn-primary:disabled { opacity: 0.4; cursor: not-allowed; }
.pistachio-window .pist-btn-secondary {
  background: var(--pist-bg-card); color: var(--pist-text);
  border-color: var(--pist-border);
}
.pistachio-window .pist-btn-secondary:hover:not(:disabled) { background: var(--pist-bg-hover); border-color: var(--pist-border-light); }
.pistachio-window .pist-btn-secondary:disabled { opacity: 0.4; cursor: not-allowed; }
.pistachio-window .pist-btn-danger {
  background: rgba(232, 93, 74, 0.1); color: var(--pist-red);
  border-color: var(--pist-red);
}
.pistachio-window .pist-btn-danger:hover:not(:disabled) { background: rgba(232, 93, 74, 0.2); }

/* ═══ Train status ═══ */
.pistachio-window .pist-status {
  padding: 10px 14px; background: var(--pist-bg-card); border-left: 3px solid var(--pist-accent);
  border-radius: 0 8px 8px 0; margin-bottom: 14px; font-size: 13px;
  font-family: 'SF Mono', 'Cascadia Code', 'Fira Code', monospace;
  color: var(--pist-text-muted); white-space: pre-wrap;
}
.pistachio-window .pist-status.error { border-color: var(--pist-red); color: var(--pist-red); }

/* ═══ Editor section header ═══ */
.pistachio-window .pist-editor-section h3 {
  font-size: 14px; font-weight: 600; color: var(--pist-text);
  text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 14px;
}
/* ═══════════════════════════════════════════════════════════════════════════
   Neurocircuit editor CSS — scope sous .pistachio-window pour pas polluer le
   reste de l'OS. Port de pistachio-circuit/editor.html avec préfixe .pist-nc-
   ═══════════════════════════════════════════════════════════════════════════ */

.pistachio-window .pist-nc {
  width: 100%; height: 100%;
  display: flex; flex-direction: column;
  background: #0d1117;
  color: #c9d1d9;
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  position: relative;
}

/* Toolbar */
.pistachio-window .pist-nc-toolbar {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 10px;
  background: linear-gradient(135deg, #0d1117, #161b22);
  border-bottom: 1px solid #30363d;
  flex-shrink: 0;
}
.pistachio-window .pist-nc-name {
  background: transparent;
  border: 1px solid transparent;
  color: #e6edf3;
  font-size: 0.85rem; font-weight: 600;
  padding: 4px 8px; border-radius: 4px;
  font-family: inherit;
  min-width: 140px;
}
.pistachio-window .pist-nc-name:focus {
  border-color: #93c47d; outline: none; background: #0d1117;
}
.pistachio-window .pist-nc-status {
  font-size: 0.7rem; color: #8b949e; margin-left: 4px;
}
.pistachio-window .pist-nc-btn {
  background: #21262d;
  border: 1px solid #30363d;
  color: #c9d1d9;
  padding: 4px 10px;
  border-radius: 5px;
  font-size: 0.78rem;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.pistachio-window .pist-nc-btn:hover {
  border-color: #93c47d; color: #93c47d;
}
.pistachio-window .pist-nc-btn-save {
  background: linear-gradient(135deg, #93c47d, #6fa35e);
  color: #0d1117; font-weight: 600; border-color: #93c47d;
}
.pistachio-window .pist-nc-btn-save:hover { box-shadow: 0 2px 10px rgba(147,196,125,0.3); }
.pistachio-window .pist-nc-zoom { font-size: 0.75rem; color: #8b949e; min-width: 38px; text-align: center; }

/* Canvas wrap */
.pistachio-window .pist-nc-canvas-wrap {
  flex: 1; position: relative; overflow: hidden;
  background-color: #0d1117;
  background-image: radial-gradient(circle, #21262d 1px, transparent 1px);
  background-size: 24px 24px;
}
.pistachio-window .pist-nc-cables {
  position: absolute; top: 0; left: 0;
}
.pistachio-window .pist-nc-nodes {
  position: absolute; top: 0; left: 0;
  transform-origin: 0 0;
}

/* Node */
.pistachio-window .pist-nc-node {
  position: absolute;
  min-width: 180px;
  background: #161b22;
  border: 2px solid #30363d;
  border-radius: 8px;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  user-select: none;
}
.pistachio-window .pist-nc-node:hover { box-shadow: 0 6px 24px rgba(0,0,0,0.5); }
.pistachio-window .pist-nc-node.selected { border-color: #58a6ff; box-shadow: 0 0 16px rgba(88,166,255,0.3); }
.pistachio-window .pist-nc-node-header {
  padding: 6px 10px; border-radius: 6px 6px 0 0;
  font-size: 0.78rem; font-weight: 700; color: #fff;
  text-shadow: 0 1px 2px rgba(0,0,0,0.4);
  cursor: grab;
  display: flex; align-items: center; justify-content: space-between;
  letter-spacing: 0.3px;
}
.pistachio-window .pist-nc-node-header:active { cursor: grabbing; }
.pistachio-window .pist-nc-node-body { padding: 6px 0; }
.pistachio-window .pist-nc-node-delete {
  width: 18px; height: 18px; border-radius: 50%;
  background: rgba(0,0,0,0.2); border: none; color: rgba(0,0,0,0.5);
  font-size: 0.75rem; cursor: pointer; display: none;
  align-items: center; justify-content: center; line-height: 1;
}
.pistachio-window .pist-nc-node:hover .pist-nc-node-delete { display: flex; }
.pistachio-window .pist-nc-node-delete:hover { background: rgba(248,81,73,0.6); color: #fff; }

/* Catégories : couleur du header */
.pistachio-window .pist-nc-cat-io     .pist-nc-node-header { background: linear-gradient(135deg, #d97706, #b45309); }
.pistachio-window .pist-nc-cat-sec    .pist-nc-node-header { background: linear-gradient(135deg, #93c47d, #6fa35e); color:#0d1117 !important; text-shadow:none; }
.pistachio-window .pist-nc-cat-nlp    .pist-nc-node-header { background: linear-gradient(135deg, #3b82f6, #1d4ed8); }
.pistachio-window .pist-nc-cat-plugin .pist-nc-node-header { background: linear-gradient(135deg, #a855f7, #7e22ce); }
.pistachio-window .pist-nc-cat-logic  .pist-nc-node-header { background: linear-gradient(135deg, #6b7280, #374151); }

/* Ports */
.pistachio-window .pist-nc-port-row {
  display: flex; align-items: center; padding: 3px 10px;
  font-size: 0.72rem; color: #c9d1d9; position: relative;
}
.pistachio-window .pist-nc-port-row.pist-nc-port-in  { justify-content: flex-start; }
.pistachio-window .pist-nc-port-row.pist-nc-port-out { justify-content: flex-end; }
.pistachio-window .pist-nc-port-circle {
  width: 12px; height: 12px; border-radius: 50%;
  border: 2px solid; cursor: crosshair;
  transition: transform 0.15s, box-shadow 0.15s;
  flex-shrink: 0;
}
.pistachio-window .pist-nc-port-circle:hover { transform: scale(1.3); box-shadow: 0 0 8px currentColor; }
.pistachio-window .pist-nc-port-label { padding: 0 6px; opacity: 0.85; }

/* Sidebar (palette) */
.pistachio-window .pist-nc-sidebar {
  position: absolute; right: 0; top: 0; bottom: 0;
  width: 230px; background: rgba(13,17,23,0.95);
  border-left: 1px solid #30363d;
  padding: 10px;
  overflow-y: auto;
  transform: translateX(100%);
  transition: transform 0.2s ease-out;
  z-index: 10;
}
.pistachio-window .pist-nc-sidebar.open { transform: translateX(0); }
.pistachio-window .pist-nc-sidebar h3 {
  font-size: 0.85rem; color: #93c47d;
  text-transform: uppercase; letter-spacing: 1px;
  margin-bottom: 12px; padding-bottom: 8px;
  border-bottom: 1px solid #30363d;
}
.pistachio-window .pist-nc-lib-cat { margin-bottom: 14px; }
.pistachio-window .pist-nc-lib-cat-title {
  font-size: 0.7rem; font-weight: 600;
  text-transform: uppercase; letter-spacing: 0.8px;
  margin-bottom: 4px;
}
.pistachio-window .pist-nc-lib-item {
  background: #161b22;
  border: 1px solid #30363d;
  padding: 6px 10px;
  margin-bottom: 3px;
  border-radius: 4px;
  font-size: 0.78rem;
  cursor: pointer;
  transition: all 0.12s;
}
.pistachio-window .pist-nc-lib-item:hover {
  border-color: #93c47d; background: #1a2026; transform: translateX(-2px);
}

/* Minimap */
.pistachio-window .pist-nc-minimap {
  position: absolute; bottom: 10px; right: 10px;
  background: rgba(13,17,23,0.85);
  border: 1px solid #30363d;
  border-radius: 4px;
  z-index: 5;
}

/* Project select */
.pistachio-window .pist-nc-project-select {
  background: #0e1612; color: #93c47d;
  border: 1px solid #243a2e;
  padding: 4px 8px; border-radius: 4px;
  font-size: 0.78rem; font-family: inherit;
  cursor: pointer;
}

/* Toast */
.pistachio-window .pist-nc-toast {
  position: absolute; bottom: 16px; left: 50%;
  transform: translateX(-50%) translateY(100%);
  background: #93c47d; color: #0d1117;
  padding: 8px 16px; border-radius: 4px;
  font-size: 0.78rem; font-weight: 600;
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  opacity: 0; transition: all 0.2s ease-out;
  z-index: 30;
}
.pistachio-window .pist-nc-toast.show {
  transform: translateX(-50%) translateY(0); opacity: 1;
}


/* ═══ Fix layout NeuroCircuit (canvas 2D 0px → 100%) ═══════════════════════ */
/* Le parent .pist-page-nc.active était display:block, ce qui empêchait ses    */
/* enfants .pist-nc-2d-host / .pist-nc-3d-host de remplir la hauteur via flex. */
.pistachio-window .pist-page-nc.active {
  display: flex;
  flex-direction: column;
  padding: 0;
}
.pistachio-window .pist-nc-2d-host,
.pistachio-window .pist-nc-3d-host {
  flex: 1 1 0%;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

/* ═══════════════════════════════════════════════════════════════════════════
   Consolidation Berry-style (sprint 2026-06-08)
   5 onglets : Circuit / Vision / SEC Studio / Dataset / Lab
   ═══════════════════════════════════════════════════════════════════════════ */

/* Top tabs styling — emoji aligned, larger touch targets */
.pistachio-window .pist-sub-btn {
  display: inline-flex !important;
  align-items: center !important;
  gap: 6px !important;
  padding: 8px 14px !important;
  font-size: 0.85rem !important;
}

/* SEC Studio : merged sections with visual dividers between models/trainings/train */
.pistachio-window .pist-page[data-page="secstudio"] {
  overflow-y: auto;
}
.pistachio-window .pist-secstudio-intro {
  padding: 16px 16px 4px;
  border-bottom: 1px solid var(--pist-border);
  margin-bottom: 0;
}
.pistachio-window .pist-secstudio-section {
  padding: 16px;
  border-bottom: 1px dashed var(--pist-border);
}
.pistachio-window .pist-secstudio-section:last-child { border-bottom: none; }

/* ─── Perception Visualizer Vision ────────────────────────────────────────── */
.pistachio-window .pist-page-vision { display: none; }
.pistachio-window .pist-page-vision.active { display: flex; flex-direction: column; }
.pistachio-window .pist-vis {
  display: flex; flex-direction: column;
  width: 100%; height: 100%; flex: 1 1 0%; min-height: 0;
}
.pistachio-window .pist-vis-toolbar {
  display: flex; align-items: center; gap: 10px;
  padding: 10px 14px;
  border-bottom: 1px solid var(--pist-border);
  background: var(--pist-bg-card);
}
.pistachio-window .pist-vis-label { color: var(--pist-text-muted); font-size: 0.8rem; }
.pistachio-window .pist-vis-prim-select,
.pistachio-window .pist-vis-prim-custom {
  background: var(--pist-bg-input); color: var(--pist-text);
  border: 1px solid var(--pist-border); border-radius: 4px;
  padding: 5px 8px; font-size: 0.8rem; font-family: inherit;
}
.pistachio-window .pist-vis-main {
  flex: 1 1 0%; display: flex; min-height: 0; overflow: hidden;
}
.pistachio-window .pist-vis-canvas-wrap {
  flex: 1 1 0%; display: flex; flex-direction: column;
  align-items: center; justify-content: flex-start;
  padding: 16px; gap: 10px;
  background: #0a0f0d; min-width: 0; overflow: auto;
}
.pistachio-window .pist-vis-canvas {
  background: #0e1612; border: 1px solid var(--pist-border);
  border-radius: 6px; cursor: crosshair;
  max-width: 100%; height: auto;
}
.pistachio-window .pist-vis-hint {
  font-size: 0.75rem; color: var(--pist-text-dim);
  font-style: italic; max-width: 640px; text-align: center;
}
.pistachio-window .pist-vis-panel {
  flex: 0 0 320px; border-left: 1px solid var(--pist-border);
  background: var(--pist-bg-card); padding: 14px; overflow-y: auto;
}
.pistachio-window .pist-vis-section { margin-bottom: 18px; }
.pistachio-window .pist-vis-section h3 {
  color: var(--pist-accent); font-size: 0.8rem;
  text-transform: uppercase; letter-spacing: 0.5px;
  margin: 0 0 8px; font-weight: 600;
}
.pistachio-window .pist-vis-prims {
  list-style: none; padding: 0; margin: 0;
  font-size: 0.75rem; max-height: 160px; overflow-y: auto;
}
.pistachio-window .pist-vis-prims li {
  display: flex; align-items: center; gap: 6px;
  padding: 3px 0; border-bottom: 1px solid var(--pist-border);
}
.pistachio-window .pist-vis-prim-swatch {
  width: 12px; height: 12px; border-radius: 3px; flex: 0 0 12px;
}
.pistachio-window .pist-vis-prim-type { color: var(--pist-text); flex: 0 0 auto; font-weight: 500; }
.pistachio-window .pist-vis-prim-coords { color: var(--pist-text-dim); font-size: 0.7rem; flex: 1 1 0%; }
.pistachio-window .pist-vis-prim-del {
  background: transparent; border: none; color: var(--pist-text-dim);
  cursor: pointer; padding: 0 4px; font-size: 0.8rem;
}
.pistachio-window .pist-vis-prim-del:hover { color: var(--pist-red); }

.pistachio-window .pist-vis-decision-label {
  font-size: 1.6rem; font-weight: 700; margin-bottom: 4px;
  text-transform: capitalize;
}
.pistachio-window .pist-vis-decision-conf { color: var(--pist-text-muted); font-size: 0.85rem; }
.pistachio-window .pist-vis-decision-conf strong { color: var(--pist-gold); }
.pistachio-window .pist-vis-decision-expl {
  color: var(--pist-text-muted); font-size: 0.8rem;
  margin-top: 8px; line-height: 1.5;
}

.pistachio-window .pist-vis-rule {
  display: inline-block;
  background: var(--pist-accent-glow); color: var(--pist-accent);
  border: 1px solid rgba(147,196,125,0.3);
  border-radius: 12px; padding: 2px 10px;
  font-size: 0.75rem; margin: 2px 4px 2px 0;
}

@media (max-width: 768px) {
  .pistachio-window .pist-vis-main { flex-direction: column !important; }
  .pistachio-window .pist-vis-panel { flex: 0 0 auto !important; border-left: none !important; border-top: 1px solid var(--pist-border); max-height: 50%; }
}
