/* LDV Systems Chatbot Widget — Managed by Sovamoon */

:root {
  --chat-primary: #1565C0;
  --chat-primary-dark: #0D47A1;
  --chat-bg: #FFFFFF;
  --chat-surface: #F8FAFF;
  --chat-border: #DBEAFE;
  --chat-text: #0B2545;
  --chat-muted: #64748B;
  --chat-bot-bg: #EEF4FC;
  --chat-user-bg: #1565C0;
  --chat-user-text: #FFFFFF;
  --chat-shadow: 0 8px 40px rgba(11, 37, 69, 0.18);
  --chat-radius: 16px;
}

/* ── Toggle Button ─────────────────────────────────────────── */
.ldv-chat-toggle {
  position: fixed;
  bottom: 28px;
  right: 28px;
  width: 60px;
  height: 60px;
  background: var(--chat-primary);
  color: #fff;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(21, 101, 192, 0.4);
  z-index: 9999;
  transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
}
.ldv-chat-toggle:hover {
  background: var(--chat-primary-dark);
  transform: scale(1.06);
  box-shadow: 0 6px 28px rgba(21, 101, 192, 0.5);
}
.ldv-chat-toggle svg { width: 26px; height: 26px; transition: opacity 0.2s; }
.ldv-chat-toggle .icon-close { display: none; }
.ldv-chat-toggle.open .icon-open  { display: none; }
.ldv-chat-toggle.open .icon-close { display: block; }

/* ── Notification Badge ────────────────────────────────────── */
.ldv-chat-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  width: 20px;
  height: 20px;
  background: #EF4444;
  color: white;
  font-size: 0.7rem;
  font-weight: 700;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  border: 2px solid #fff;
  animation: pulse-badge 2s infinite;
}
@keyframes pulse-badge {
  0%, 100% { transform: scale(1); }
  50%       { transform: scale(1.15); }
}

/* ── Chat Window ───────────────────────────────────────────── */
.ldv-chat-window {
  position: fixed;
  bottom: 100px;
  right: 28px;
  width: 380px;
  max-height: 560px;
  background: var(--chat-bg);
  border-radius: var(--chat-radius);
  box-shadow: var(--chat-shadow);
  display: flex;
  flex-direction: column;
  z-index: 9998;
  border: 1px solid var(--chat-border);
  overflow: hidden;
  transform: translateY(20px) scale(0.96);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s ease, opacity 0.25s ease;
}
.ldv-chat-window.open {
  transform: translateY(0) scale(1);
  opacity: 1;
  pointer-events: all;
}

/* ── Header ────────────────────────────────────────────────── */
.ldv-chat-header {
  background: var(--chat-primary);
  padding: 16px 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
.ldv-chat-avatar {
  width: 40px;
  height: 40px;
  background: rgba(255,255,255,0.15);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.ldv-chat-avatar svg { width: 22px; height: 22px; color: white; }
.ldv-chat-header-info { flex: 1; }
.ldv-chat-header-name { font-size: 0.95rem; font-weight: 700; color: white; }
.ldv-chat-header-status { font-size: 0.75rem; color: rgba(255,255,255,0.8); display: flex; align-items: center; gap: 5px; }
.ldv-status-dot { width: 7px; height: 7px; background: #4ADE80; border-radius: 50%; }

/* ── Messages ──────────────────────────────────────────────── */
.ldv-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 20px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--chat-surface);
  scroll-behavior: smooth;
}
.ldv-chat-messages::-webkit-scrollbar { width: 4px; }
.ldv-chat-messages::-webkit-scrollbar-thumb { background: var(--chat-border); border-radius: 4px; }

.ldv-msg {
  display: flex;
  gap: 8px;
  align-items: flex-end;
  animation: msg-in 0.2s ease;
}
@keyframes msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}
.ldv-msg-bot { flex-direction: row; }
.ldv-msg-user { flex-direction: row-reverse; }

