/* ragchatbot – Oberflaeche.
   Auslegung: normale Software-Oberflaeche. Feste Grundschrift von 14 px,
   kompakte Bedienelemente (Knopfhoehe 30 px), ruhige Graustufen mit einem
   einzigen Akzentblau. Links eine feste Seitenleiste, rechts der
   Arbeitsbereich – wie in einem Warenwirtschafts- oder Mailprogramm. */

:root {
  --grund: #f4f6f8;          /* Hintergrund des Arbeitsbereichs */
  --flaeche: #ffffff;
  --leiste: #1f2937;         /* Seitenleiste */
  --leiste-hell: #2c3846;
  --leiste-schrift: #cbd5e1;
  --rand: #dbe1e8;
  --rand-stark: #c2cad4;
  --schrift: #1a2430;
  --gedaempft: #5f6b7a;
  --akzent: #1e5aa8;
  --akzent-dunkel: #17497f;
  --akzent-hell: #eaf1f9;
  --gruen: #15693f;
  --gruen-hell: #e6f4ec;
  --rot: #a12a20;
  --rot-hell: #fbeceb;
  --gelb: #7a5300;
  --gelb-hell: #fdf3de;
  --radius: 4px;
  --leiste-breite: 220px;
  --kopf-hoehe: 30px;
}

* { box-sizing: border-box; }

html { font-size: 14px; }

body {
  margin: 0;
  font-family: "Segoe UI", Roboto, system-ui, -apple-system, "Helvetica Neue", sans-serif;
  font-size: 14px;
  line-height: 1.45;
  color: var(--schrift);
  background: var(--grund);
  -webkit-font-smoothing: antialiased;
}

h1 { font-size: 17px; font-weight: 600; margin: 0; }
h2 { font-size: 14px; font-weight: 600; margin: 0 0 8px; }
p { margin: 0 0 8px; }

code {
  background: #eef1f5; border: 1px solid var(--rand); border-radius: 3px;
  padding: 0 3px; font-size: 12px; font-family: Consolas, "SF Mono", monospace;
}

.versteckt { display: none !important; }
.klein { font-size: 12px; color: var(--gedaempft); }
.rechts { text-align: right; }
.hinweis { color: var(--gedaempft); }
.fehlertext { color: var(--rot); font-weight: 600; min-height: 18px; margin: 8px 0 0; }
.abstand { margin-top: 16px; }
.abstand-klein { margin-top: 10px; }
.klein-abstand-unten { margin-bottom: 10px; }

.nur-vorleser {
  position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px;
  overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0;
}

/* --- Bedienelemente ----------------------------------------------------- */
.knopf {
  display: inline-flex; align-items: center; justify-content: center; gap: 5px;
  background: var(--akzent); color: #fff; border: 1px solid var(--akzent);
  border-radius: var(--radius); padding: 0 12px; height: 30px;
  font: inherit; font-size: 13px; font-weight: 500; line-height: 1;
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.knopf:hover { background: var(--akzent-dunkel); border-color: var(--akzent-dunkel); }
.knopf:disabled { opacity: .55; cursor: default; }
.knopf.voll { width: 100%; }
.knopf.leise {
  background: var(--flaeche); color: var(--schrift); border-color: var(--rand-stark);
}
.knopf.leise:hover { background: #f0f4f8; border-color: var(--akzent); color: var(--akzent); }
.knopf.klein { height: 24px; padding: 0 8px; font-size: 12px; }
.knopf.gefahr { background: var(--flaeche); color: var(--rot); border-color: var(--rand-stark); }
.knopf.gefahr:hover { background: var(--rot-hell); border-color: var(--rot); color: var(--rot); }

input, select, textarea {
  font: inherit; font-size: 13px; color: inherit; background: var(--flaeche);
  border: 1px solid var(--rand-stark); border-radius: var(--radius);
  padding: 0 8px; height: 30px; width: 100%;
}
textarea { padding: 6px 8px; height: auto; resize: vertical; line-height: 1.45; }
select { cursor: pointer; padding-right: 4px; }
input[type="file"] { padding: 4px; height: auto; }
input[type="checkbox"] { width: 14px; height: 14px; margin: 0; accent-color: var(--akzent); }

input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--akzent); box-shadow: 0 0 0 2px var(--akzent-hell);
}
button:focus-visible, a:focus-visible, summary:focus-visible,
label.knopf:focus-within {
  outline: 2px solid var(--akzent); outline-offset: 1px;
}

