/* ===========================================================================
   Optik Klein - Chatfenster. Gegenstueck zu assets/chat.js.

   Aussehen nach chat-agent/vorschau.html. Alle Klassen tragen den Vorsatz
   okc-, weil das Theme "section", "ul", "p" und "a" allgemein gestaltet.
   Schriften und Farben kommen aus den Variablen in style.css, nichts von aussen.
   Geladen wird die Datei nur, wenn der Startschalter in functions.php an ist.
   ========================================================================= */

#ok-chat{
  --okc-unten: 18px;
  position:fixed; right:18px; bottom:var(--okc-unten); z-index:50;
  font-family:var(--sans); line-height:1.5; color:var(--ink);
}
#ok-chat button, #ok-chat input{ font-family:inherit; }

/* Der Knopf darf die Impressum- und Datenschutz-Links am Seitenende nicht
   verdecken: Die Fusszeile bekommt unten so viel Luft, wie er braucht. */
.site-footer{ padding-bottom:84px; }

/* Am Handy steht unten die feste Leiste mit Termin und Anruf, der Knopf sitzt
   darueber. Auf /termin/ gibt es die Leiste nicht, dort bleibt er unten. */
@media (max-width: 760px){
  body:has(.mobile-cta) #ok-chat{ --okc-unten:calc(68px + env(safe-area-inset-bottom)); }
  /* Leiste (58 px) und Knopf stehen uebereinander, gemessen bei 412 px. */
  .site-footer{ padding-bottom:calc(136px + env(safe-area-inset-bottom)); }
  /* Wie die Leiste: weg, solange das Menue offen ist */
  body:has(.nav-links.open) #ok-chat{ display:none; }
}

.okc-blase{
  display:flex; align-items:center; gap:8px; min-height:44px;
  padding:12px 18px; border:0; border-radius:999px; cursor:pointer;
  background:var(--primary); color:var(--bg); font-size:1rem; font-weight:700;
  box-shadow:0 10px 30px -8px rgba(0,0,0,.7);
}
.okc-blase:hover{ filter:brightness(1.08); }
.okc-blase[hidden]{ display:none; }
.okc-blase svg{ width:20px; height:20px; }

.okc-fenster{
  position:absolute; right:0; bottom:0;
  width:min(380px, calc(100vw - 28px));
  height:min(560px, calc(100vh - var(--okc-unten) - 18px));
  height:min(560px, calc(100dvh - var(--okc-unten) - 18px));
  display:flex; flex-direction:column; overflow:hidden;
  background:var(--surface); border:1px solid var(--line); border-radius:20px;
  box-shadow:0 24px 60px -12px rgba(0,0,0,.8);
}
.okc-fenster[hidden]{ display:none; }
.okc-fenster:focus{ outline:none; }

.okc-kopf{ display:flex; align-items:center; gap:12px; padding:12px 14px; border-bottom:1px solid var(--line); }
.okc-figur{
  flex:none; width:46px; height:46px; border-radius:50%; overflow:hidden;
  display:grid; place-items:center; background:var(--surface-tint); color:var(--primary-deep);
}
.okc-figur svg{ width:100%; height:100%; display:block; }
.okc-titel{ display:block; font:600 1.05rem/1.2 var(--serif); color:var(--ink); }
.okc-zu{
  margin-left:auto; flex:none; width:44px; height:44px; padding:0; border:0; border-radius:8px;
  background:none; color:var(--ink-soft); font-size:1.4rem; line-height:1; cursor:pointer;
}
.okc-zu:hover{ color:var(--ink); }

