/* ============================================================
   routinefrei: KI-Chat-Widget ("Quiet Premium")
   Nutzt die Tokens aus styles.css (--paper, --ink, --accent ...).
   ============================================================ */

.rf-chat,
.rf-chat * { box-sizing: border-box; }

/* ---- Launcher (schwebender Button) ---- */
.rf-launch {
  position: fixed;
  right: clamp(16px, 4vw, 28px);
  bottom: clamp(16px, 4vw, 28px);
  z-index: 9998;
  display: inline-flex;
  align-items: center;
  gap: 0.55rem;
  padding: 0.7rem 1.05rem 0.7rem 0.85rem;
  font-family: var(--body);
  font-size: 0.95rem;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: #fff;
  background: var(--ink);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: var(--shadow);
  transition: transform 0.18s ease, background 0.18s ease, opacity 0.18s ease;
}
.rf-launch:hover { transform: translateY(-2px); background: #1c3052; }
.rf-launch svg { width: 22px; height: 22px; flex: none; }
.rf-launch .rf-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: var(--accent); flex: none;
  box-shadow: 0 0 0 0 rgba(228, 87, 46, 0.5);
  animation: rf-pulse 2.4s ease-out infinite;
}
@keyframes rf-pulse {
  0% { box-shadow: 0 0 0 0 rgba(228, 87, 46, 0.45); }
  70% { box-shadow: 0 0 0 9px rgba(228, 87, 46, 0); }
  100% { box-shadow: 0 0 0 0 rgba(228, 87, 46, 0); }
}
.rf-chat.is-open .rf-launch { opacity: 0; pointer-events: none; }

