/* Protexium Chatbot Widget
   Nutzt vorhandene CSS-Variablen aus style.css (--blue, --bg-800, etc.)
   Scoped ueber .px-chat-* um Konflikte zu vermeiden. */

.px-chat-launcher {
  position: fixed;
  right: 1.25rem;
  bottom: 1.25rem;
  z-index: 9990;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: linear-gradient(135deg, #386ffb 0%, #2558d4 100%);
  color: #fff;
  box-shadow:
    0 10px 30px rgba(56, 111, 251, 0.45),
    0 0 0 0 rgba(56, 111, 251, 0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 200ms ease, box-shadow 200ms ease;
  animation: px-chat-pulse 2.4s ease-in-out infinite;
}

.px-chat-launcher:hover { transform: scale(1.06); }
.px-chat-launcher:focus-visible { outline: 3px solid #fff; outline-offset: 3px; }
.px-chat-launcher svg { width: 28px; height: 28px; stroke: #fff; }

@keyframes px-chat-pulse {
  0%, 100% { box-shadow: 0 10px 30px rgba(56,111,251,.45), 0 0 0 0 rgba(56,111,251,.5); }
  50%      { box-shadow: 0 10px 30px rgba(56,111,251,.45), 0 0 0 14px rgba(56,111,251,0); }
}

.px-chat-launcher.is-open { animation: none; }
.px-chat-launcher .px-chat-icon-close { display: none; }
.px-chat-launcher.is-open .px-chat-icon-open { display: none; }
.px-chat-launcher.is-open .px-chat-icon-close { display: block; }

.px-chat-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  border-radius: 999px;
  min-width: 18px;
  height: 18px;
  padding: 0 5px;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid var(--bg-900, #0b1120);
}

/* Panel ------------------------------------------------------------ */
.px-chat-panel {
  position: fixed;
  right: 1.25rem;
  bottom: 5.5rem;
  z-index: 9991;
  width: min(380px, calc(100vw - 2rem));
  height: min(600px, calc(100vh - 7rem));
  background: var(--bg-800, #111827);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 20px;
  box-shadow:
    0 30px 60px rgba(0, 0, 0, 0.6),
    0 0 0 1px rgba(56, 111, 251, 0.1);
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: #e2e8f0;
  transform: translateY(20px) scale(0.96);
  opacity: 0;
  transition: transform 220ms ease, opacity 220ms ease;
}

.px-chat-panel.is-open {
  display: flex;
  transform: translateY(0) scale(1);
  opacity: 1;
}

/* Header */
.px-chat-header {
  padding: 1rem 1.25rem;
  background: linear-gradient(135deg, #1e293b 0%, #0b1120 100%);
  border-bottom: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.px-chat-avatar {
  width: 40px;
  height: 40px;
  border-radius: 50%;
  background: linear-gradient(135deg, #386ffb 0%, #2558d4 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  box-shadow: 0 4px 12px rgba(56,111,251,0.4);
}
.px-chat-avatar svg { width: 22px; height: 22px; stroke: #fff; }

.px-chat-header-text { flex: 1; min-width: 0; }
.px-chat-header-title {
  font-size: 0.95rem;
  font-weight: 700;
  color: #fff;
  margin: 0;
  line-height: 1.2;
}
.px-chat-header-status {
  font-size: 0.75rem;
  color: #94a3b8;
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 2px;
}
.px-chat-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 0 rgba(34,197,94,0.6);
  animation: px-chat-dot-pulse 2s infinite;
}
@keyframes px-chat-dot-pulse {
  0%,100% { box-shadow: 0 0 0 0 rgba(34,197,94,0.6); }
  50%     { box-shadow: 0 0 0 6px rgba(34,197,94,0); }
}

.px-chat-header-close {
  background: transparent;
  border: none;
  color: #94a3b8;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  transition: background 150ms ease, color 150ms ease;
}
.px-chat-header-close:hover { background: rgba(255,255,255,0.06); color: #fff; }
.px-chat-header-close svg { width: 18px; height: 18px; }

/* Messages area */
.px-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 1.25rem 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  scroll-behavior: smooth;
  background:
    radial-gradient(circle at 50% 0%, rgba(56,111,251,0.06), transparent 60%),
    var(--bg-800, #111827);
}

.px-chat-messages::-webkit-scrollbar { width: 6px; }
.px-chat-messages::-webkit-scrollbar-track { background: transparent; }
.px-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(255,255,255,0.08);
  border-radius: 3px;
}
.px-chat-messages::-webkit-scrollbar-thumb:hover { background: rgba(255,255,255,0.15); }

/* Messages */
.px-chat-msg {
  max-width: 85%;
  padding: 0.75rem 1rem;
  border-radius: 16px;
  font-size: 0.9rem;
  line-height: 1.5;
  word-wrap: break-word;
  animation: px-chat-msg-in 260ms ease both;
}
@keyframes px-chat-msg-in {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

.px-chat-msg.user {
  align-self: flex-end;
  background: linear-gradient(135deg, #386ffb 0%, #2558d4 100%);
  color: #fff;
  border-bottom-right-radius: 4px;
  box-shadow: 0 4px 12px rgba(56,111,251,0.25);
}

.px-chat-msg.bot {
  align-self: flex-start;
  background: var(--bg-700, #1e293b);
  color: #e2e8f0;
  border-bottom-left-radius: 4px;
  border: 1px solid rgba(255,255,255,0.06);
}

.px-chat-msg.bot a {
  color: #60a5fa;
  text-decoration: underline;
  text-decoration-color: rgba(96,165,250,0.4);
  text-underline-offset: 2px;
}
.px-chat-msg.bot a:hover { color: #93c5fd; text-decoration-color: #93c5fd; }

.px-chat-msg.bot strong { color: #fff; }
.px-chat-msg.bot ul { margin: 0.4rem 0 0.2rem; padding-left: 1.2rem; }
.px-chat-msg.bot li { margin: 0.2rem 0; }
.px-chat-msg.bot p { margin: 0.3rem 0; }
.px-chat-msg.bot p:first-child { margin-top: 0; }
.px-chat-msg.bot p:last-child { margin-bottom: 0; }

.px-chat-msg.error {
  align-self: flex-start;
  background: rgba(239,68,68,0.1);
  border: 1px solid rgba(239,68,68,0.3);
  color: #fca5a5;
  font-size: 0.85rem;
}

/* Typing indicator */
.px-chat-typing {
  align-self: flex-start;
  display: flex;
  gap: 4px;
  padding: 0.85rem 1rem;
  background: var(--bg-700, #1e293b);
  border-radius: 16px;
  border-bottom-left-radius: 4px;
  border: 1px solid rgba(255,255,255,0.06);
}
.px-chat-typing span {
  width: 7px;
  height: 7px;
  background: #64748b;
  border-radius: 50%;
  animation: px-chat-typing 1.3s infinite ease-in-out;
}
.px-chat-typing span:nth-child(2) { animation-delay: 0.15s; }
.px-chat-typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes px-chat-typing {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%           { transform: translateY(-5px); opacity: 1; }
}

/* Quick actions */
.px-chat-chips {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
  padding: 0.5rem 1rem 0.75rem;
  border-top: 1px solid rgba(255,255,255,0.06);
  background: var(--bg-800, #111827);
}
.px-chat-chip {
  background: rgba(56,111,251,0.1);
  border: 1px solid rgba(56,111,251,0.3);
  color: #93c5fd;
  padding: 0.4rem 0.75rem;
  border-radius: 999px;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: background 150ms ease, transform 150ms ease, border-color 150ms ease;
  white-space: nowrap;
  font-family: inherit;
}
.px-chat-chip:hover {
  background: rgba(56,111,251,0.2);
  border-color: rgba(56,111,251,0.5);
  transform: translateY(-1px);
}
.px-chat-chip:active { transform: translateY(0); }

/* Region-Gate (Flaggen-Kacheln) */
.px-chat-intro {
  align-self: stretch;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.6rem;
  margin: 0.25rem 0 0.4rem;
  animation: px-chat-msg-in 260ms ease both;
}

.px-chat-intro-card {
  background: var(--bg-700, #1e293b);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  padding: 0.9rem 0.7rem;
  cursor: pointer;
  transition: transform 150ms ease, border-color 150ms ease, background 150ms ease, box-shadow 150ms ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  font-family: inherit;
  color: inherit;
  text-align: center;
}

.px-chat-intro-card:hover {
  transform: translateY(-2px);
  border-color: rgba(56,111,251,0.5);
  background: var(--bg-600, #334155);
  box-shadow: 0 10px 24px rgba(56,111,251,0.18);
}

.px-chat-intro-card:focus-visible {
  outline: 2px solid var(--blue, #386ffb);
  outline-offset: 2px;
}

.px-chat-flag {
  width: 48px;
  height: 32px;
  border-radius: 6px;
  overflow: hidden;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  flex-shrink: 0;
  display: block;
}
.px-chat-flag svg { display: block; width: 100%; height: 100%; }

.px-chat-intro-card-label {
  font-size: 0.85rem;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
}

.px-chat-intro-card-sub {
  font-size: 0.72rem;
  color: #94a3b8;
  line-height: 1.3;
}

.px-chat-region-badge {
  align-self: flex-start;
  display: inline-flex;
  align-items: center;
  gap: 0.4rem;
  background: rgba(56,111,251,0.12);
  border: 1px solid rgba(56,111,251,0.3);
  color: #93c5fd;
  padding: 0.25rem 0.6rem;
  border-radius: 999px;
  font-size: 0.72rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 150ms ease;
}
.px-chat-region-badge:hover { background: rgba(56,111,251,0.2); }
.px-chat-region-badge .px-chat-flag { width: 18px; height: 12px; border-radius: 2px; }
.px-chat-region-badge-swap {
  font-size: 0.68rem;
  color: #64748b;
  margin-left: 0.2rem;
}

/* Contact-Card (rich widget) */
.px-chat-card {
  align-self: flex-start;
  background: var(--bg-700, #1e293b);
  border: 1px solid rgba(56,111,251,0.3);
  border-radius: 16px;
  padding: 0.85rem 1rem;
  max-width: 85%;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  animation: px-chat-msg-in 260ms ease both;
}
.px-chat-card-title {
  font-size: 0.8rem;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  font-weight: 600;
}
.px-chat-card-actions { display: flex; flex-direction: column; gap: 0.4rem; }
.px-chat-card-btn {
  background: linear-gradient(135deg, #386ffb 0%, #2558d4 100%);
  color: #fff;
  border: none;
  padding: 0.6rem 0.9rem;
  border-radius: 10px;
  font-size: 0.85rem;
  font-weight: 600;
  text-align: center;
  text-decoration: none;
  cursor: pointer;
  transition: transform 150ms ease, box-shadow 150ms ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  font-family: inherit;
}
.px-chat-card-btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 18px rgba(56,111,251,0.35);
  color: #fff;
}
.px-chat-card-btn.ghost {
  background: transparent;
  border: 1px solid rgba(255,255,255,0.12);
  color: #e2e8f0;
}
.px-chat-card-btn.ghost:hover { background: rgba(255,255,255,0.05); }
.px-chat-card-btn svg { width: 14px; height: 14px; }

/* Input area */
.px-chat-input-wrap {
  padding: 0.75rem 1rem 1rem;
  background: var(--bg-800, #111827);
  border-top: 1px solid rgba(255,255,255,0.08);
}
.px-chat-input-row {
  display: flex;
  align-items: flex-end;
  gap: 0.5rem;
  background: var(--bg-700, #1e293b);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  padding: 0.4rem 0.4rem 0.4rem 0.85rem;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.px-chat-input-row:focus-within {
  border-color: rgba(56,111,251,0.5);
  box-shadow: 0 0 0 3px rgba(56,111,251,0.15);
}
.px-chat-input {
  flex: 1;
  background: transparent;
  border: none;
  color: #f1f5f9;
  font-size: 0.9rem;
  font-family: inherit;
  resize: none;
  outline: none;
  max-height: 100px;
  min-height: 24px;
  padding: 0.45rem 0;
  line-height: 1.4;
}
.px-chat-input::placeholder { color: #64748b; }

.px-chat-send {
  background: linear-gradient(135deg, #386ffb 0%, #2558d4 100%);
  border: none;
  color: #fff;
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: transform 150ms ease, opacity 150ms ease;
  flex-shrink: 0;
}
.px-chat-send:hover { transform: scale(1.05); }
.px-chat-send:disabled { opacity: 0.4; cursor: not-allowed; transform: none; }
.px-chat-send svg { width: 16px; height: 16px; }

.px-chat-footer {
  font-size: 0.7rem;
  color: #64748b;
  text-align: center;
  margin-top: 0.5rem;
}
.px-chat-footer a { color: #94a3b8; text-decoration: underline; }

/* Mobile --------------------------------------------------------- */
@media (max-width: 480px) {
  .px-chat-panel {
    right: 0.5rem;
    left: 0.5rem;
    bottom: 4.5rem;
    width: auto;
    height: calc(100vh - 6rem);
    border-radius: 16px;
  }
  .px-chat-launcher {
    right: 0.9rem;
    bottom: 0.9rem;
    width: 54px;
    height: 54px;
  }
}

/* Reduced motion */
@media (prefers-reduced-motion: reduce) {
  .px-chat-launcher,
  .px-chat-dot,
  .px-chat-msg,
  .px-chat-panel,
  .px-chat-typing span { animation: none !important; transition: none !important; }
}
