/* ════════════════════════════════════════════════════════════════════════
 *  Plugin: edenshell — fenêtre flottante draggable + resizable
 * ════════════════════════════════════════════════════════════════════════ */

/* Variables overridables via les préférences (cf. plugin.js _applyPrefs) */
.esh-window {
  --esh-opacity:   0.85;
  --esh-fontSize:  13px;
  --esh-accent:    #58c8ff;
  --esh-accent-hot: #8be9fd;

  position: fixed;
  display: flex;
  flex-direction: column;
  background: rgba(8, 14, 28, var(--esh-opacity));
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: var(--r-lg);
  box-shadow:
    0 18px 60px rgba(0, 0, 0, 0.55),
    0 0 24px rgba(88, 200, 255, 0.18);
  overflow: hidden;
  z-index: 100;
  font-family: var(--font-mono);
  font-size: var(--esh-fontSize);
  color: var(--fg);
  /* Pas de transition sur left/top/width/height : drag et resize doivent
     répondre instantanément. La fenêtre apparaît avec un fade-in léger. */
  animation: esh-win-in 0.25s ease-out;
}
@keyframes esh-win-in { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; } }

.esh-window.esh-maximized { border-radius: 0; box-shadow: none; }

/* Le shell-content (parent) ne doit pas appliquer de padding qui décale la fenêtre */
.shell-content { padding: 0 !important; position: relative; }

/* ── Titlebar ─────────────────────────────────────────────────────────── */
.esh-titlebar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 32px;
  padding: 0 10px 0 12px;
  background: rgba(255,255,255,0.04);
  border-bottom: 1px solid rgba(255,255,255,0.06);
  cursor: grab;
  user-select: none;
}
.esh-titlebar:active { cursor: grabbing; }
.esh-titlebar-left {
  display: flex; align-items: center; gap: 8px;
}
.esh-titlebar-right {
  display: flex; align-items: center; gap: 4px;
}
.esh-window-title {
  margin-left: 8px;
  font-size: 11px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-dim);
}

