/* ═══════════════════════════════════════════════════════════
   ARBORESCENCE FICHIERS — "Console d'audit" · thème CLAIR
   Layout 2 colonnes · arbre indenté CSS · accent #930000
   ═══════════════════════════════════════════════════════════ */

:root {
  /* ── Surfaces (light, légèrement bleutées) ── */
  --bg:        #e9edf3;
  --pane:      #ffffff;
  --pane2:     #f4f7fb;
  --surf:      #f0f3f9;
  --surf2:     #e6ecf4;
  --border:    #dce2ec;
  --border2:   #c7cfdd;

  /* ── Marque ── */
  --brand:     #930000;
  --brand-dim: rgba(147,0,0,.07);
  --brand-bd:  rgba(147,0,0,.30);

  /* ── Niveaux d'accès ── */
  --mod:       #b03a3a;  --mod-bg:  rgba(176,58,58,.08);   --mod-bd: rgba(176,58,58,.26);
  --lec:       #2d6ab0;  --lec-bg:  rgba(45,106,176,.08);  --lec-bd: rgba(45,106,176,.26);
  --nav:       #1a8a72;  --nav-bg:  rgba(26,138,114,.09);  --nav-bd: rgba(26,138,114,.26);
  --grp:       #6b4db0;

  /* ── Texte ── */
  --text:      #2a3140;
  --text2:     #5a7090;
  --text3:     #8593a6;

  --amber-bg:  rgba(160,112,24,.12);
  --amber-bd:  rgba(160,112,24,.45);

  --mono: 'JetBrains Mono', ui-monospace, 'SF Mono', Menlo, monospace;
  --sans: 'DM Sans', system-ui, -apple-system, sans-serif;

  --row-h: 24px;
  --indent: 16px;
}

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

html, body { height: 100%; }

body {
  font-family: var(--sans);
  background: var(--bg);
  color: var(--text);
  font-size: 12px;
  line-height: 1.5;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

/* le topnav garde son propre CSS (nav.css) ; on borne juste le reste */
#workspace {
  flex: 1;
  min-height: 0;
  display: grid;
  grid-template-columns: minmax(320px, 1.2fr) minmax(340px, 1fr);
  gap: 1px;
  background: var(--border);   /* les gaps deviennent des séparateurs */
}

/* ── Pane générique ── */
.pane {
  background: var(--pane);
  display: flex;
  flex-direction: column;
  min-height: 0;
  min-width: 0;
}

.pane-head {
  padding: 14px 16px 12px;
  border-bottom: 1px solid var(--border);
  background: var(--pane2);
  position: relative;
  z-index: 5;   /* l'en-tête (et donc la zone de résultats) passe au-dessus de l'arbre */
}

.pane-eyebrow {
  font-family: var(--mono);
  font-size: 9px;
  font-weight: 600;
  letter-spacing: .18em;
  text-transform: uppercase;
  color: var(--text3);
}

.pane-title {
  font-family: var(--sans);
  font-size: 15px;
  font-weight: 600;
  letter-spacing: -.01em;
  color: var(--text);
  margin-top: 2px;
}

.tree-name.no-export {
  color: var(--text3);
  font-style: italic;
}

.tree-actions {
  margin-left: auto;
  flex: 0 0 auto;
  display: flex;
  align-items: center;
  gap: 6px;
  padding-left: 8px;
}

/* la taille n'a plus besoin de pousser elle-même */
.tree-size { margin-left: 0; padding-left: 0; }

.tree-reload {
  flex: 0 0 auto;
  font-size: 11px;
  color: var(--text3);
  padding: 0 4px;
  border-radius: 4px;
  opacity: 0;
  transition: opacity .12s, color .12s, background .12s;
}
.tree-line:hover .tree-reload { opacity: 1; }
.tree-reload:hover { color: var(--brand); background: var(--brand-dim); }
.tree-reload.spinning { opacity: 1; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* fine barre d'accent sous le titre de la 1re colonne */
#tree-panel .pane-title { position: relative; }
#tree-panel .pane-title::after {
  content: '';
  position: absolute;
  left: 0; bottom: -5px;
  width: 26px; height: 2px;
  background: var(--brand);
  border-radius: 2px;
}

.pane-scroll {
  flex: 1;
  min-height: 0;
  overflow: auto;
  padding: 8px 0;
}
.pane-scroll::-webkit-scrollbar { width: 9px; height: 9px; }
.pane-scroll::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 5px; border: 2px solid var(--pane); }
.pane-scroll::-webkit-scrollbar-track { background: transparent; }

/* ── Outils de colonne (search + boutons) ── */
.tree-tools { margin-top: 11px; display: flex; flex-direction: column; gap: 7px; }

.tree-search { position: relative; display: flex; align-items: center; }
.tree-search-ic {
  position: absolute; left: 9px;
  font-size: 11px; opacity: .6; pointer-events: none;
}

