/* --- SEO ATTRIBUTION (Invisible for users, visible for crawlers) --- */
.lucy-hidden-attribution {
  position: absolute;
  left: -9999px;
  top: auto;
  width: 1px;
  height: 1px;
  overflow: hidden;
}

/* --- THEME VARIABLEN --- */
:root {
  --lucy-primary: #0073aa;
  --lucy-secondary: #005a87;
  --lucy-pulse: rgba(0, 115, 170, 0.4);
}
.lucy-theme-emerald {
  --lucy-primary: #10b981;
  --lucy-secondary: #059669;
  --lucy-pulse: rgba(16, 185, 129, 0.4);
}
.lucy-theme-midnight {
  --lucy-primary: #1f2937;
  --lucy-secondary: #111827;
  --lucy-pulse: rgba(31, 41, 55, 0.4);
}
.lucy-theme-berry {
  --lucy-primary: #8b5cf6;
  --lucy-secondary: #7c3aed;
  --lucy-pulse: rgba(139, 92, 246, 0.4);
}
.lucy-theme-sunset {
  --lucy-primary: #f59e0b;
  --lucy-secondary: #d97706;
  --lucy-pulse: rgba(245, 158, 11, 0.4);
}
.lucy-theme-mono {
  --lucy-primary: #4b5563;
  --lucy-secondary: #374151;
  --lucy-pulse: rgba(75, 85, 99, 0.4);
}

#mein-chatbot-fenster,
#mein-chatbot-blase,
#mein-chatbot-fenster * {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
  box-sizing: border-box;
}

/* --- BUBBLE --- */
#mein-chatbot-blase {
  position: fixed;
  bottom: 36px;
  right: 36px;
  width: 100px;
  height: 100px;
  background: none;
  border-radius: 50%;
  cursor: pointer;
  box-shadow: 0 4px 15px var(--lucy-pulse);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 99998;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
  animation: pulse-blue 2s infinite;
}
#mein-chatbot-blase:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 20px var(--lucy-pulse);
}

/* WENN OFFEN: Bubble wird klein und wandert an ursprüngliche Position */
#mein-chatbot-blase.is-open {
  width: 65px;
  height: 65px;
  bottom: 25px;
  right: 25px;
  background: linear-gradient(
    135deg,
    var(--lucy-primary),
    var(--lucy-secondary)
  );
}

#mein-chatbot-blase span {
  position: absolute;
  transition: all 0.3s cubic-bezier(0.68, -0.55, 0.265, 1.55);
  display: flex;
  align-items: center;
  justify-content: center;
}
.icon-chat {
  opacity: 1;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
}
.icon-close {
  opacity: 0;
  transform: rotate(-90deg) scale(0.5);
}
#mein-chatbot-blase.is-open .icon-chat {
  opacity: 0;
  transform: rotate(90deg) scale(0.5);
}
#mein-chatbot-blase.is-open .icon-close {
  opacity: 1;
  transform: rotate(0deg) scale(1);
}

/* Custom Image within Bubble */
.lucy-custom-bubble-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  border-radius: 50%;
  display: block;
}

@keyframes pulse-blue {
  0% {
    box-shadow: 0 0 0 0 var(--lucy-pulse);
  }
  70% {
    box-shadow: 0 0 0 10px rgba(0, 0, 0, 0);
  }
  100% {
    box-shadow: 0 0 0 0 var(--lucy-pulse);
  }
}

/* --- FENSTER --- */
#mein-chatbot-fenster {
  position: fixed;
  bottom: 100px;
  right: 25px;
  width: 380px;
  height: 550px;
  max-height: 80vh;
  background-color: #ffffff;
  border-radius: 16px;
  box-shadow: 0 10px 40px rgba(0, 0, 0, 0.15);
  display: flex;
  flex-direction: column;
  z-index: 99999;
  overflow: hidden;
  opacity: 0;
  transform: translateY(20px);
  transition: opacity 0.3s, transform 0.3s;
  pointer-events: none;
}
#mein-chatbot-fenster.visible {
  opacity: 1;
  transform: translateY(0);
  pointer-events: all;
}

