/*
 * Beratung / Chat mit Tilo (Contract v1.56 §21) – Gestaltung nach CI-Vorgabe ci/ci/docs/tilo-anbauberatung.md §9.
 * Nur Tokens aus sevenridge-tokens.css (--sr-*, --bs-*), keine festen Farbwerte.
 */

/* Menü-Icon (Mono, übernimmt die Textfarbe der Navigation wie Bootstrap-Icons) */
.tilo-nav-icon {
  display: inline-block;
  width: 1em;
  height: 1em;
  vertical-align: -0.125em;
  background-color: currentColor;
  -webkit-mask: url("tilo/tilo_icon_mono.svg") center / contain no-repeat;
  mask: url("tilo/tilo_icon_mono.svg") center / contain no-repeat;
}
.gc-sidebar .nav-link .tilo-nav-icon { width: 1.25rem; height: 1em; }
.gc-bottomnav a .tilo-nav-icon { display: block; margin: 0 auto; width: 1.1rem; height: 1.1rem; }

/* Avatar hell/dunkel */
.tilo-avatar { flex-shrink: 0; border-radius: 50%; }
.tilo-avatar-dark { display: none; }
[data-bs-theme="dark"] .tilo-avatar-light { display: none; }
[data-bs-theme="dark"] .tilo-avatar-dark { display: inline-block; }

/* Kopf */
.tilo-head-sub { font-size: .875rem; color: var(--bs-secondary-color); }
.tilo-status { display: inline-flex; align-items: center; gap: .375rem; font-size: .875rem; color: var(--bs-body-color); }
.tilo-status-dot { width: .625rem; height: .625rem; border-radius: 50%; flex-shrink: 0; background: var(--sr-stone); }
.tilo-status-ready .tilo-status-dot { background: var(--sr-leaf); }
.tilo-status-ready .bi { color: var(--sr-leaf); }
.tilo-status-warn .tilo-status-dot { background: var(--sr-dusk-amber); }
.tilo-status-warn .bi { color: var(--sr-dusk-amber); }
.tilo-status-neutral .bi, .tilo-status-disabled .bi { color: var(--sr-stone); }
[data-bs-theme="dark"] .tilo-status-ready .tilo-status-dot { background: var(--sr-sprout); }
[data-bs-theme="dark"] .tilo-status-ready .bi { color: var(--sr-sprout); }
[data-bs-theme="dark"] .tilo-status-dot { background: var(--sr-dark-text-muted); }
[data-bs-theme="dark"] .tilo-status-warn .tilo-status-dot { background: var(--sr-dusk-amber); }
[data-bs-theme="dark"] .tilo-status-neutral .bi, [data-bs-theme="dark"] .tilo-status-disabled .bi { color: var(--sr-dark-text-muted); }
.tilo-status-note { border-left: 3px solid var(--sr-dusk-amber); padding-left: .5rem; }
.tilo-status-note.tilo-note-neutral { border-left-color: var(--bs-border-color); }

