/* ============================================================
   SEA DEAL by TARAGONA — Allegra Chat-Overlay
   Schwarz/Gold, passend zum App-Theme (nutzt app.css-Variablen).
   ============================================================ */

#sd-chat-btn {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  z-index: 800;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--grad, linear-gradient(120deg, #e8c25a 0%, #f3dd92 45%, #caa23a 100%));
  color: #1a1305;
  box-shadow: 0 12px 30px -8px rgba(232, 194, 90, 0.55), 0 4px 12px rgba(0, 0, 0, 0.4);
  transition: transform 0.18s ease, box-shadow 0.25s ease;
}
#sd-chat-btn:hover { transform: translateY(-3px) scale(1.04); box-shadow: 0 18px 38px -8px rgba(232, 194, 90, 0.7), 0 6px 16px rgba(0, 0, 0, 0.45); }
#sd-chat-btn svg { width: 26px; height: 26px; display: block; }
#sd-chat-btn.hidden { display: none; }

/* ---------- Fenster ---------- */
#sd-chat {
  position: fixed;
  right: 22px;
  bottom: 22px;
  width: 360px;
  max-width: calc(100vw - 32px);
  height: 520px;
  max-height: calc(100vh - 40px);
  z-index: 900;
  display: flex;
  flex-direction: column;
  background: var(--bg2, #141417);
  border: 1px solid var(--border, rgba(232, 194, 90, 0.16));
  border-radius: 18px;
  overflow: hidden;
  box-shadow: 0 24px 60px -12px rgba(0, 0, 0, 0.7);
  transform-origin: bottom right;
  animation: sd-chat-in 0.28s cubic-bezier(0.2, 0.7, 0.2, 1);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
}
@keyframes sd-chat-in {
  from { opacity: 0; transform: translateY(24px) scale(0.96); }
  to   { opacity: 1; transform: none; }
}
@media (prefers-reduced-motion: reduce) {
  #sd-chat { animation: none; }
}

/* ---------- Header ---------- */
.sd-chat-head {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 15px 16px;
  border-bottom: 1px solid var(--border, rgba(232, 194, 90, 0.16));
  background: linear-gradient(180deg, rgba(232, 194, 90, 0.08), transparent);
}
.sd-chat-avatar {
  width: 34px; height: 34px; border-radius: 50%;
  flex: 0 0 auto;
  display: flex; align-items: center; justify-content: center;
  background: var(--grad, linear-gradient(120deg, #e8c25a, #caa23a));
  color: #1a1305;
}
.sd-chat-avatar svg { width: 19px; height: 19px; }
.sd-chat-titles { flex: 1 1 auto; line-height: 1.2; }
.sd-chat-name { font-family: 'Space Grotesk', sans-serif; font-weight: 700; font-size: 0.98rem; color: var(--text, #f4f1ea); }
.sd-chat-status { font-size: 0.72rem; color: var(--muted, #9b958a); display: flex; align-items: center; gap: 6px; margin-top: 1px; }
.sd-chat-status::before {
  content: ''; width: 6px; height: 6px; border-radius: 50%;
  background: var(--green, #34d399);
}
.sd-chat-close {
  flex: 0 0 auto;
  width: 30px; height: 30px; border-radius: 8px;
  border: none; cursor: pointer;
  background: transparent; color: var(--muted, #9b958a);
  font-size: 1.4rem; line-height: 1;
  display: flex; align-items: center; justify-content: center;
  transition: background 0.15s, color 0.15s;
}
.sd-chat-close:hover { background: rgba(255, 255, 255, 0.06); color: var(--text, #f4f1ea); }

/* ---------- Nachrichten ---------- */
.sd-chat-log {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scrollbar-width: thin;
  scrollbar-color: rgba(232, 194, 90, 0.3) transparent;
}
.sd-chat-log::-webkit-scrollbar { width: 7px; }
.sd-chat-log::-webkit-scrollbar-thumb { background: rgba(232, 194, 90, 0.25); border-radius: 4px; }

.sd-msg {
  max-width: 82%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 0.9rem;
  line-height: 1.5;
  white-space: pre-wrap;
  word-wrap: break-word;
}
.sd-msg.bot {
  align-self: flex-start;
  background: var(--card-solid, #17171b);
  border: 1px solid var(--border, rgba(232, 194, 90, 0.16));
  color: var(--text, #f4f1ea);
  border-bottom-left-radius: 5px;
}
.sd-msg.user {
  align-self: flex-end;
  background: var(--grad, linear-gradient(120deg, #e8c25a 0%, #f3dd92 45%, #caa23a 100%));
  color: #1a1305;
  font-weight: 500;
  border-bottom-right-radius: 5px;
}
.sd-msg a { color: inherit; text-decoration: underline; }

/* Tipp-Indikator */
.sd-typing { align-self: flex-start; display: flex; gap: 4px; padding: 12px 14px; background: var(--card-solid, #17171b); border: 1px solid var(--border, rgba(232,194,90,0.16)); border-radius: 14px; border-bottom-left-radius: 5px; }
.sd-typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--muted, #9b958a);
  animation: sd-blink 1.3s infinite ease-in-out both;
}
.sd-typing span:nth-child(2) { animation-delay: 0.18s; }
.sd-typing span:nth-child(3) { animation-delay: 0.36s; }
@keyframes sd-blink { 0%, 80%, 100% { opacity: 0.25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

/* ---------- Eingabe ---------- */
.sd-chat-form {
  display: flex;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--border, rgba(232, 194, 90, 0.16));
  background: var(--bg2, #141417);
}
.sd-chat-input {
  flex: 1 1 auto;
  resize: none;
  max-height: 96px;
  padding: 11px 13px;
  border-radius: 11px;
  border: 1px solid var(--border, rgba(232, 194, 90, 0.16));
  background: rgba(255, 255, 255, 0.04);
  color: var(--text, #f4f1ea);
  font-family: inherit;
  font-size: 0.9rem;
  line-height: 1.4;
}
.sd-chat-input::placeholder { color: var(--muted, #9b958a); }
.sd-chat-input:focus { outline: none; border-color: var(--cyan, #e8c25a); }
.sd-chat-send {
  flex: 0 0 auto;
  width: 42px; height: 42px;
  align-self: flex-end;
  border-radius: 11px;
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  background: var(--grad, linear-gradient(120deg, #e8c25a 0%, #f3dd92 45%, #caa23a 100%));
  color: #1a1305;
  transition: transform 0.15s, opacity 0.15s;
}
.sd-chat-send:hover { transform: translateY(-1px); }
.sd-chat-send:disabled { opacity: 0.5; cursor: default; transform: none; }
.sd-chat-send svg { width: 19px; height: 19px; }

/* Nie im Druck / PDF-Export der Angebots- & Datenblatt-Dokumente */
@media print {
  #sd-chat-btn, #sd-chat { display: none !important; }
}

/* ---------- Mobile ---------- */
@media (max-width: 600px) {
  #sd-chat {
    right: 0; bottom: 0;
    width: 100vw; max-width: 100vw;
    height: 100dvh; max-height: 100dvh;
    border-radius: 0;
    border: none;
  }
  #sd-chat-btn { right: 16px; bottom: 16px; }
}
