/* ================================================================
   NETZWERK24 – Chatbot Widget
   ================================================================ */

/* ── Toggle-Button ────────────────────────────────────────────── */
.cb-toggle {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9000;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1d4ed8, #2563eb);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 8px 28px rgba(37, 99, 235, .50);
  transition: transform .2s ease, box-shadow .2s ease;
  outline: none;
}
.cb-toggle:hover {
  transform: scale(1.08);
  box-shadow: 0 10px 36px rgba(37, 99, 235, .65);
}
.cb-toggle svg { transition: opacity .18s ease, transform .18s ease; }
.cb-toggle .cb-icon-open  { opacity: 1;  transform: scale(1) rotate(0deg); }
.cb-toggle .cb-icon-close { opacity: 0;  transform: scale(.6) rotate(-90deg); position: absolute; }
.cb-toggle.is-open .cb-icon-open  { opacity: 0;  transform: scale(.6) rotate(90deg); }
.cb-toggle.is-open .cb-icon-close { opacity: 1;  transform: scale(1) rotate(0deg); }

/* Unread-Badge */
.cb-badge {
  position: absolute;
  top: -2px;
  right: -2px;
  width: 14px;
  height: 14px;
  background: #f97316;
  border-radius: 50%;
  border: 2px solid #07101e;
  display: none;
}
.cb-badge.visible { display: block; }

/* ── Chat-Fenster ─────────────────────────────────────────────── */
.cb-window {
  position: fixed;
  bottom: 92px;
  right: 24px;
  z-index: 8999;
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 540px;
  max-height: calc(100vh - 120px);
  background: #0b1629;
  border: 1px solid rgba(37, 99, 235, .2);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 24px 64px rgba(0, 0, 0, .6), 0 0 0 1px rgba(255,255,255,.04);

  /* Startzustand: ausgeblendet, leicht nach unten verschoben */
  opacity: 0;
  transform: translateY(16px) scale(.97);
  pointer-events: none;
  transition: opacity .22s cubic-bezier(.16,1,.3,1),
              transform .22s cubic-bezier(.16,1,.3,1);
}
.cb-window.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ── Header ───────────────────────────────────────────────────── */
.cb-header {
  display: flex;
  align-items: center;
  gap: .75rem;
  padding: .875rem 1.125rem;
  background: #071018;
  border-bottom: 1px solid rgba(37, 99, 235, .15);
  flex-shrink: 0;
}

.cb-header-avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, #1d4ed8, #2563eb);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
}
.cb-header-avatar::after {
  content: '';
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 9px;
  height: 9px;
  background: #22c55e;
  border-radius: 50%;
  border: 2px solid #071018;
}

.cb-header-info { flex: 1; min-width: 0; }
.cb-header-name {
  font-size: .82rem;
  font-weight: 700;
  color: #eef2f7;
  letter-spacing: -.01em;
}
.cb-header-status {
  font-size: .7rem;
  color: #22c55e;
  font-weight: 500;
  margin-top: 1px;
}

.cb-header-close {
  background: none;
  border: none;
  cursor: pointer;
  color: #5a7090;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  transition: color .15s ease, background .15s ease;
}
.cb-header-close:hover { color: #eef2f7; background: rgba(255,255,255,.06); }

/* ── Nachrichten-Bereich ──────────────────────────────────────── */
.cb-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem .875rem;
  display: flex;
  flex-direction: column;
  gap: .625rem;
  scroll-behavior: smooth;
}
.cb-messages::-webkit-scrollbar { width: 4px; }
.cb-messages::-webkit-scrollbar-track { background: transparent; }
.cb-messages::-webkit-scrollbar-thumb { background: rgba(148,163,184,.15); border-radius: 2px; }

/* Einzelne Nachricht */
.cb-msg {
  display: flex;
  flex-direction: column;
  max-width: 82%;
  animation: cbMsgIn .2s ease;
}
@keyframes cbMsgIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.cb-msg--bot  { align-self: flex-start; align-items: flex-start; }
.cb-msg--user { align-self: flex-end;   align-items: flex-end; }

.cb-msg-bubble {
  padding: .55rem .875rem;
  border-radius: 14px;
  font-size: .845rem;
  line-height: 1.6;
  word-break: break-word;
}
.cb-msg--bot  .cb-msg-bubble {
  background: #0e1d35;
  border: 1px solid rgba(37, 99, 235, .14);
  color: #eef2f7;
  border-bottom-left-radius: 4px;
}
.cb-msg--user .cb-msg-bubble {
  background: #1d4ed8;
  color: #fff;
  border-bottom-right-radius: 4px;
}