.feldname {
  display: block; font-size: 12px; font-weight: 600; color: var(--gedaempft);
  margin-bottom: 3px;
}
.feld { margin-bottom: 10px; }
.zeile { display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end; }
.zeile > .feld { margin-bottom: 0; min-width: 150px; }
.wachsend { flex: 1 1 160px; }
.schmal-feld { flex: 0 0 90px; min-width: 90px; }
.feld-knopf { display: flex; gap: 6px; }
.schmal { width: auto; min-width: 150px; }
.felderraster {
  display: grid; grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
  gap: 10px; margin-top: 12px;
}
.felderraster .feld.breit { grid-column: 1 / -1; }

/* --- Anmeldung ---------------------------------------------------------- */
.anmeldeseite {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  background: linear-gradient(160deg, #243447 0%, #16202c 100%); padding: 16px;
}
.anmeldekasten {
  background: var(--flaeche); padding: 28px; border-radius: 6px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, .25); width: min(340px, 100%);
}
.anmeldekasten h1 { font-size: 20px; margin-bottom: 2px; }
.anmeldekasten label {
  display: block; font-size: 12px; font-weight: 600; color: var(--gedaempft);
  margin: 14px 0 3px;
}
.anmeldekasten .knopf.voll { margin-top: 18px; height: 34px; }
.passwortzeile { display: flex; gap: 6px; }
.passwortzeile .knopf { flex: 0 0 auto; }

/* --- Grundgeruest ------------------------------------------------------- */
.app { display: flex; height: 100vh; overflow: hidden; }

