/* =====================================================
   Foundry Bot – Chat-Widget CSS
   Funktioniert theme-unabhängig auf jeder WordPress-Seite.
   ===================================================== */

.fbot-chat-widget {
  --fbot-accent:      #2563eb;
  --fbot-accent-dark: color-mix(in srgb, var(--fbot-accent) 80%, black);
  --fbot-accent-glow: color-mix(in srgb, var(--fbot-accent) 15%, transparent);
  --fbot-height:      520px;
  --fbot-radius:      16px;
  --fbot-shadow:      0 8px 32px rgba(0,0,0,.1), 0 2px 8px rgba(0,0,0,.06);

  display: flex;
  flex-direction: column;
  height: var(--fbot-height);
  border-radius: var(--fbot-radius);
  overflow: hidden;
  box-shadow: var(--fbot-shadow);
  font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  line-height: 1.5;
  background: #fff;
  border: 1px solid #e2e8f0;
  max-width: 680px;
  margin-inline: auto;
}

/* ── Header ── */
.fbot-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--fbot-accent);
  color: #fff;
  flex-shrink: 0;
  gap: 1rem;
}
.fbot-chat-header-info {
  display: flex;
  align-items: center;
  gap: 11px;
}
.fbot-chat-avatar {
  width: 42px; height: 42px;
  border-radius: 50%;
  background: transparent;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  overflow: hidden;
  box-shadow: 0 0 0 2px rgba(255,255,255,.35);
}
.fbot-chat-avatar img {
  width: 42px;
  height: 42px;
  object-fit: cover;
  object-position: center top;
  border-radius: 50%;
  display: block;
}
.fbot-chat-name {
  font-weight: 700;
  font-size: 15px;
  color: #fff;
}
.fbot-chat-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: rgba(255,255,255,.8);
  margin-top: 1px;
}
.fbot-status-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: #4ade80;
  box-shadow: 0 0 5px rgba(74,222,128,.8);
  animation: fbot-pulse 2s ease infinite;
}
@keyframes fbot-pulse { 0%,100%{opacity:1} 50%{opacity:.5} }

.fbot-chat-reset {
  background: rgba(255,255,255,.15);
  border: none;
  color: #fff;
  width: 32px; height: 32px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .18s;
  flex-shrink: 0;
}
.fbot-chat-reset:hover { background: rgba(255,255,255,.28); }
.fbot-chat-reset svg { width: 15px; height: 15px; }

/* ── Nachrichten-Bereich ── */
.fbot-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 16px 8px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: #f8fafc;
  scroll-behavior: smooth;
}
.fbot-chat-messages::-webkit-scrollbar { width: 5px; }
.fbot-chat-messages::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

/* ── Nachrichten ── */
.fbot-msg {
  display: flex;
  gap: 8px;
  max-width: 82%;
  animation: fbot-msg-in .2s ease;
}
@keyframes fbot-msg-in {
  from { opacity:0; transform: translateY(6px); }
  to   { opacity:1; transform: translateY(0); }
}

.fbot-msg--bot { align-self: flex-start; }
.fbot-msg--user { align-self: flex-end; flex-direction: row-reverse; }

.fbot-msg-bubble {
  padding: 9px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.6;
  white-space: pre-wrap;
  word-break: break-word;
}
.fbot-msg--bot .fbot-msg-bubble {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-bottom-left-radius: 4px;
  color: #1e293b;
  box-shadow: 0 1px 3px rgba(0,0,0,.04);
}
.fbot-msg--user .fbot-msg-bubble {
  background: var(--fbot-accent);
  color: #fff;
  border-bottom-right-radius: 4px;
}

/* Ticket-Bestätigung */
.fbot-msg--ticket .fbot-msg-bubble {
  background: #f0fdf4;
  border-color: #86efac;
  color: #166534;
  font-weight: 500;
}

