/* ============================================================
   LRV Sachsen-Anhalt – Messenger Styles
   ============================================================ */

/* ── Envelope Icon Button ── */
.messenger-btn {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border2);
  border-radius: 8px;
  background: var(--surface3);
  cursor: pointer;
  transition: background 0.2s, border-color 0.2s;
  flex-shrink: 0;
  margin-right: 12px;  /* Abstand zur Trennlinie */
}
.messenger-btn:hover { background: rgba(255,255,255,0.08); border-color: var(--accent-red); }
.messenger-btn svg { width: 18px; height: 18px; color: var(--text-dim); }
.messenger-btn:hover svg { color: #fff; }

.messenger-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: var(--accent-red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 10px;
  min-width: 18px;
  height: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  line-height: 1;
  display: none;
}
.messenger-badge.visible { display: flex; }

/* ── Messenger Panel (Overlay-Dropdown) ── */
.messenger-panel {
  position: fixed;
  top: var(--topbar-h);
  right: 0;
  width: 420px;
  max-width: 100vw;
  height: calc(100vh - var(--topbar-h));
  background: var(--surface);
  border-left: 1px solid var(--border);
  border-top: 2px solid var(--accent-red);
  display: flex;
  flex-direction: column;
  z-index: 500;
  transform: translateX(100%);
  transition: transform 0.28s cubic-bezier(.4,0,.2,1);
  box-shadow: -8px 0 40px rgba(0,0,0,0.6);
}
.messenger-panel.open { transform: translateX(0); }

/* ── Panel Header ── */
.messenger-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 18px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.messenger-header h3 {
  font-family: 'Rajdhani', sans-serif;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: #fff;
  margin: 0;
  flex: 1;
}
.messenger-tab-bar {
  display: flex;
  gap: 4px;
  padding: 8px 12px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.messenger-tab {
  padding: 5px 14px;
  font-size: 11px;
  font-family: 'Rajdhani', sans-serif;
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  border-radius: 4px;
  cursor: pointer;
  border: 1px solid transparent;
  color: var(--text-muted);
  background: transparent;
  transition: all 0.15s;
}
.messenger-tab:hover { color: #fff; background: rgba(255,255,255,0.05); }
.messenger-tab.active { background: rgba(212,32,32,0.15); border-color: rgba(212,32,32,0.4); color: #ff6060; }

/* ── Compose Button ── */
.messenger-compose-btn {
  margin: 10px 12px;
  padding: 8px 14px;
  background: var(--accent-red);
  border: none;
  border-radius: 6px;
  color: #fff;
  font-family: 'Rajdhani', sans-serif;
  font-size: 12px;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.2s;
  flex-shrink: 0;
}
.messenger-compose-btn:hover { background: #b51c1c; }
.messenger-compose-btn svg { width: 14px; height: 14px; }

/* ── Message List ── */
.messenger-list {
  flex: 1;
  overflow-y: auto;
  padding: 4px 0;
}
.messenger-list::-webkit-scrollbar { width: 4px; }
.messenger-list::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

.msg-item {
  padding: 11px 16px;
  border-bottom: 1px solid var(--border);
  cursor: pointer;
  transition: background 0.15s;
  display: flex;
  gap: 10px;
  align-items: flex-start;
}
.msg-item:hover { background: rgba(255,255,255,0.03); }
.msg-item.unread { border-left: 3px solid var(--accent-red); }
.msg-item.read { opacity: 0.6; }

.msg-item__icon {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1e3a6e, #2a4f96);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Rajdhani', sans-serif;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
  margin-top: 1px;
}
.msg-item__content { flex: 1; min-width: 0; }
.msg-item__from {
  font-size: 12px;
  font-weight: 700;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.msg-item.unread .msg-item__from { color: #fff; }
.msg-item__subject {
  font-size: 12px;
  color: var(--text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
}
.msg-item.unread .msg-item__subject { color: var(--text-dim); font-weight: 600; }
.msg-item__meta {
  font-size: 10px;
  color: var(--text-muted);
  margin-top: 2px;
  display: flex;
  gap: 6px;
  align-items: center;
}
.msg-item__del {
  background: none;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 2px 4px;
  border-radius: 3px;
  font-size: 12px;
  flex-shrink: 0;
  line-height: 1;
  transition: color 0.15s, background 0.15s;
}
.msg-item__del:hover { color: #ff6060; background: rgba(212,32,32,0.1); }

.messenger-empty {
  text-align: center;
  padding: 40px 20px;
  color: var(--text-muted);
  font-size: 13px;
}
.messenger-empty svg { width: 40px; height: 40px; opacity: 0.3; margin-bottom: 10px; }

/* ── Overlay Modal (Nachricht lesen / verfassen) ── */
.msg-modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(8,11,18,0.85);
  z-index: 3000;
  display: flex;
  align-items: center;
  justify-content: center;
}
.msg-modal {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-top: 3px solid var(--accent-red);
  border-radius: 8px;
  width: 640px;
  max-width: 96vw;
  max-height: 88vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 24px 80px rgba(0,0,0,0.9);
}
.msg-modal__header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}
.msg-modal__title {
  font-family: 'Rajdhani', sans-serif;
  font-size: 16px;
  font-weight: 700;
  letter-spacing: 1px;
  color: #fff;
  flex: 1;
}
.msg-modal__close {
  background: rgba(212,32,32,0.1);
  border: 1px solid rgba(212,32,32,0.3);
  color: #ff6060;
  border-radius: 4px;
  padding: 5px 12px;
  font-size: 11px;
  font-family: 'Rajdhani', sans-serif;
  font-weight: 700;
  letter-spacing: 1px;
  cursor: pointer;
}
.msg-modal__close:hover { background: rgba(212,32,32,0.25); }
.msg-modal__body {
  padding: 20px;
  overflow-y: auto;
  flex: 1;
}
.msg-modal__body::-webkit-scrollbar { width: 4px; }
.msg-modal__body::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }
.msg-modal__footer {
  padding: 14px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  flex-shrink: 0;
}

/* ── Message Read View ── */
.msg-view__meta {
  display: grid;
  grid-template-columns: 80px 1fr;
  gap: 4px 10px;
  margin-bottom: 16px;
  font-size: 12px;
}
.msg-view__meta-label { color: var(--text-muted); font-weight: 600; }
.msg-view__meta-val { color: var(--text-dim); }
.msg-view__subject {
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  margin-bottom: 16px;
  line-height: 1.3;
}
.msg-view__body {
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.7;
  white-space: pre-wrap;
  background: var(--surface3);
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 14px;
}
.msg-view__attachments {
  margin-top: 14px;
}
.msg-view__attachments-label {
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 8px;
}

/* ── Compose Form ── */
.msg-compose__field { margin-bottom: 14px; }
.msg-compose__label {
  display: block;
  font-size: 11px;
  color: var(--text-muted);
  font-weight: 600;
  letter-spacing: 1px;
  text-transform: uppercase;
  margin-bottom: 6px;
}
.msg-compose__select-wrapper {
  position: relative;
}
.msg-compose__recipients-list {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  min-height: 38px;
  background: var(--surface3);
  border: 1px solid var(--border2);
  border-radius: 6px;
  padding: 6px 10px;
  cursor: pointer;
  align-items: center;
}
.msg-compose__recipients-list.active { border-color: var(--accent-blue); }
.msg-recipient-chip {
  background: rgba(26,58,255,0.15);
  border: 1px solid rgba(26,58,255,0.3);
  border-radius: 12px;
  padding: 2px 10px 2px 8px;
  font-size: 11px;
  color: #8aacff;
  display: flex;
  align-items: center;
  gap: 5px;
}
.msg-recipient-chip__remove {
  background: none;
  border: none;
  color: #8aacff;
  cursor: pointer;
  padding: 0;
  font-size: 13px;
  line-height: 1;
  opacity: 0.7;
}
.msg-recipient-chip__remove:hover { opacity: 1; }
.msg-compose__placeholder { font-size: 12px; color: var(--text-muted); }

/* Dropdown für Empfänger */
.msg-recipients-dropdown {
  position: absolute;
  top: calc(100% + 4px);
  left: 0;
  right: 0;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 6px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 100;
  box-shadow: 0 8px 24px rgba(0,0,0,0.7);
}
.msg-recipients-dropdown::-webkit-scrollbar { width: 4px; }
.msg-recipients-dropdown::-webkit-scrollbar-thumb { background: var(--border2); }
.msg-recipients-search {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border);
}
.msg-recipients-search input {
  width: 100%;
  background: var(--surface3);
  border: 1px solid var(--border2);
  border-radius: 4px;
  padding: 5px 10px;
  font-size: 12px;
  color: var(--text-dim);
  font-family: inherit;
}
.msg-recipients-search input:focus { outline: none; border-color: var(--accent-blue); }
.msg-recipient-option {
  padding: 8px 12px;
  cursor: pointer;
  font-size: 12px;
  color: var(--text-dim);
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.1s;
}
.msg-recipient-option:hover { background: rgba(255,255,255,0.04); color: #fff; }
.msg-recipient-option.selected { background: rgba(26,58,255,0.1); color: #8aacff; }
.msg-recipient-option__role {
  font-size: 10px;
  color: var(--text-muted);
  margin-left: auto;
}

/* ============================================================
   Thread / Chat-Verlauf
   ============================================================ */

.msg-modal--thread {
  display: flex;
  flex-direction: column;
  max-height: 85vh;
  width: 560px;
}

/* Header mit Avatar + Name + Betreff */
.msg-thread__header-info {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.msg-thread__avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-blue), var(--accent-red));
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Rajdhani', sans-serif;
  font-size: 13px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.msg-thread__name {
  font-size: 13px;
  font-weight: 700;
  color: var(--text-bright);
  display: flex;
  align-items: center;
  gap: 8px;
}

.msg-thread__role {
  font-size: 10px;
  font-weight: 500;
  color: var(--text-muted);
  background: var(--surface3);
  border: 1px solid var(--border2);
  border-radius: 4px;
  padding: 1px 6px;
}

.msg-thread__subject {
  font-size: 11px;
  color: var(--text-muted);
  margin-top: 2px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 340px;
}

/* Scrollbarer Verlauf-Bereich */
.msg-thread__body {
  flex: 1;
  overflow-y: auto;
  padding: 16px 20px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--bg);
  min-height: 200px;
  max-height: 55vh;
}

.msg-thread__body::-webkit-scrollbar { width: 4px; }
.msg-thread__body::-webkit-scrollbar-thumb { background: var(--border2); border-radius: 2px; }

/* Chat-Bubbles */
.msg-bubble {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 80%;
}

.msg-bubble--mine {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.msg-bubble--theirs {
  align-self: flex-start;
}

.msg-bubble__avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: linear-gradient(135deg, #2a3f6a, #1e2c46);
  border: 1px solid var(--border2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: 'Rajdhani', sans-serif;
  font-size: 10px;
  font-weight: 700;
  color: #fff;
  flex-shrink: 0;
}

.msg-bubble__avatar--mine {
  background: linear-gradient(135deg, var(--accent-red), #8b0000);
}

.msg-bubble__inner {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.msg-bubble--mine .msg-bubble__inner { align-items: flex-end; }
.msg-bubble--theirs .msg-bubble__inner { align-items: flex-start; }

.msg-bubble__name {
  font-size: 10px;
  color: var(--text-muted);
  padding: 0 4px;
  font-weight: 600;
}

.msg-bubble__text {
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 12px;
  padding: 9px 13px;
  font-size: 13px;
  color: var(--text-dim);
  line-height: 1.5;
  word-break: break-word;
}

.msg-bubble--mine .msg-bubble__text {
  background: rgba(212, 32, 32, 0.18);
  border-color: rgba(212, 32, 32, 0.3);
  border-bottom-right-radius: 4px;
  color: #e8d5d5;
}

.msg-bubble--theirs .msg-bubble__text {
  border-bottom-left-radius: 4px;
}

.msg-bubble__time {
  font-size: 10px;
  color: var(--text-muted);
  padding: 0 4px;
}

.msg-bubble__attachments {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  margin-top: 4px;
}

/* Antwort-Bereich */
.msg-thread__reply {
  border-top: 1px solid var(--border);
  padding: 12px 16px;
  background: var(--surface);
  flex-shrink: 0;
}

.msg-thread__reply--sent-info {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 11px;
  color: var(--text-muted);
  padding: 10px 16px;
}

.msg-thread__reply-input-wrap {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.msg-thread__reply-input {
  width: 100%;
  background: var(--surface2);
  border: 1px solid var(--border2);
  border-radius: 8px;
  color: var(--text-dim);
  font-size: 13px;
  font-family: inherit;
  padding: 9px 12px;
  resize: none;
  transition: border-color 0.2s;
  box-sizing: border-box;
  line-height: 1.5;
}

.msg-thread__reply-input:focus {
  outline: none;
  border-color: rgba(212, 32, 32, 0.5);
}

.msg-thread__reply-actions {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.msg-thread__attach-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 6px;
  background: var(--surface3);
  border: 1px solid var(--border2);
  cursor: pointer;
  color: var(--text-muted);
  transition: background 0.2s, color 0.2s;
}

.msg-thread__attach-btn:hover {
  background: rgba(255,255,255,0.08);
  color: #fff;
}

.msg-thread__send-btn {
  padding: 7px 16px;
  font-size: 12px;
  display: flex;
  align-items: center;
  gap: 5px;
}

/* Reply-Datei-Chips */
#msg-reply-files {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
}

.msg-reply-file-chip {
  background: var(--surface3);
  border: 1px solid var(--border2);
  border-radius: 4px;
  padding: 3px 8px;
  font-size: 11px;
  color: var(--text-dim);
  display: inline-flex;
  align-items: center;
  gap: 5px;
}

.msg-reply-file-chip button {
  background: none;
  border: none;
  color: #ff6060;
  cursor: pointer;
  font-size: 12px;
  padding: 0;
  line-height: 1;
}

/* ── Konversations-Liste Verbesserungen ── */
.msg-item__unread-count {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--accent-red);
  color: #fff;
  font-size: 10px;
  font-weight: 700;
  border-radius: 10px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  margin-left: 6px;
  vertical-align: middle;
  font-family: 'Rajdhani', sans-serif;
}

.msg-item__preview {
  font-size: 11px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-top: 1px;
  max-width: 200px;
}

.msg-item.unread .msg-item__preview {
  color: var(--text-dim);
}
