/**
 * Product Finder - Chat-Widget (Dummy).
 *
 * Bewusst neutral gehalten. Alle Farben, Radien und Abstände stehen als
 * Variablen unter :root - das Corporate Design von lenord.de wird durch
 * Überschreiben dieser Werte gesetzt, nicht durch Ändern der Regeln.
 *
 * Jede Klasse trägt das Präfix pf-, damit nichts mit dem CMS kollidiert.
 */

:root {
  --pf-accent: #aa1210;
  --pf-accent-soft: rgba(170, 18, 16, 0.12);
  --pf-ink: #131a24;
  --pf-ink-soft: #5b6573;
  --pf-ink-faint: #8a93a2;
  --pf-line: #e4e7ec;
  --pf-surface: #ffffff;
  --pf-surface-soft: #f2f4f7;
  --pf-error: #b42318;
  --pf-radius: 12px;
  --pf-font: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
  --pf-font-mono: ui-monospace, "SFMono-Regular", Menlo, Consolas, monospace;
}

/* Nur für die Demoseite. Im echten Einbau entfällt dieser Block. */
body {
  margin: 0;
  background: #fafbfc;
  font-family: var(--pf-font);
  color: var(--pf-ink);
}

/* Muss vor allem anderen stehen: ein eigenes display: hätte sonst Vorrang
   vor dem hidden-Attribut, und Verstecktes bliebe sichtbar. */
.pf-widget [hidden] {
  display: none !important;
}

.pf-page {
  max-width: 860px;
  margin: 0 auto;
  padding: 24px 16px;
  box-sizing: border-box;
  height: 100vh;
  height: 100dvh;
  display: flex;
}

.pf-widget {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 0;
  min-height: 0;
  gap: 16px;
}

/* Kopf */

.pf-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 16px;
}

.pf-header h1 {
  margin: 0;
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.02em;
}

.pf-header p {
  margin: 4px 0 0;
  font-size: 13.5px;
  color: var(--pf-ink-soft);
}

.pf-header-actions {
  display: flex;
  flex-wrap: wrap;
  justify-content: flex-end;
  gap: 8px;
}

.pf-header-actions p {
  flex-basis: 100%;
  contain: inline-size;
  margin: 0;
  text-align: right;
}

/* Schaltflächen */

.pf-button-primary,
.pf-button-secondary {
  display: inline-block;
  border-radius: 9px;
  padding: 0 20px;
  min-height: 40px;
  font: inherit;
  font-size: 13px;
  font-weight: 500;
  line-height: 40px;
  text-decoration: none;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, border-color 0.15s;
}

.pf-button-primary {
  border: none;
  background: var(--pf-accent);
  color: #fff;
}

.pf-button-primary:disabled {
  background: var(--pf-line);
  color: #a8b0bc;
  cursor: default;
}

.pf-button-secondary {
  border: 1px solid var(--pf-line);
  background: var(--pf-surface);
  color: var(--pf-ink-soft);
}

.pf-button-secondary:hover:not(:disabled) {
  background: var(--pf-surface-soft);
}

/* Panel */

.pf-panel {
  flex: 1;
  min-height: 0;
  display: flex;
  flex-direction: column;
  border: 1px solid var(--pf-line);
  border-radius: var(--pf-radius);
  background: var(--pf-surface);
  overflow: hidden;
}

/* Einwilligung */

.pf-consent {
  padding: 28px;
  gap: 12px;
  justify-content: center;
  justify-content: safe center;
  overflow-y: auto;
}

.pf-consent h2 {
  margin: 0;
  font-size: 17px;
  font-weight: 600;
}

.pf-consent p {
  margin: 0;
  max-width: 62ch;
  font-size: 13.5px;
  line-height: 1.6;
  color: var(--pf-ink-soft);
}

.pf-consent-error {
  color: var(--pf-error) !important;
}

.pf-consent-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 8px;
}

/* Nachrichten */

.pf-messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  padding: 20px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.pf-empty {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  text-align: center;
}

.pf-empty p {
  margin: 0;
  font-size: 14px;
  color: var(--pf-ink-soft);
}

.pf-row {
  display: flex;
}

.pf-row-user {
  justify-content: flex-end;
}

.pf-row-assistant {
  justify-content: flex-start;
}

