/* Overlay global : caché par défaut, visible quand .open est présent */
.knowledge-modal {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.55);
  display: none;             /* <- clé : caché tant qu'on n'a pas .open */
  align-items: center;
  justify-content: center;
  z-index: 10010;
}

.knowledge-modal.open {
  display: flex;             /* <- le JS ajoute/enlève cette classe */
}

/* Bouton fermeture */
.knowledge-close {
  position: absolute;
  top: 8px;
  right: 10px;
  border: 0;
  background: transparent;
  color: #e5e7eb;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  z-index: 2;
}
.knowledge-close:hover {
  transform: scale(1.05);
}

/* Header */
.knowledge-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding-right: 28px;
}
.knowledge-header-main {
  display: flex;
  align-items: center;
  gap: 12px;
}
.knowledge-avatar {
  width: 64px;
  height: 64px;
  border-radius: 12px;
  background: #020617;
  border: 2px solid #0f5d7a;
  display: grid;
  place-items: center;
  overflow: hidden;
}
.knowledge-avatar img {
  max-width: 90%;
  max-height: 90%;
  object-fit: contain;
  image-rendering: pixelated;
}
.knowledge-header-text p {
  margin: 0;
}
.knowledge-label-top {
  font-size: .78rem;
  text-transform: uppercase;
  letter-spacing: .12em;
  opacity: .75;
}
#knowledge-title {
  margin: 0;
  font-family: "Jersey 10", system-ui;
  font-size: clamp(1.4rem, 2.8vw, 1.9rem);
}
.knowledge-subtitle {
  margin-top: 2px;
  font-size: .9rem;
  opacity: .86;
}
.knowledge-subtitle .knowledge-profile-inline {
  font-weight: 600;
}

/* Compteur + mode */
.knowledge-header-meta {
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 4px;
}
.knowledge-counter {
  font-family: var(--font-mono, "IBM Plex Mono", ui-monospace);
  font-size: .8rem;
  padding: 4px 8px;
  border-radius: 999px;
  background: rgba(147,51,234,.08);
  border: 1px solid rgba(236,72,153,.65);
}
.knowledge-mode-pill {
  font-family: var(--font-mono, "IBM Plex Mono", ui-monospace);
  font-size: .78rem;
  padding: 3px 9px;
  border-radius: 999px;
  border: 1px dashed rgba(148,163,184,.8);
  color: #e5e7eb;
  opacity: .8;
}

/* Layout principal */
.knowledge-layout {
  display: grid;
  grid-template-columns: minmax(0, 2.1fr) minmax(230px, 1fr);
  gap: 14px;
  flex: 1 1 auto;
  min-height: 0;
}

/* Cadre pixel-art-ish */
.knowledge-frame {
  position: relative;
  background: #fbfaf9;
  border-radius: 16px;
  padding: 12px 10px 14px;
  border: 2px solid #fab760;
  box-shadow:
    0 0 0 1px rgba(235, 182, 37, 0.25),
    0 18px 35px rgba(42, 31, 15, 0.18);
  display: flex;
  flex-direction: column;
  gap: 8px;
  overflow: hidden;
  min-height: 0;
}

/* pseudo bordure "pixelisée" simplifiée */
.knowledge-frame::before {
  content: "";
  position: absolute;
  inset: 4px;
  border: 2px solid #0b4f6c;
  /* clip-path: polygon(
    8% 0, 92% 0,
    100% 8%, 100% 92%,
    92% 100%, 8% 100%,
    0 92%, 0 8%
  ); */
  pointer-events: none;
  opacity: .9;
}

.knowledge-frame-top,
.knowledge-frame-bottom {
  position: relative;
  z-index: 1;
  display: flex;
  justify-content: center;
}
.knowledge-frame-chip {
  padding: 4px 10px;
  border-radius: 999px;
  background: #0f172a;
  border: 1px solid #1e293b;
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .14em;
  opacity: .9;
}
.knowledge-frame-bottom .knowledge-footer-label {
  padding: 4px 10px;
  border-radius: 999px;
  background: #0f172a;
  border: 1px solid #1e293b;
  font-size: .8rem;
}

