/* ══════════════════════════════════════════════════════════
   Styles custom — complement au DSFR
   (split layout, chat, tree viz, result card internals)
   ══════════════════════════════════════════════════════════ */

/* ── Page layout ── */
html, body { height: 100%; margin: 0; overflow: hidden; }
#page { display: flex; flex-direction: column; height: 100vh; }

/* ── Split layout (horizontal 50/50) ── */
.split { flex: 1; display: flex; overflow: hidden; min-height: 0; }

/* ── Chat column (left, 50%) ── */
.chat-col {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
  background: var(--background-alt-blue-france, #f5f5fe);
  border-right: 1px solid var(--border-default-grey, #ddd);
  overflow: hidden;
}
#conversation {
  flex: 1; overflow-y: auto; padding: 1rem;
  display: flex; flex-direction: column; gap: .85rem;
  min-height: 0;
}

/* ── Messages ── */
.msg { display: flex; gap: .65rem; align-items: flex-start; }
.msg.user { flex-direction: row-reverse; }
.msg-avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: .85rem; flex-shrink: 0;
}
.msg.bot  .msg-avatar { background: var(--background-action-high-blue-france, #000091); color: #fff; }
.msg.user .msg-avatar { background: var(--background-alt-blue-france, #e3e3fd); color: var(--text-action-high-blue-france, #000091); }
.msg-bubble {
  max-width: 82%; padding: .7rem .9rem;
  border-radius: .25rem; font-size: .875rem; line-height: 1.55;
}
.msg.bot  .msg-bubble { background: var(--background-default-grey, #fff); border: 1px solid var(--border-default-grey, #e0e0e0); }
.msg.user .msg-bubble { background: var(--background-action-high-blue-france, #000091); color: #fff; }

/* ── Thinking animation ── */
.thinking { display: flex; gap: 5px; align-items: center; padding: .4rem 0; }
.thinking span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--background-action-high-blue-france, #000091);
  opacity: .3; animation: blink 1.2s infinite;
}
.thinking span:nth-child(2) { animation-delay: .2s; }
.thinking span:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%,80%,100%{opacity:.3} 40%{opacity:1} }

/* ── Input zone ── */
#input-zone {
  flex-shrink: 0;
  background: var(--background-default-grey, #fff);
  border-top: 1px solid var(--border-default-grey, #e0e0e0);
  padding: .65rem .9rem; display: flex; gap: .5rem; align-items: flex-end;
}
#user-input {
  flex: 1; border: 1px solid var(--border-default-grey, #aaa); border-radius: .25rem;
  outline: none; font-size: .875rem; resize: none;
  min-height: 80px; max-height: 200px;
  font-family: inherit; line-height: 1.5; padding: .4rem .6rem;
}
#user-input:focus {
  border-color: var(--border-active-blue-france, #000091);
  box-shadow: inset 0 -2px 0 0 var(--border-active-blue-france, #000091);
}

/* ── Config panel extras ── */
.config-grid {
  display: grid; grid-template-columns: 1fr 1fr;
  gap: .6rem .9rem; margin-top: .75rem;
}
@media (max-width: 600px) { .config-grid { grid-template-columns: 1fr; } }
.config-grid .full { grid-column: 1/-1; }
.config-preset-bar { display: flex; flex-wrap: wrap; gap: .4rem; }
.config-status { margin-top: .6rem; font-size: .78rem; display: flex; align-items: center; gap: .4rem; }
.config-status.ok  { color: var(--text-default-success, #18753c); }
.config-status.err { color: var(--text-default-error, #ce0500); }

/* ── Result card internals ── */
.result-card .fr-card__content { padding: .85rem; }
.result-label { font-size: .9rem; font-weight: 700; margin-bottom: .65rem; color: var(--text-action-high-blue-france, #000091); }
.sortie-item {
  display: flex; align-items: flex-start; gap: .55rem;
  padding: .5rem .65rem; border-radius: .25rem; margin-bottom: .4rem; font-size: .82rem;
}
.sortie-item.priorite-1 { background: var(--background-default-grey, #fff); border: 2px solid var(--border-action-high-blue-france, #000091); }
.sortie-item.priorite-2 { background: var(--background-alt-blue-france, #f5f5fe); border: 1px solid var(--border-default-grey, #e0e0e0); }
.sortie-item.priorite-3 { background: var(--background-contrast-grey, #f9f9f9); border: 1px solid var(--border-default-grey, #e0e0e0); }
.sortie-icon  { font-size: 1rem; flex-shrink: 0; margin-top: .1rem; }
.sortie-content { flex: 1; }
.sortie-title { font-weight: 700; margin-bottom: .15rem; }
.sortie-url a { font-size: .76rem; color: var(--text-action-high-blue-france, #000091); word-break: break-all; }
.sortie-note  { font-size: .76rem; color: var(--text-mention-grey, #666); margin-top: .15rem; font-style: italic; }

.sc-badge { margin-bottom: .65rem; }

.pivot-question {
  background: var(--background-alt-blue-france, #e8edff);
  border-left: 3px solid var(--border-action-high-blue-france, #000091);
  padding: .55rem .8rem; border-radius: 0 .25rem .25rem 0;
  font-size: .82rem; margin: .65rem 0;
}
.pivot-question strong { display: block; margin-bottom: .4rem; }
.pivot-btns { display: flex; flex-wrap: wrap; gap: .4rem; }

.mediateur-block {
  background: var(--background-alt-blue-france, #f0f5ff);
  border: 1px dashed var(--border-action-high-blue-france, #000091);
  padding: .5rem .75rem; border-radius: .25rem; font-size: .76rem; margin-top: .65rem;
}
.mediateur-block strong { display: block; margin-bottom: .15rem; }

/* ── Tree column (right, 50%) ── */
.tree-col {
  flex: 1; min-width: 0;
  display: flex; flex-direction: column;
  background: var(--background-alt-grey, #fafbff);
  overflow: hidden; position: relative;
}
.tree-toolbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: .45rem 1rem;
  background: var(--background-default-grey, #fff);
  border-bottom: 1px solid var(--border-default-grey, #e8e8f0);
  flex-shrink: 0;
}
.tree-toolbar-title {
  font-size: .78rem; font-weight: 700; color: var(--text-action-high-blue-france, #000091);
  display: flex; align-items: center; gap: .4rem;
}
.tree-state-label {
  font-size: .7rem; font-weight: 400;
  color: var(--text-mention-grey, #888);
  background: var(--background-alt-grey, #f0f0f8);
  padding: .1rem .45rem; border-radius: 2rem;
}

#tree-svg-wrap { flex: 1; overflow: hidden; position: relative; cursor: grab; }
#tree-svg-wrap:active { cursor: grabbing; }
#tree-svg-wrap svg { display: block; width: 100%; height: 100%; }

.tree-node-tooltip {
  position: absolute; background: #1a1a3e; color: #fff;
  font-size: .75rem; padding: .35rem .7rem; border-radius: .25rem;
  pointer-events: none; z-index: 100; max-width: 260px;
  line-height: 1.4; box-shadow: 0 4px 12px rgba(0,0,9,.2);
  opacity: 0; transition: opacity .15s;
}
.tree-node-tooltip.visible { opacity: 1; }

.tree-placeholder {
  position: absolute; inset: 0; display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: .5rem;
  color: var(--text-mention-grey, #aaa); font-size: .85rem; pointer-events: none;
}
.tree-placeholder-icon { font-size: 2.5rem; opacity: .3; }

#tree-footer {
  flex-shrink: 0; padding: .35rem .85rem;
  background: var(--background-default-grey, #fff);
  border-top: 1px solid var(--border-default-grey, #eee);
  display: flex; align-items: center; justify-content: space-between;
  font-size: .7rem; color: var(--text-mention-grey, #999);
}
.tree-legend { display: flex; flex-wrap: wrap; gap: .5rem; }
.tree-legend-item { display: flex; align-items: center; gap: .3rem; }
.tree-legend-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }

/* ── Fiche viewer (panneau droit) ── */
#fiche-viewer {
  flex: 1; overflow-y: auto;
  padding: 1rem 1.25rem;
  background: var(--background-default-grey, #fff);
}
#fiche-viewer-content article {
  font-size: .875rem; line-height: 1.65;
}
#fiche-viewer-content article h1 {
  font-size: 1.25rem; margin-top: 0;
  color: var(--text-action-high-blue-france, #000091);
}
#fiche-viewer-content article h2 {
  font-size: 1.05rem; margin-top: 1.5rem;
  padding-bottom: .4rem;
  border-bottom: 1px solid var(--border-default-grey, #e0e0e0);
}
#fiche-viewer-content article h3 { font-size: .95rem; margin-top: 1rem; }
#fiche-viewer-content article ul,
#fiche-viewer-content article ol { padding-left: 1.5rem; }
#fiche-viewer-content article a {
  color: var(--text-action-high-blue-france, #000091);
  word-break: break-word;
}
#fiche-viewer-content .fr-breadcrumb { margin-bottom: .75rem; }

/* ── Bloc "En bref" dans la result card ── */
.fiche-en-bref {
  background: var(--background-alt-blue-france, #f5f5fe);
  border-left: 3px solid var(--border-action-high-blue-france, #000091);
  padding: .55rem .8rem; border-radius: 0 .25rem .25rem 0;
  font-size: .82rem; line-height: 1.55;
  margin: .5rem 0 .65rem;
  color: var(--text-default-grey, #333);
}

/* ── Responsive ── */
@media (max-width: 900px) {
  .split { flex-direction: column; }
  .chat-col { border-right: none; border-bottom: 1px solid var(--border-default-grey, #ddd); }
  .tree-col { min-height: 250px; }
}