.okc-liste{scrollbar-width:thin;scrollbar-color:var(--line) transparent;
  flex:1; min-height:0; overflow-y:auto; overscroll-behavior:contain;
  padding:14px; display:flex; flex-direction:column; gap:10px;
}
.okc-msg{
  flex:none; max-width:86%; padding:9px 12px; border-radius:14px;
  font-size:.92rem; color:var(--ink); overflow-wrap:anywhere;
}
.okc-agent{ align-self:flex-start; background:var(--surface-tint); border-bottom-left-radius:4px; }
.okc-kunde{
  align-self:flex-end; background:var(--primary); color:var(--bg);
  border-bottom-right-radius:4px; white-space:pre-wrap;
}
.okc-msg p{ margin:0 0 .5em; color:inherit; font-size:inherit; }
.okc-msg p:last-child, .okc-msg ul:last-child, .okc-msg ol:last-child{ margin-bottom:0; }
.okc-msg ul, .okc-msg ol{ margin:0 0 .5em; padding-left:1.3em; }
.okc-msg ul{ list-style:disc; }
.okc-msg ol{ list-style:decimal; }
.okc-msg li{ color:inherit; font-size:inherit; }
.okc-msg a{ color:var(--primary-deep); text-decoration:underline; }

.okc-schnell{ flex:none; display:flex; flex-wrap:wrap; gap:6px; }
.okc-schnell button{
  min-height:34px; padding:6px 11px; border:1px solid var(--line); border-radius:999px;
  background:none; color:var(--primary-deep); font-size:.82rem; cursor:pointer;
}
.okc-schnell button:hover:not(:disabled){ border-color:var(--primary); }
.okc-schnell button:disabled{ opacity:.55; cursor:default; }

/* Laufanzeige: drei Punkte. Ohne Bewegung bleiben sie einfach stehen. */
.okc-lauf{ display:flex; gap:5px; align-items:center; min-height:40px; }
.okc-lauf i{ width:7px; height:7px; border-radius:50%; background:var(--ink-soft); }
@media (prefers-reduced-motion: no-preference){
  .okc-lauf i{ animation:okc-puls 1.1s ease-in-out infinite; }
  .okc-lauf i:nth-child(2){ animation-delay:.15s; }
  .okc-lauf i:nth-child(3){ animation-delay:.3s; }
}
@keyframes okc-puls{ 0%,60%,100%{ opacity:.35; } 30%{ opacity:1; } }

.okc-eingabe{ flex:none; display:flex; gap:8px; padding:10px 12px 0; }
/* 16 px sind Pflicht: darunter zoomt das iPhone beim Antippen in die Seite. */
.okc-eingabe input{
  flex:1; min-width:0; min-height:44px; padding:10px 12px; font-size:16px;
  color:var(--ink); background:var(--bg); border:1px solid var(--line); border-radius:12px;
}
.okc-eingabe input::placeholder{ color:var(--ink-soft); opacity:1; }
.okc-eingabe input:focus{ border-color:var(--primary); outline:none; }
.okc-eingabe input:read-only{ opacity:.7; }
.okc-eingabe button{
  flex:none; min-height:44px; padding:0 14px; border:0; border-radius:12px; cursor:pointer;
  background:var(--accent); color:var(--bg); font-size:1rem; font-weight:700;
}
.okc-eingabe button:disabled{ opacity:.55; cursor:default; }

.okc-hinweis{ flex:none; margin:0; padding:8px 14px 12px; color:var(--ink-soft); font-size:.72rem; line-height:1.35; }
.okc-hinweis a{ color:var(--ink-soft); text-decoration:underline; }

.okc-vh{
  position:absolute; width:1px; height:1px; margin:-1px; padding:0; border:0;
  overflow:hidden; clip-path:inset(50%); white-space:nowrap;
}

/* Handy: Fenster bildschirmfuellend. Hoehe und Lage setzt chat.js, damit die
   Eingabe bei offener Tastatur sichtbar bleibt; 100dvh ist der Stand ohne Skript. */
@media (max-width: 480px){
  #ok-chat{ --okc-unten:12px; right:12px; }
  html.okc-offen, html.okc-offen body{ overflow:hidden; }
  .okc-fenster{
    position:fixed; left:0; right:0; bottom:auto; top:var(--okc-oben, 0);
    width:100%; height:100vh; height:var(--okc-hoehe, 100dvh);
    border:0; border-radius:0;
  }
  .okc-schnell button{ min-height:44px; padding:8px 14px; }
  .okc-hinweis{ padding-bottom:calc(12px + env(safe-area-inset-bottom)); }
}
@media print{ #ok-chat{ display:none; } }
