/* Modul chat – schwebendes Fenster und Vollbild-Ansicht des Team-Chats. */

/* Damit der eingeklappte Chat die Hinweisfenster nicht verdeckt,
   rücken die Hinweise ein Stück nach oben. */
body.chat-dock-ready .toast-stack { bottom: 82px; }

/* ---- Schwebendes Fenster unten rechts ---- */
.chat-dock {
  position: fixed; z-index: 45; right: 22px; bottom: 22px;
  width: min(360px, calc(100vw - 36px));
  display: flex; flex-direction: column; gap: 8px; align-items: stretch;
  pointer-events: none;
}
.chat-dock > * { pointer-events: auto; }
.chat-dock-toggle {
  order: 2; align-self: flex-end; min-width: 190px;
  display: flex; align-items: center; gap: 9px;
  min-height: 44px; padding: 8px 14px; border: 1px solid var(--line); border-radius: 12px;
  background: var(--navy-900); color: #fff; font-weight: 700; font-size: 13px;
  box-shadow: 0 12px 28px rgba(6, 24, 44, .22);
}
.chat-dock-toggle:hover { background: var(--navy-800); }
.chat-dock-toggle svg { width: 18px; }
.chat-dock-toggle svg:last-child { margin-left: auto; transform: rotate(90deg); transition: .2s; }
.chat-dock.open .chat-dock-toggle svg:last-child { transform: rotate(-90deg); }
.chat-dock-toggle span { flex: 1; text-align: left; }

.chat-badge {
  min-width: 20px; height: 20px; padding: 0 6px; display: inline-grid; place-items: center;
  border-radius: 10px; background: var(--red); color: #fff;
  font-size: 10px; font-weight: 800; font-style: normal;
}

.chat-dock-panel {
  order: 1; display: none; flex-direction: column; overflow: hidden;
  height: min(460px, calc(100vh - 130px));
  border: 1px solid var(--line); border-radius: var(--radius);
  background: var(--paper); box-shadow: var(--shadow);
}
.chat-dock.open .chat-dock-panel { display: flex; }
.chat-dock.open .chat-dock-toggle { align-self: stretch; }
.chat-dock-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 11px 14px; border-bottom: 1px solid var(--line); background: #fbfcfd;
}
.chat-dock-head .eyebrow { margin: 0; }