/* Tipp-Indikator */
.fbot-msg--typing .fbot-msg-bubble {
  padding: 11px 16px;
}
.fbot-typing-dots {
  display: flex;
  gap: 4px;
  align-items: center;
  height: 16px;
}
.fbot-typing-dots span {
  width: 6px; height: 6px;
  border-radius: 50%;
  background: #94a3b8;
  animation: fbot-dot .9s ease infinite;
}
.fbot-typing-dots span:nth-child(2) { animation-delay: .15s; }
.fbot-typing-dots span:nth-child(3) { animation-delay: .30s; }
@keyframes fbot-dot { 0%,80%,100%{transform:scale(.7)} 40%{transform:scale(1)} }

/* ── Eingabe-Bereich ── */
.fbot-chat-input-area {
  display: flex;
  align-items: flex-end;
  gap: 6px;
  padding: 10px 12px;
  background: #fff;
  border-top: 1px solid #e2e8f0;
  flex-shrink: 0;
}

.fbot-chat-input {
  flex: 1;
  border: 1.5px solid #e2e8f0;
  border-radius: 10px;
  padding: 8px 12px;
  font-family: inherit;
  font-size: 14px;
  color: #1e293b;
  background: #f8fafc;
  resize: none;
  outline: none;
  max-height: 100px;
  overflow-y: auto;
  transition: border-color .18s, box-shadow .18s;
  line-height: 1.5;
}
.fbot-chat-input:focus {
  border-color: var(--fbot-accent);
  box-shadow: 0 0 0 3px var(--fbot-accent-glow);
  background: #fff;
}
.fbot-chat-input::placeholder { color: #94a3b8; }

.fbot-chat-send {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--fbot-accent);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .18s, transform .15s, box-shadow .18s;
  box-shadow: 0 2px 8px rgba(37,99,235,.25);
}
.fbot-chat-send:hover { background: var(--fbot-accent-dark); transform: scale(1.08); box-shadow: 0 4px 14px rgba(37,99,235,.4); }
.fbot-chat-send:disabled { opacity: .5; cursor: default; transform: none; box-shadow: none; }
.fbot-chat-send svg { width: 16px; height: 16px; }

/* ── Fehlermeldung ── */
.fbot-msg--error .fbot-msg-bubble {
  background: #fef2f2;
  border-color: #fca5a5;
  color: #991b1b;
  font-size: 13px;
}

/* ── Responsive ── */
@media (max-width: 480px) {
  .fbot-chat-widget { border-radius: 10px; }
  .fbot-msg { max-width: 92%; }
}

/* ═══════════════════════════════════════════════
   VOICE BOT – Mikrofon-Button & Audio-UI  (v4.0)
   ═══════════════════════════════════════════════ */

.fbot-voice-btn {
  width: 38px; height: 38px;
  border-radius: 50%;
  border: none;
  background: transparent;
  color: var(--fbot-accent, #2563eb);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  border: 1.5px solid var(--fbot-accent, #2563eb);
  box-shadow: 0 1px 4px rgba(37,99,235,.15);
  transition: transform .2s, box-shadow .2s, background .2s, color .2s;
  animation: fbot-voice-invite 3s ease-in-out infinite;
}
.fbot-voice-btn:hover {
  background: var(--fbot-accent, #2563eb);
  color: #fff;
  transform: scale(1.1);
  box-shadow: 0 4px 16px rgba(37,99,235,.4);
  animation: none;
}
.fbot-voice-btn svg { width: 17px; height: 17px; pointer-events: none; }

/* Dezente Einlade-Animation im Ruhezustand */
@keyframes fbot-voice-invite {
  0%, 100% { transform: scale(1);    box-shadow: 0 1px 4px rgba(37,99,235,.15); }
  40%       { transform: scale(1.07); box-shadow: 0 3px 12px rgba(37,99,235,.3); }
  60%       { transform: scale(1.04); box-shadow: 0 2px 8px rgba(37,99,235,.22); }
}

/* Aktiv – pulsierend rot */
.fbot-voice-btn.fbot-voice-active {
  background: #dc2626;
  box-shadow: 0 0 0 0 rgba(220,38,38,.5);
  animation: fbot-voice-pulse 1.5s ease-out infinite;
}
@keyframes fbot-voice-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(220,38,38,.5); }
  70%  { box-shadow: 0 0 0 12px rgba(220,38,38,0); }
  100% { box-shadow: 0 0 0 0 rgba(220,38,38,0); }
}