.pf-bubble {
  max-width: 78%;
  padding: 10px 16px;
  font-size: 13px;
  line-height: 1.6;
}

.pf-bubble-user {
  background: var(--pf-accent);
  color: #fff;
  border-radius: 13px 13px 4px 13px;
  white-space: pre-wrap;
}

.pf-bubble-assistant {
  background: var(--pf-surface-soft);
  color: #222b36;
  border-radius: 13px 13px 13px 4px;
}

/* Tippanzeige */

.pf-status {
  display: flex;
  align-items: center;
  gap: 8px;
  color: var(--pf-ink-faint);
  font-size: 12px;
}

.pf-dots {
  display: flex;
  gap: 4px;
}

.pf-dots i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #98a2b3;
  animation: pf-bounce 0.9s infinite ease-in-out;
}

.pf-dots i:nth-child(2) { animation-delay: 0.15s; }
.pf-dots i:nth-child(3) { animation-delay: 0.3s; }

@keyframes pf-bounce {
  0%, 60%, 100% { transform: translateY(0); }
  30% { transform: translateY(-4px); }
}

@media (prefers-reduced-motion: reduce) {
  .pf-dots i { animation: none; }
}

/* Antworttext */

.pf-markdown > *:first-child { margin-top: 0; }
.pf-markdown > *:last-child { margin-bottom: 0; }

.pf-markdown p,
.pf-markdown ul,
.pf-markdown ol,
.pf-markdown blockquote {
  margin: 0 0 10px;
}

.pf-markdown ul,
.pf-markdown ol {
  padding-left: 20px;
}

.pf-markdown li { margin-bottom: 4px; }

.pf-markdown h3,
.pf-markdown h4,
.pf-markdown h5,
.pf-markdown h6 {
  margin: 14px 0 6px;
  font-size: 13.5px;
  font-weight: 600;
}

.pf-markdown a {
  color: var(--pf-accent);
}

.pf-markdown code {
  font-family: var(--pf-font-mono);
  font-size: 12px;
  background: rgba(19, 26, 36, 0.06);
  border-radius: 4px;
  padding: 1px 5px;
}

.pf-markdown pre {
  margin: 0 0 10px;
  padding: 10px 12px;
  overflow-x: auto;
  background: rgba(19, 26, 36, 0.06);
  border-radius: 8px;
}

.pf-markdown pre code {
  background: none;
  padding: 0;
}

.pf-math {
  font-family: "STIX Two Math", "Cambria Math", "Times New Roman", serif;
  font-size: 1.05em;
}

.pf-math-display {
  display: block;
  max-width: 100%;
  margin: 8px 0 10px;
  overflow-x: auto;
  overflow-y: hidden;
  text-align: center;
}

.pf-math-display .pf-math {
  margin: 0 auto;
}

.pf-markdown blockquote {
  padding-left: 12px;
  border-left: 3px solid var(--pf-line);
  color: var(--pf-ink-soft);
}

.pf-markdown hr {
  border: none;
  border-top: 1px solid var(--pf-line);
  margin: 14px 0;
}

/* Tabellen scrollen in ihrem eigenen Rahmen, damit die Blase nicht aufreißt. */
.pf-table-wrap {
  overflow-x: auto;
  margin: 0 0 10px;
}

.pf-markdown table {
  border-collapse: collapse;
  font-size: 12.5px;
  min-width: 100%;
}

.pf-markdown th,
.pf-markdown td {
  border: 1px solid var(--pf-line);
  padding: 6px 10px;
  text-align: left;
  vertical-align: top;
  background: var(--pf-surface);
}

.pf-markdown th {
  font-weight: 600;
  background: #eceff3;
  white-space: nowrap;
}

.pf-error {
  color: var(--pf-error);
  margin: 8px 0 0;
}

/* Zitate */

.pf-cite {
  margin: 0 2px;
  color: var(--pf-accent);
  font-weight: 500;
}

.pf-cite-link {
  text-decoration: none;
}

/* Quellenkarten */

.pf-sources {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--pf-line);
}

.pf-sources-title {
  margin: 0 0 8px;
  font-family: var(--pf-font-mono);
  font-size: 10.5px;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--pf-ink-faint);
}

.pf-sources ul {
  display: flex;
  flex-direction: column;
  gap: 8px;
  list-style: none;
  padding: 0;
  margin: 0;
}

