/* ════════════════════════════════════════════════════════════════
   NACHRICHTEN (js/views/nachrichten.js)
   1. Hinweiskarten oben rechts, wie eine Mitteilung unter macOS und iOS
   2. Nachrichtenfenster (Gespräche und Chat)
   Nur Tokens, keine eigenen Farb- und Maßwerte außer Symbol- und Bildgrößen.
   ════════════════════════════════════════════════════════════════ */

/* ─── 1. Hinweiskarten ─── */
.nh-behaelter {
  position: fixed;
  top: calc(var(--topbar) + var(--s-3));
  right: var(--s-5);
  width: 360px;
  max-width: calc(100vw - var(--s-8));
  z-index: var(--z-hinweis);
  display: flex; flex-direction: column;
  pointer-events: none;           /* der Behälter selbst fängt keine Klicks, nur die Karten */
}
.nh-karte {
  pointer-events: auto;
  display: flex; align-items: flex-start;
  margin-bottom: var(--s-2);
  background: var(--c-surface);
  border: 1px solid var(--c-border);
  border-radius: var(--r-md);
  box-shadow: var(--sh-lg);
  opacity: 0;
  transform: translateY(calc(var(--s-2) * -1)) scale(0.98);
  transform-origin: top right;
  transition: opacity var(--dur-base) var(--ease-standard), transform var(--dur-base) var(--ease-standard);
}
.nh-karte.nh-da { opacity: 1; transform: none; }
.nh-karte.nh-weg { opacity: 0; transform: translateX(var(--s-6)); }
.nh-haupt {
  flex: 1; min-width: 0;
  display: flex; align-items: flex-start; gap: var(--s-3);
  padding: var(--s-3) var(--s-2) var(--s-3) var(--s-4);
  border: none; background: transparent; border-radius: var(--r-md);
  font-family: inherit; text-align: left; color: var(--c-text); cursor: pointer;
}
.nh-haupt:hover { background: var(--c-hover-soft); }
.nh-bild {
  flex-shrink: 0; width: 36px; height: 36px; border-radius: var(--r-full);
  display: flex; align-items: center; justify-content: center;
  background: var(--c-accent-soft); color: var(--c-accent);
  font-size: var(--fs-xs); font-weight: var(--fw-bold);
}
.nh-bild svg { width: 18px; height: 18px; }
.nh-inhalt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.nh-kopf { display: flex; align-items: baseline; gap: var(--s-2); }
.nh-titel { flex: 1; min-width: 0; font-size: var(--fs-sm); font-weight: var(--fw-semibold); line-height: var(--lh-tight); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nh-zeit { flex-shrink: 0; font-size: var(--fs-xs); color: var(--c-muted); }
.nh-text {
  font-size: var(--fs-sm); line-height: var(--lh-normal); color: var(--c-muted);
  display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; overflow-wrap: anywhere;
}
.nh-zu {
  flex-shrink: 0; width: 28px; height: 28px; margin: var(--s-2) var(--s-2) 0 0; padding: 0;
  border: none; background: transparent; border-radius: var(--r-full); color: var(--c-muted);
  display: flex; align-items: center; justify-content: center; cursor: pointer;
}
.nh-zu:hover { background: var(--c-neutral-soft); color: var(--c-text); }
.nh-zu svg { width: 14px; height: 14px; }
@media (pointer: coarse) { .nh-zu { width: 44px; height: 44px; margin: 0; } }
@media (max-width: 768px) {
  .nh-behaelter { top: calc(var(--topbar-mobile) + var(--s-2)); left: var(--s-3); right: var(--s-3); width: auto; max-width: none; }
}

/* ─── 2. Nachrichtenfenster ─── */
.nf-modal {
  width: min(920px, 94vw); height: min(640px, 88vh); max-height: 88vh;
  padding: 0; display: flex; flex-direction: column; overflow: hidden;
}
.nf-kopf { margin: 0; padding: var(--s-4) var(--s-5); border-bottom: 1px solid var(--c-border); flex-shrink: 0; }
.nf-neu { display: inline-flex; align-items: center; gap: var(--s-2); }
.nf-neu svg { width: 14px; height: 14px; }
.nf-koerper { flex: 1; min-height: 0; display: grid; grid-template-columns: 300px minmax(0, 1fr); }
.nf-liste-spalte { border-right: 1px solid var(--c-border); overflow-y: auto; overscroll-behavior: contain; min-height: 0; }
.nf-chat { display: flex; flex-direction: column; min-width: 0; min-height: 0; background: var(--c-surface-2); }

.nf-liste { list-style: none; margin: 0; padding: var(--s-2); }
.nf-zeile {
  width: 100%; min-height: 56px; display: flex; align-items: center; gap: var(--s-3);
  padding: var(--s-2) var(--s-3); border: none; background: transparent; border-radius: var(--r-md);
  font-family: inherit; text-align: left; color: var(--c-text); cursor: pointer;
  transition: background var(--dur-fast) var(--ease-standard);
}
.nf-zeile:hover { background: var(--c-hover-soft); }
.nf-zeile.ist-aktiv { background: var(--c-accent-soft); }
.nf-av {
  flex-shrink: 0; width: 36px; height: 36px; border-radius: var(--r-full);
  display: flex; align-items: center; justify-content: center;
  background: var(--c-accent-soft); color: var(--c-accent);
  font-size: var(--fs-xs); font-weight: var(--fw-bold);
}
.nf-zeile.ist-aktiv .nf-av { background: var(--c-surface); }
.nf-zeile-inhalt { flex: 1; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.nf-zeile-kopf { display: flex; align-items: baseline; gap: var(--s-2); }
.nf-zeile-name { flex: 1; min-width: 0; font-size: var(--fs-sm); font-weight: var(--fw-medium); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nf-zeile.hat-neu .nf-zeile-name { font-weight: var(--fw-bold); }
.nf-zeile-zeit { flex-shrink: 0; font-size: var(--fs-xs); color: var(--c-muted); }
.nf-zeile-text { font-size: var(--fs-xs); color: var(--c-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nf-zeile.hat-neu .nf-zeile-text { color: var(--c-text); }
.nf-neu-punkt {
  flex-shrink: 0; min-width: 20px; height: 20px; padding: 0 var(--s-1); border-radius: var(--r-full);
  display: flex; align-items: center; justify-content: center;
  background: var(--c-accent); color: var(--c-text-inverse); font-size: var(--fs-xs); font-weight: var(--fw-bold);
}

.nf-leer { padding: var(--s-8) var(--s-4); text-align: center; color: var(--c-muted); font-size: var(--fs-sm); display: flex; flex-direction: column; align-items: center; gap: var(--s-2); }
.nf-leer-chat { flex: 1; justify-content: center; }
.nf-leer-t { font-weight: var(--fw-semibold); color: var(--c-text); }
.nf-leer-s { font-size: var(--fs-xs); margin-bottom: var(--s-2); }

.nf-chat-kopf { display: flex; align-items: center; gap: var(--s-3); padding: var(--s-3) var(--s-4); background: var(--c-surface); border-bottom: 1px solid var(--c-border); flex-shrink: 0; min-height: 56px; }
.nf-chat-name { flex: 1; min-width: 0; font-size: var(--fs-base); font-weight: var(--fw-semibold); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.nf-zurueck {
  display: none; width: 44px; height: 44px; margin-left: calc(var(--s-3) * -1); padding: 0;
  border: none; background: transparent; border-radius: var(--r-full); color: var(--c-text);
  align-items: center; justify-content: center; cursor: pointer;
}
.nf-zurueck svg { width: 20px; height: 20px; }
.nf-zurueck:hover { background: var(--c-hover-soft); }
.nf-suchzeile { padding: var(--s-3) var(--s-4); background: var(--c-surface); border-bottom: 1px solid var(--c-border); flex-shrink: 0; }
.nf-kontakte { flex: 1; min-height: 0; overflow-y: auto; background: var(--c-surface); }

.nf-verlauf { flex: 1; min-height: 0; overflow-y: auto; overscroll-behavior: contain; padding: var(--s-4) var(--s-5); display: flex; flex-direction: column; gap: var(--s-1); }
.nf-aeltere { text-align: center; margin-bottom: var(--s-2); }
.nf-tag { text-align: center; margin: var(--s-3) 0 var(--s-2); }
.nf-tag span { font-size: var(--fs-xs); font-weight: var(--fw-semibold); color: var(--c-muted); }
.nf-blase-zeile { display: flex; }
.nf-blase-zeile.ist-eigene { justify-content: flex-end; }
.nf-blase { max-width: min(78%, 520px); padding: var(--s-2) var(--s-3); border-radius: var(--r-lg); font-size: var(--fs-base); line-height: var(--lh-normal); color: var(--c-text); }
.nf-blase-zeile.ist-fremd .nf-blase { background: var(--c-surface); border: 1px solid var(--c-border); border-bottom-left-radius: var(--r-xs); }
.nf-blase-zeile.ist-eigene .nf-blase { background: var(--c-accent-soft); border-bottom-right-radius: var(--r-xs); }
.nf-blase-text { white-space: pre-wrap; overflow-wrap: anywhere; }
.nf-blase-zeit { margin-top: 2px; font-size: var(--fs-xs); color: var(--c-muted); text-align: right; }
.nf-gelesen { text-align: right; font-size: var(--fs-xs); color: var(--c-muted); padding-right: var(--s-1); }

.nf-eingabe { flex-shrink: 0; padding: var(--s-3) var(--s-4); background: var(--c-surface); border-top: 1px solid var(--c-border); }
.nf-eingabe-zeile { display: flex; align-items: flex-end; gap: var(--s-2); }
.nf-text { flex: 1; min-width: 0; resize: none; min-height: 40px; max-height: 132px; padding: var(--s-2) var(--s-3); line-height: var(--lh-normal); font-family: inherit; }
.nf-senden { flex-shrink: 0; width: 40px; height: 40px; min-height: 40px; padding: 0; border-radius: var(--r-full); display: flex; align-items: center; justify-content: center; }
.nf-senden svg { width: 18px; height: 18px; }
.nf-senden:disabled { cursor: default; opacity: 0.4; }
.nf-hinweis { margin-top: var(--s-1); font-size: var(--fs-xs); color: var(--c-muted); }
.nf-zaehler { margin-top: var(--s-1); font-size: var(--fs-xs); color: var(--c-muted); text-align: right; }
.nf-zaehler[hidden] { display: none; }
.nf-zaehler.nf-zu-lang { color: var(--c-danger-strong); font-weight: var(--fw-semibold); }
.nf-fehler { margin-bottom: var(--s-2); padding: var(--s-2) var(--s-3); border-radius: var(--r-sm); background: var(--c-danger-soft); color: var(--c-danger-deep); font-size: var(--fs-sm); }
.nf-fehler[hidden] { display: none; }

/* Schmal: Liste und Gespräch nacheinander statt nebeneinander, das Fenster füllt den Schirm. */
@media (max-width: 768px) {
  .nf-modal { width: 100vw; max-width: 100vw; height: 100dvh; max-height: 100dvh; border-radius: 0; }
  .nf-koerper { grid-template-columns: minmax(0, 1fr); }
  .nf-liste-spalte { border-right: none; }
  .nf-chat { display: none; }
  .nf-zeigt-chat .nf-liste-spalte { display: none; }
  .nf-zeigt-chat .nf-chat { display: flex; }
  .nf-zurueck { display: flex; }
  .nf-verlauf { padding: var(--s-3) var(--s-4); }
  .nf-blase { max-width: 88%; }
  .nf-hinweis { display: none; }
  .nf-zeile { min-height: 64px; }
}

/* ─── Glocken-Panel: Fußzeile mit dem Weg zu den Nachrichten ─── */
.tb-np-fuss { display: flex; justify-content: space-between; gap: var(--s-2); padding: var(--s-2) var(--s-3); border-top: 1px solid var(--c-border); flex-shrink: 0; }
@media (pointer: coarse) { .tb-np-fuss .tb-link { min-height: 44px; } }
