/*
 * Chat-Balken unten rechts (siehe includes/chat-widget.php).
 * Eigene Datei statt in custom.css: Er gehört zum Plugin, nicht zum Theme —
 * damit läuft er auch, wenn das Theme einmal ausgetauscht wird.
 *
 * Bewusst eigene Namen (zbc-*) und keine Theme-Variablen: Das Widget steht auf
 * fremden Seiten und darf nicht davon abhängen, was dort definiert ist.
 */

.zbc {
  position: fixed; right: 18px; bottom: 18px; z-index: 9998;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  display: flex; flex-direction: column; align-items: flex-end; gap: 12px;
}

/* Runder Knopf */
.zbc-knopf {
  width: 58px; height: 58px; border-radius: 50%; border: 0; cursor: pointer;
  background: radial-gradient(circle at 32% 26%, #2b2418, #1a1712);
  color: #d9b46a;
  display: grid; place-items: center;
  box-shadow: 0 8px 24px rgba(0,0,0,.34), 0 0 0 1px rgba(217,180,106,.35);
  transition: transform .15s ease;
}
/* Ruhiger Gold-Puls, damit der Knopf dezent auffaellt (pausiert bei reduce-motion). */
.zbc-knopf::after {
  content: ""; position: absolute; inset: -6px; border-radius: 50%;
  border: 2px solid rgba(217,180,106,.45); opacity: 0;
  animation: zbc-puls 2.8s ease-out infinite; pointer-events: none;
}
@keyframes zbc-puls {
  0%   { transform: scale(.82); opacity: .55; }
  70%  { transform: scale(1.28); opacity: 0; }
  100% { opacity: 0; }
}
/* Hinweis im Fenster: die Unterhaltung bleibt dem Besucher erhalten. */
.zbc-hinweis {
  margin: 0; padding: 9px 16px; font-size: 12.5px; line-height: 1.4;
  color: #6b5b3a; background: #faf4e6; border-bottom: 1px solid #efe6d2;
}
.zbc-knopf:hover  { transform: scale(1.05); }
.zbc-knopf:active { transform: scale(.96); }
.zbc.offen .zbc-knopf { display: none; }   /* offen braucht es ihn nicht */

/* Fenster */
.zbc-fenster {
  width: min(360px, calc(100vw - 32px));
  max-height: min(560px, calc(100dvh - 100px));
  display: flex; flex-direction: column; overflow: hidden;
  background: #fff; color: #16181d;
  border-radius: 16px; box-shadow: 0 12px 40px rgba(0,0,0,.28);
  animation: zbc-auf .16s ease both;
}
@keyframes zbc-auf { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.zbc-fenster[hidden] { display: none; }

.zbc-kopf {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 12px;
  padding: 16px 16px 12px; border-bottom: 1px solid #e6e8ec;
}
.zbc-kopf strong { display: block; font-size: 16px; }
.zbc-status { display: block; margin-top: 3px; font-size: 13px; color: #5f6672; }
.zbc-status::before {
  content: ''; display: inline-block; width: 7px; height: 7px; border-radius: 50%;
  background: #12864a; margin-right: 6px;
}
.zbc-zu {
  border: 0; background: none; cursor: pointer;
  font-size: 26px; line-height: 1; color: #5f6672; padding: 0 4px;
}

.zbc-verlauf {
  flex: 1; min-height: 120px; overflow-y: auto;
  padding: 14px 16px; display: flex; flex-direction: column; gap: 8px;
  background: #f6f7f9;
}
.zbc-blase {
  max-width: 86%; align-self: flex-start;
  background: #fff; border: 1px solid #e6e8ec;
  border-radius: 14px 14px 14px 4px; padding: 10px 13px;
  font-size: 15px; line-height: 1.45;
}
.zbc-blase.ich {
  align-self: flex-end; background: #1a1712; color: #fff; border-color: #1a1712;
  border-radius: 14px 14px 4px 14px;
}
/* Zeitstempel unter der Blase — dezent, damit der Text fuehrt. */
.zbc-blase time { display: block; margin-top: 5px; font-size: 11px; opacity: .6; }
/* Ungelesene Antwort, waehrend der Balken zu ist: Punkt am Knopf. */
.zbc-knopf { position: relative; }
.zbc-punkt {
  position: absolute; top: 2px; right: 2px;
  width: 13px; height: 13px; border-radius: 50%;
  background: #e5484d; border: 2px solid #fff;
}
.zbc-punkt[hidden] { display: none; }

.zbc-form { border-top: 1px solid #e6e8ec; background: #fff; }
.zbc-felder { display: flex; flex-direction: column; gap: 8px; padding: 12px 16px 0; }
.zbc-felder input {
  width: 100%; border: 1px solid #dcdfe4; border-radius: 10px;
  padding: 10px 12px; font: inherit;
  font-size: 16px;                    /* 16px: iOS zoomt sonst beim Tippen */
  color: #16181d; background: #fff;
}
.zbc-felder input:focus { outline: none; border-color: #1a1712; }
/* Nach dem ersten Senden sind Name und Adresse bekannt. */
.zbc-form.gesendet .zbc-felder { display: none; }

.zbc-eingabe { display: flex; align-items: flex-end; gap: 8px; padding: 12px 16px; }
.zbc-eingabe textarea {
  flex: 1; min-height: 42px; max-height: 110px; resize: none;
  border: 1px solid #dcdfe4; border-radius: 12px; padding: 10px 12px;
  font: inherit; font-size: 16px; line-height: 1.4; color: #16181d; background: #fff;
}
.zbc-eingabe textarea:focus { outline: none; border-color: #1a1712; }
.zbc-eingabe button {
  flex: 0 0 auto; width: 42px; height: 42px; border: 0; border-radius: 50%;
  background: #1a1712; color: #d9b46a; display: grid; place-items: center; cursor: pointer;
}
.zbc-eingabe button:disabled { opacity: .5; cursor: default; }

/* Auf dem Handy den ganzen unteren Bereich nutzen. */
@media (max-width: 480px) {
  .zbc { right: 12px; bottom: 12px; left: 12px; align-items: stretch; }
  .zbc-knopf { align-self: flex-end; }
  .zbc-fenster { width: 100%; max-height: calc(100dvh - 80px); }
}

/* Dunkles Systemthema: Der Balken bleibt hell, aber nicht grell. */
@media (prefers-color-scheme: dark) {
  .zbc-fenster { background: #16181d; color: #f2f3f5; }
  .zbc-kopf, .zbc-form { border-color: #2a2d33; background: #16181d; }
  .zbc-verlauf { background: #101114; }
  .zbc-blase { background: #1c1f25; border-color: #2a2d33; color: #f2f3f5; }
  .zbc-felder input, .zbc-eingabe textarea {
    background: #1c1f25; border-color: #2a2d33; color: #f2f3f5;
  }
  .zbc-status { color: #9aa1ac; }
  .zbc-zu { color: #9aa1ac; }
  .zbc-hinweis { background: #14151a; color: #b9a06f; border-bottom-color: #2a2d33; }
}

@media (prefers-reduced-motion: reduce) {
  .zbc-fenster { animation: none; }
  .zbc-knopf { transition: none; }
  .zbc-knopf::after { animation: none; opacity: 0; }
}

/* ── Gesprächsseite (/nachricht/?c=…) ────────────────────────────────────── */
/*
 * Eigenständige Seite, auf der der Kunde antwortet. Bewusst schlicht und ohne
 * Abhängigkeit vom Theme — sie wird aus einer E-Mail heraus geöffnet, oft auf
 * dem Handy, oft von jemandem, der die Seite sonst nie sieht.
 */
.zbk-huelle { padding: 24px 16px 40px; display: flex; justify-content: center; }
.zbk {
  width: 100%; max-width: 560px;
  background: #fff; color: #16181d;
  border: 1px solid #e6e8ec; border-radius: 16px; overflow: hidden;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  display: flex; flex-direction: column;
}
.zbk-kopf { padding: 16px; border-bottom: 1px solid #e6e8ec; }
.zbk-kopf strong { display: block; font-size: 17px; }
.zbk-kopf span   { display: block; margin-top: 3px; font-size: 14px; color: #5f6672; }

.zbk-verlauf {
  padding: 16px; background: #f6f7f9;
  display: flex; flex-direction: column; gap: 10px;
  min-height: 220px; max-height: 60dvh; overflow-y: auto;
}
.zbk-laedt { margin: auto; color: #5f6672; font-size: 15px; }
.zbk-blase { max-width: 86%; border-radius: 14px; padding: 10px 13px; font-size: 15px; line-height: 1.45; }
.zbk-blase p { margin: 0; white-space: pre-wrap; }
.zbk-blase time { display: block; margin-top: 5px; font-size: 12px; opacity: .65; }
/* „ich" ist hier der KUNDE — die Seite gehört ihm, nicht dem Team. */
.zbk-blase.ich  { align-self: flex-end; background: #1a1712; color: #fff; border-radius: 14px 14px 4px 14px; }
.zbk-blase.team { align-self: flex-start; background: #fff; border: 1px solid #e6e8ec; border-radius: 14px 14px 14px 4px; }

.zbk-form { display: flex; align-items: flex-end; gap: 8px; padding: 12px 16px; border-top: 1px solid #e6e8ec; }
.zbk-form textarea {
  flex: 1; min-height: 44px; max-height: 120px; resize: none;
  border: 1px solid #dcdfe4; border-radius: 12px; padding: 11px 13px;
  font: inherit; font-size: 16px;      /* 16px: iOS zoomt sonst beim Tippen */
  line-height: 1.4; color: #16181d; background: #fff;
}
.zbk-form textarea:focus { outline: none; border-color: #1a1712; }
.zbk-form button {
  flex: 0 0 auto; width: 44px; height: 44px; border: 0; border-radius: 50%;
  background: #1a1712; color: #d9b46a; display: grid; place-items: center; cursor: pointer;
}
.zbk-form button:disabled { opacity: .5; cursor: default; }
.zbk-weg { padding: 32px 20px; text-align: center; }
.zbk-weg h1 { margin: 0 0 10px; font-size: 21px; }
.zbk-weg p  { margin: 0; color: #5f6672; font-size: 15px; }

@media (prefers-color-scheme: dark) {
  .zbk { background: #16181d; color: #f2f3f5; border-color: #2a2d33; }
  .zbk-kopf, .zbk-form { border-color: #2a2d33; }
  .zbk-kopf span, .zbk-laedt, .zbk-weg p { color: #9aa1ac; }
  .zbk-verlauf { background: #101114; }
  .zbk-blase.team { background: #1c1f25; border-color: #2a2d33; color: #f2f3f5; }
  .zbk-form textarea { background: #1c1f25; border-color: #2a2d33; color: #f2f3f5; }
}
