/* ─────────────────────────────────────────────────────────
 * Pappelbaum Chat Widget — gemeinsame Styles
 * Wird sowohl vom embedded Widget (chat.js)
 * als auch von den Pages im iFrame verwendet.
 * ────────────────────────────────────────────────────── */

/* ===== Variablen ===== */
:root {
  --pb-bg:        #ffffff;
  --pb-bg-soft:   #faf9f6;
  --pb-fg:        #111111;
  --pb-fg-soft:   #555555;
  --pb-border:    #e8e6e0;
  --pb-accent:    #1a1a1a;
  --pb-accent-fg: #ffffff;
  --pb-bubble-me: #111111;
  --pb-bubble-bot:#f2f0ea;
  --pb-shadow:    0 12px 40px rgba(0, 0, 0, 0.18);
  --pb-radius:    16px;
  --pb-radius-sm: 10px;
  --pb-font:      -apple-system, BlinkMacSystemFont, "Segoe UI", "Helvetica Neue", Arial, sans-serif;
  --pb-z:         2147483000;
}

/* ===== Floating Button (im Webflow Parent-Doc) ===== */
.pb-chat-launcher {
  position: fixed;
  z-index: var(--pb-z);
  bottom: 24px;
  right: 24px;
  display: inline-flex;
  align-items: center;
  gap: 10px;
  padding: 14px 22px 14px 18px;
  background: var(--pb-accent);
  color: var(--pb-accent-fg);
  font: 500 15px/1 var(--pb-font);
  border: none;
  border-radius: 999px;
  cursor: pointer;
  box-shadow: var(--pb-shadow);
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.pb-chat-launcher:hover {
  transform: translateY(-2px);
  box-shadow: 0 16px 48px rgba(0, 0, 0, 0.22);
}
.pb-chat-launcher__icon {
  display: inline-flex;
  width: 22px;
  height: 22px;
  align-items: center;
  justify-content: center;
  font-size: 16px;
}

/* ===== Iframe Overlay ===== */
.pb-chat-overlay {
  position: fixed;
  z-index: var(--pb-z);
  inset: 0;
  pointer-events: none; /* Klicks außerhalb gehen durch */
}
.pb-chat-overlay__frame {
  position: absolute;
  bottom: 24px;
  right: 24px;
  width: min(420px, calc(100vw - 48px));
  height: min(640px, calc(100vh - 48px));
  border: none;
  border-radius: var(--pb-radius);
  box-shadow: var(--pb-shadow);
  background: var(--pb-bg);
  pointer-events: auto;
  opacity: 0;
  transform: translateY(20px) scale(0.98);
  transition: opacity 0.22s ease, transform 0.22s ease;
}
.pb-chat-overlay--open .pb-chat-overlay__frame {
  opacity: 1;
  transform: translateY(0) scale(1);
}

/* Mobile: vollflächig */
@media (max-width: 640px) {
  .pb-chat-overlay__frame {
    bottom: 0;
    right: 0;
    width: 100vw;
    height: 100vh;
    border-radius: 0;
  }
}

/* ─────────────────────────────────────────────────────────
 * Styles innerhalb der iFrame-Pages
 * ────────────────────────────────────────────────────── */

html {
  margin: 0;
  padding: 0;
  background: var(--pb-bg);
  min-height: 100%;
}
.pb-page {
  margin: 0 auto;
  padding: 0;
  font-family: var(--pb-font);
  background: var(--pb-bg);
  color: var(--pb-fg);
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  -webkit-font-smoothing: antialiased;
}

/* Standalone-Modus: als zentrierte Card anzeigen
   (greift nur außerhalb des Iframes, der max 420px breit ist) */
@media (min-width: 540px) {
  html {
    background: #edece7;
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    box-sizing: border-box;
  }
  .pb-page {
    width: 100%;
    max-width: 500px;
    height: min(780px, calc(100vh - 32px));
    border-radius: var(--pb-radius);
    box-shadow: var(--pb-shadow);
    overflow: hidden;
  }
}

/* Header */
.pb-header {
  flex-shrink: 0;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 20px;
  border-bottom: 1px solid var(--pb-border);
  background: var(--pb-bg);
}
.pb-header__logo {
  width: 40px;
  height: 40px;
  flex-shrink: 0;
  display: block;
  object-fit: contain;
}
.pb-header__text {
  flex: 1;
  min-width: 0;
}
.pb-header__title {
  font-size: 15px;
  font-weight: 600;
  margin: 0;
  line-height: 1.2;
}
.pb-header__subtitle {
  font-size: 12px;
  color: var(--pb-fg-soft);
  margin: 2px 0 0;
  line-height: 1.3;
}
.pb-header__actions {
  display: flex;
  align-items: center;
  gap: 6px;
}
.pb-header__link {
  width: 36px;
  height: 36px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--pb-fg-soft);
  text-decoration: none;
  transition: background 0.15s ease, color 0.15s ease;
}
.pb-header__link:hover,
.pb-header__link:focus-visible {
  background: var(--pb-bg-soft);
  color: var(--pb-fg);
  outline: none;
}
.pb-header__link svg {
  width: 20px;
  height: 20px;
  fill: currentColor;
  display: block;
}