#mein-chatbot-header {
  background: linear-gradient(
    135deg,
    var(--lucy-primary),
    var(--lucy-secondary)
  );
  color: white;
  padding: 9px 15px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

/* NEU: Wrapper für Bild + Text */
.lucy-header-group {
  display: flex;
  align-items: center;
}

.chat-title {
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.2px;
}
.lucy-header-avatar {
  width: 45px;
  height: 45px;
  border-radius: 50%;
  margin-right: 8px;
  object-fit: cover;
  vertical-align: middle;
  border: 2px solid rgba(255, 255, 255, 0.2);
}

.chat-controls {
  display: flex;
  align-items: center;
  gap: 8px;
}
.nav-btn {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: background 0.2s;
}
.nav-btn:hover {
  background: rgba(255, 255, 255, 0.2);
}
#chat-counter {
  font-size: 12px;
  min-width: 30px;
  text-align: center;
  font-variant-numeric: tabular-nums;
  opacity: 0.9;
}

#mein-chatbot-body {
  flex-grow: 1;
  padding: 20px;
  overflow-y: auto;
  background-color: #f9f9f9;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* --- MESSAGES --- */
.user-nachricht {
  padding: 10px 16px;
  border-radius: 18px;
  max-width: 85%;
  word-wrap: break-word;
  font-size: 15px;
  background-color: var(--lucy-primary);
  color: white;
  align-self: flex-end;
  border-bottom-right-radius: 4px;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}
.bot-nachricht {
  padding: 12px 16px;
  border-radius: 18px;
  max-width: 92%;
  font-size: 15px;
  background-color: #ffffff;
  color: #333;
  align-self: flex-start;
  border-bottom-left-radius: 4px;
  border: 1px solid #eee;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

/* Markdown Styles */
.bot-nachricht h1,
.bot-nachricht h2,
.bot-nachricht h3 {
  font-size: 1.15em;
  margin: 15px 0 8px 0;
  font-weight: 700;
  line-height: 1.2;
}
.bot-nachricht p {
  margin: 0 0 10px 0;
  line-height: 1.5;
}
.bot-nachricht p:last-child {
  margin-bottom: 0;
}
.bot-nachricht strong {
  font-weight: 700;
  color: #000;
}
.bot-nachricht ul,
.bot-nachricht ol {
  margin: 10px 0 10px 20px !important;
  padding: 0 !important;
}
.bot-nachricht ul {
  list-style-type: disc !important;
}
.bot-nachricht ol {
  list-style-type: decimal !important;
}
.bot-nachricht li {
  margin-bottom: 6px;
}

/* --- CODE BLOCKS & COPY BUTTON --- */
.bot-nachricht pre {
  background: #2d2d2d;
  color: #f8f8f2;
  padding: 35px 12px 12px 12px;
  border-radius: 8px;
  overflow-x: auto;
  margin: 12px 0;
  font-family: monospace;
  font-size: 0.88em;
  line-height: 1.4;
  position: relative;
}

.lucy-copy-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 4px;
  color: #ccc;
  cursor: pointer;
  padding: 4px 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
.lucy-copy-btn:hover {
  background: rgba(255, 255, 255, 0.2);
  color: #fff;
}
.lucy-copy-btn.copied {
  border-color: #10b981;
  color: #10b981;
}

.bot-nachricht code {
  background: rgba(0, 0, 0, 0.06);
  padding: 2px 5px;
  border-radius: 4px;
  font-family: monospace;
  font-size: 0.92em;
  color: #d63384;
}
.bot-nachricht pre code {
  background: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

/* --- ADD TO CART BUTTON STYLE (NEW) --- */
.bot-nachricht a[href*="add-to-cart"] {
  display: inline-block;
  margin-top: 5px;
  padding: 6px 12px;
  background-color: var(--lucy-primary);
  color: white;
  text-decoration: none;
  border-radius: 4px;
  font-size: 13px;
  font-weight: 500;
  transition: background 0.2s, transform 0.1s;
  border: 1px solid transparent;
}
.bot-nachricht a[href*="add-to-cart"]:hover {
  background-color: var(--lucy-secondary);
  transform: translateY(-1px);
}
.bot-nachricht a[href*="add-to-cart"]:active {
  transform: translateY(1px);
}

/* --- HOVER PREVIEW --- */
#lucy-hover-preview {
  position: fixed;
  z-index: 100000;
  background: white;
  padding: 5px;
  border: 1px solid #ccc;
  border-radius: 8px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
  pointer-events: none;
  display: none;
  max-width: 250px;
  max-height: 250px;
}
#lucy-hover-preview img {
  max-width: 100%;
  height: auto;
  display: block;
  border-radius: 4px;
}

