/* ==========================================================================
   Chat-Assistent (js/chat.js) – konradsigl.ch
   Nutzt die Variablen aus style.css (Farben, Schrift, Radien).
   ========================================================================== */

.kc { font-family: var(--font-sans); }
.kc-sr { position: absolute; width: 1px; height: 1px; padding: 0; margin: -1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; border: 0; }
.kc .hp { position: absolute; left: -10000px; width: 1px; height: 1px; overflow: hidden; }

/* Knopf unten rechts */
.kc-launcher {
  position: fixed; z-index: 90;
  right: max(16px, env(safe-area-inset-right)); bottom: max(16px, env(safe-area-inset-bottom));
  display: inline-flex; align-items: center; gap: 0.5em;
  padding: 12px 18px 12px 14px; border-radius: 999px; border: 1px solid var(--ink);
  background: var(--ink); color: #fff;
  font: inherit; font-size: 13.5px; font-weight: 600; letter-spacing: 0.06em; text-transform: uppercase; line-height: 1.2;
  cursor: pointer; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
  transition: background 0.18s, border-color 0.18s, transform 0.18s;
}
.kc-launcher:hover { background: var(--accent); border-color: var(--accent); }
.kc-launcher:active { transform: translateY(1px); }
.kc-launcher:focus-visible { outline: 2px solid var(--accent); outline-offset: 3px; }
.kc-open .kc-launcher, body.nav-open .kc-launcher { display: none; }

/* Fenster */
.kc-panel {
  position: fixed; z-index: 200; right: 16px; bottom: 16px;
  width: min(400px, calc(100vw - 32px)); height: min(640px, calc(100dvh - 32px));
  display: flex; flex-direction: column; overflow: hidden;
  background: #fff; color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius-lg);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.22);
}
.kc-panel[hidden] { display: none; }