/* Messages container */
.pb-messages {
  flex: 1 1 0;
  min-height: 0;
  overflow-y: auto;
  padding: 20px 20px 12px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  background: var(--pb-bg-soft);
  scroll-behavior: smooth;
}

/* Message bubbles */
.pb-msg {
  display: flex;
  max-width: 85%;
  animation: pb-fade-in 0.25s ease;
}
.pb-msg__bubble {
  padding: 12px 16px;
  border-radius: var(--pb-radius-sm);
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.pb-msg--bot {
  align-self: flex-start;
}
.pb-msg--bot .pb-msg__bubble {
  background: var(--pb-bubble-bot);
  color: var(--pb-fg);
  border-bottom-left-radius: 4px;
}
.pb-msg--me {
  align-self: flex-end;
}
.pb-msg--me .pb-msg__bubble {
  background: var(--pb-bubble-me);
  color: #ffffff;
  border-bottom-right-radius: 4px;
}

@keyframes pb-fade-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* Typing indicator */
.pb-typing {
  align-self: flex-start;
  display: inline-flex;
  gap: 4px;
  padding: 14px 16px;
  background: var(--pb-bubble-bot);
  border-radius: var(--pb-radius-sm);
  border-bottom-left-radius: 4px;
}
.pb-typing__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--pb-fg-soft);
  animation: pb-typing 1.2s infinite ease-in-out;
}
.pb-typing__dot:nth-child(2) { animation-delay: 0.15s; }
.pb-typing__dot:nth-child(3) { animation-delay: 0.30s; }
@keyframes pb-typing {
  0%, 60%, 100% { opacity: 0.3; transform: translateY(0); }
  30%           { opacity: 1;   transform: translateY(-3px); }
}

/* Quick-reply buttons */
.pb-options {
  flex-shrink: 0;
  max-height: 55vh;
  overflow-y: auto;
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding: 0 20px 12px;
  background: var(--pb-bg-soft);
}
.pb-option {
  background: var(--pb-bg);
  color: var(--pb-fg);
  border: 1px solid var(--pb-border);
  border-radius: 999px;
  padding: 9px 16px;
  font: 500 13px/1 var(--pb-font);
  cursor: pointer;
  transition: all 0.15s ease;
}
.pb-option:hover {
  background: var(--pb-accent);
  color: var(--pb-accent-fg);
  border-color: var(--pb-accent);
}
.pb-option:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
/* Sekundäre Variante — z. B. "Anfrage abschicken" während freiem Chat */
.pb-option--ghost {
  background: transparent;
  color: var(--pb-fg-soft);
  border-style: dashed;
  font-weight: 500;
}
.pb-option--ghost:hover {
  background: var(--pb-accent);
  color: var(--pb-accent-fg);
  border-style: solid;
  border-color: var(--pb-accent);
}