.seitenleiste {
  width: var(--leiste-breite); flex: 0 0 var(--leiste-breite);
  background: var(--leiste); color: var(--leiste-schrift);
  display: flex; flex-direction: column; overflow: hidden;
}
.marke {
  font-size: 14px; font-weight: 600; color: #fff;
  padding: 12px 14px; border-bottom: 1px solid var(--leiste-hell);
}
.navi { padding: 6px; display: flex; flex-direction: column; gap: 1px; }
.navi-knopf {
  display: flex; align-items: center; gap: 8px; width: 100%;
  background: transparent; border: 0; border-radius: var(--radius);
  padding: 0 8px; height: 30px; font: inherit; font-size: 13px;
  color: var(--leiste-schrift); cursor: pointer; text-align: left;
}
.navi-zeichen { font-size: 13px; width: 16px; text-align: center; }
.navi-knopf:hover { background: var(--leiste-hell); color: #fff; }
.navi-knopf.aktiv { background: var(--akzent); color: #fff; }

.seitenleiste-teil {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: 10px; border-top: 1px solid var(--leiste-hell);
}
.seitenleiste-teil.versteckt + .seitenleiste-fuss { margin-top: auto; }
.seitenleiste-teil .feldname { color: #8fa0b3; margin-top: 8px; }
.seitenleiste-teil select {
  background: var(--leiste-hell); border-color: #3d4b5c; color: #fff;
}
.seitenleiste-titel {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .06em; color: #8fa0b3; margin: 16px 0 6px;
}
.seitenliste { list-style: none; margin: 0; padding: 0; }
.seitenliste li {
  padding: 5px 7px; border-radius: var(--radius); cursor: pointer;
  font-size: 12.5px; color: var(--leiste-schrift); margin-bottom: 1px;
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.seitenliste li:hover { background: var(--leiste-hell); color: #fff; }
.seitenliste li.aktiv { background: var(--akzent); color: #fff; }
.seitenliste li .klein { color: inherit; opacity: .7; font-size: 11px; }

.seitenleiste-fuss {
  margin-top: auto; padding: 8px 10px; border-top: 1px solid var(--leiste-hell);
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
}
.seitenleiste-fuss .klein { color: #8fa0b3; overflow: hidden; text-overflow: ellipsis; }
.seitenleiste-fuss .knopf.leise {
  background: transparent; color: var(--leiste-schrift); border-color: #3d4b5c;
}
.seitenleiste-fuss .knopf.leise:hover { background: var(--leiste-hell); color: #fff; }

.hauptbereich { flex: 1; min-width: 0; display: flex; flex-direction: column; overflow: hidden; }

.warnleiste {
  background: var(--gelb-hell); border-bottom: 1px solid #e0c68b; color: #5c4408;
  padding: 6px 16px; font-size: 12.5px;
}
.warnleiste p { margin: 2px 0; }

/* --- Seiten ------------------------------------------------------------- */
.seite { flex: 1; min-height: 0; overflow-y: auto; padding: 16px 20px 24px; }
.seite.chatseite { display: flex; flex-direction: column; padding: 0; overflow: hidden; }

.seitenkopf {
  display: flex; align-items: center; justify-content: space-between;
  gap: 12px; flex-wrap: wrap; margin-bottom: 10px;
}
.werkzeugleiste { display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }
.statuszeile {
  font-size: 12.5px; color: var(--gedaempft); margin: 0 0 12px;
}

.kasten {
  background: var(--flaeche); border: 1px solid var(--rand);
  border-radius: var(--radius); padding: 14px; margin-bottom: 14px;
}
details.kasten summary {
  cursor: pointer; font-weight: 600; font-size: 13px; color: var(--akzent);
}
.spalten { display: grid; grid-template-columns: repeat(auto-fit, minmax(320px, 1fr)); gap: 14px; }

/* --- Fragen ------------------------------------------------------------- */
.verlauf { flex: 1; overflow-y: auto; padding: 20px; }
.blase { max-width: 780px; margin: 0 auto 18px; }
.blase.nutzer { display: flex; justify-content: flex-end; }
.blase.nutzer .text {
  background: var(--akzent); color: #fff; border-radius: 6px 6px 2px 6px;
  padding: 8px 12px; max-width: 80%;
}
.blase.assistent .text {
  background: var(--flaeche); border: 1px solid var(--rand);
  border-radius: 6px; padding: 14px 16px;
  /* Luft zwischen den Zeilen: eine Antwort mit Zahlen und Paragraphen ist
     sonst ein einziger Block. */
  line-height: 1.6;
}
.blase .text p { margin: 0 0 10px; }
.blase .text p:last-child { margin-bottom: 0; }
.blase .text .antwortliste {
  margin: 0 0 10px; padding-left: 20px;
}
.blase .text .antwortliste li { margin-bottom: 5px; }
.blase .text .antwortliste li:last-child { margin-bottom: 0; }
.blase .text .antwortliste:last-child { margin-bottom: 0; }
.blase .text em { color: var(--gedaempft); font-style: italic; font-size: 12px; }

/* Unter der Antwort steht nur die Quelle, auf die sie sich stuetzt – als eine
   Zeile, nicht als Kartenstapel. Alles Weitere liegt zugeklappt darunter. */
.quellenblock { margin-top: 10px; font-size: 12.5px; }
.quellenkopf { color: var(--gedaempft); margin-right: 4px; }
.quelle {
  display: inline; color: var(--akzent); text-decoration: none;
  border-bottom: 1px solid transparent;
}
.quelle + .quelle { margin-left: 10px; }
.quelle:hover { border-bottom-color: var(--akzent); }
.quelle .titel { font-weight: 600; }
.quelle .klein { color: var(--gedaempft); }
.weitere { margin-top: 6px; }
.weitere summary {
  cursor: pointer; color: var(--gedaempft); font-size: 12px; width: fit-content;
}
.weitere summary:hover { color: var(--akzent); }
.weitere .quelle { display: block; margin: 8px 0 0; }
.weitere .auszug {
  color: var(--gedaempft); margin: 2px 0 0; padding-left: 8px;
  border-left: 2px solid var(--rand);
}
.marke-veraltet {
  background: var(--rot-hell); color: var(--rot); border-radius: 3px;
  padding: 0 4px; font-size: 11px; font-weight: 600; margin-left: 5px;
  white-space: nowrap;
}

.blase.denkt .text { display: flex; align-items: center; gap: 8px; color: var(--gedaempft); }
.punkte span {
  display: inline-block; width: 5px; height: 5px; border-radius: 50%;
  background: var(--akzent); margin-right: 2px; animation: huepfen 1.2s infinite;
}
.punkte span:nth-child(2) { animation-delay: .2s; }
.punkte span:nth-child(3) { animation-delay: .4s; }
@keyframes huepfen { 0%, 60%, 100% { opacity: .25; } 30% { opacity: 1; } }

.frageleiste {
  display: flex; gap: 8px; align-items: flex-end;
  border-top: 1px solid var(--rand); background: var(--flaeche);
  padding: 12px 20px 6px;
}
.frageleiste textarea {
  flex: 1; max-width: 780px; margin: 0 auto; min-height: 32px; max-height: 180px;
  font-size: 14px;
}
.frageleiste .knopf { flex: 0 0 auto; height: 32px; }
.frageleiste-fuss {
  margin: 0; background: var(--flaeche); color: var(--gedaempft);
  font-size: 11.5px; padding: 0 20px 10px; text-align: center;
}

.leerhinweis { max-width: 620px; margin: 8vh auto 0; text-align: center; }
.leerhinweis h2 { font-size: 18px; margin-bottom: 6px; }
.leerhinweis p { color: var(--gedaempft); }

/* --- Zweispalter: Ordnerbaum und Liste ---------------------------------- */
.zweispalter { display: flex; gap: 14px; align-items: flex-start; }
.baumspalte {
  flex: 0 0 240px; background: var(--flaeche); border: 1px solid var(--rand);
  border-radius: var(--radius); overflow: hidden;
}
.listenspalte {
  flex: 1; min-width: 0; background: var(--flaeche);
  border: 1px solid var(--rand); border-radius: var(--radius); overflow: hidden;
}
.spaltenkopf {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  background: #f7f9fb; border-bottom: 1px solid var(--rand);
  padding: 0 10px; height: 32px; font-size: 12px; font-weight: 600;
  color: var(--gedaempft);
}
.auswahlleiste { display: flex; align-items: center; gap: 6px; }
/* Der Ordnerpfad steht links, „Alle wählen“ und die Auswahlleiste rechts. */
.spaltenkopf #ordner-pfad { margin-right: auto; }

.baum { list-style: none; margin: 0; padding: 4px; }
.baum li { margin: 0; }
.baum-zeile {
  display: flex; align-items: center; gap: 5px; padding: 3px 6px;
  border-radius: var(--radius); cursor: pointer; font-size: 13px;
}
.baum-zeile:hover { background: var(--akzent-hell); }
.baum-zeile.aktiv { background: var(--akzent); color: #fff; }
.baum-zeile.aktiv .baum-anzahl { color: rgba(255, 255, 255, .75); }
.baum-name { flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.baum-anzahl { font-size: 11px; color: var(--gedaempft); }
.baum-zeichen { width: 14px; text-align: center; font-size: 12px; }
.baum-werkzeuge { display: none; gap: 2px; }
.baum-zeile:hover .baum-werkzeuge, .baum-zeile.aktiv .baum-werkzeuge { display: flex; }
.baum-werkzeug {
  background: transparent; border: 0; cursor: pointer; padding: 0 2px;
  font-size: 11px; color: inherit; opacity: .75; line-height: 1;
}
.baum-werkzeug:hover { opacity: 1; }

/* --- Tabellen ----------------------------------------------------------- */
.tabellenrahmen { overflow-x: auto; }
.tabelle { width: 100%; border-collapse: collapse; background: var(--flaeche); font-size: 13px; }
.tabelle th {
  text-align: left; font-size: 11px; font-weight: 600; color: var(--gedaempft);
  text-transform: uppercase; letter-spacing: .04em;
  background: #f7f9fb; border-bottom: 1px solid var(--rand);
  padding: 6px 10px; white-space: nowrap; position: sticky; top: 0;
}
.tabelle td {
  padding: 6px 10px; border-bottom: 1px solid #eef1f5; vertical-align: middle;
  /* Lange Dateinamen ohne Leerzeichen haben die Tabelle breiter gemacht als
     das Fenster. Sie duerfen jetzt umbrechen. */
  overflow-wrap: anywhere;
}
.tabelle tbody tr:hover { background: #f8fafc; }
.tabelle tr:last-child td { border-bottom: 0; }
.tabelle .spalte-wahl { width: 28px; }
.tabelle .werkzeuge { display: flex; gap: 4px; justify-content: flex-end; flex-wrap: wrap; }
.tabelle .titelzelle strong { font-weight: 600; }

/* Dokumentenliste: feste Spaltenbreiten, damit nie seitlich geschoben werden
   muss. Der Titel bekommt den Rest und wird notfalls mit … abgekuerzt. */
#dokumententabelle, #vorlagentabelle { table-layout: fixed; }
#dokumententabelle .spalte-art, #vorlagentabelle .spalte-art { width: 20%; min-width: 130px; }
#dokumententabelle .spalte-zustand, #vorlagentabelle .spalte-zustand { width: 15%; min-width: 110px; }
#dokumententabelle .spalte-werkzeuge { width: 300px; }
#vorlagentabelle .spalte-werkzeuge { width: 210px; }
/* Alles, was zu lang ist, wird mit … abgekuerzt; der volle Text erscheint,
   wenn die Maus darauf zeigt. */
#dokumententabelle .titelzelle strong, #dokumententabelle .titelzelle .klein,
#vorlagentabelle .titelzelle strong, #vorlagentabelle .titelzelle .klein,
#vorlagentabelle td .klein {
  display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
/* Schmales Fenster: die Knoepfe rutschen in zwei Reihen, statt die Tabelle
   ueber den Rand zu schieben. */
@media (max-width: 1280px) {
  #dokumententabelle .spalte-werkzeuge { width: 170px; }
  #vorlagentabelle .spalte-werkzeuge { width: 120px; }
}

/* Ampel fuer die Aktualitaetspruefung. Die Farbe allein entscheidet nie –
   daneben steht immer Klartext, auch fuer Farbfehlsichtige. */
.ampelzeile { display: flex; align-items: center; gap: 5px; }
.ampel {
  flex: 0 0 auto; width: 9px; height: 9px; border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, .18);
}
.ampel.gruen { background: #1e9e5a; }
.ampel.gelb { background: #e0a516; }
.ampel.rot { background: #d0342c; }
.ampel.grau { background: #c7cdd6; }

.knopf.bestaetigen {
  background: var(--gruen-hell); color: var(--gruen); border-color: #a9d5bd;
}
.knopf.bestaetigen:hover { background: #d5ebe0; border-color: var(--gruen); }
.knopf.leise.aktiv {
  background: var(--akzent-hell); border-color: var(--akzent); color: var(--akzent);
}

.zustand {
  display: inline-block; font-size: 11px; font-weight: 600;
  border-radius: 3px; padding: 1px 6px; white-space: nowrap;
}
.zustand.fertig { color: var(--gruen); background: var(--gruen-hell); }
.zustand.fehler { color: var(--rot); background: var(--rot-hell); }
.zustand.laeuft, .zustand.neu { color: var(--gelb); background: var(--gelb-hell); }

.meldungen { margin-top: 8px; font-size: 12.5px; }
.meldungen p { margin: 3px 0; }
.meldungen .ok { color: var(--gruen); }
.meldungen .schlecht { color: var(--rot); }

.marke-platzhalter {
  display: inline-block; background: #eef1f5; border: 1px solid var(--rand);
  border-radius: 3px; padding: 0 4px; margin: 0 3px 2px 0; font-size: 11px;
  font-family: Consolas, "SF Mono", monospace; color: var(--gedaempft);
}

/* --- Dialog ------------------------------------------------------------- */
.dialog {
  border: 1px solid var(--rand-stark); border-radius: 6px; padding: 0;
  width: min(460px, 92vw); box-shadow: 0 12px 40px rgba(0, 0, 0, .22);
  color: var(--schrift);
}
.dialog::backdrop { background: rgba(20, 28, 38, .45); }
.dialog form { padding: 16px; }
.dialog h2 { font-size: 15px; }
.dialog-fuss { display: flex; justify-content: flex-end; gap: 8px; margin-top: 14px; }
.dialog textarea { min-height: 90px; }

/* --- Anzeigen ----------------------------------------------------------- */
.ladeanzeige {
  position: fixed; inset: 0; background: rgba(255, 255, 255, .5);
  display: flex; align-items: center; justify-content: center; z-index: 100;
}
.kreisel {
  width: 26px; height: 26px; border: 3px solid var(--rand);
  border-top-color: var(--akzent); border-radius: 50%;
  animation: drehen .8s linear infinite;
}
@keyframes drehen { to { transform: rotate(360deg); } }

.hinweisblase {
  position: fixed; bottom: 18px; left: 50%; transform: translateX(-50%);
  background: var(--schrift); color: #fff; padding: 8px 14px;
  border-radius: var(--radius); z-index: 200; font-size: 13px;
  box-shadow: 0 6px 20px rgba(0, 0, 0, .2); max-width: 90vw;
}
.hinweisblase.schlecht { background: var(--rot); }

@media (prefers-reduced-motion: reduce) {
  * { animation-duration: .01ms !important; animation-iteration-count: 1 !important; }
}

/* --- Schmaler Bildschirm ------------------------------------------------ */
@media (max-width: 900px) {
  .app { height: auto; min-height: 100vh; flex-direction: column; overflow: visible; }
  .seitenleiste { width: 100%; flex: none; }
  .navi { flex-direction: row; flex-wrap: wrap; }
  .navi-knopf { width: auto; }
  .seitenleiste-teil { max-height: 220px; }
  .hauptbereich { overflow: visible; }
  .seite { overflow: visible; }
  .seite.chatseite { height: 75vh; }
  .zweispalter { flex-direction: column; }
  .baumspalte { flex: none; width: 100%; }
}