/* Body scrollable dans le cadre */
.knowledge-frame-body {
  position: relative;
  z-index: 1;
  margin: 4px 6px 6px;
  padding: 10px 10px 12px;
  background: radial-gradient(circle at top, #171602 0, #170d02 45%, #170e02 100%);
  border-radius: 12px;
  overflow-y: auto;
  max-height: 100%;
  flex: 1 1 auto;
  min-height: 0;
}
.knowledge-type-line {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  margin-bottom: 6px;
}
.knowledge-type-badge {
  font-family: var(--font-mono, "IBM Plex Mono", ui-monospace);
  font-size: .8rem;
  padding: 3px 8px;
  border-radius: 999px;
  border: 1px solid #c084fc;
  background: rgba(233,213,255,.35);
}
.knowledge-kind-bot {
  font-size: .78rem;
  opacity: .8;
}

.knowledge-title-field {
  margin: 4px 0 6px;
  font-size: 1rem;
  font-weight: 700;
}

.knowledge-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-bottom: 8px;
}
.knowledge-tags .tag-chip {
  font-family: var(--font-mono, "IBM Plex Mono", ui-monospace);
  font-size: .72rem;
  padding: 2px 7px;
  border-radius: 999px;
  background: rgba(15,118,110,.18);
  border: 1px solid rgba(34,197,94,.25);
}

.knowledge-text {
  font-size: .9rem;
  line-height: 1.45;
  color: #2e0450;
  margin-bottom: 10px;
}
.knowledge-text p {
  margin: 0 0 6px;
}
.knowledge-text p:last-child {
  margin-bottom: 0;
}

/* Source */
.knowledge-source-block {
  font-size: .78rem;
  color: #9ca3af;
  border-top: 1px solid rgba(148,163,184,.28);
  padding-top: 6px;
  margin-top: 4px;
}
.knowledge-source-title {
  font-weight: 500;
}
.knowledge-source-link a {
  color: #38bdf8;
  text-decoration: underline;
  word-break: break-all;
}

/* Sidebar listing */
.knowledge-sidebar {
  border-radius: 14px;
  background: #f9fafb;
  border: 1px solid rgba(148,163,184,.6);
  padding: 8px 8px 8px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  min-height: 0;
}
.knowledge-sidebar-title {
  margin: 0 0 4px;
  font-size: .85rem;
  text-transform: uppercase;
  letter-spacing: .14em;
  opacity: .8;
}
.knowledge-list {
  flex: 1 1 auto;
  overflow-y: auto;
  max-height: 100%;
}

/* item liste */
.knowledge-list-item {
  font-size: .8rem;
  padding: 6px 7px;
  border-radius: 8px;
  border: 1px solid transparent;
  background: #e5e7eb;
  margin-bottom: 4px;
  cursor: pointer;
  display: grid;
  grid-template-columns: auto 1fr;
  gap: 4px 8px;
  align-items: baseline;
}
.knowledge-list-item:last-child {
  margin-bottom: 0;
}
.knowledge-list-item-label {
  font-family: var(--font-mono, "IBM Plex Mono", ui-monospace);
  opacity: .9;
}
.knowledge-list-item-title {
  color: #e5e7eb;
}
.knowledge-list-item[data-kind="style"] .knowledge-list-item-kind {
  font-size: .75rem;
  opacity: .7;
}
.knowledge-list-item[data-selected="true"] {
  border-color: #c084fc;
  background: radial-gradient(circle at left, rgba(236,72,153,.20),rgba(59,7,100,.96));
}

/* variantes par bot (jusqu’à 4) */
.knowledge-list-item[data-bot-index="0"] { background-color: rgba(148,163,184,.14); }
.knowledge-list-item[data-bot-index="1"] { background-color: rgba(96,165,250,.10); }
.knowledge-list-item[data-bot-index="2"] { background-color: rgba(248,250,252,.06); }
.knowledge-list-item[data-bot-index="3"] { background-color: rgba(251,191,36,.08); }
.knowledge-list-item[data-selected="true"][data-bot-index] {
  border-color: #c084fc;
}

/* Footer : nav + outils */
.knowledge-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 4px 4px 0;
}
.knowledge-nav {
  display: flex;
  align-items: center;
  gap: 8px;
}
.knowledge-arrow {
  border-radius: 999px;
  border: 1px solid rgba(148,163,184,.7);
  background: rgba(15,23,42,.9);
  color: #e5e7eb;
  width: 34px;
  height: 34px;
  display: grid;
  place-items: center;
  cursor: pointer;
}
.knowledge-arrow:disabled {
  opacity: .4;
  cursor: default;
}
.knowledge-jump {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: .86rem;
}
.knowledge-input-index {
  width: 64px;
  padding: 3px 6px;
  border-radius: 6px;
  border: 1px solid rgba(148,163,184,.9);
  background: #020617;
  color: #e5e7eb;
  font-family: var(--font-mono, "IBM Plex Mono", ui-monospace);
  font-size: .86rem;
}
.knowledge-go {
  padding: 4px 8px;
  border-radius: 999px;
  border: 1px solid #c084fc;
  background: rgba(22,163,74,.15);
  color: #730cd3;
  font-family: var(--font-mono, "IBM Plex Mono", ui-monospace);
  font-size: .8rem;
  cursor: pointer;
}