.cb-msg-time {
  font-size: .65rem;
  color: #3d5068;
  margin-top: 3px;
  padding: 0 3px;
}

/* Typing-Indikator */
.cb-typing {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: .55rem .875rem;
  background: #0e1d35;
  border: 1px solid rgba(37, 99, 235, .14);
  border-radius: 14px;
  border-bottom-left-radius: 4px;
  width: fit-content;
  align-self: flex-start;
}
.cb-typing span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #3b82f6;
  animation: cbDot 1.4s ease-in-out infinite;
}
.cb-typing span:nth-child(2) { animation-delay: .18s; }
.cb-typing span:nth-child(3) { animation-delay: .36s; }
@keyframes cbDot {
  0%, 80%, 100% { transform: scale(.75); opacity: .4; }
  40%            { transform: scale(1);  opacity: 1;  }
}

/* Lead-Erfolgs-Banner */
.cb-lead-banner {
  margin: .5rem .875rem;
  padding: .625rem .875rem;
  background: rgba(34, 197, 94, .08);
  border: 1px solid rgba(34, 197, 94, .22);
  border-radius: 8px;
  font-size: .775rem;
  color: #86efac;
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-shrink: 0;
}

/* Retry-Hinweis (temporär, wird entfernt bei Erfolg/Abbruch) */
.cb-retry-notice {
  margin: .5rem .875rem;
  padding: .55rem .875rem;
  background: rgba(245, 158, 11, .08);
  border: 1px solid rgba(245, 158, 11, .22);
  border-radius: 8px;
  font-size: .775rem;
  color: #fcd34d;
  display: flex;
  align-items: center;
  gap: .5rem;
  flex-shrink: 0;
}

/* ── Eingabe-Bereich ──────────────────────────────────────────── */
.cb-input-area {
  padding: .75rem .875rem .875rem;
  border-top: 1px solid rgba(37, 99, 235, .12);
  display: flex;
  gap: .5rem;
  align-items: flex-end;
  flex-shrink: 0;
  background: #071018;
}

.cb-input {
  flex: 1;
  min-width: 0;
  background: #0e1d35;
  border: 1.5px solid rgba(148, 163, 184, .1);
  border-radius: 10px;
  color: #eef2f7;
  font-family: inherit;
  font-size: .845rem;
  padding: .6rem .875rem;
  resize: none;
  outline: none;
  line-height: 1.5;
  max-height: 100px;
  overflow-y: auto;
  transition: border-color .15s ease;
}
.cb-input::placeholder { color: #3d5068; }
.cb-input:focus { border-color: rgba(37, 99, 235, .45); }

.cb-send {
  width: 38px;
  height: 38px;
  border-radius: 10px;
  background: #2563eb;
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: #fff;
  transition: background .15s ease, transform .15s ease;
}
.cb-send:hover:not(:disabled) { background: #3b82f6; transform: scale(1.05); }
.cb-send:disabled { background: #1e3a5f; cursor: default; opacity: .5; }

/* ── Proaktive Sprechblase ────────────────────────────────────── */
.cb-proactive {
  position: fixed;
  bottom: 90px;
  right: 16px;
  z-index: 9001;
  max-width: 220px;
  background: #0e1d35;
  border: 1px solid rgba(37, 99, 235, .3);
  border-radius: 12px 12px 4px 12px;
  padding: .65rem .875rem .65rem .875rem;
  box-shadow: 0 8px 28px rgba(0,0,0,.5);
  display: flex;
  align-items: center;
  gap: .5rem;
  cursor: pointer;

  opacity: 0;
  transform: translateY(10px) scale(.95);
  pointer-events: none;
  transition: opacity .25s ease, transform .25s ease;
}
.cb-proactive.is-visible {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}
.cb-proactive-text {
  font-size: .82rem;
  color: #eef2f7;
  line-height: 1.4;
  flex: 1;
}
.cb-proactive-close {
  background: none;
  border: none;
  cursor: pointer;
  color: #5a7090;
  padding: 2px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  flex-shrink: 0;
  transition: color .15s;
}
.cb-proactive-close:hover { color: #eef2f7; }

/* ── Mobile ───────────────────────────────────────────────────── */
@media (max-width: 420px) {
  .cb-window {
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: 100%;
    height: 100%;
    max-height: 100%;
    border-radius: 0;
    border: none;
  }
  .cb-toggle { bottom: 16px; right: 16px; }
}