/* Verbindung wird aufgebaut */
.fbot-voice-btn.fbot-voice-connecting {
  background: #f59e0b;
  animation: fbot-spin-btn 1s linear infinite;
}
@keyframes fbot-spin-btn {
  to { transform: rotate(360deg); }
}

/* Voice-Overlay im Chat-Fenster */
.fbot-voice-overlay {
  position: absolute;
  inset: 0;
  background: rgba(255,255,255,.97);
  backdrop-filter: blur(4px);
  z-index: 20;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1.25rem;
  border-radius: inherit;
  animation: fbot-fade-in .25s ease;
}
@keyframes fbot-fade-in { from{opacity:0;transform:scale(.96)} to{opacity:1;transform:scale(1)} }

.fbot-voice-orb {
  width: 88px;
  height: 88px;
  border-radius: 50%;
  background: radial-gradient(circle at 38% 36%, #60a5fa, var(--fbot-accent, #2563eb));
  box-shadow: 0 0 0 12px rgba(37,99,235,.1), 0 0 0 24px rgba(37,99,235,.05);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .15s;
}
.fbot-voice-orb svg { width: 36px; height: 36px; color: #fff; }

/* Sprechen-Animation */
.fbot-voice-orb.fbot-orb-speaking {
  animation: fbot-orb-talk .6s ease-in-out infinite alternate;
}
@keyframes fbot-orb-talk {
  from { transform: scale(1);   box-shadow: 0 0 0 12px rgba(37,99,235,.1),  0 0 0 24px rgba(37,99,235,.05); }
  to   { transform: scale(1.1); box-shadow: 0 0 0 18px rgba(37,99,235,.15), 0 0 0 36px rgba(37,99,235,.06); }
}

/* Hören-Animation */
.fbot-voice-orb.fbot-orb-listening {
  background: radial-gradient(circle at 38% 36%, #4ade80, #16a34a);
  animation: fbot-orb-listen .8s ease-in-out infinite alternate;
}
@keyframes fbot-orb-listen {
  from { transform: scale(.97); box-shadow: 0 0 0 8px rgba(22,163,74,.12), 0 0 0 18px rgba(22,163,74,.06); }
  to   { transform: scale(1.05); box-shadow: 0 0 0 16px rgba(22,163,74,.18), 0 0 0 30px rgba(22,163,74,.07); }
}

.fbot-voice-status {
  font-size: .9rem;
  font-weight: 600;
  color: #334155;
  letter-spacing: .01em;
}
.fbot-voice-transcript {
  font-size: .82rem;
  color: #64748b;
  max-width: 240px;
  text-align: center;
  min-height: 2.4em;
  line-height: 1.5;
  font-style: italic;
}

/* Wellenform-Visualizer */
.fbot-waveform {
  display: flex;
  align-items: center;
  gap: 3px;
  height: 28px;
}
.fbot-waveform span {
  display: block;
  width: 4px;
  border-radius: 2px;
  background: var(--fbot-accent, #2563eb);
  height: 8px;
  transition: height .1s;
}
.fbot-waveform.fbot-waveform-active span:nth-child(1) { animation: fbot-bar .7s .0s ease-in-out infinite alternate; }
.fbot-waveform.fbot-waveform-active span:nth-child(2) { animation: fbot-bar .7s .1s ease-in-out infinite alternate; }
.fbot-waveform.fbot-waveform-active span:nth-child(3) { animation: fbot-bar .7s .2s ease-in-out infinite alternate; }
.fbot-waveform.fbot-waveform-active span:nth-child(4) { animation: fbot-bar .7s .3s ease-in-out infinite alternate; }
.fbot-waveform.fbot-waveform-active span:nth-child(5) { animation: fbot-bar .7s .15s ease-in-out infinite alternate; }
@keyframes fbot-bar { from{height:6px} to{height:22px} }

.fbot-voice-close {
  position: absolute;
  top: 12px;
  right: 14px;
  background: #f1f5f9;
  border: none;
  color: #64748b;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  cursor: pointer;
  font-size: 1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
}
.fbot-voice-close:hover { background: #e2e8f0; color: #1e293b; }



/* Floating Voice Button (außerhalb Chat) */
.fbot-voice-float-wrap {
  position: fixed;
  bottom: 1.75rem;
  right: 1.75rem;
  z-index: 9998;
}
.fbot-voice-float-btn {
  width: 58px !important;
  height: 58px !important;
  border-radius: 50% !important;
  background: var(--fbot-accent, #2563eb) !important;
  color: #fff !important;
  border: none !important;
  box-shadow: 0 6px 24px rgba(37,99,235,.4) !important;
  animation: fbot-voice-invite 3s ease-in-out infinite !important;
}
.fbot-voice-float-btn:hover {
  animation: none !important;
  transform: scale(1.1) !important;
}
.fbot-voice-float-btn svg { width: 24px !important; height: 24px !important; }

/* Floating Overlay (body-level) */
.fbot-voice-overlay--float {
  position: fixed !important;
  bottom: 5.5rem;
  right: 1.75rem;
  width: min(360px, calc(100vw - 2rem));
  height: auto;
  min-height: 240px;
  border-radius: 20px !important;
  box-shadow: 0 12px 44px rgba(0,0,0,.18) !important;
  inset: auto !important;
}

/* Voice Debug Panel */
.fbot-voice-debug-btn {
  position: absolute;
  top: 12px;
  left: 14px;
  background: #f1f5f9;
  border: none;
  border-radius: 50%;
  width: 28px;
  height: 28px;
  cursor: pointer;
  font-size: .9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
  z-index: 2;
}
.fbot-voice-debug-btn:hover { background: #e2e8f0; }

.fbot-voice-debug-panel {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  max-height: 55%;
  overflow-y: auto;
  background: rgba(15,23,42,.92);
  color: #e2e8f0;
  font-size: .72rem;
  font-family: monospace;
  padding: .75rem;
  border-radius: 0 0 inherit inherit;
  backdrop-filter: blur(4px);
  line-height: 1.5;
}

/* Float Widget – Header-Buttons nebeneinander */
#fbot-float-overlay .fbot-chat-header {
  position: relative;
}
#fbot-float-overlay .fbot-chat-header .fbot-chat-header-actions {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-left: auto;
}
/* Schließen-Button im Float-Header */
#fbot-float-close {
  background: rgba(255,255,255,.2);
  border: none;
  color: #fff;
  border-radius: 50%;
  width: 30px;
  height: 30px;
  cursor: pointer;
  font-size: 1rem;
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
#fbot-float-close:hover { background: rgba(255,255,255,.35); }

/* Voice-Button im Float-Header – überschreibt position:absolute */
#fbot-float-overlay .fbot-chat-header .fbot-voice-btn {
  position: static !important;
  bottom: auto !important;
  right: auto !important;
  width: 30px !important;
  height: 30px !important;
  flex-shrink: 0;
}

/* ── Online-Statusleuchte am Float-Button ── */
.fbot-float-btn { position: relative; }
.fbot-online-dot {
  position: absolute;
  top: -3px;
  right: -3px;
  width: 13px;
  height: 13px;
  border-radius: 50%;
  background: #22c55e;
  border: 2.5px solid #fff;
  box-shadow: 0 0 0 0 rgba(34,197,94,.6);
  animation: fbot-online-pulse 2.5s ease-in-out infinite;
}
@keyframes fbot-online-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(34,197,94,.7); }
  60%  { box-shadow: 0 0 0 7px rgba(34,197,94,0); }
  100% { box-shadow: 0 0 0 0 rgba(34,197,94,0); }
}