/* Multi-select: Checkbox-Style statt Pills — 2er-Grid */
.pb-options--multi {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(165px, 1fr));
  gap: 8px;
}
.pb-options--multi .pb-multi-done {
  grid-column: 1 / -1;
  justify-self: start;
}
.pb-check {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 14px;
  background: var(--pb-bg);
  border: 1.5px solid var(--pb-border);
  border-radius: var(--pb-radius-sm);
  cursor: pointer;
  transition: border-color 0.15s ease, background 0.15s ease;
  font: 500 14px/1.3 var(--pb-font);
  color: var(--pb-fg);
  text-align: left;
  user-select: none;
}
.pb-check:hover {
  border-color: var(--pb-fg-soft);
  background: var(--pb-bg-soft);
}
.pb-check__box {
  width: 22px;
  height: 22px;
  border: 1.5px solid var(--pb-border);
  border-radius: 6px;
  background: var(--pb-bg);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.pb-check__mark {
  width: 14px;
  height: 14px;
  stroke: var(--pb-accent-fg);
  stroke-width: 3;
  fill: none;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
  transform: scale(0.6);
  transition: opacity 0.15s ease, transform 0.15s ease;
}
.pb-check[data-selected="true"] {
  border-color: var(--pb-accent);
  background: var(--pb-bg-soft);
}
.pb-check[data-selected="true"] .pb-check__box {
  background: var(--pb-accent);
  border-color: var(--pb-accent);
}
.pb-check[data-selected="true"] .pb-check__mark {
  opacity: 1;
  transform: scale(1);
}
.pb-check__label {
  flex: 1;
  min-width: 0;
  word-break: break-word;
}
.pb-multi-done {
  background: var(--pb-accent);
  color: var(--pb-accent-fg);
  border: none;
  border-radius: 999px;
  padding: 11px 22px;
  font: 600 13px/1 var(--pb-font);
  cursor: pointer;
  margin-top: 4px;
  align-self: flex-start;
  transition: opacity 0.15s ease;
}
.pb-multi-done:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

/* Input area */
.pb-input {
  flex-shrink: 0;
  border-top: 1px solid var(--pb-border);
  padding: 12px 16px 14px;
  background: var(--pb-bg);
  display: flex;
  align-items: flex-end;
  gap: 10px;
}
.pb-input__field {
  flex: 1;
  font: 400 14px/1.4 var(--pb-font);
  color: var(--pb-fg);
  background: var(--pb-bg-soft);
  border: 1px solid var(--pb-border);
  border-radius: 12px;
  padding: 11px 14px;
  resize: none;
  max-height: 120px;
  outline: none;
  transition: border-color 0.15s ease;
}
.pb-input__field:focus {
  border-color: var(--pb-fg);
}
.pb-input__send {
  background: var(--pb-accent);
  color: var(--pb-accent-fg);
  border: none;
  border-radius: 10px;
  width: 42px;
  height: 42px;
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: opacity 0.15s ease;
}
.pb-input__send:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Footer with privacy link */
.pb-footer {
  flex-shrink: 0;
  padding: 8px 20px 12px;
  background: var(--pb-bg);
  font-size: 11px;
  color: var(--pb-fg-soft);
  text-align: center;
  border-top: 1px solid var(--pb-border);
}
.pb-footer a {
  color: var(--pb-fg-soft);
  text-decoration: underline;
}

/* Form-Summary (am Ende einer Anfrage) */
.pb-summary {
  background: var(--pb-bg);
  border: 1px solid var(--pb-border);
  border-radius: var(--pb-radius-sm);
  padding: 16px;
  margin: 4px 0;
  font-size: 13px;
  align-self: stretch;
  max-width: 100%;
}
.pb-summary__title {
  font-weight: 600;
  margin: 0 0 10px;
  font-size: 14px;
}
.pb-summary__row {
  display: flex;
  justify-content: space-between;
  gap: 12px;
  padding: 6px 0;
  border-bottom: 1px solid var(--pb-border);
}
.pb-summary__row:last-child { border-bottom: none; }
.pb-summary__key {
  color: var(--pb-fg-soft);
  flex-shrink: 0;
}
.pb-summary__val {
  text-align: right;
  font-weight: 500;
  word-break: break-word;
}

/* Loading state */
.pb-loading {
  padding: 12px;
  text-align: center;
  color: var(--pb-fg-soft);
  font-size: 13px;
}

/* Sending state — großer Loader am Ende der Anfrage */
.pb-sending {
  align-self: stretch;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 28px 20px;
  background: var(--pb-bg);
  border: 1px solid var(--pb-border);
  border-radius: var(--pb-radius-sm);
  margin: 4px 0;
  animation: pb-fade-in 0.25s ease;
}
.pb-sending__spinner {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  border: 3px solid var(--pb-border);
  border-top-color: var(--pb-accent);
  animation: pb-spin 0.85s linear infinite;
}
.pb-sending__title {
  font-size: 14px;
  font-weight: 600;
  color: var(--pb-fg);
  margin-top: 6px;
}
.pb-sending__sub {
  font-size: 12px;
  color: var(--pb-fg-soft);
  text-align: center;
  line-height: 1.4;
}
@keyframes pb-spin {
  to { transform: rotate(360deg); }
}

/* Error state */
.pb-error {
  background: #fdecea;
  color: #8a1c14;
  border: 1px solid #f5c2bd;
  border-radius: var(--pb-radius-sm);
  padding: 12px 14px;
  font-size: 13px;
  margin: 4px 0;
}

/* Scrollbar */
.pb-messages::-webkit-scrollbar { width: 6px; }
.pb-messages::-webkit-scrollbar-thumb {
  background: rgba(0,0,0,0.15);
  border-radius: 3px;
}