/* ---- Kanalreiter im schwebenden Fenster ---- */
.chat-channel-tabs {
  display: flex; gap: 6px; overflow-x: auto; padding: 9px 12px;
  border-bottom: 1px solid var(--line); background: #fff;
}
.chat-channel-tab {
  display: inline-flex; align-items: center; gap: 6px; flex: 0 0 auto;
  padding: 6px 10px; border: 1px solid var(--line); border-radius: 999px;
  background: #fff; color: var(--muted); font-size: 11px; font-weight: 700;
}
.chat-channel-tab svg { width: 15px; }
.chat-channel-tab:hover { background: var(--soft); color: var(--ink); }
.chat-channel-tab.active { border-color: var(--blue); background: #eaf5fb; color: var(--navy-900); }

/* ---- Verlauf ---- */
.chat-stream {
  flex: 1; min-height: 0; overflow-y: auto; display: flex; flex-direction: column; gap: 10px;
  padding: 13px 14px; background: var(--canvas);
}
.chat-stream.large { height: min(58vh, 620px); border-radius: 13px; border: 1px solid var(--line); }
.chat-stream .empty { margin: auto; }

.chat-message {
  padding: 9px 11px; border: 1px solid var(--line); border-radius: 12px;
  background: #fff; box-shadow: 0 3px 10px rgba(18, 38, 60, .04);
}
.chat-message.own { border-color: #bfdcef; background: #f4fafe; }
.chat-message.removed { background: #f7f8fa; border-style: dashed; }
.chat-message.removed .chat-text { color: var(--muted); font-style: italic; }
.chat-message > header { display: flex; align-items: baseline; gap: 8px; }
.chat-message > header strong { font-size: 12px; }
.chat-message > header small { color: var(--muted); font-size: 10px; }
.chat-text { margin: 5px 0 0; font-size: 13px; line-height: 1.55; overflow-wrap: anywhere; }
.chat-message-actions { display: flex; flex-wrap: wrap; gap: 12px; margin-top: 7px; }

.chat-link {
  padding: 0; border: 0; background: none; color: var(--blue);
  font-size: 11px; font-weight: 700; text-decoration: none;
}
.chat-link:hover { text-decoration: underline; }
.chat-link.danger { color: var(--red); }

.chat-idea-note {
  display: flex; align-items: center; gap: 6px; margin: 7px 0 0;
  padding: 6px 8px; border-radius: 9px; background: var(--gold-soft);
  color: #8a5d00; font-size: 10px; font-weight: 700;
}
.chat-idea-note svg { width: 14px; }

.chat-idea-form, .chat-edit-form { display: flex; flex-wrap: wrap; align-items: flex-end; gap: 8px; margin-top: 9px; }
.chat-idea-form label { display: grid; gap: 3px; flex: 1 1 150px; color: var(--muted); font-size: 10px; font-weight: 700; }
.chat-idea-form select, .chat-edit-form textarea {
  width: 100%; padding: 7px 9px; border: 1px solid var(--line); border-radius: 9px;
  background: #fff; color: var(--ink); font-size: 12px;
}
.chat-edit-form textarea { resize: vertical; }
.chat-edit-actions { display: flex; justify-content: flex-end; gap: 8px; width: 100%; }
.chat-idea-form .button, .chat-edit-form .button { min-height: 34px; padding: 6px 11px; font-size: 11px; }

/* ---- Eingabe ---- */
.chat-composer { display: grid; gap: 7px; padding: 11px 13px; border-top: 1px solid var(--line); background: #fff; }
.chat-composer textarea {
  width: 100%; min-height: 46px; max-height: 160px; padding: 9px 11px; resize: vertical;
  border: 1px solid var(--line); border-radius: 11px; background: #fff; color: var(--ink); font-size: 13px;
}
.chat-composer textarea:focus { outline: 2px solid rgba(20, 139, 209, .35); outline-offset: 1px; }
.chat-composer-foot { display: flex; align-items: center; justify-content: space-between; gap: 10px; }
.chat-composer-foot small { color: var(--muted); font-size: 10px; }
.chat-composer-foot .button { min-height: 36px; padding: 6px 13px; font-size: 12px; }
.chat-composer-foot .button svg { width: 15px; }

/* ---- Vollbild-Route ---- */
.chat-page { display: grid; grid-template-columns: 258px minmax(0, 1fr); gap: 16px; align-items: start; }
.chat-page-rail {
  display: grid; gap: 10px; padding: 13px;
  border: 1px solid var(--line); border-radius: 14px; background: #fff;
}
.chat-rail-title { margin: 0; color: var(--muted); font-size: 10px; font-weight: 800; letter-spacing: .09em; text-transform: uppercase; }
.chat-rail-list { display: grid; gap: 5px; }
.chat-rail-item {
  display: grid; grid-template-columns: 30px minmax(0, 1fr) auto; gap: 2px 9px; align-items: center;
  padding: 9px 10px; border: 1px solid transparent; border-radius: 11px;
  background: transparent; color: var(--ink); text-align: left;
}
.chat-rail-item > span { grid-row: 1 / 3; width: 28px; height: 28px; display: grid; place-items: center; color: var(--muted); }
.chat-rail-item strong { font-size: 12px; }
.chat-rail-item small { grid-column: 2; color: var(--muted); font-size: 9px; }
.chat-rail-item .chat-badge { grid-row: 1 / 3; grid-column: 3; }
.chat-rail-item:hover { background: #f0f6fa; }
.chat-rail-item.active { border-color: #bfdcef; background: #eaf5fb; }
.chat-rail-item.active > span { color: var(--blue); }

.chat-hint { display: flex; align-items: center; gap: 6px; margin: 0; color: var(--muted); font-size: 11px; }
.chat-hint svg { width: 14px; }

.chat-admin { display: grid; gap: 8px; padding-top: 11px; border-top: 1px solid var(--line); }
.chat-admin-list { display: grid; gap: 4px; }
.chat-admin-row { display: grid; grid-template-columns: minmax(0, 1fr) auto auto auto; gap: 4px; align-items: center; }
.chat-admin-row span { font-size: 11px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.chat-admin-row .icon-button { width: 30px; height: 30px; }
.chat-admin-row .icon-button svg { width: 14px; }
.chat-admin-row [data-direction="up"] svg { transform: rotate(-90deg); }
.chat-admin-row [data-direction="down"] svg { transform: rotate(90deg); }
.chat-admin > .button { min-height: 36px; font-size: 11px; }

.chat-channel-form { display: grid; gap: 7px; padding: 11px; border: 1px solid var(--line); border-radius: 11px; background: #fbfcfd; }
.chat-channel-form label { display: grid; gap: 3px; color: var(--muted); font-size: 10px; font-weight: 700; }
.chat-channel-form input, .chat-channel-form select {
  padding: 7px 9px; border: 1px solid var(--line); border-radius: 9px;
  background: #fff; color: var(--ink); font-size: 12px;
}
.chat-channel-form-actions { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; }
.chat-channel-form-actions span { flex: 1; }
.chat-channel-form-actions .button { min-height: 34px; padding: 6px 10px; font-size: 11px; }

.chat-page-main { display: grid; gap: 11px; min-width: 0; }
.chat-page-head { display: flex; flex-wrap: wrap; align-items: flex-start; justify-content: space-between; gap: 12px; }
.chat-page-head h2 { margin: 0; font: 800 20px/1.2 'Manrope', system-ui, sans-serif; letter-spacing: -.02em; }
.chat-page-head p { margin: 4px 0 0; color: var(--muted); font-size: 12px; }
.chat-page-main .chat-composer { border: 1px solid var(--line); border-radius: 13px; }

@media (max-width: 900px) {
  .chat-page { grid-template-columns: minmax(0, 1fr); }
  .chat-dock { right: 12px; bottom: 12px; width: calc(100vw - 24px); }
  .chat-dock-panel { height: min(60vh, 420px); }
}