.knowledge-tools {
  display: flex;
  align-items: center;
  gap: 4px;
}
.knowledge-tool-btn {
  border-radius: 999px;
  border: 1px dashed rgba(148,163,184,.7);
  background: rgba(15,23,42,.85);
  color: #e5e7eb;
  width: 30px;
  height: 30px;
  display: grid;
  place-items: center;
  cursor: pointer;
  font-size: 14px;
}

/* Responsive : petit écran → on masque la sidebar et on laisse respirer la fiche */
@media (max-width: 780px) {
  .knowledge-dialog {
    max-height: 96vh;
  }
  .knowledge-layout {
    grid-template-columns: minmax(0, 1fr);
  }
  .knowledge-sidebar {
    display: none;
  }
}

@media (max-width: 520px) {
  .knowledge-header {
    flex-direction: column;
    align-items: flex-start;
    padding-right: 18px;
  }
  .knowledge-header-meta {
    flex-direction: row;
    align-items: center;
    gap: 8px;
  }
  .knowledge-footer {
    flex-direction: column;
    align-items: stretch;
  }
  .knowledge-nav {
    justify-content: space-between;
  }
}

/* 2) Le dialog a une vraie hauteur, mais reste limité à la fenêtre */
.knowledge-dialog {
  position: relative;
  color: #0f172a;
  background: #ffffff; /* ou ton fond "jour" */
  border-radius: 18px;
  width: min(1100px, 96vw);
  max-height: 92vh;
  /* 👇 clé : le contenu interne va se caler dedans */
  display: flex;
  flex-direction: column;
  padding: 16px 16px 14px;
  box-shadow: 0 16px 60px rgba(0,0,0,.45);
  overflow: hidden;          /* on garde le scroll sur les zones internes */
}

/* 3) La zone centrale (fiche + listing) occupe tout l’espace restant */
.knowledge-layout {
  flex: 1 1 auto;
  min-height: 0;             /* nécessaire pour que le scroll interne marche */
  display: grid;
  grid-template-columns: minmax(0, 2.1fr) minmax(230px, 1fr);
  gap: 14px;
}