.ldv-msg-icon {
  width: 28px;
  height: 28px;
  background: var(--chat-primary);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.ldv-msg-icon svg { width: 14px; height: 14px; color: white; }

.ldv-msg-bubble {
  max-width: 80%;
  padding: 10px 14px;
  border-radius: 14px;
  font-size: 0.88rem;
  line-height: 1.55;
}
.ldv-msg-bot  .ldv-msg-bubble { background: var(--chat-bot-bg); color: var(--chat-text); border-bottom-left-radius: 4px; border: 1px solid var(--chat-border); }
.ldv-msg-user .ldv-msg-bubble { background: var(--chat-user-bg); color: var(--chat-user-text); border-bottom-right-radius: 4px; }

/* ── Typing Indicator ──────────────────────────────────────── */
.ldv-typing .ldv-msg-bubble {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 12px 16px;
}
.ldv-typing-dot {
  width: 7px;
  height: 7px;
  background: var(--chat-primary);
  border-radius: 50%;
  animation: typing-dot 1.2s infinite;
  opacity: 0.4;
}
.ldv-typing-dot:nth-child(2) { animation-delay: 0.2s; }
.ldv-typing-dot:nth-child(3) { animation-delay: 0.4s; }
@keyframes typing-dot {
  0%, 80%, 100% { transform: scale(1);    opacity: 0.4; }
  40%           { transform: scale(1.3);  opacity: 1; }
}

/* ── Input ─────────────────────────────────────────────────── */
.ldv-chat-input-wrap {
  padding: 12px 16px;
  background: var(--chat-bg);
  border-top: 1px solid var(--chat-border);
  display: flex;
  gap: 8px;
  align-items: flex-end;
  flex-shrink: 0;
}
.ldv-chat-input {
  flex: 1;
  border: 1px solid var(--chat-border);
  border-radius: 22px;
  padding: 10px 16px;
  font-size: 0.88rem;
  font-family: inherit;
  outline: none;
  resize: none;
  max-height: 120px;
  line-height: 1.5;
  color: var(--chat-text);
  background: var(--chat-surface);
  transition: border-color 0.2s;
}
.ldv-chat-input:focus { border-color: var(--chat-primary); }
.ldv-chat-input::placeholder { color: var(--chat-muted); }
.ldv-chat-send {
  width: 40px;
  height: 40px;
  background: var(--chat-primary);
  color: white;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.15s;
}
.ldv-chat-send:hover:not(:disabled) { background: var(--chat-primary-dark); transform: scale(1.05); }
.ldv-chat-send:disabled { opacity: 0.5; cursor: default; }
.ldv-chat-send svg { width: 18px; height: 18px; }

/* ── Footer ────────────────────────────────────────────────── */
.ldv-chat-footer {
  padding: 6px 16px 10px;
  background: var(--chat-bg);
  text-align: center;
}
.ldv-chat-footer a {
  font-size: 0.68rem;
  color: var(--chat-muted);
  text-decoration: none;
  opacity: 0.7;
}
.ldv-chat-footer a:hover { opacity: 1; }

/* ── Quick Replies ─────────────────────────────────────────── */
.ldv-quick-replies {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
  padding: 0 16px 12px;
  background: var(--chat-surface);
}
.ldv-quick-btn {
  background: white;
  border: 1px solid var(--chat-primary);
  color: var(--chat-primary);
  padding: 6px 14px;
  border-radius: 20px;
  font-size: 0.78rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
}
.ldv-quick-btn:hover { background: var(--chat-primary); color: white; }

/* ── Mobile ────────────────────────────────────────────────── */
@media (max-width: 480px) {
  .ldv-chat-window {
    width: calc(100vw - 20px);
    right: 10px;
    bottom: 90px;
    max-height: 70vh;
  }
  .ldv-chat-toggle { bottom: 80px; right: 20px; }
}