.pf-source {
  display: flex;
  align-items: center;
  gap: 10px;
  border: 1px solid var(--pf-line);
  border-radius: 8px;
  padding: 10px;
  background: var(--pf-surface);
  text-decoration: none;
  color: inherit;
  transition: box-shadow 0.16s, border-color 0.16s;
}

a.pf-source:hover {
  border-color: #d5d9df;
  box-shadow: 0 2px 8px rgba(19, 26, 36, 0.08);
}

.pf-source-photo {
  width: 60px;
  height: 60px;
  flex-shrink: 0;
  border: 1px solid var(--pf-line);
  border-radius: 6px;
  background: #fafbfc;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.pf-source-photo img {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

/* Das Logo tritt an die Stelle eines fehlenden Produktfotos und braucht Luft,
   weil es sonst bis an den Rahmen stößt. */
.pf-source-photo-logo img {
  padding: 8px;
  box-sizing: border-box;
}

.pf-source-text {
  flex: 1;
  min-width: 0;
}

.pf-source-head {
  display: flex;
  align-items: center;
  gap: 6px;
}

.pf-source-number {
  font-family: var(--pf-font-mono);
  font-size: 10.5px;
  font-weight: 600;
  background: var(--pf-surface-soft);
  border-radius: 4px;
  padding: 1px 6px;
}

.pf-source-name {
  font-size: 13px;
  font-weight: 500;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.pf-source-sub {
  margin: 2px 0 0;
  font-size: 12px;
  color: var(--pf-ink-soft);
}

/* Eingabe */

.pf-composer {
  border-top: 1px solid var(--pf-line);
  flex-shrink: 0;
}

.pf-composer-row {
  display: flex;
  align-items: flex-end;
  gap: 10px;
  padding: 12px 16px 8px;
}

.pf-composer textarea {
  flex: 1;
  resize: none;
  border: 1px solid var(--pf-line);
  border-radius: 8px;
  padding: 9px 12px;
  font: inherit;
  font-size: 13px;
  color: var(--pf-ink);
  outline: none;
  min-height: 40px;
  max-height: 160px;
  overflow-y: auto;
  box-sizing: border-box;
}

.pf-composer textarea:focus {
  border-color: var(--pf-accent);
  box-shadow: 0 0 0 3px var(--pf-accent-soft);
}

.pf-disclaimer {
  margin: 0;
  padding: 0 16px 10px;
  font-size: 11.5px;
  line-height: 1.5;
  color: var(--pf-ink-faint);
  text-align: center;
}

.pf-notice {
  margin: 0;
  padding: 0 16px 10px;
  font-size: 13px;
  line-height: 1.5;
  color: var(--pf-ink);
  text-align: center;
}

@media (max-width: 600px) {
  .pf-page { padding: 12px 8px; }
  .pf-bubble { max-width: 92%; }
  .pf-header { flex-direction: column; }
  .pf-header-actions { justify-content: flex-start; }
  .pf-header-actions p { text-align: left; }
}

/* Kontaktformular: nativer Dialog mit Fokusbegrenzung und Escape-Unterstützung. */
.pf-contact-dialog {
  box-sizing: border-box;
  width: min(520px, calc(100% - 32px));
  max-height: calc(100% - 32px);
  overflow: auto;
  padding: 24px;
  border: 1px solid var(--pf-line);
  border-radius: var(--pf-radius);
  color: var(--pf-ink);
  background: var(--pf-surface);
  font: inherit;
}
.pf-contact-dialog::backdrop { background: rgb(0 0 0 / 45%); }
.pf-contact-dialog h2 { margin-top: 0; font-size: 20px; }
.pf-contact-dialog p { font-size: 13px; line-height: 1.55; }
.pf-contact-dialog fieldset { border: 0; padding: 0; margin: 0; min-width: 0; }
.pf-contact-dialog label { display: block; margin: 16px 0 6px; font-size: 13px; }
.pf-contact-dialog input,
.pf-contact-dialog textarea {
  box-sizing: border-box;
  width: 100%;
  padding: 10px;
  border: 1px solid var(--pf-line);
  border-radius: 6px;
  font: inherit;
}
.pf-contact-dialog textarea { resize: vertical; }
.pf-contact-actions { display: flex; justify-content: flex-end; flex-wrap: wrap; gap: 8px; margin-top: 12px; }