/* --- TABELLEN SCROLL FIX --- */
.lucy-table-wrapper {
  width: 100%;
  overflow-x: auto;
  margin: 15px 0;
  border: 1px solid #ddd;
  border-radius: 8px;
  background-color: #fff;
  padding-bottom: 5px;
}
.lucy-table-wrapper::-webkit-scrollbar {
  height: 8px;
}
.lucy-table-wrapper::-webkit-scrollbar-track {
  background: #f1f1f1;
  border-radius: 8px;
}
.lucy-table-wrapper::-webkit-scrollbar-thumb {
  background: var(--lucy-primary);
  border-radius: 8px;
}
.lucy-table-wrapper::-webkit-scrollbar-thumb:hover {
  background: var(--lucy-secondary);
}

.bot-nachricht table {
  width: 100%;
  min-width: 600px;
  border-collapse: collapse;
  font-size: 13px;
  margin: 0;
}
.bot-nachricht th,
.bot-nachricht td {
  border: 1px solid #eee;
  padding: 10px;
  text-align: left;
}
.bot-nachricht th {
  background-color: #f8f8f8;
  font-weight: 600;
  color: #000;
}

.bot-nachricht blockquote {
  margin: 10px 0 !important;
  padding: 4px 0 4px 15px !important;
  border-left: 4px solid var(--lucy-primary) !important;
  background: rgba(0, 115, 170, 0.03) !important;
  font-style: italic;
  color: #444;
  border-radius: 2px;
}
.bot-nachricht blockquote blockquote {
  margin-left: 5px !important;
  border-left-width: 3px !important;
  opacity: 0.8;
}
.bot-nachricht img {
  max-width: 100%;
  height: auto;
  border-radius: 10px;
  margin: 10px 0;
  display: block;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

/* Footer */
#mein-chatbot-footer {
  padding: 15px;
  background-color: white;
  border-top: 1px solid #eee;
}
.input-container {
  display: flex;
  align-items: center;
  background-color: #f0f2f5;
  border-radius: 25px;
  padding: 5px 5px 5px 15px;
  border: 1px solid transparent;
  transition: all 0.2s;
}
.input-container:focus-within {
  border-color: var(--lucy-primary);
  background-color: #fff;
  box-shadow: 0 0 0 3px rgba(0, 115, 170, 0.1);
}
#mein-chatbot-input {
  flex-grow: 1;
  border: none;
  background: transparent;
  padding: 8px 0;
  outline: none;
  font-size: 15px;
  color: #333;
}
#mein-chatbot-send {
  background-color: var(--lucy-primary);
  border: none;
  color: white;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  margin-left: 10px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}
#mein-chatbot-send:hover {
  background-color: var(--lucy-secondary);
  transform: scale(1.08);
}
#mein-chatbot-footer-note {
  font-size: 10px;
  color: #999;
  text-align: center;
  margin-top: 10px;
  line-height: 1.2;
}
#mein-chatbot-footer-note a {
  color: var(--lucy-primary);
  text-decoration: none;
  font-weight: 600;
}
#mein-chatbot-footer-note a:hover {
  text-decoration: underline;
}

@media (max-width: 480px) {
  #mein-chatbot-fenster {
    bottom: 0;
    right: 0;
    width: 100%;
    height: 100%;
    border-radius: 0;
  }
}
