/* RDN Repair Tickets - Live-Chat */

.rdn-chat { }
.rdn-chat-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; }
.rdn-chat-head h3 { margin: 0; }
.rdn-chat-presence {
  font-size: 13px; font-weight: 600; padding: 4px 10px; border-radius: 999px;
  background: #f1f5f9; color: #64748b;
}
.rdn-chat-presence.is-on  { background: #dcfce7; color: #15803d; }
.rdn-chat-presence.is-off { background: #fef2f2; color: #b91c1c; }
.rdn-chat-hint, .rdn-chat-note { font-size: 12.5px; color: #64748b; margin: 8px 0 0; }

/* Offline-Verweis (Kunde) */
.rdn-chat-offline {
  margin: 14px 0; padding: 16px; border: 1px solid #fde68a; background: #fffbeb;
  border-radius: 12px; color: #92400e;
}
.rdn-chat-offline p { margin: 0 0 10px; }

/* Thread */
.rdn-chat-thread {
  margin-top: 14px; min-height: 240px; max-height: 460px; overflow-y: auto;
  border: 1px solid #e5e7eb; border-radius: 12px; padding: 14px; background: #f8fafc;
  display: flex; flex-direction: column; gap: 8px;
}
.rdn-chat-placeholder, .rdn-chat-empty { color: #94a3b8; font-size: 13px; text-align: center; padding: 20px; }

.rdn-chat-msg { display: flex; flex-direction: column; max-width: 78%; }
.rdn-chat-msg.is-mine { align-self: flex-end; align-items: flex-end; }
.rdn-chat-msg.is-them { align-self: flex-start; align-items: flex-start; }
.rdn-chat-bubble {
  padding: 8px 12px; border-radius: 14px; font-size: 14px; line-height: 1.45;
  background: #fff; border: 1px solid #e5e7eb; color: #0f172a; word-break: break-word;
}
.rdn-chat-msg.is-mine .rdn-chat-bubble { background: #2563eb; border-color: #2563eb; color: #fff; }
.rdn-chat-imglink { display: inline-block; margin-top: 4px; }
.rdn-chat-imglink img { max-width: 220px; max-height: 220px; border-radius: 12px; border: 1px solid #e5e7eb; display: block; }
.rdn-chat-meta { font-size: 11px; color: #94a3b8; margin-top: 3px; }

/* Eingabe */
.rdn-chat-form {
  display: flex; align-items: flex-end; gap: 8px; margin-top: 12px;
}
.rdn-chat-form textarea {
  flex: 1; resize: none; border: 1px solid #d1d5db; border-radius: 10px; padding: 9px 12px;
  font-size: 14px; font-family: inherit; max-height: 120px; line-height: 1.4;
}
.rdn-chat-form textarea:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.rdn-chat-img-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 40px; height: 40px;
  border: 1px solid #d1d5db; border-radius: 10px; cursor: pointer; font-size: 18px; background: #fff; flex: 0 0 auto;
}
.rdn-chat-img-btn:hover { background: #f8fafc; }
.rdn-chat-img-btn input { display: none; }
.rdn-chat-img-preview {
  margin-top: 8px; font-size: 13px; color: #334155; display: flex; align-items: center; gap: 10px;
}
.rdn-chat-img-x {
  border: 1px solid #e5e7eb; background: #fff; border-radius: 8px; padding: 3px 10px; cursor: pointer; font-size: 12px; color: #b91c1c;
}

/* Mitarbeiter: Split-Layout */
.rdn-chat-split { display: flex; gap: 14px; margin-top: 14px; }
.rdn-chat-sessions {
  flex: 0 0 240px; max-height: 520px; overflow-y: auto; border: 1px solid #e5e7eb;
  border-radius: 12px; padding: 6px; background: #fff;
}
.rdn-chat-session {
  display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; width: 100%; text-align: left;
  border: 0; background: transparent; padding: 9px 10px; border-radius: 9px; cursor: pointer; margin-bottom: 2px;
}
.rdn-chat-session:hover { background: #f1f5f9; }
.rdn-chat-session.is-active { background: #e0e7ff; }
.rdn-chat-session-name { font-weight: 600; font-size: 13.5px; color: #0f172a; flex: 1; }
.rdn-chat-session-time { font-size: 11px; color: #94a3b8; width: 100%; }
.rdn-chat-badge {
  background: #dc2626; color: #fff; border-radius: 999px; font-size: 11px; font-weight: 700;
  min-width: 18px; height: 18px; display: inline-flex; align-items: center; justify-content: center; padding: 0 5px;
}
.rdn-chat-main { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.rdn-chat-main .rdn-chat-thread { margin-top: 0; flex: 1; }

@media (max-width: 640px) {
  .rdn-chat-split { flex-direction: column; }
  .rdn-chat-sessions { flex: none; max-height: 200px; }
  .rdn-chat-msg { max-width: 90%; }
}

/* Einstellungen (Mitarbeiter) */
.rdn-chat-settings { margin-top: 12px; border: 1px solid #e5e7eb; border-radius: 12px; background: #fff; }
.rdn-chat-settings > summary {
  cursor: pointer; padding: 10px 14px; font-weight: 700; font-size: 14px; color: #0f172a; list-style: none;
}
.rdn-chat-settings > summary::-webkit-details-marker { display: none; }
.rdn-chat-settings-body { padding: 4px 14px 14px; display: flex; flex-direction: column; gap: 14px; }
.rdn-chat-set-row { display: flex; align-items: center; gap: 8px; font-size: 14px; }
.rdn-chat-set-block { }
.rdn-chat-set-label { font-weight: 600; font-size: 13.5px; margin-bottom: 4px; color: #0f172a; }
.rdn-chat-muted { color: #64748b; font-weight: 400; }
.rdn-chat-sm { font-size: 12px; }
.rdn-chat-operators { display: flex; flex-wrap: wrap; gap: 6px 16px; margin-top: 6px; }
.rdn-chat-op { display: flex; align-items: center; gap: 6px; font-size: 13.5px; }
.rdn-chat-set-block textarea {
  width: 100%; border: 1px solid #d1d5db; border-radius: 10px; padding: 8px 10px; font-family: inherit; font-size: 13.5px;
}
.rdn-chat-set-actions { display: flex; align-items: center; gap: 10px; }
.rdn-chat-set-msg { font-size: 13px; color: #15803d; }
.rdn-chat-online-now {
  font-size: 12.5px; color: #334155; background: #f1f5f9; border-radius: 8px; padding: 6px 10px;
}

/* ================================================================
   Oeffentlicher Chat-Button (Bubble) + Panel
   ================================================================ */
.rdn-chatw-btn {
  position: fixed; right: 20px; bottom: 20px; z-index: 2147483646;
  width: 58px; height: 58px; border-radius: 50%; border: none; cursor: pointer;
  background: #2563eb; color: #fff; font-size: 26px; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 24px rgba(37,99,235,.35), 0 2px 6px rgba(15,23,42,.15);
  transition: transform .15s ease, background .15s ease;
}
.rdn-chatw-btn:hover { transform: translateY(-2px); }
.rdn-chatw-btn.is-online { background: #16a34a; box-shadow: 0 8px 24px rgba(22,163,74,.35), 0 2px 6px rgba(15,23,42,.15); }
.rdn-chatw-btn.is-open { background: #334155; box-shadow: 0 6px 18px rgba(15,23,42,.3); }
.rdn-chatw-badge {
  position: absolute; top: -2px; right: -2px; min-width: 20px; height: 20px; padding: 0 5px;
  border-radius: 999px; background: #dc2626; color: #fff; font-size: 11px; font-weight: 700;
  display: flex; align-items: center; justify-content: center; border: 2px solid #fff;
}

.rdn-chatw-panel {
  position: fixed; right: 20px; bottom: 90px; z-index: 2147483647;
  width: 340px; max-width: calc(100vw - 32px); max-height: 70vh;
  background: #fff; border-radius: 16px; overflow: hidden;
  box-shadow: 0 20px 50px rgba(15,23,42,.28), 0 2px 8px rgba(15,23,42,.12);
  display: flex; flex-direction: column; font-size: 14px; color: #0f172a;
}
.rdn-chatw-head {
  display: flex; align-items: center; justify-content: space-between; gap: 10px;
  padding: 12px 14px; background: #0f172a; color: #fff;
}
.rdn-chatw-head strong { font-size: 15px; }
.rdn-chatw-status { font-size: 12px; opacity: .85; margin-top: 2px; }
.rdn-chatw-status.is-on  { color: #86efac; opacity: 1; }
.rdn-chatw-status.is-off { color: #fca5a5; opacity: 1; }
.rdn-chatw-close {
  background: transparent; border: 0; color: #fff; font-size: 24px; line-height: 1;
  cursor: pointer; padding: 0 4px; opacity: .8;
}
.rdn-chatw-close:hover { opacity: 1; }

.rdn-chatw-notice { padding: 16px 14px; background: #fffbeb; color: #92400e; font-size: 13.5px; }
.rdn-chatw-notice p { margin: 0 0 10px; }
.rdn-chatw-notice p:last-child { margin-bottom: 0; }
.rdn-chatw-cta {
  display: inline-block; background: #2563eb; color: #fff !important; text-decoration: none;
  padding: 7px 13px; border-radius: 9px; font-size: 13px; font-weight: 600; margin-right: 6px;
}
.rdn-chatw-cta.is-ghost { background: #fff; color: #1e293b !important; border: 1px solid #e5e7eb; }

.rdn-chatw-thread {
  flex: 1; overflow-y: auto; padding: 14px; background: #f8fafc;
  display: flex; flex-direction: column; gap: 8px; min-height: 180px;
}
.rdn-chatw-msg { display: flex; flex-direction: column; max-width: 85%; }
.rdn-chatw-msg.is-mine { align-self: flex-end; align-items: flex-end; }
.rdn-chatw-msg.is-them { align-self: flex-start; align-items: flex-start; }
.rdn-chatw-bubble {
  padding: 8px 12px; border-radius: 14px; font-size: 13.5px; line-height: 1.45;
  background: #fff; border: 1px solid #e5e7eb; word-break: break-word;
}
.rdn-chatw-msg.is-mine .rdn-chatw-bubble { background: #2563eb; border-color: #2563eb; color: #fff; }
.rdn-chatw-imglink img { max-width: 180px; max-height: 180px; border-radius: 10px; display: block; margin-top: 4px; }
.rdn-chatw-meta { font-size: 10.5px; color: #94a3b8; margin-top: 3px; }

.rdn-chatw-form {
  display: flex; align-items: flex-end; gap: 6px; padding: 10px; border-top: 1px solid #e5e7eb; background: #fff;
}
.rdn-chatw-form textarea {
  flex: 1; resize: none; border: 1px solid #d1d5db; border-radius: 10px; padding: 8px 10px;
  font-size: 13.5px; font-family: inherit; max-height: 90px; line-height: 1.4;
}
.rdn-chatw-form textarea:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,.15); }
.rdn-chatw-img-btn {
  display: inline-flex; align-items: center; justify-content: center; width: 36px; height: 36px;
  border: 1px solid #d1d5db; border-radius: 10px; cursor: pointer; font-size: 16px; background: #fff; flex: 0 0 auto;
}
.rdn-chatw-img-btn input { display: none; }
.rdn-chatw-send {
  width: 36px; height: 36px; border: 0; border-radius: 10px; background: #2563eb; color: #fff;
  cursor: pointer; font-size: 15px; flex: 0 0 auto;
}
.rdn-chatw-preview {
  display: flex; align-items: center; justify-content: space-between; gap: 8px;
  padding: 8px 12px; font-size: 12.5px; color: #334155; background: #f1f5f9;
}
.rdn-chatw-x { border: 1px solid #e5e7eb; background: #fff; border-radius: 8px; padding: 3px 8px; cursor: pointer; font-size: 11.5px; color: #b91c1c; }

@media (max-width: 640px) {
  /* Auf dem Handy als Vollbild-Fenster von unten (Bottom Sheet) statt kleiner Kachel. */
  .rdn-chatw-panel {
    left: 0; right: 0; bottom: 0; top: auto;
    width: 100%; max-width: 100%;
    height: 88vh; max-height: none;
    border-radius: 18px 18px 0 0;
  }
  /* Neuere Browser: dynamische Hoehe, damit die Adressleiste nicht stoert. */
  @supports (height: 100dvh) {
    .rdn-chatw-panel { height: 88dvh; }
  }

  .rdn-chatw-btn {
    right: 14px;
    bottom: calc(14px + env(safe-area-inset-bottom, 0px));
  }

  /* WICHTIG: iOS/Safari zoomt automatisch in die Seite, sobald ein Eingabefeld
     mit weniger als 16px Schrift den Fokus bekommt. Genau das verschiebt die
     Darstellung. Deshalb auf kleinen Bildschirmen mindestens 16px. */
  .rdn-chatw-form textarea,
  .rdn-chatw-namerow input {
    font-size: 16px;
  }

  .rdn-chatw-thread { flex: 1 1 auto; min-height: 0; padding: 12px; }
  .rdn-chatw-msg { max-width: 88%; }
  .rdn-chatw-bubble { font-size: 15px; }

  /* Eingabezeile: groessere Tippflaechen, Rand fuer die Home-Leiste */
  .rdn-chatw-form {
    padding: 10px 10px calc(10px + env(safe-area-inset-bottom, 0px));
    gap: 8px;
  }
  .rdn-chatw-plus, .rdn-chatw-send { width: 42px; height: 42px; }
  .rdn-chatw-namerow { padding: 10px 10px 0; }

  .rdn-chatw-drop { left: 8px; right: 8px; bottom: 64px; }
  .rdn-chatw-head { padding: 14px; }
  .rdn-chatw-notice { padding: 14px; }
}

/* Der Einstieg ist ein Link (funktioniert auch ohne JavaScript) */
a.rdn-chatw-btn, a.rdn-chatw-btn:hover, a.rdn-chatw-btn:focus,
a.rdn-chatw-btn:visited { text-decoration: none; color: #fff !important; }

/* Namensfeld fuer Gaeste */
.rdn-chatw-namerow { padding: 10px 10px 0; background: #fff; }
.rdn-chatw-namerow input {
  width: 100%; border: 1px solid #d1d5db; border-radius: 10px; padding: 7px 10px; font-size: 13px; font-family: inherit;
}
.rdn-chatw-namerow input:focus { outline: none; border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,.15); }

/* Gast-Kennzeichnung in der Mitarbeiter-Liste */
.rdn-chat-guest {
  background: #fef3c7; color: #92400e; border: 1px solid #fde68a; border-radius: 999px;
  font-size: 10.5px; font-weight: 700; padding: 1px 7px;
}

/* ================================================================
   Theme-Härtung: verhindert, dass Theme-Regeln (Mesmerize) in den
   Chat hineinwirken – bekannte Störquellen sind ::before-Symbole,
   Button-Rahmen, Zeilenhöhen und Schriftfamilien.
   ================================================================ */
.rdn-chatw-panel, .rdn-chatw-panel *,
.rdn-chatw-btn, .rdn-chatw-btn * {
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
}
.rdn-chatw-panel *::before, .rdn-chatw-panel *::after,
.rdn-chatw-btn::before, .rdn-chatw-btn::after {
  content: none !important;
}
.rdn-chatw-panel p { margin: 0 0 10px; padding: 0; line-height: 1.5; }
.rdn-chatw-panel p:last-child { margin-bottom: 0; }
.rdn-chatw-panel button,
.rdn-chatw-panel input,
.rdn-chatw-panel textarea {
  margin: 0; letter-spacing: normal; text-transform: none; box-shadow: none;
  min-height: 0; min-width: 0; line-height: 1.4;
}
.rdn-chatw-panel a { box-shadow: none; }
.rdn-chatw-btn {
  padding: 0; margin: 0; letter-spacing: normal; text-transform: none; min-width: 0; min-height: 0;
}
/* Gleiches für den Chat im Dashboard */
.rdn-chat *::before, .rdn-chat *::after { content: none !important; }
.rdn-chat button, .rdn-chat input, .rdn-chat textarea, .rdn-chat select {
  letter-spacing: normal; text-transform: none; min-height: 0;
}
.rdn-chat .rdn-chat-thread p { margin: 0; }

/* ================================================================
   Bild anhängen: Plus-Button + Ziehfläche
   ================================================================ */
.rdn-chatw-plus {
  width: 36px; height: 36px; flex: 0 0 auto; cursor: pointer;
  border: 1px solid #d1d5db; border-radius: 10px; background: #fff; color: #334155;
  font-size: 22px; line-height: 1; display: flex; align-items: center; justify-content: center;
  transition: background .15s ease, border-color .15s ease, transform .15s ease;
}
.rdn-chatw-plus:hover { background: #f1f5f9; border-color: #cbd5e1; }
.rdn-chatw-plus.is-open { background: #2563eb; border-color: #2563eb; color: #fff; transform: rotate(45deg); }

.rdn-chatw-drop {
  position: absolute; left: 10px; right: 10px; bottom: 58px; z-index: 3;
  background: #fff; border: 1px solid #e5e7eb; border-radius: 14px;
  box-shadow: 0 12px 32px rgba(15,23,42,.22); overflow: hidden;
}
.rdn-chatw-drop-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 9px 12px; font-size: 13px; font-weight: 700; color: #0f172a;
  border-bottom: 1px solid #f1f5f9; background: #f8fafc;
}
.rdn-chatw-drop-x {
  border: 0; background: transparent; cursor: pointer; font-size: 20px; line-height: 1; color: #64748b; padding: 0 2px;
}
.rdn-chatw-drop-x:hover { color: #0f172a; }
.rdn-chatw-dropzone {
  margin: 10px; padding: 16px 12px; text-align: center;
  border: 2px dashed #cbd5e1; border-radius: 12px; background: #f8fafc;
  transition: border-color .15s ease, background .15s ease;
}
.rdn-chatw-dropzone.is-over { border-color: #2563eb; background: #eff6ff; }
.rdn-chatw-dropicon { font-size: 26px; line-height: 1; margin-bottom: 6px; }
.rdn-chatw-droptext { font-size: 13.5px; color: #334155; margin: 0 0 8px; }
.rdn-chatw-droptext span { color: #94a3b8; font-size: 12px; }
.rdn-chatw-choose {
  border: 1px solid #2563eb; background: #2563eb; color: #fff; border-radius: 9px;
  padding: 7px 14px; font-size: 13px; font-weight: 600; cursor: pointer;
}
.rdn-chatw-choose:hover { background: #1d4ed8; border-color: #1d4ed8; }
.rdn-chatw-drophint { font-size: 11.5px; color: #94a3b8; margin: 8px 0 0; }

/* Vorschau des gewählten Bildes */
.rdn-chatw-preview { align-items: center; gap: 10px; }
.rdn-chatw-thumb { flex: 0 0 auto; }
.rdn-chatw-thumb img {
  width: 38px; height: 38px; object-fit: cover; border-radius: 8px; border: 1px solid #e5e7eb; display: block;
}
.rdn-chatw-fname {
  flex: 1; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; font-size: 12.5px; color: #334155;
}

/* Leiste über dem Verlauf (Mitarbeiter) */
.rdn-chat-threadbar { display: flex; justify-content: flex-end; margin-bottom: 6px; }
.rdn-chat-del {
  border: 1px solid #fecaca; background: #fff; color: #b91c1c; border-radius: 9px;
  padding: 5px 11px; font-size: 12.5px; cursor: pointer;
}
.rdn-chat-del:hover { background: #fef2f2; }

/* Auf dem Handy: Seite hinter dem geöffneten Chat nicht mitscrollen lassen */
@media (max-width: 640px) {
  html.rdn-chatw-active, html.rdn-chatw-active body { overflow: hidden; }
}

/* Solange der Chat offen ist: schwebende Elemente anderer Plugins (vor allem
   Cookie-Hinweise) zurückstellen, damit sie die Bedienung nicht blockieren.
   Beim Schließen erscheinen sie sofort wieder. */
html.rdn-chatw-active #moove_gdpr_save_popup_button_button,
html.rdn-chatw-active #moove_gdpr_cookie_info_bar,
html.rdn-chatw-active .cky-btn-revisit-wrapper,
html.rdn-chatw-active #cmplz-manage-consent,
html.rdn-chatw-active .cmplz-manage-consent,
html.rdn-chatw-active #CybotCookiebotDialog,
html.rdn-chatw-active #BorlabsCookieBox,
html.rdn-chatw-active .borlabs-cookie-widget,
html.rdn-chatw-active #usercentrics-root,
html.rdn-chatw-active #cookie-notice,
html.rdn-chatw-active #cookie-law-info-bar,
html.rdn-chatw-active .cli-modal,
html.rdn-chatw-active .rcb-banner {
  display: none !important;
}
