/* Wind Clean GmbH – KI Chat Widget Styles (v3 mit Markdown-Support) */
#wc-chat-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  background: #0f172a;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 30px -10px rgba(37, 150, 190, 0.65), 0 0 0 1px rgba(37, 150, 190, 0.35);
  cursor: pointer;
  transition: transform 0.3s ease, box-shadow 0.3s ease;
  border: none;
  padding: 0;
  bottom: calc(24px + env(safe-area-inset-bottom, 0px));
}
#wc-chat-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 14px 40px -10px rgba(37, 150, 190, 0.85), 0 0 0 1px rgba(37, 150, 190, 0.55);
}
#wc-chat-btn svg { width: 28px; height: 28px; }
#wc-chat-btn::after {
  content: '';
  position: absolute;
  top: 4px;
  right: 4px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #10b981;
  border: 2px solid #0f172a;
}

#wc-chat-window {
  position: fixed;
  bottom: 100px;
  right: 24px;
  z-index: 9998;
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 120px);
  background: rgba(255, 255, 255, 0.98);
  backdrop-filter: blur(24px) saturate(160%);
  -webkit-backdrop-filter: blur(24px) saturate(160%);
  border: 1px solid rgba(226, 232, 240, 0.8);
  border-radius: 24px;
  box-shadow: 0 20px 50px -30px rgba(15, 23, 42, 0.45);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transition: opacity 0.3s ease, transform 0.3s ease, visibility 0.3s;
  transform-origin: bottom right;
  font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}
#wc-chat-window.hidden {
  opacity: 0;
  visibility: hidden;
  transform: scale(0.95);
  pointer-events: none;
}

.wc-chat-header {
  background: #0f172a;
  color: #fff;
  padding: 16px 20px;
  padding-top: calc(16px + env(safe-area-inset-top, 0px));
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
  gap: 12px;
}
.wc-chat-header h3 { margin: 0; font-size: 15px; font-weight: 600; }
.wc-chat-header p { margin: 3px 0 0; font-size: 11px; color: #94a3b8; display: flex; align-items: center; gap: 6px; }
.wc-chat-header p::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #10b981;
  box-shadow: 0 0 6px #10b981;
}
.wc-chat-close {
  background: rgba(255, 255, 255, 0.08);
  border: none;
  color: #cbd5e1;
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, color 0.2s;
}
.wc-chat-close:hover { background: rgba(255, 255, 255, 0.15); color: #fff; }
.wc-chat-close svg { width: 18px; height: 18px; }

.wc-chat-quickbar {
  display: flex;
  gap: 6px;
  padding: 10px 12px;
  background: #fff;
  border-bottom: 1px solid #e2e8f0;
  flex-shrink: 0;
}
.wc-chat-quickbar button,
.wc-chat-quickbar a {
  flex: 1;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 8px 10px;
  font-size: 12px;
  font-weight: 600;
  border-radius: 10px;
  border: 1px solid #e2e8f0;
  background: #f8fafc;
  color: #0f172a;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s ease;
  font-family: inherit;
}
.wc-chat-quickbar button:hover,
.wc-chat-quickbar a:hover {
  background: #2596be;
  color: #fff;
  border-color: #2596be;
}
.wc-chat-quickbar button.primary {
  background: #0f172a;
  color: #fff;
  border-color: #0f172a;
}
.wc-chat-quickbar button.primary:hover {
  background: #2596be;
  border-color: #2596be;
}
.wc-chat-quickbar svg { width: 14px; height: 14px; }

.wc-chat-body {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: #f8fafc;
}
.wc-chat-body::-webkit-scrollbar { width: 6px; }
.wc-chat-body::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }

/* ---------- Message-Bubbles ---------- */
.wc-msg {
  max-width: 85%;
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.5;
  word-wrap: break-word;
  overflow-wrap: break-word;
}

/* Bot-Nachrichten: HTML-Rendering (Markdown) */
.wc-msg.bot {
  background: #fff;
  border: 1px solid #e2e8f0;
  color: #0f172a;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  white-space: normal;
}

/* User-Nachrichten: rein textuell, Zeilenumbrüche erhalten */
.wc-msg.user {
  background: #2596be;
  color: #fff;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  white-space: pre-wrap;
}

.wc-msg.typing {
  color: #94a3b8;
  font-style: italic;
  font-size: 13px;
}

