/* ============================================================================
   WP International Trade GmbH - Chatbot Linda
   Eigenstaendiges Widget-Stylesheet, scoped unter .wpit-chat-* Praefix.
   Nutzt Brand-Tokens aus refresh.css (--brand-primary, --brand-amber, --space-*).
   Fallbacks fuer den Fall, dass refresh.css spaeter geladen wird.
   ============================================================================ */

#wpitChatRoot {
  position: fixed;
  inset: 0;
  pointer-events: none;
  z-index: 9000;
  font-family: 'Manrope', system-ui, -apple-system, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

#wpitChatRoot * {
  box-sizing: border-box;
}

/* ============================================================================
   FAB - Floating Action Button rechts unten
   ============================================================================ */
.wpit-chat-fab {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: 64px;
  height: 64px;
  border-radius: 999px;
  border: none;
  padding: 0;
  cursor: pointer;
  background: var(--brand-primary, #13447a);
  color: #ffffff;
  box-shadow:
    0 4px 12px rgba(10, 37, 64, 0.18),
    0 12px 28px rgba(10, 37, 64, 0.18);
  pointer-events: auto;
  display: grid;
  place-items: center;
  overflow: visible;
  transition:
    transform 220ms cubic-bezier(0.22, 1, 0.36, 1),
    box-shadow 220ms cubic-bezier(0.22, 1, 0.36, 1);
}

.wpit-chat-fab:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow:
    0 6px 16px rgba(10, 37, 64, 0.22),
    0 16px 32px rgba(10, 37, 64, 0.22);
}

.wpit-chat-fab:focus-visible {
  outline: 3px solid var(--brand-amber, #d4a017);
  outline-offset: 3px;
}

.wpit-chat-fab__avatar {
  display: grid;
  place-items: center;
  width: 100%;
  height: 100%;
  border-radius: inherit;
  overflow: hidden;
  transition: opacity 180ms ease;
}

.wpit-chat-fab__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: inherit;
  display: block;
}

.wpit-chat-fab__close {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  opacity: 0;
  transform: scale(0.6) rotate(-90deg);
  transition:
    opacity 180ms ease,
    transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
}

.wpit-chat-fab__close svg {
  width: 24px;
  height: 24px;
  color: #ffffff;
}

.wpit-chat-fab.is-open .wpit-chat-fab__avatar {
  opacity: 0;
  transform: scale(0.4);
}

.wpit-chat-fab.is-open .wpit-chat-fab__close {
  opacity: 1;
  transform: scale(1) rotate(0deg);
}

/* Subtiler Pulse-Ring, der nur 1x bei Page-Load aufmerksam macht */
.wpit-chat-fab__pulse {
  position: absolute;
  inset: -4px;
  border-radius: inherit;
  border: 2px solid var(--brand-amber, #d4a017);
  opacity: 0;
  pointer-events: none;
  animation: wpit-chat-pulse 2.6s ease-out 1.4s 2;
}

.wpit-chat-fab.is-open .wpit-chat-fab__pulse {
  display: none;
}

@keyframes wpit-chat-pulse {
  0%   { opacity: 0;   transform: scale(0.96); }
  20%  { opacity: 0.7; transform: scale(1.02); }
  100% { opacity: 0;   transform: scale(1.35); }
}

@media (prefers-reduced-motion: reduce) {
  .wpit-chat-fab,
  .wpit-chat-fab__close,
  .wpit-chat-fab__avatar,
  .wpit-chat-fab__pulse {
    animation: none !important;
    transition: none !important;
  }
}

/* ============================================================================
   Panel
   ============================================================================ */
.wpit-chat-panel {
  position: fixed;
  right: 22px;
  bottom: 100px;
  width: min(400px, calc(100vw - 32px));
  height: min(640px, calc(100vh - 130px));
  background: #ffffff;
  border-radius: 20px;
  box-shadow:
    0 4px 16px rgba(10, 37, 64, 0.10),
    0 24px 60px rgba(10, 37, 64, 0.22);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  pointer-events: auto;
  opacity: 0;
  transform: translateY(16px) scale(0.96);
  transform-origin: bottom right;
  visibility: hidden;
  transition:
    opacity 240ms cubic-bezier(0.22, 1, 0.36, 1),
    transform 280ms cubic-bezier(0.22, 1, 0.36, 1),
    visibility 0s linear 280ms;
}

.wpit-chat-panel.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  visibility: visible;
  transition:
    opacity 240ms cubic-bezier(0.22, 1, 0.36, 1),
    transform 280ms cubic-bezier(0.22, 1, 0.36, 1),
    visibility 0s linear;
}