/* Gesprächsliste */
.tilo-conv-list .list-group-item { border-radius: var(--sr-radius-card); margin-bottom: 2px; border: 0; }
.tilo-conv-list .list-group-item.active {
  background-color: var(--sr-mesa-sand);
  color: var(--sr-deep-ridge);
  box-shadow: inset 3px 0 0 var(--sr-leaf);
}
[data-bs-theme="dark"] .tilo-conv-list .list-group-item.active {
  background-color: var(--bs-tertiary-bg);
  color: var(--sr-mesa-sand);
  box-shadow: inset 3px 0 0 var(--sr-sprout);
}
.tilo-conv-title { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
@media (min-width: 992px) {
  .tilo-conv-col { max-width: 20rem; }
}

/* Verlauf */
.tilo-log { display: flex; flex-direction: column; gap: .75rem; }
.tilo-row { display: flex; gap: .5rem; align-items: flex-start; }
.tilo-row-user { justify-content: flex-end; }
.tilo-row-user > .tilo-msg { align-items: flex-end; }
.tilo-msg { display: flex; flex-direction: column; min-width: 0; max-width: min(72ch, 100%); }
.tilo-sender { font-size: .875rem; margin-bottom: .125rem; }
.tilo-sender strong { font-weight: 600; }
.tilo-sender time { color: var(--bs-secondary-color); }
.tilo-bubble { border-radius: var(--sr-radius-card); padding: .625rem .875rem; overflow-wrap: anywhere; }
.tilo-bubble-user { background: var(--sr-leaf); color: var(--sr-white); white-space: pre-wrap; }
.tilo-bubble-ai { background: var(--sr-mist); color: var(--sr-deep-ridge); }
[data-bs-theme="dark"] .tilo-bubble-ai { background: var(--sr-dark-surface-raised); color: var(--sr-mesa-sand); }
.tilo-bubble-ai a { color: inherit; }
.tilo-avatar-col { width: 32px; }
@media (max-width: 575.98px) {
  .tilo-avatar-col, .tilo-avatar-col .tilo-avatar { width: 28px; height: 28px; }
}

/* Markdown-Teilmenge in Antworten */
.tilo-md > :last-child { margin-bottom: 0; }
.tilo-md p, .tilo-md ul, .tilo-md ol { margin-bottom: .5rem; }
.tilo-md ul, .tilo-md ol { padding-left: 1.25rem; }
.tilo-md strong { font-weight: 600; }
.tilo-md h3, .tilo-md h4, .tilo-md h5 { font-family: var(--sr-font-heading); font-weight: 600; margin: .5rem 0 .25rem; color: inherit; }
.tilo-md .tilo-md-h1 { font-size: 1.125rem; }
.tilo-md .tilo-md-h2 { font-size: 1.0625rem; }
.tilo-md .tilo-md-h3 { font-size: 1rem; }

/* Fotos an einer Frage / Anhänge */
.tilo-thumb { width: 96px; height: 96px; object-fit: cover; border-radius: var(--sr-radius-card); background: var(--bs-tertiary-bg); }
.tilo-thumb-placeholder { display: inline-flex; align-items: center; justify-content: center; color: var(--bs-secondary-color); }
.tilo-photo-preview { max-width: 100%; max-height: 240px; border-radius: var(--sr-radius-card); }

/* Fehler einer Frage: Warnung, kein Alarm-Rot */
.tilo-error { border-left: 3px solid var(--sr-dusk-amber); padding: .375rem .625rem; font-size: .875rem; color: var(--bs-body-color); background: var(--bs-body-bg); max-width: min(72ch, 100%); }
.tilo-error .bi-exclamation-triangle { color: var(--sr-dusk-amber); }

/* Hinweise und Quellen */
.tilo-notes, .tilo-sources { font-size: .875rem; color: var(--bs-secondary-color); }
.tilo-sources summary { cursor: pointer; }
.tilo-src-off { opacity: .75; }

/* Nachdenken: drei ruhig pulsierende Punkte; Text steht immer daneben */
.tilo-dots { display: inline-flex; gap: .25rem; margin-left: .375rem; vertical-align: middle; }
.tilo-dots span { width: .375rem; height: .375rem; border-radius: 50%; background: currentColor; opacity: .35; animation: tilo-pulse 1.4s ease-in-out infinite; }
.tilo-dots span:nth-child(2) { animation-delay: .2s; }
.tilo-dots span:nth-child(3) { animation-delay: .4s; }
@keyframes tilo-pulse { 0%, 80%, 100% { opacity: .25; } 40% { opacity: .9; } }

/* Neue Nachrichten höchstens 150 ms einblenden */
.tilo-fade { animation: tilo-fade-in 150ms ease-out; }
@keyframes tilo-fade-in { from { opacity: 0; } to { opacity: 1; } }

@media (prefers-reduced-motion: reduce) {
  .tilo-dots span { animation: none; opacity: .6; }
  .tilo-fade { animation: none; }
}

/* Fester Beratungshinweis: Einordnung, keine Warnung */
.tilo-disclaimer { font-size: .875rem; color: var(--bs-secondary-color); }
.tilo-disclaimer-short { display: none; }
@media (max-width: 399.98px) {
  .tilo-disclaimer-long { display: none; }
  .tilo-disclaimer-short { display: block; }
}
/* Kurzfassung per Antippen/Tastatur aufklappbar (summary ist fokussierbar) */
.tilo-disclaimer-short > summary { cursor: pointer; }

/* Eingabe */
.tilo-input textarea { resize: vertical; min-height: 3rem; max-height: 40vh; }
.tilo-counter { font-size: .875rem; color: var(--bs-secondary-color); }