.tree-reload {
  margin-left: auto;
  flex: 0 0 auto;
  font-size: 11px;
  color: var(--text3);
  padding: 0 4px;
  border-radius: 4px;
  opacity: 0;                /* visible au survol de la ligne */
  transition: opacity .12s, color .12s, background .12s;
}

.tree-reload:hover { color: var(--brand); background: var(--brand-dim); }
.tree-reload.spinning { opacity: 1; animation: spin .8s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

.search-input {
  width: 100%;
  background: var(--bg);
  border: 1px solid var(--border2);
  border-radius: 6px;
  color: var(--text);
  font-family: var(--sans);
  font-size: 12px;
  padding: 6px 10px 6px 28px;
  outline: none;
  transition: border-color .15s, box-shadow .15s;
}
.search-input:focus {
  border-color: var(--brand);
  box-shadow: 0 0 0 3px var(--brand-dim);
}
.search-input::placeholder { color: var(--text3); }

.tree-btns { display: flex; gap: 6px; }
.ghost-btn {
  flex: 1;
  background: var(--surf);
  color: var(--text2);
  border: 1px solid var(--border2);
  border-radius: 6px;
  padding: 5px 8px;
  font-family: var(--mono);
  font-size: 10px;
  letter-spacing: .03em;
  cursor: pointer;
  transition: background .12s, color .12s, border-color .12s;
}
.ghost-btn:hover { background: var(--surf2); color: var(--text); border-color: var(--brand-bd); }
.ghost-btn:focus-visible { outline: 2px solid var(--brand); outline-offset: 1px; }

/* ── Résultats de recherche ──
   Boîte distincte qui ne chevauche plus l'arbre :
   fond plein, bordure, scroll interne, items non écrasés. */
.search-results {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 230px;
  overflow-y: auto;
  background: var(--pane);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 4px;
  box-shadow: 0 6px 16px rgba(20,30,50,.10);
}
.search-results:empty {
  display: none;       /* pas de boîte vide quand aucun résultat */
}
.search-results::-webkit-scrollbar { width: 8px; }
.search-results::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 5px; }

.search-result-item {
  flex: 0 0 auto;          /* empêche l'écrasement vertical des items */
  min-height: 26px;
  display: flex;
  align-items: center;
  padding: 5px 9px;
  border-radius: 5px;
  cursor: pointer;
  color: var(--text2);
  font-family: var(--mono);
  font-size: 11px;
  line-height: 1.3;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  border: 1px solid transparent;
  transition: background .1s, color .1s, border-color .1s;
}
.search-result-item:hover {
  background: var(--surf);
  color: var(--text);
  border-color: var(--border2);
}
.search-result-item.user-result { color: var(--nav); }

/* ═══════════ ARBRE (indentation CSS) ═══════════ */
ul.tree { list-style: none; padding-left: 0; }
ul.tree.collapsed { display: none; }
.tree-item { white-space: nowrap; }

.tree-line {
  display: flex;
  align-items: center;
  gap: 6px;
  height: var(--row-h);
  padding: 0 10px 0 calc(8px + var(--lvl, 0) * var(--indent));
  cursor: pointer;
  user-select: none;
  position: relative;
  transition: background .1s;
}
.tree-line:hover { background: var(--surf); }
.tree-line:hover .tree-reload { opacity: 1; }
.tree-line.active {
  background: linear-gradient(90deg, var(--brand-dim), transparent 60%);
  box-shadow: inset 2px 0 0 var(--brand);
}
.tree-line.search-hit {
  background: var(--amber-bg);
  box-shadow: inset 2px 0 0 var(--amber-bd);
}

/* chevron de pliage (remplace l'ASCII) */
.tree-twist {
  width: 12px; flex: 0 0 12px;
  font-size: 9px;
  color: var(--text3);
  text-align: center;
  transition: transform .12s;
}
.tree-twist.open { transform: rotate(90deg); }
.tree-twist.leaf { visibility: hidden; }

.tree-icon { font-size: 12px; flex: 0 0 auto; }

.tree-name {
  color: var(--text);
  overflow: hidden;
  text-overflow: ellipsis;
}
.tree-name.has-droits { color: var(--text); font-weight: 500; }
.tree-name.leaf { color: var(--text2); }

.tree-badge {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--grp);
  background: rgba(107,77,176,.08);
  border: 1px solid rgba(107,77,176,.24);
  border-radius: 4px;
  padding: 0 6px;
  line-height: 15px;
  flex: 0 0 auto;
}
.tree-size {
  font-family: var(--mono);
  font-size: 9px;
  color: var(--text3);
  margin-left: auto;
  padding-left: 8px;
  flex: 0 0 auto;
}

/* ═══════════ PANNEAU DÉTAIL ═══════════ */
#info { padding: 16px; }