.kc-head { display: flex; align-items: center; gap: 4px; padding: 14px 10px 14px 18px; background: var(--ink); color: #fff; }
.kc-head-text { flex: 1; min-width: 0; }
.kc-title { font-size: 16px; font-weight: 600; letter-spacing: -0.01em; line-height: 1.25; }
.kc-sub { font-size: 12.5px; color: var(--on-dark); margin-top: 2px; }
.kc-icon { width: 36px; height: 36px; flex: none; display: grid; place-items: center; border: 0; border-radius: 999px; background: transparent; color: #fff; cursor: pointer; }
.kc-icon:hover { background: rgba(255, 255, 255, 0.12); }
.kc-icon:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

/* Verlauf */
.kc-log { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 16px; display: flex; flex-direction: column; gap: 12px; background: var(--paper); }
.kc-msg { display: flex; flex-direction: column; gap: 6px; max-width: 88%; }
.kc-user { align-self: flex-end; align-items: flex-end; }
.kc-bot { align-self: flex-start; align-items: flex-start; }
.kc-bubble { padding: 10px 14px; border-radius: 16px; font-size: 15px; line-height: 1.5; white-space: pre-wrap; overflow-wrap: anywhere; }
.kc-user .kc-bubble { background: var(--ink); color: #fff; border-bottom-right-radius: 6px; }
.kc-bot .kc-bubble { background: #fff; border: 1px solid var(--line); border-bottom-left-radius: 6px; }

.kc-links { display: flex; flex-wrap: wrap; align-items: center; gap: 6px; font-size: 13px; }
.kc-links-label { color: var(--muted); }
.kc-link { padding: 4px 10px; border: 1px solid var(--line-2); border-radius: 999px; background: #fff; text-decoration: none; line-height: 1.4; }
.kc-link:hover { border-color: var(--accent); color: var(--accent); }
.kc-link:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }

.kc-handoff { font: inherit; font-size: 13px; font-weight: 600; padding: 8px 14px; border-radius: 999px; border: 1px solid var(--ink); background: #fff; color: var(--ink); cursor: pointer; }
.kc-handoff:hover { background: var(--ink); color: #fff; }
.kc-handoff:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

.kc-typing .kc-bubble { display: inline-flex; align-items: center; gap: 5px; padding: 14px 16px; }
.kc-dot { width: 6px; height: 6px; border-radius: 50%; background: var(--muted); animation: kc-blink 1.2s infinite ease-in-out; }
.kc-dot:nth-child(3) { animation-delay: 0.15s; }
.kc-dot:nth-child(4) { animation-delay: 0.3s; }
@keyframes kc-blink { 0%, 80%, 100% { opacity: 0.25; } 40% { opacity: 1; } }

/* Hinweis, Eingabe (keine vorgegebenen Fragen, Wunsch Konrad Sigl 23.10.2026) */
.kc-left { font-size: 12px; color: var(--muted); padding: 8px 16px 0; background: #fff; }
.kc-left:empty { display: none; }

.kc-form { display: flex; align-items: flex-end; gap: 8px; padding: 12px; border-top: 1px solid var(--line); background: #fff; }
/* Eingabe: zwei Zeilen hoch, wächst beim Schreiben (js/chat.js, bis 176 px), Zähler unten rechts */
.kc-input-wrap { position: relative; flex: 1; min-width: 0; display: flex; }
.kc-form textarea {
  flex: 1; min-width: 0; resize: none; overflow-y: hidden; scrollbar-width: thin;
  min-height: calc(2 * 1.45em + 28px); max-height: 176px;
  font: inherit; font-size: 15px; line-height: 1.45; padding: 11px 12px 15px;
  border: 1px solid var(--line-2); border-radius: 12px; background: var(--paper); color: var(--ink);
}
.kc-count { position: absolute; right: 8px; bottom: 3px; padding: 1px 4px; border-radius: 6px; background: var(--paper); font-size: 11px; line-height: 1; color: var(--muted); pointer-events: none; }
.kc-input-wrap:focus-within .kc-count { background: #fff; }
.kc-count:empty { display: none; }
.kc-count-max { color: #b3261e; font-weight: 600; }
.kc-form textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); background: #fff; }
.kc-send { width: 42px; height: 42px; flex: none; display: grid; place-items: center; border: 0; border-radius: 999px; background: var(--ink); color: #fff; cursor: pointer; transition: background 0.18s; }
.kc-send:hover { background: var(--accent); }
.kc-send:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }
.kc-send:disabled { opacity: 0.45; cursor: wait; }

.kc-note { font-size: 11.5px; line-height: 1.45; color: var(--muted); padding: 0 14px 12px; background: #fff; }
.kc-note a { color: inherit; text-underline-offset: 2px; }

/* Weiterleitung an Konrad Sigl */
.kc-hand { align-self: stretch; display: grid; gap: 10px; padding: 14px; background: #fff; border: 1px solid var(--line); border-radius: 14px; }
.kc-hand label { display: block; font-size: 12.5px; font-weight: 600; margin-bottom: 4px; }
.kc-hand input, .kc-hand textarea {
  width: 100%; font: inherit; font-size: 14px; padding: 9px 11px;
  border: 1px solid var(--line-2); border-radius: 10px; background: var(--paper); color: var(--ink);
}
.kc-hand textarea { min-height: 130px; resize: vertical; line-height: 1.45; }
.kc-hand input:focus, .kc-hand textarea:focus { outline: 2px solid var(--accent); outline-offset: 0; border-color: var(--accent); background: #fff; }
.kc-hand-note { font-size: 12px; line-height: 1.45; color: var(--muted); }
.kc-hand-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.kc-hand-status { font-size: 13px; min-height: 1.2em; }
.kc-hand-status:empty { display: none; }
.kc-hand-status.err { color: #b3261e; }

/* Handy: Fenster über die ganze Fläche */
@media (max-width: 560px) {
  .kc-panel { right: 0; bottom: 0; width: 100%; height: 100%; height: 100dvh; border: 0; border-radius: 0; }
  .kc-head { padding-top: max(14px, env(safe-area-inset-top)); }
  .kc-note { padding-bottom: max(12px, env(safe-area-inset-bottom)); }
  .kc-form textarea { font-size: 16px; } /* verhindert Zoom auf iOS */
}

@media (prefers-reduced-motion: reduce) {
  .kc-dot { animation: none; opacity: 0.6; }
  .kc-launcher, .kc-send { transition: none; }
}

@media print { .kc { display: none !important; } }