/* 4) La fiche elle-même peut scroller */
.knowledge-frame {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.knowledge-frame-body {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

/* 5) Le listing à droite a son scroll séparé */
.knowledge-sidebar {
  display: flex;
  flex-direction: column;
  min-height: 0;
}
.knowledge-list {
  flex: 1 1 auto;
  min-height: 0;
  overflow-y: auto;
}

/* ===========================================================
   🎨 MODE JOUR BAGOU AI – OVERRIDES
   Couleurs harmonisées sur le gradient du logo fourni
   =========================================================== */

:root {
  --bagou-pink:      #FF00A8;
  --bagou-magenta:   #FF0099;
  --bagou-peach:     #FF7A5C;
  --bagou-orange:    #FFA94A;
  --bagou-yellow:    #FFE85C;
  --bagou-white:     #FFFFFF;
  --bagou-black:     #000000;

  --bagou-gradient: linear-gradient(
    135deg,
    var(--bagou-pink) 0%,
    var(--bagou-peach) 40%,
    var(--bagou-orange) 65%,
    var(--bagou-yellow) 100%
  );
}

/* Overlay clair */
.knowledge-modal {
  background: rgba(255,255,255,.75) !important;
  backdrop-filter: blur(6px);
}

/* Dialog blanc propre */
.knowledge-dialog {
  background: #ffffff !important;
  color: #111827 !important;
  box-shadow:
    0 12px 40px rgba(0,0,0,.15),
    0 0 0 3px rgba(255,255,255,.8);
}

/* Avatar */
.knowledge-avatar {
  background: #ffffff !important;
  border: 2px solid var(--bagou-pink) !important;
}

/* Titre principal – noir + halo dégradé discret */
#knowledge-title {
  color: #111827 !important;
  text-shadow:
    0 0 6px rgba(255,0,168,.25),
    0 0 18px rgba(255,122,92,.15),
    0 0 28px rgba(255,232,92,.20);
}

/* Compteur */
.knowledge-counter {
  background: rgba(255,0,168,.10) !important;
  border: 1px solid var(--bagou-pink) !important;
  color: #111827 !important;
}

/* Pills monobot/multibot */
.knowledge-mode-pill {
  border: 1px dashed rgba(0,0,0,.25) !important;
  color: #374151 !important;
  background: rgba(255,255,255,.6) !important;
}

/* ===== CADRE PRINCIPAL DE LA FICHE ===== */

.knowledge-frame {
  background: #ffffff !important;
  border: 6px solid transparent !important;
  /* border-image: var(--bagou-gradient) 1 !important; */
  box-shadow:
    0 0 0 1px rgba(255,122,92,.25),
    0 18px 35px rgba(0,0,0,.12) !important;
}

.knowledge-frame::before {
  border: 2px solid var(--bagou-white) !important;
  opacity: .75 !important;
}

/* Header du cadre */
.knowledge-frame-chip {
  background: #ffffff !important;
  border: 1px solid rgba(0,0,0,.15) !important;
  color: #374151 !important;
}

/* Body clair et lisible */
.knowledge-frame-body {
  background: #f8fafc !important;
  color: #111827 !important;
}

/* Type de fiche */
.knowledge-type-badge {
  background: rgba(255,0,168,.12) !important;
  color: #111827 !important;
  border-color: var(--bagou-pink) !important;
}

/* Tags */
.tag-chip {
  background: rgba(255,232,92,.35) !important;
  border-color: var(--bagou-orange) !important;
  color: #111827 !important;
}

/* ===== SIDEBAR ===== */

.knowledge-sidebar {
  background: #f3f4f6 !important;
  border-color: rgba(0,0,0,.12) !important;
}

/* Items */
.knowledge-list-item {
  background: #ffffff !important;
  color: #111827 !important;
  border: 1px solid transparent !important;
}

/* Item sélectionné */
.knowledge-list-item[data-selected="true"] {
  border-color: var(--bagou-pink) !important;
  background: linear-gradient(
    135deg,
    rgba(255,0,168,.20),
    rgba(255,232,92,.20)
  ) !important;
}

/* Sidebar "titre d'item" */
.knowledge-list-item-title {
  color: #374151 !important;
}

/* Variantes multibot (couleurs plus douces) */
.knowledge-list-item[data-bot-index="0"] { background-color: #fff3fc !important; }
.knowledge-list-item[data-bot-index="1"] { background-color: #fffae5 !important; }
.knowledge-list-item[data-bot-index="2"] { background-color: #fff5ea !important; }
.knowledge-list-item[data-bot-index="3"] { background-color: #fff7d1 !important; }

/* ===== FOOTER ===== */
.knowledge-arrow {
  background: #e5e7eb !important;
  color: #111827 !important;
  border-color: rgba(0,0,0,.18) !important;
}

.knowledge-input-index {
  background: #ffffff !important;
  color: #111827 !important;
}

.knowledge-go {
  background: #7702fd !important;
  color: #e2e2e2 !important;
  border-color: #5c07e4 !important;
}

/* Outils édition */
.knowledge-tool-btn {
  background: #ffffff !important;
  color: #111827 !important;
  border-color: rgba(0,0,0,.25) !important;
}

.knowledge-header {
  align-items: center;
}

/* nouvelle rangée d’icônes */
.knowledge-header-extra {
  flex: 1 1 auto;
  display: flex;
  justify-content: center;
}

.knowledge-icons-row {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

/* style des icônes */
.knowledge-icons-row img {
  width: 34px;
  height: 34px;
  border-radius: 999px;
  padding: 4px;
  background: #f3f4ff;
  border: 1px solid rgba(148,163,184,.8);
  box-shadow: 0 2px 6px rgba(15,23,42,.15);
  object-fit: contain;
  margin-left: 8px;
  flex-shrink: 0;  
}

/* responsive : sur très petits écrans on peut les réduire ou les faire passer sur une ligne 2 */
@media (max-width: 520px) {
  .knowledge-icons-row img {
    width: 26px;
    height: 26px;
    padding: 3px;
  }
}

/* Bouton désactivé */
.knowledge-tool-btn.is-disabled {
  opacity: 0.85;
  cursor: not-allowed;
  filter: grayscale(100%);
  pointer-events: none; /* BLOQUE CLAVIER + SOURIS */
}

/* Sur petits et moyens écrans (tél + tablette) :
   on sacrifie le listing, on garde seulement la fiche */
@media (max-width: 1024px) {
  .knowledge-layout {
    grid-template-columns: minmax(0, 1fr);
  }

  .knowledge-sidebar {
    display: none !important;
  }
}

.knowledge-modal.open {
  align-items: flex-start;      /* modale collée en haut, le reste défile */
  overflow-y: auto;             /* scroll vertical possible */
  padding: 16px 0;              /* laisse un peu de marge en haut/bas */
}

.knowledge-image-block {
  margin-top: 10px;
  padding-top: 8px;
  border-top: 1px solid rgba(148,163,184,.28);
  display: none; /* on l’affiche seulement si on a une image */
}

.knowledge-image {
  max-width: 75%;
  height: auto;
  display: block;
  margin: 6px auto 0;
  border-radius: 10px;
  box-shadow: 0 4px 16px rgba(15,23,42,.18);
  object-fit: contain;
}