/* ---- Panel ---- */
.rf-panel {
  position: fixed;
  right: clamp(16px, 4vw, 28px);
  bottom: clamp(16px, 4vw, 28px);
  z-index: 9999;
  width: min(400px, calc(100vw - 32px));
  height: min(620px, calc(100dvh - 32px));
  display: flex;
  flex-direction: column;
  background: var(--paper);
  border: 1px solid var(--line-2);
  border-radius: var(--radius);
  box-shadow: 0 2px 6px rgba(20, 35, 58, 0.08), 0 40px 80px -32px rgba(20, 35, 58, 0.40);
  overflow: hidden;
  opacity: 0;
  transform: translateY(14px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.rf-chat.is-open .rf-panel {
  opacity: 1;
  transform: none;
  pointer-events: auto;
}

/* ---- Kopf ---- */
.rf-head {
  display: flex;
  align-items: center;
  gap: 0.7rem;
  padding: 0.95rem 1.05rem;
  background: var(--ink);
  color: #fff;
}
.rf-head .rf-ava {
  width: 38px; height: 38px; border-radius: 50%; flex: none;
  display: grid; place-items: center;
  background: linear-gradient(140deg, var(--accent), var(--accent-2));
  font-family: var(--display); font-weight: 600; font-size: 1.05rem;
}
.rf-head .rf-meta { display: flex; flex-direction: column; line-height: 1.25; }
.rf-head .rf-title { font-family: var(--display); font-weight: 600; font-size: 1.02rem; }
.rf-head .rf-sub { font-size: 0.76rem; color: rgba(255, 255, 255, 0.7); display: flex; align-items: center; gap: 0.35rem; }
.rf-head .rf-sub::before {
  content: ""; width: 7px; height: 7px; border-radius: 50%;
  background: #4ade80;
}
.rf-head .rf-close {
  margin-left: auto;
  background: rgba(255, 255, 255, 0.1);
  border: none; color: #fff; cursor: pointer;
  width: 32px; height: 32px; border-radius: 9px;
  display: grid; place-items: center;
  transition: background 0.15s ease;
}
.rf-head .rf-close:hover { background: rgba(255, 255, 255, 0.22); }
.rf-head .rf-close svg { width: 18px; height: 18px; }

/* ---- Nachrichtenbereich ---- */
.rf-body {
  flex: 1;
  overflow-y: auto;
  padding: 1.1rem 1.05rem 0.6rem;
  display: flex;
  flex-direction: column;
  gap: 0.7rem;
  scroll-behavior: smooth;
}
.rf-msg {
  max-width: 86%;
  padding: 0.62rem 0.85rem;
  border-radius: 14px;
  font-size: 0.93rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.rf-msg.bot {
  align-self: flex-start;
  background: var(--card);
  border: 1px solid var(--line);
  border-bottom-left-radius: 5px;
  color: var(--ink);
}
.rf-msg.user {
  align-self: flex-end;
  background: var(--ink);
  color: #fff;
  border-bottom-right-radius: 5px;
}
.rf-msg a { color: var(--accent-2); }
.rf-msg.bot a { text-underline-offset: 2px; }

/* Tipp-Indikator */
.rf-typing { align-self: flex-start; display: inline-flex; gap: 4px; padding: 0.7rem 0.9rem; background: var(--card); border: 1px solid var(--line); border-radius: 14px; border-bottom-left-radius: 5px; }
.rf-typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--ink-3); animation: rf-bounce 1.2s infinite ease-in-out; }
.rf-typing span:nth-child(2) { animation-delay: 0.18s; }
.rf-typing span:nth-child(3) { animation-delay: 0.36s; }
@keyframes rf-bounce { 0%, 60%, 100% { transform: translateY(0); opacity: 0.5; } 30% { transform: translateY(-5px); opacity: 1; } }

/* Schnellfragen-Chips */
.rf-chips { display: flex; flex-wrap: wrap; gap: 0.4rem; padding: 0.2rem 0.1rem 0.4rem; }
.rf-chip {
  font-family: var(--body); font-size: 0.82rem; color: var(--ink-2);
  background: var(--card); border: 1px solid var(--line-2);
  border-radius: 999px; padding: 0.4rem 0.75rem; cursor: pointer;
  transition: border-color 0.15s ease, color 0.15s ease, background 0.15s ease;
}
.rf-chip:hover { border-color: var(--accent); color: var(--accent-2); }

/* ---- Eingabe ---- */
.rf-foot { border-top: 1px solid var(--line); padding: 0.7rem 0.8rem; background: var(--paper); }
.rf-inrow { display: flex; align-items: flex-end; gap: 0.5rem; }
.rf-inrow textarea {
  flex: 1; resize: none; max-height: 110px;
  font-family: var(--body); font-size: 0.93rem; line-height: 1.45; color: var(--ink);
  background: var(--card); border: 1px solid var(--line-2); border-radius: 12px;
  padding: 0.6rem 0.7rem; outline: none;
  transition: border-color 0.15s ease;
}
.rf-inrow textarea:focus { border-color: var(--accent); }
.rf-send {
  flex: none; width: 42px; height: 42px; border-radius: 11px;
  border: none; cursor: pointer; background: var(--accent); color: #fff;
  display: grid; place-items: center; transition: background 0.15s ease, transform 0.15s ease;
}
.rf-send:hover:not(:disabled) { background: var(--accent-2); transform: translateY(-1px); }
.rf-send:disabled { opacity: 0.45; cursor: default; }
.rf-send svg { width: 19px; height: 19px; }
.rf-legal { margin-top: 0.45rem; font-size: 0.68rem; color: var(--ink-3); text-align: center; }
.rf-legal a { color: var(--ink-3); }

/* Lead-Button im Footer */
.rf-leadbtn {
  display: inline-flex; align-items: center; gap: 0.4rem;
  margin-bottom: 0.55rem; width: 100%; justify-content: center;
  font-family: var(--body); font-size: 0.83rem; font-weight: 600; color: var(--ink-2);
  background: transparent; border: 1px dashed var(--line-2); border-radius: 10px;
  padding: 0.45rem; cursor: pointer; transition: border-color 0.15s ease, color 0.15s ease;
}
.rf-leadbtn:hover { border-color: var(--accent); color: var(--accent-2); }
.rf-leadbtn svg { width: 15px; height: 15px; }

/* ---- Lead-Formular (Overlay im Panel) ---- */
.rf-lead {
  position: absolute; inset: 0; z-index: 2;
  background: var(--paper);
  display: flex; flex-direction: column;
  padding: 1.1rem 1.15rem;
  transform: translateY(100%);
  transition: transform 0.25s ease;
  overflow-y: auto;
}
.rf-chat.lead-open .rf-lead { transform: none; }
.rf-lead h3 { font-family: var(--display); font-size: 1.25rem; color: var(--ink); margin-bottom: 0.3rem; }
.rf-lead p.rf-lead-intro { font-size: 0.9rem; color: var(--ink-2); margin-bottom: 1rem; }
.rf-lead label { display: block; font-size: 0.82rem; font-weight: 600; color: var(--ink-2); margin: 0.6rem 0 0.25rem; }
.rf-lead input, .rf-lead textarea {
  width: 100%; font-family: var(--body); font-size: 0.92rem; color: var(--ink);
  background: var(--card); border: 1px solid var(--line-2); border-radius: 11px;
  padding: 0.6rem 0.7rem; outline: none; transition: border-color 0.15s ease;
}
.rf-lead input:focus, .rf-lead textarea:focus { border-color: var(--accent); }
.rf-lead textarea { resize: vertical; min-height: 72px; }
.rf-lead .rf-lead-actions { display: flex; gap: 0.5rem; margin-top: 1rem; }
.rf-lead .rf-lead-actions button { flex: 1; font-family: var(--body); font-size: 0.9rem; font-weight: 600; border-radius: 11px; padding: 0.65rem; cursor: pointer; border: 1px solid var(--line-2); }
.rf-lead .rf-cancel { background: transparent; color: var(--ink-2); }
.rf-lead .rf-submit { background: var(--accent); color: #fff; border-color: var(--accent); }
.rf-lead .rf-submit:disabled { opacity: 0.5; cursor: default; }
.rf-lead .rf-lead-note { font-size: 0.7rem; color: var(--ink-3); margin-top: 0.7rem; }
.rf-lead .rf-lead-msg { font-size: 0.86rem; margin-top: 0.6rem; min-height: 1.1rem; }
.rf-lead .rf-lead-msg.ok { color: var(--sea); }
.rf-lead .rf-lead-msg.err { color: var(--accent-2); }
.rf-lead-done { text-align: center; margin: auto 0; }
.rf-lead-done svg { width: 46px; height: 46px; color: var(--sea); }
.rf-lead-done h3 { margin-top: 0.6rem; }

@media (max-width: 480px) {
  .rf-panel {
    right: 0; bottom: 0;
    width: 100vw; height: 100dvh;
    border-radius: 0; border: none;
  }
  .rf-launch span.rf-launch-label { display: none; }
  .rf-launch { padding: 0.8rem; }
}

@media (prefers-reduced-motion: reduce) {
  .rf-launch, .rf-panel, .rf-lead, .rf-send, .rf-chip, .rf-leadbtn { transition: none; }
  .rf-launch .rf-dot, .rf-typing span { animation: none; }
}