/* ---------- Markdown-Elemente in Bot-Nachrichten ---------- */
.wc-msg.bot strong { font-weight: 700; color: #0f172a; }
.wc-msg.bot em { font-style: italic; }
.wc-msg.bot code {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.88em;
  background: #f1f5f9;
  padding: 1px 5px;
  border-radius: 4px;
  color: #334155;
}
.wc-msg.bot ul {
  margin: 6px 0 6px 0;
  padding-left: 20px;
  list-style: none;
}
.wc-msg.bot li {
  position: relative;
  margin-bottom: 4px;
  padding-left: 4px;
}
.wc-msg.bot li:last-child { margin-bottom: 0; }
.wc-msg.bot li::before {
  content: '';
  position: absolute;
  left: -12px;
  top: 9px;
  width: 4px;
  height: 4px;
  border-radius: 50%;
  background: #2596be;
}
.wc-msg.bot .wc-md-line {
  margin: 0;
}
.wc-msg.bot .wc-md-line + .wc-md-line {
  margin-top: 2px;
}
.wc-msg.bot .wc-md-spacer {
  height: 8px;
}
.wc-msg.bot .wc-md-heading {
  font-weight: 700;
  color: #0f172a;
  margin: 8px 0 4px;
}
.wc-msg.bot .wc-md-heading:first-child { margin-top: 0; }

.wc-chat-footer {
  padding: 12px;
  padding-bottom: calc(12px + env(safe-area-inset-bottom, 0px));
  background: #fff;
  border-top: 1px solid #e2e8f0;
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}
.wc-chat-footer input {
  flex: 1;
  min-width: 0;
  border: 1px solid #e2e8f0;
  border-radius: 20px;
  padding: 10px 16px;
  font-size: 16px;
  outline: none;
  transition: border-color 0.2s;
  font-family: inherit;
  background: #fff;
  color: #0f172a;
}
.wc-chat-footer input:focus { border-color: #2596be; }
.wc-chat-footer button {
  background: #0f172a;
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 40px;
  height: 40px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: background 0.2s;
  flex-shrink: 0;
  padding: 0;
}
.wc-chat-footer button:hover { background: #1e293b; }
.wc-chat-footer button:disabled { opacity: 0.5; cursor: not-allowed; }

/* Consent Screen */
.wc-consent {
  flex: 1;
  padding: 24px;
  display: flex;
  flex-direction: column;
  gap: 16px;
  background: #f8fafc;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
}
.wc-consent h4 { margin: 0; font-size: 16px; font-weight: 700; color: #0f172a; }
.wc-consent p { margin: 0; font-size: 13px; line-height: 1.55; color: #475569; }
.wc-consent a { color: #2596be; text-decoration: underline; font-weight: 600; }
.wc-consent-info {
  background: #fff;
  border: 1px solid #e2e8f0;
  border-radius: 12px;
  padding: 14px;
  font-size: 12px;
  line-height: 1.55;
  color: #475569;
}
.wc-consent-info strong { color: #0f172a; }
.wc-consent-info ul { margin: 8px 0 0; padding-left: 18px; }
.wc-consent-info li { margin-bottom: 4px; }
.wc-consent-check {
  display: flex;
  gap: 10px;
  align-items: flex-start;
  font-size: 12.5px;
  line-height: 1.5;
  color: #334155;
  cursor: pointer;
  background: #fff;
  padding: 12px;
  border-radius: 12px;
  border: 1px solid #e2e8f0;
}
.wc-consent-check input {
  margin-top: 2px;
  width: 16px;
  height: 16px;
  accent-color: #2596be;
  flex-shrink: 0;
}
.wc-consent-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: auto;
}
.wc-consent-actions button {
  padding: 12px 16px;
  border-radius: 12px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  font-family: inherit;
  transition: all 0.2s ease;
}
.wc-consent-btn-accept { background: #0f172a; color: #fff; }
.wc-consent-btn-accept:hover:not(:disabled) { background: #2596be; }
.wc-consent-btn-accept:disabled { background: #cbd5e1; cursor: not-allowed; color: #64748b; }
.wc-consent-call {
  background: #fff;
  color: #0f172a;
  border: 1px solid #e2e8f0 !important;
  text-decoration: none;
  text-align: center;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}
.wc-consent-call:hover { border-color: #2596be !important; color: #2596be; }

/* Lead Form */
.wc-leadform {
  flex: 1;
  padding: 20px;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  background: #f8fafc;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.wc-leadform h4 { margin: 0 0 4px; font-size: 15px; font-weight: 700; color: #0f172a; }
.wc-leadform .wc-hint { font-size: 12px; color: #64748b; line-height: 1.5; margin: 0; }
.wc-leadform label { display: block; font-size: 12px; font-weight: 600; color: #334155; margin-bottom: 4px; }
.wc-leadform input,
.wc-leadform textarea {
  width: 100%;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 10px 12px;
  font-size: 16px;
  font-family: inherit;
  background: #fff;
  color: #0f172a;
  outline: none;
  transition: border-color 0.2s;
  box-sizing: border-box;
}
.wc-leadform input:focus,
.wc-leadform textarea:focus { border-color: #2596be; }
.wc-leadform textarea { resize: vertical; min-height: 60px; }
.wc-leadform .wc-req { color: #2596be; }
.wc-leadform .wc-consent-mini {
  display: flex;
  gap: 8px;
  align-items: flex-start;
  font-size: 11.5px;
  color: #475569;
  line-height: 1.45;
}
.wc-leadform .wc-consent-mini input {
  width: 16px;
  height: 16px;
  margin-top: 2px;
  accent-color: #2596be;
  flex-shrink: 0;
}
.wc-leadform .wc-actions { display: flex; gap: 8px; margin-top: 4px; }
.wc-leadform button {
  flex: 1;
  padding: 12px 14px;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  font-family: inherit;
  transition: all 0.2s;
}
.wc-leadform .wc-btn-back {
  background: #fff;
  color: #475569;
  border: 1px solid #e2e8f0 !important;
}
.wc-leadform .wc-btn-back:hover { border-color: #2596be !important; color: #2596be; }
.wc-leadform .wc-btn-submit { background: #2596be; color: #fff; }
.wc-leadform .wc-btn-submit:hover:not(:disabled) { background: #1e7a9e; }
.wc-leadform .wc-btn-submit:disabled { opacity: 0.6; cursor: not-allowed; }
.wc-leadform .wc-error {
  color: #e11d48;
  font-size: 12px;
  background: #fef2f2;
  padding: 8px 10px;
  border-radius: 8px;
  display: none;
}
.wc-lead-success {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 24px;
  gap: 12px;
  background: #f8fafc;
}
.wc-lead-success .wc-check {
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: #10b981;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
}
.wc-lead-success h4 { margin: 0; color: #0f172a; font-size: 16px; }
.wc-lead-success p { margin: 0; font-size: 13px; color: #475569; line-height: 1.5; }

/* ============================================
   BODY SCROLL LOCK
   ============================================ */
body.wc-chat-open {
  overflow: hidden !important;
  position: fixed;
  width: 100%;
  height: 100%;
  touch-action: none;
}
body.wc-chat-open #wc-chat-window,
body.wc-chat-open .wc-chat-body,
body.wc-chat-open .wc-consent,
body.wc-chat-open .wc-leadform {
  touch-action: auto;
}

/* ============================================
   TABLET (bis 768px)
   ============================================ */
@media (max-width: 768px) {
  #wc-chat-window {
    width: calc(100vw - 32px);
    max-width: 500px;
    height: 70vh;
    max-height: calc(100dvh - 140px);
    right: 16px;
    bottom: calc(90px + env(safe-area-inset-bottom, 0px));
  }
  #wc-chat-btn {
    width: 56px;
    height: 56px;
    bottom: calc(20px + env(safe-area-inset-bottom, 0px));
    right: 20px;
  }
}

/* ============================================
   SMARTPHONE (bis 480px) – Vollbild
   ============================================ */
@media (max-width: 480px) {
  #wc-chat-window {
    top: 0;
    bottom: 0;
    right: 0;
    left: 0;
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    height: 100dvh;
    max-height: 100vh;
    max-height: 100dvh;
    border-radius: 0;
    border: none;
    transform-origin: center;
  }
  #wc-chat-window.hidden {
    transform: translateY(20px);
    opacity: 0;
  }

  .wc-chat-header {
    padding: 14px 16px;
    padding-top: calc(14px + env(safe-area-inset-top, 0px));
  }
  .wc-chat-header h3 { font-size: 15px; }
  .wc-chat-close {
    width: 40px;
    height: 40px;
    background: rgba(255, 255, 255, 0.12);
  }
  .wc-chat-close svg { width: 20px; height: 20px; }

  .wc-chat-quickbar {
    padding: 8px 12px;
    gap: 6px;
  }
  .wc-chat-quickbar button,
  .wc-chat-quickbar a {
    padding: 10px 8px;
    font-size: 11.5px;
  }

  .wc-chat-body { padding: 16px; gap: 10px; }
  .wc-msg { font-size: 15px; padding: 11px 15px; max-width: 88%; }

  .wc-chat-footer {
    padding: 10px 12px;
    padding-bottom: calc(10px + env(safe-area-inset-bottom, 0px));
  }
  .wc-chat-footer input { padding: 11px 16px; font-size: 16px; }
  .wc-chat-footer button { width: 44px; height: 44px; }

  .wc-consent,
  .wc-leadform { padding: 20px 16px; }
  .wc-consent h4,
  .wc-leadform h4 { font-size: 17px; }
  .wc-consent p { font-size: 13.5px; }
  .wc-consent-actions button,
  .wc-leadform button { padding: 14px 16px; font-size: 15px; }

  #wc-chat-btn.wc-hidden-mobile {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
  }
}

/* ============================================
   QUERFORMAT (Landscape auf Handy)
   ============================================ */
@media (max-width: 900px) and (orientation: landscape) {
  #wc-chat-window {
    top: 0;
    bottom: 0;
    right: 0;
    left: auto;
    width: 420px;
    max-width: 55vw;
    height: 100vh;
    height: 100dvh;
    border-radius: 0;
  }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  #wc-chat-window,
  #wc-chat-btn,
  .wc-msg {
    transition: none !important;
  }
}