@media (max-width: 520px) {
  .wpit-chat-panel {
    right: 12px;
    left: 12px;
    bottom: 92px;
    width: auto;
    height: min(82vh, calc(100vh - 110px));
    border-radius: 18px;
  }
}

/* ============================================================================
   Header
   ============================================================================ */
.wpit-chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--brand-primary, #13447a) 0%, var(--brand-primary-dark, #0e2f56) 100%);
  color: #ffffff;
  flex: none;
}

.wpit-chat-header__avatar {
  width: 40px;
  height: 40px;
  border-radius: 999px;
  overflow: hidden;
  flex: none;
  background: rgba(255, 255, 255, 0.12);
  display: grid;
  place-items: center;
}

.wpit-chat-header__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.wpit-chat-header__text {
  flex: 1;
  min-width: 0;
}

.wpit-chat-header__title {
  font-size: 16px;
  font-weight: 700;
  line-height: 1.2;
  letter-spacing: -0.01em;
}

.wpit-chat-header__sub {
  font-size: 12px;
  font-weight: 400;
  line-height: 1.2;
  opacity: 0.82;
  margin-top: 2px;
}

.wpit-chat-header__actions {
  display: flex;
  gap: 4px;
  flex: none;
}

.wpit-chat-iconbtn {
  width: 32px;
  height: 32px;
  border-radius: 8px;
  border: none;
  padding: 0;
  background: transparent;
  color: rgba(255, 255, 255, 0.85);
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: background 160ms ease, color 160ms ease;
}

.wpit-chat-iconbtn:hover {
  background: rgba(255, 255, 255, 0.14);
  color: #ffffff;
}

.wpit-chat-iconbtn:focus-visible {
  outline: 2px solid var(--brand-amber, #d4a017);
  outline-offset: 2px;
}

.wpit-chat-iconbtn svg {
  width: 16px;
  height: 16px;
}

.wpit-chat-iconbtn--close svg {
  width: 18px;
  height: 18px;
}

/* ============================================================================
   Body / Messages
   ============================================================================ */
.wpit-chat-body {
  flex: 1;
  min-height: 0;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  background: #f7f9fb;
}

.wpit-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 18px 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  scroll-behavior: smooth;
  scrollbar-width: thin;
  scrollbar-color: rgba(10, 37, 64, 0.18) transparent;
}

.wpit-chat-messages::-webkit-scrollbar {
  width: 6px;
}

.wpit-chat-messages::-webkit-scrollbar-thumb {
  background: rgba(10, 37, 64, 0.18);
  border-radius: 3px;
}

.wpit-chat-welcome {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 24px 16px 12px;
  gap: 14px;
  color: #1f2937;
}

.wpit-chat-welcome__avatar {
  width: 56px;
  height: 56px;
  border-radius: 999px;
  overflow: hidden;
  background: var(--brand-primary-soft, rgba(19, 68, 122, 0.12));
}

.wpit-chat-welcome__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.wpit-chat-welcome p {
  margin: 0;
  font-size: 14px;
  line-height: 1.55;
  color: #1f2937;
  max-width: 320px;
}