.placeholder {
  height: 100%;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
  gap: 12px;
  text-align: center;
  color: var(--text3);
  padding: 40px 20px;
}
.placeholder-mark {
  font-size: 30px;
  opacity: .5;
  color: var(--brand);
}
.placeholder p { font-size: 12px; line-height: 1.7; }

#info h3 {
  font-family: var(--sans);
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 5px;
  word-break: break-all;
}

#info .chemin {
  font-family: var(--mono);
  color: var(--text3);
  font-size: 10px;
  margin-bottom: 12px;
  word-break: break-all;
}
#info .empty, .no-users {
  color: var(--text3);
  font-style: italic;
  font-size: 11px;
}

.taille-info {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--nav);
  background: var(--nav-bg);
  border: 1px solid var(--nav-bd);
  border-radius: 5px;
  padding: 3px 9px;
  margin-bottom: 12px;
  display: inline-block;
}

/* ── Breadcrumb ── */
.breadcrumb {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text3);
  margin-bottom: 10px;
  display: flex; flex-wrap: wrap; gap: 3px; align-items: center;
}
.breadcrumb-item { color: var(--lec); cursor: pointer; transition: color .1s; }
.breadcrumb-item:hover { color: var(--text); text-decoration: underline; }
.breadcrumb-sep { color: var(--text3); }

/* ── Server badge ── */
.server-badge {
  display: inline-flex; align-items: center; gap: 5px;
  font-family: var(--mono);
  font-size: 9px; font-weight: 700;
  background: var(--brand-dim);
  color: var(--brand);
  border: 1px solid var(--brand-bd);
  border-radius: 5px;
  padding: 3px 8px;
  margin-bottom: 10px;
  text-transform: uppercase;
  letter-spacing: .06em;
}

/* ── Section title ── */
.section-title {
  font-family: var(--mono);
  font-size: 9px; font-weight: 700;
  text-transform: uppercase; letter-spacing: .12em;
  color: var(--text3);
  margin: 16px 0 8px;
  display: flex; align-items: center; gap: 8px;
}
.section-title::after { content: ''; flex: 1; height: 1px; background: var(--border); }

/* ── Droit card ── */
.droit-card {
  background: var(--surf);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: 9px 11px;
  margin-bottom: 7px;
}
.droit-card.herite { opacity: .6; border-style: dashed; }

.droit-groupe {
  font-family: var(--mono);
  color: var(--grp);
  font-size: 11px; font-weight: 600;
  margin-bottom: 6px;
  display: flex; align-items: center; gap: 6px; flex-wrap: wrap;
}
.herite-badge {
  margin-left: auto;
  font-size: 8px;
  color: var(--text3);
  border: 1px solid var(--border2);
  border-radius: 4px;
  padding: 1px 5px;
  font-family: var(--mono);
  text-transform: uppercase;
  letter-spacing: .05em;
}

.droit-type {
  display: inline-block;
  font-family: var(--mono);
  font-size: 9px; font-weight: 700;
  padding: 2px 8px;
  border-radius: 4px;
  margin-bottom: 4px;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.droit-type.mod { background: var(--mod-bg); color: var(--mod); border: 1px solid var(--mod-bd); }
.droit-type.lec { background: var(--lec-bg); color: var(--lec); border: 1px solid var(--lec-bd); }
.droit-type.nav { background: var(--nav-bg); color: var(--nav); border: 1px solid var(--nav-bd); }

.droit-portee { font-family: var(--mono); color: var(--text3); font-size: 9px; }

/* ── Access level ── */
.access-level-title {
  font-family: var(--mono);
  font-size: 9px; font-weight: 700;
  padding: 3px 9px;
  border-radius: 5px;
  margin: 12px 0 6px;
  display: inline-block;
  text-transform: uppercase;
  letter-spacing: .06em;
}
.access-level-title.mod { background: var(--mod-bg); color: var(--mod); border: 1px solid var(--mod-bd); }
.access-level-title.lec { background: var(--lec-bg); color: var(--lec); border: 1px solid var(--lec-bd); }
.access-level-title.nav { background: var(--nav-bg); color: var(--nav); border: 1px solid var(--nav-bd); }

/* ── User list ── */
.user-list { display: flex; flex-direction: column; margin-bottom: 8px; }
.user-item {
  font-family: var(--mono);
  font-size: 10px;
  color: var(--text);
  padding: 3px 0;
  border-bottom: 1px solid var(--border);
  display: flex; align-items: baseline; gap: 6px;
}
.user-item.user-herite { opacity: .5; font-style: italic; }
.user-login { color: var(--text3); font-size: 9px; }

/* ═══════════ Responsive ═══════════ */
@media (max-width: 820px) {
  body { overflow: auto; }
  #workspace { display: flex; flex-direction: column; height: auto; }
  .pane { min-height: 300px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; }
}