/* Pastilles macOS-style — couleur indique l'action */
.esh-traffic-light {
  width: 12px; height: 12px; border-radius: 50%;
  display: inline-block;
  cursor: pointer;
  transition: transform .15s ease;
}
.esh-traffic-light:hover { transform: scale(1.15); }
.esh-traffic-light.dot-r { background: #ff5f56; }
.esh-traffic-light.dot-y { background: #ffbd2e; }
.esh-traffic-light.dot-g { background: #27c93f; }

/* La pastille rouge ne ferme pas vraiment (on perdrait la console) — on la
   laisse passive pour l'instant, juste décorative. */

.esh-icon-btn {
  display: flex; align-items: center; justify-content: center;
  width: 26px; height: 26px;
  background: transparent;
  border: none;
  color: var(--fg-dim);
  border-radius: var(--r-sm);
  cursor: pointer;
  transition: color .15s ease, background .15s ease;
}
.esh-icon-btn:hover { color: var(--esh-accent); background: rgba(255,255,255,0.05); }

/* ── Tree de panes (splits récursifs) ────────────────────────────────── */
.edenshell-root {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  overflow: hidden;
}
.esh-pane-tree {
  flex: 1;
  display: flex;
  min-height: 0;
  overflow: hidden;
}
.esh-pane-split {
  flex: 1;
  display: flex;
  min-height: 0; min-width: 0;
  overflow: hidden;
}
.esh-pane-split.horizontal { flex-direction: row; }
.esh-pane-split.vertical   { flex-direction: column; }

/* Divider entre 2 panes — draggable pour resize */
.esh-divider {
  background: rgba(255,255,255,0.04);
  flex-shrink: 0;
  position: relative;
  z-index: 5;
  transition: background .15s ease;
}
.esh-divider.vertical   { width: 4px;  cursor: ew-resize; }
.esh-divider.horizontal { height: 4px; cursor: ns-resize; }
.esh-divider:hover { background: rgba(88,200,255,0.30); }

/* Pane leaf (la "feuille" du tree : un shell réel) */
.esh-pane-leaf {
  flex: 1;
  display: flex;
  flex-direction: column;
  /* min-width/height : empêche les panes de descendre sous une taille viable
     pour leur contenu (header + prompt). Le flex shrink les réduira jusqu'à
     ces valeurs puis stoppera. _canSplit() refuse de splitter sous 2*MIN+4. */
  min-width: 220px;
  min-height: 130px;
  background: rgba(255,255,255,0.01);
  border: 1px solid transparent;
  transition: border-color .15s ease;
  overflow: hidden;
}
.esh-pane-leaf.active {
  border-color: rgba(88,200,255,0.18);
  box-shadow: inset 0 0 0 1px rgba(88,200,255,0.10);
}

.esh-pane-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 4px 8px 4px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.04);
  font-size: 10px;
  letter-spacing: 0.12em;
  text-transform: uppercase;
  color: var(--fg-muted);
  user-select: none;
  flex-shrink: 0;
  min-width: 0; /* permet à .esh-pane-title de tronquer au lieu de pousser les actions */
}
.esh-pane-title {
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.esh-pane-actions { flex-shrink: 0; }
.esh-pane-leaf.active .esh-pane-head {
  color: var(--fg-dim);
}
.esh-pane-actions {
  display: flex;
  gap: 2px;
}
.esh-pane-actions .esh-icon-btn {
  width: 22px; height: 22px;
}

.esh-out {
  flex: 1;
  overflow-y: auto;
  padding: 10px 14px 6px;
  scrollbar-width: thin;
  scrollbar-color: rgba(88,200,255,0.25) transparent;
  line-height: 1.55;
  min-height: 0;
}

/* Zone takeover : héberge le DOM d'un plugin qui prend le pane.
   Hidden par défaut ; affichée par _takeoverPane(), masquée par _releasePane(). */
.esh-takeover {
  flex: 1;
  min-height: 0;
  overflow: auto;
  display: flex;
  flex-direction: column;
}
.esh-takeover[hidden] { display: none; }
.esh-release-btn[hidden] { display: none; }
.esh-out::-webkit-scrollbar { width: 8px; }
.esh-out::-webkit-scrollbar-thumb { background: rgba(88,200,255,0.25); border-radius: 4px; }

.esh-line { white-space: pre-wrap; word-break: break-word; padding: 1px 0; color: var(--fg); }
.esh-line.esh-dim   { color: var(--fg-dim); }
.esh-line.esh-err   { color: #ffb3bb; }
.esh-line.esh-ok    { color: var(--success); }
.esh-line.esh-warn  { color: var(--warning); }
.esh-line.esh-echo  { color: var(--fg-dim); }
.esh-line.esh-echo .esh-prompt { color: var(--esh-accent); margin-right: 6px; }

/* Coloration ls : type d'entrée + extension de fichier.
   Couleur fixe pour les dossiers (pas via --esh-accent) : sinon ça colle
   au prompt quand l'utilisateur choisit l'accent vert. */
.esh-dir       { color: #a4b8ff; font-weight: 600; }
.esh-f         { color: var(--fg); }
.esh-f-md      { color: #5ddc9a; }   /* markdown — vert  */
.esh-f-json    { color: #ffb454; }   /* json     — orange */
.esh-f-js      { color: #ffd966; }   /* js/ts    — jaune */
.esh-f-css     { color: #bd93f9; }   /* css      — violet */
.esh-f-html    { color: #ff96b8; }   /* html/xml/svg — rose */
.esh-f-img     { color: #5dade2; }   /* images   — bleu  */
.esh-f-sh      { color: #50c878; }   /* shell    — vert émeraude */
.esh-f-cfg     { color: #d4a5a5; }   /* yaml/toml — taupe */
.esh-f-rs      { color: #d77a61; }   /* rust     — orange brûlé */
.esh-f-py      { color: #76d6ff; }   /* python   — bleu clair */
.esh-meta      { color: var(--fg-muted); font-style: italic; }

/* Bloc cat avec highlight.js : reset des paddings, conserve la couleur du theme */
.esh-cat {
  margin: 4px 0;
  padding: 8px 10px;
  background: rgba(0, 0, 0, 0.25);
  border-left: 2px solid var(--esh-accent, #58c8ff);
  border-radius: 3px;
  font-family: var(--font-mono);
  font-size: var(--esh-fontSize);
  line-height: 1.55;
  white-space: pre-wrap;
  word-break: break-word;
  overflow-x: auto;
}
.esh-cat code { font-family: inherit; background: transparent !important; padding: 0 !important; }

.esh-input-row {
  display: flex; align-items: center; gap: 8px;
  padding: 6px 14px 10px;
  border-top: 1px solid rgba(255,255,255,0.04);
  flex-shrink: 0;
}
.esh-input-row .esh-prompt {
  color: var(--esh-accent);
  font-weight: 500;
  user-select: none;
  white-space: nowrap;
}
.esh-input {
  flex: 1;
  background: transparent;
  border: none; outline: none;
  color: var(--fg);
  font-family: inherit; font-size: inherit; line-height: inherit;
  padding: 0;
  caret-color: var(--esh-accent);
}
.esh-input::placeholder { color: var(--fg-muted); }
.edenshell-root ::selection { background: rgba(88, 200, 255, 0.35); color: #fff; }

/* ── Resize handles (8 directions) ────────────────────────────────────── */
.esh-resize { position: absolute; z-index: 10; }
.esh-resize.n { top: -3px;    left: 8px;   right: 8px;   height: 6px;  cursor: ns-resize; }
.esh-resize.s { bottom: -3px; left: 8px;   right: 8px;   height: 6px;  cursor: ns-resize; }
.esh-resize.e { right: -3px;  top: 8px;    bottom: 8px;  width: 6px;   cursor: ew-resize; }
.esh-resize.w { left: -3px;   top: 8px;    bottom: 8px;  width: 6px;   cursor: ew-resize; }
.esh-resize.ne { top: -3px;    right: -3px; width: 12px; height: 12px; cursor: nesw-resize; }
.esh-resize.nw { top: -3px;    left: -3px;  width: 12px; height: 12px; cursor: nwse-resize; }
.esh-resize.se { bottom: -3px; right: -3px; width: 12px; height: 12px; cursor: nwse-resize; }
.esh-resize.sw { bottom: -3px; left: -3px;  width: 12px; height: 12px; cursor: nesw-resize; }
.esh-window.esh-maximized .esh-resize { display: none; }

/* ── Panel préférences (popover interne) ─────────────────────────────── */
.esh-prefs {
  position: absolute;
  top: 38px; right: 10px;
  width: 280px;
  background: rgba(12, 18, 32, 0.95);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: var(--r-md);
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
  padding: 12px 14px;
  z-index: 20;
}
.esh-prefs-head {
  font-size: 11px; letter-spacing: 0.16em; text-transform: uppercase;
  color: var(--fg-dim); margin-bottom: 10px;
}
.esh-prefs-row {
  display: flex; align-items: center; gap: 10px;
  margin: 8px 0;
  font-size: 12px;
}
.esh-prefs-row label {
  flex: 0 0 78px;
  color: var(--fg-dim);
  font-size: 11px;
}
.esh-prefs-row input[type="range"] {
  flex: 1;
  accent-color: var(--esh-accent);
}
.esh-prefs-row [data-pref-val] {
  flex: 0 0 32px; text-align: right; color: var(--fg);
  font-family: var(--font-mono); font-size: 11px;
}
.esh-prefs-row .btn-ghost {
  font-family: var(--font-mono); font-size: 10px;
  padding: 5px 10px;
}

.esh-accents {
  display: flex; gap: 6px; flex: 1;
}
.esh-accent-swatch {
  --swatch: #58c8ff;
  width: 22px; height: 22px;
  border-radius: 50%;
  background: var(--swatch);
  border: 2px solid transparent;
  cursor: pointer;
  padding: 0;
  transition: transform .15s ease, border-color .15s ease;
}
.esh-accent-swatch:hover { transform: scale(1.15); }
.esh-accent-swatch.selected { border-color: #fff; box-shadow: 0 0 8px var(--swatch); }

/* ════════════════════════════════════════════════════════════════════════
 *  Palette de commandes (Alt+K)
 * ════════════════════════════════════════════════════════════════════════ */

.esh-palette {
  position: fixed;
  inset: 0;
  z-index: 9000;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 12vh;
  font-family: var(--font-mono);
}
.esh-palette[hidden] { display: none; }

.esh-palette-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  backdrop-filter: blur(4px);
  -webkit-backdrop-filter: blur(4px);
}

.esh-palette-dialog {
  position: relative;
  width: min(640px, 90vw);
  max-height: 70vh;
  display: flex;
  flex-direction: column;
  background: rgba(12, 18, 32, 0.96);
  border: 1px solid rgba(88, 200, 255, 0.30);
  border-radius: 12px;
  box-shadow:
    0 24px 60px rgba(0, 0, 0, 0.55),
    0 0 24px rgba(88, 200, 255, 0.18);
  overflow: hidden;
  animation: esh-palette-in 0.18s ease-out;
}
@keyframes esh-palette-in {
  from { opacity: 0; transform: translateY(-8px) scale(0.98); }
  to   { opacity: 1; }
}

.esh-palette-input-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.esh-palette-icon { color: var(--fg-muted); flex-shrink: 0; }
.esh-palette-input {
  flex: 1;
  background: transparent;
  border: none;
  outline: none;
  color: var(--fg);
  font-family: var(--font-mono);
  font-size: 14px;
  padding: 0;
}
.esh-palette-input::placeholder { color: var(--fg-muted); }

.esh-palette-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
  scrollbar-width: thin;
  scrollbar-color: rgba(88,200,255,0.25) transparent;
}
.esh-palette-list::-webkit-scrollbar { width: 6px; }
.esh-palette-list::-webkit-scrollbar-thumb { background: rgba(88,200,255,0.25); border-radius: 3px; }

.esh-palette-empty {
  padding: 18px;
  color: var(--fg-muted);
  text-align: center;
  font-size: 12px;
}

.esh-palette-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 9px 16px;
  cursor: pointer;
  font-size: 13px;
  border-left: 2px solid transparent;
}
.esh-palette-item.selected {
  background: rgba(88, 200, 255, 0.12);
  border-left-color: var(--accent);
}
.esh-palette-name {
  color: var(--fg);
  font-weight: 500;
  flex-shrink: 0;
  min-width: 100px;
}
.esh-palette-desc {
  color: var(--fg-dim);
  font-size: 12px;
  flex: 1;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.esh-palette-plug {
  color: var(--fg-muted);
  font-size: 10px;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  background: rgba(255,255,255,0.04);
  padding: 2px 6px;
  border-radius: 4px;
  flex-shrink: 0;
}

.esh-palette-footer {
  display: flex;
  gap: 18px;
  padding: 9px 16px;
  border-top: 1px solid rgba(255,255,255,0.06);
  font-size: 10px;
  color: var(--fg-muted);
}
.esh-palette-footer kbd {
  display: inline-block;
  font-family: var(--font-mono);
  font-size: 10px;
  background: rgba(255,255,255,0.06);
  border: 1px solid rgba(255,255,255,0.10);
  border-radius: 3px;
  padding: 1px 5px;
  margin-right: 4px;
  color: var(--fg-dim);
}

/* ── Bouton restore (mode minimisé) ───────────────────────────────────── */
.esh-restore-btn {
  position: fixed;
  right: 20px; bottom: 20px;
  height: 44px;
  padding: 0 14px 0 12px;
  display: flex; align-items: center; gap: 8px;
  background: rgba(8, 14, 28, 0.9);
  border: 1px solid #58c8ff;
  border-radius: 22px;
  color: #58c8ff;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(0,0,0,0.5);
  z-index: 200;
  transition: transform .15s ease, box-shadow .15s ease;
  font-family: var(--font-mono);
  font-size: 11px;
  letter-spacing: 0.08em;
}
.esh-restore-btn:hover {
  transform: scale(1.05);
  box-shadow: 0 6px 24px rgba(88,200,255,0.5);
}
.esh-restore-label { color: var(--fg-dim); }

/* Drop zone visual : cible active (cross-window VFS drag&drop). Appliqué
   par Eden.shell.acceptVfsDrop sur la winEl quand un drag VFS survole. */
.eden-vfs-drop-active {
  outline: 2px dashed #4ade80;
  outline-offset: -2px;
  box-shadow: 0 0 0 4px rgba(74, 222, 128, 0.18), 0 0 30px rgba(74, 222, 128, 0.35);
  transition: box-shadow 0.12s ease;
}
