.reference-panel {
  display: flex;
  flex-direction: column;
  background: #0d1117;
  border: 1px solid #1f2937;
  border-radius: 12px;
  overflow: hidden;
  height: 100%;
  min-height: 0;
}

// ─────────────── Tabs ───────────────
.ref-tabs {
  display: flex;
  flex-wrap: wrap; // 6 onglets : on passe sur 2 rangs plutôt que de rogner « Scènes ».
  background: #111827;
  border-bottom: 1px solid #1f2937;
}

.ref-tab {
  flex: 1 1 33.333%;
  min-width: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.3rem;
  background: transparent;
  color: #9ca3af;
  border: none;
  padding: 0.55rem 0.4rem;
  font-size: 0.78rem;
  white-space: nowrap;
  font-weight: 500;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  transition: color 0.15s, border-color 0.15s, background 0.15s;

  &:hover { color: #e5e7eb; background: rgba(108, 99, 255, 0.06); }

  &--active {
    color: #c4bdff;
    border-bottom-color: #6c63ff;
    background: rgba(108, 99, 255, 0.1);
  }
}

.ref-content {
  padding: 1rem;
  overflow-y: auto;
  flex: 1;
  min-height: 0;
}

/*
 * Onglet IA : on retire l'overflow du conteneur (le panneau de chat gère
 * son propre scroll interne pour les messages) et on force display flex
 * pour que l'enfant prenne toute la hauteur.
 */
.ref-content--fill {
  display: flex;
  overflow: hidden;

  > app-session-ai-chat-panel {
    flex: 1;
    min-height: 0;
    display: flex;
  }
}

// ─────────────── Listes (PJ/PNJ/Scènes) ───────────────
.ref-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.ref-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;

  h4 {
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    color: #9ca3af;
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.4px;
    margin: 0 0 0.25rem 0;
  }
}

// En-tête de section repliable (PJ / PNJ / arc), stylé comme un <h4> mais cliquable.
.ref-group-head {
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  width: 100%;
  margin: 0 0 0.25rem 0;
  padding: 0;
  background: none;
  border: none;
  cursor: pointer;
  color: #9ca3af;
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  text-align: left;

  &:hover { color: #d1d5db; }

  .ref-group-chevron { opacity: 0.6; flex-shrink: 0; }

  .ref-group-count {
    margin-left: auto;
    font-weight: 400;
    text-transform: none;
    letter-spacing: 0;
    color: #6b7280;
  }
}

.ref-subgroup {
  display: flex;
  flex-direction: column;
  gap: 0.2rem;
  padding-left: 0.25rem;
  margin-top: 0.35rem;

  .ref-subgroup-title {
    color: #6b7280;
    font-size: 0.72rem;
    margin-bottom: 0.15rem;
  }

  // En-tête de dossier de PNJ (repliable) dans l'onglet Personnages.
  .ref-subgroup-head {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    width: 100%;
    margin-bottom: 0.15rem;
    padding: 0;
    background: none;
    border: none;
    cursor: pointer;
    text-align: left;
    color: #8a93a3;
    font-size: 0.72rem;

    &:hover { color: #c0c7d1; }

    .ref-group-chevron { opacity: 0.55; flex-shrink: 0; }
    .ref-group-count { margin-left: auto; color: #6b7280; }
  }
}

.ref-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 0.5rem;
  background: #111827;
  border: 1px solid #1f2937;
  color: #e5e7eb;
  font-size: 0.82rem;
  text-align: left;
  padding: 0.45rem 0.65rem;
  border-radius: 6px;
  cursor: pointer;
  transition: border-color 0.15s, background 0.15s;

  &:hover { border-color: #6c63ff; background: #131c2e; }

  &--nested { padding-left: 0.9rem; }

  .ref-item-name {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
  }

  .ref-item-icon {
    color: #6b7280;
    flex-shrink: 0;
  }
}

.loading-hint,
.empty-hint {
  color: #6b7280;
  font-size: 0.8rem;
  font-style: italic;
  text-align: center;
  margin: 0.5rem 0;
}