.wpit-chat-msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  max-width: 100%;
  animation: wpit-chat-bubble-in 220ms cubic-bezier(0.22, 1, 0.36, 1);
}

.wpit-chat-msg.is-user {
  justify-content: flex-end;
}

.wpit-chat-msg__avatar {
  width: 28px;
  height: 28px;
  border-radius: 999px;
  overflow: hidden;
  flex: none;
  background: var(--brand-primary-soft, rgba(19, 68, 122, 0.12));
}

.wpit-chat-msg__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.wpit-chat-bubble {
  max-width: calc(100% - 44px);
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.55;
  color: #1f2937;
  background: #ffffff;
  box-shadow: 0 1px 2px rgba(10, 37, 64, 0.06);
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.wpit-chat-msg.is-ai .wpit-chat-bubble {
  border-bottom-left-radius: 4px;
}

.wpit-chat-msg.is-user .wpit-chat-bubble {
  background: var(--brand-primary, #13447a);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

.wpit-chat-bubble p {
  margin: 0 0 6px;
}

.wpit-chat-bubble p:last-child {
  margin-bottom: 0;
}

.wpit-chat-bubble a {
  color: var(--brand-amber-dark, #b08410);
  font-weight: 600;
  text-decoration: underline;
  text-decoration-thickness: 1px;
  text-underline-offset: 2px;
}

.wpit-chat-msg.is-user .wpit-chat-bubble a {
  color: var(--brand-amber, #d4a017);
}

.wpit-chat-bubble strong {
  font-weight: 700;
  color: var(--brand-primary, #13447a);
}

.wpit-chat-msg.is-user .wpit-chat-bubble strong {
  color: #ffffff;
}

.wpit-chat-bubble ul {
  margin: 6px 0;
  padding-left: 18px;
}

.wpit-chat-bubble li {
  margin-bottom: 3px;
}

.wpit-chat-bubble code {
  font-family: ui-monospace, 'SFMono-Regular', Menlo, Consolas, monospace;
  font-size: 12.5px;
  background: rgba(10, 37, 64, 0.08);
  padding: 1px 6px;
  border-radius: 4px;
}

.wpit-chat-msg.is-user .wpit-chat-bubble code {
  background: rgba(255, 255, 255, 0.18);
  color: #ffffff;
}

@keyframes wpit-chat-bubble-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Typing indicator */
.wpit-chat-typing {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
}

.wpit-chat-typing span {
  width: 6px;
  height: 6px;
  border-radius: 999px;
  background: var(--brand-primary, #13447a);
  opacity: 0.4;
  animation: wpit-chat-blink 1.2s infinite ease-in-out;
}

.wpit-chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.wpit-chat-typing span:nth-child(3) { animation-delay: 0.4s; }

@keyframes wpit-chat-blink {
  0%, 80%, 100% { opacity: 0.4; transform: scale(1); }
  40%           { opacity: 1;   transform: scale(1.2); }
}

.wpit-chat-hint {
  text-align: center;
  font-size: 12px;
  color: #6b7280;
  font-style: italic;
}

.wpit-chat-error {
  background: #fff5f5;
  color: #b91c1c;
  border: 1px solid #fecaca;
  border-radius: 10px;
  padding: 10px 14px;
  font-size: 13px;
  line-height: 1.5;
}

.wpit-chat-error.is-rate {
  background: #fffbeb;
  color: #92400e;
  border-color: #fde68a;
}

/* ============================================================================
   Input Area
   ============================================================================ */
.wpit-chat-input-area {
  flex: none;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 14px 14px;
  background: #ffffff;
  border-top: 1px solid #e5e7eb;
}

.wpit-chat-input {
  flex: 1;
  min-height: 40px;
  max-height: 120px;
  padding: 10px 14px;
  border-radius: 12px;
  border: 1px solid #d1d5db;
  background: #f9fafb;
  font: inherit;
  font-size: 14px;
  line-height: 1.45;
  color: #1f2937;
  resize: none;
  outline: none;
  transition: border-color 160ms ease, background 160ms ease;
  font-family: inherit;
}

.wpit-chat-input:focus {
  border-color: var(--brand-primary, #13447a);
  background: #ffffff;
}

.wpit-chat-send {
  width: 40px;
  height: 40px;
  border-radius: 12px;
  border: none;
  background: var(--brand-primary, #13447a);
  color: #ffffff;
  cursor: pointer;
  display: grid;
  place-items: center;
  flex: none;
  transition: background 160ms ease, transform 160ms ease, opacity 160ms ease;
}

.wpit-chat-send:hover:not(:disabled) {
  background: var(--brand-primary-dark, #0e2f56);
  transform: translateY(-1px);
}

.wpit-chat-send:focus-visible {
  outline: 2px solid var(--brand-amber, #d4a017);
  outline-offset: 2px;
}

.wpit-chat-send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.wpit-chat-send svg {
  width: 16px;
  height: 16px;
}

/* ============================================================================
   Consent / Buttons
   ============================================================================ */
.wpit-chat-consent {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 28px 22px;
  gap: 14px;
  color: #1f2937;
}

.wpit-chat-consent__icon {
  width: 56px;
  height: 56px;
  border-radius: 999px;
  background: var(--brand-primary-soft, rgba(19, 68, 122, 0.12));
  display: grid;
  place-items: center;
  color: var(--brand-primary, #13447a);
}

.wpit-chat-consent__icon svg {
  width: 28px;
  height: 28px;
}

.wpit-chat-consent h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--brand-primary, #13447a);
}

.wpit-chat-consent p {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.6;
  color: #374151;
}

.wpit-chat-consent p a {
  color: var(--brand-amber-dark, #b08410);
  text-decoration: underline;
}

.wpit-chat-consent__btns {
  display: flex;
  gap: 10px;
  margin-top: 8px;
  flex-wrap: wrap;
  justify-content: center;
}

.wpit-chat-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 999px;
  border: 1px solid transparent;
  padding: 10px 20px;
  font-size: 13.5px;
  font-weight: 600;
  font-family: inherit;
  cursor: pointer;
  transition: background 160ms ease, transform 160ms ease, color 160ms ease;
  line-height: 1.2;
}

.wpit-chat-btn--primary {
  background: var(--brand-amber, #d4a017);
  color: #1a1a1a;
}

.wpit-chat-btn--primary:hover {
  background: var(--brand-amber-dark, #b08410);
  color: #ffffff;
  transform: translateY(-1px);
}

.wpit-chat-btn--ghost {
  background: transparent;
  color: var(--brand-primary, #13447a);
  border-color: rgba(19, 68, 122, 0.25);
}

.wpit-chat-btn--ghost:hover {
  background: rgba(19, 68, 122, 0.07);
}

.wpit-chat-btn:focus-visible {
  outline: 2px solid var(--brand-amber, #d4a017);
  outline-offset: 2px;
}

.wpit-chat-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ============================================================================
   Kontakt-Pane
   ============================================================================ */
.wpit-chat-contact {
  flex: 1;
  overflow-y: auto;
  padding: 18px 18px 22px;
  background: #f7f9fb;
}

.wpit-chat-contact__title {
  margin: 0 0 4px;
  font-size: 16px;
  font-weight: 700;
  color: var(--brand-primary, #13447a);
}

.wpit-chat-contact__intro {
  margin: 0 0 14px;
  font-size: 13px;
  line-height: 1.55;
  color: #4b5563;
}

.wpit-chat-contact__form {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.wpit-chat-honeypot {
  position: absolute !important;
  left: -9999px !important;
  opacity: 0 !important;
  pointer-events: none !important;
}

.wpit-chat-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.wpit-chat-field > span {
  font-size: 12.5px;
  font-weight: 600;
  color: #374151;
}

.wpit-chat-field input,
.wpit-chat-field textarea {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid #d1d5db;
  border-radius: 10px;
  background: #ffffff;
  font: inherit;
  font-size: 14px;
  font-family: inherit;
  color: #1f2937;
  outline: none;
  transition: border-color 160ms ease;
}

.wpit-chat-field textarea {
  min-height: 90px;
  resize: vertical;
  line-height: 1.5;
}

.wpit-chat-field input:focus,
.wpit-chat-field textarea:focus {
  border-color: var(--brand-primary, #13447a);
}

.wpit-chat-checkrow {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  font-size: 12.5px;
  line-height: 1.5;
  color: #4b5563;
}

.wpit-chat-checkrow input {
  margin-top: 2px;
  accent-color: var(--brand-primary, #13447a);
  flex: none;
}

.wpit-chat-checkrow a {
  color: var(--brand-amber-dark, #b08410);
  text-decoration: underline;
}

.wpit-chat-contact__error {
  background: #fff5f5;
  color: #b91c1c;
  border: 1px solid #fecaca;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: 13px;
  line-height: 1.4;
}

.wpit-chat-contact__actions {
  margin-top: 4px;
  display: flex;
  justify-content: flex-end;
}

.wpit-chat-success {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  padding: 28px 22px;
  gap: 14px;
  color: #1f2937;
}

.wpit-chat-success__icon {
  width: 56px;
  height: 56px;
  border-radius: 999px;
  background: rgba(212, 160, 23, 0.18);
  display: grid;
  place-items: center;
  color: var(--brand-amber-dark, #b08410);
}

.wpit-chat-success__icon svg {
  width: 28px;
  height: 28px;
}

.wpit-chat-success h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 700;
  color: var(--brand-primary, #13447a);
}

.wpit-chat-success p {
  margin: 0;
  font-size: 13.5px;
  line-height: 1.6;
  color: #374151;
  max-width: 320px;
}

/* ============================================================================
   Hero-CTA "Frag Linda" (auf der Startseite ueber externe Klasse einbindbar)
   ============================================================================ */
.wpit-ask-linda {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 10px 18px 10px 12px;
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.92);
  border: 1px solid rgba(19, 68, 122, 0.18);
  color: var(--brand-primary, #13447a);
  font-family: 'Manrope', system-ui, -apple-system, sans-serif;
  font-size: 14px;
  font-weight: 600;
  text-decoration: none;
  cursor: pointer;
  box-shadow: 0 4px 14px rgba(10, 37, 64, 0.10);
  transition: transform 220ms cubic-bezier(0.22, 1, 0.36, 1), box-shadow 220ms ease;
}

.wpit-ask-linda:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 18px rgba(10, 37, 64, 0.15);
  color: var(--brand-primary-dark, #0e2f56);
}

.wpit-ask-linda:focus-visible {
  outline: 2px solid var(--brand-amber, #d4a017);
  outline-offset: 2px;
}

.wpit-ask-linda__avatar {
  width: 32px;
  height: 32px;
  border-radius: 999px;
  overflow: hidden;
  flex: none;
  background: var(--brand-primary-soft, rgba(19, 68, 122, 0.12));
  display: grid;
  place-items: center;
}

.wpit-ask-linda__avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.wpit-ask-linda__pulse {
  width: 8px;
  height: 8px;
  border-radius: 999px;
  background: var(--brand-amber, #d4a017);
  flex: none;
  box-shadow: 0 0 0 0 rgba(212, 160, 23, 0.6);
  animation: wpit-ask-pulse 2.4s infinite ease-out;
}

@keyframes wpit-ask-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(212, 160, 23, 0.6); }
  70%  { box-shadow: 0 0 0 8px rgba(212, 160, 23, 0); }
  100% { box-shadow: 0 0 0 0 rgba(212, 160, 23, 0); }
}

@media (prefers-reduced-motion: reduce) {
  .wpit-ask-linda__pulse {
    animation: none !important;
  }
}
