/* ============================================================
   chat-widget.css — VERDE WIRE · Arlan AI Chat
   Dark red / maroon theme matching original design (image #3).
   Features: 2-ring pulse animation on launcher button.
   ============================================================ */

/* ---------- Design tokens ---------- */
:root {
  --vw-red: #8B1A1A;
  --vw-red-dark: #6B1212;
  --vw-red-darker: #4E0D0D;
  --vw-red-soft: rgba(139, 26, 26, .08);
  --vw-red-glow: rgba(139, 26, 26, .35);
  --vw-online: #22c55e;
  --vw-bg: #ffffff;
  --vw-bg-alt: #f8f6f5;
  --vw-card: #ffffff;
  --vw-fg: #1a1a1a;
  --vw-fg-light: #f5f5f5;
  --vw-muted: #7a7a7a;
  --vw-border: #eaeaea;
  --vw-shadow: 0 2px 12px rgba(0,0,0,.06);
  --vw-shadow-lg: 0 12px 40px rgba(0,0,0,.12);
  --vw-radius: 18px;
  --vw-radius-sm: 12px;
  --vw-font-head: "Space Grotesk", system-ui, sans-serif;
  --vw-font-body: "Plus Jakarta Sans", system-ui, sans-serif;
}

/* Inherit site variables when available */
.vw-chat-btn,
.vw-chat-panel {
  --vw-bg: var(--bg, #ffffff);
  --vw-bg-alt: var(--bg-alt, #f8f6f5);
  --vw-card: var(--card, #ffffff);
  --vw-fg: var(--fg, #1a1a1a);
  --vw-muted: var(--muted, #7a7a7a);
  --vw-border: var(--border, #eaeaea);
  --vw-radius: var(--radius, 18px);
  --vw-font-head: var(--font-head, "Space Grotesk", sans-serif);
  --vw-font-body: var(--font-body, "Plus Jakarta Sans", sans-serif);
}

/* ============================================================
   LAUNCHER BUTTON — dark red + 2-ring pulse animation
   ============================================================ */
.vw-chat-btn {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 9999;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  background: linear-gradient(145deg, #a52020, var(--vw-red));
  color: #fff;
  cursor: pointer;
  box-shadow: 0 6px 24px var(--vw-red-glow);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform .25s ease, box-shadow .25s ease;
}
.vw-chat-btn:hover {
  transform: translateY(-3px) scale(1.06);
  box-shadow: 0 10px 32px rgba(139, 26, 26, .5);
}
.vw-chat-btn:active { transform: scale(.96); }
.vw-chat-btn svg {
  width: 27px; height: 27px;
  position: relative; z-index: 2;
}

/* ---- Pulse rings (2 concentric expanding circles) ---- */
.vw-chat-btn::before,
.vw-chat-btn::after {
  content: '';
  position: absolute;
  top: 0; left: 0;
  width: 100%; height: 100%;
  border-radius: 50%;
  border: 2px solid var(--vw-red);
  opacity: 0;
  animation: vw-pulse-ring 2.4s ease-out infinite;
  pointer-events: none;
}
.vw-chat-btn::after {
  animation-delay: 1.2s;
}
@keyframes vw-pulse-ring {
  0% {
    transform: scale(1);
    opacity: .55;
  }
  80% {
    transform: scale(1.85);
    opacity: 0;
  }
  100% {
    transform: scale(1.85);
    opacity: 0;
  }
}

/* ============================================================
   PANEL
   ============================================================ */
.vw-chat-panel {
  position: fixed;
  bottom: 20px;
  right: 20px;
  z-index: 10000;
  width: 380px;
  max-width: calc(100vw - 40px);
  height: 560px;
  max-height: calc(100vh - 40px);
  background: var(--vw-card);
  border: none;
  border-radius: var(--vw-radius);
  box-shadow: var(--vw-shadow-lg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  font-family: var(--vw-font-body);
  color: var(--vw-fg);
}

/* ============================================================
   HEADER — solid dark red bar with avatar + online status
   ============================================================ */
.vw-chat-header {
  background: var(--vw-red);
  color: #fff;
  padding: 16px 18px;
  font-family: var(--vw-font-head);
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-radius: var(--vw-radius) var(--vw-radius) 0 0;
}
.vw-chat-header-left {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
}
/* Avatar circle */
.vw-avatar {
  width: 38px; height: 38px;
  border-radius: 50%;
  background: rgba(255,255,255,.15);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.vw-avatar svg { width: 20px; height: 20px; opacity: .9; }
/* Title block */
.vw-chat-title-block {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
}
#vw-chat-title {
  font-weight: 700;
  font-size: 14.5px;
  letter-spacing: .15px;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
/* Online status dot + text */
.vw-online-status {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 11.5px;
  font-weight: 500;
  opacity: .92;
}
.vw-online-dot {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--vw-online);
  box-shadow: 0 0 6px var(--vw-online);
  animation: vw-dot-pulse 2s ease-in-out infinite;
}
@keyframes vw-dot-pulse {
  0%, 100% { opacity: 1; box-shadow: 0 0 6px var(--vw-online); }
  50% { opacity: .55; box-shadow: 0 0 3px var(--vw-online); }
}
/* Close button */
.vw-chat-header button {
  background: rgba(255,255,255,.14);
  border: none;
  color: #fff;
  width: 30px; height: 30px;
  border-radius: 8px;
  font-size: 20px;
  cursor: pointer;
  line-height: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s;
  flex-shrink: 0;
  margin-left: 8px;
}
.vw-chat-header button:hover { background: rgba(255,255,255,.28); }

/* ============================================================
   BODY — message area
   ============================================================ */
#vw-chat-body {
  flex: 1;
  overflow-y: auto;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  background: var(--vw-bg-alt);
}
.vw-msg { max-width: 84%; position: relative; word-wrap: break-word; }
.vw-msg-left { align-self: flex-start; }
.vw-msg-right { align-self: flex-end; }
.vw-msg-txt {
  padding: 11px 15px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.58;
  word-break: break-word;
  box-shadow: var(--vw-shadow);
}
/* User bubble — dark red */
.vw-msg-user .vw-msg-txt {
  background: var(--vw-red);
  color: #fff;
  border-bottom-right-radius: 5px;
}
/* Bot/AI bubble — white */
.vw-msg-bot .vw-msg-txt {
  background: var(--vw-card);
  color: var(--vw-fg);
  border: 1px solid var(--vw-border);
  border-bottom-left-radius: 5px;
}
/* System messages */
.vw-msg-system {
  align-self: center;
  font-size: 11.5px;
  color: var(--vw-muted);
  padding: 5px 14px;
  background: var(--vw-card);
  border: 1px solid var(--vw-border);
  border-radius: 999px;
  max-width: 90%;
  text-align: center;
}

/* ============================================================
   TYPING INDICATOR
   ============================================================ */
.vw-typing {
  display: flex;
  gap: 5px;
  padding: 11px 15px;
  align-self: flex-start;
  background: var(--vw-card);
  border: 1px solid var(--vw-border);
  border-bottom-left-radius: 5px;
  border-radius: 16px;
  box-shadow: var(--vw-shadow);
}
.vw-typing span {
  width: 7px; height: 7px;
  border-radius: 50%;
  background: var(--vw-muted);
  opacity: .5;
  animation: vw-bounce 1.3s infinite;
}
.vw-typing span:nth-child(2) { animation-delay: .18s; }
.vw-typing span:nth-child(3) { animation-delay: .36s; }
@keyframes vw-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: .35; }
  40% { transform: translateY(-6px); opacity: 1; }
}

/* ============================================================
   INPUT BAR
   ============================================================ */
.vw-chat-input {
  display: flex;
  padding: 12px 14px;
  gap: 8px;
  border-top: 1px solid var(--vw-border);
  background: var(--vw-card);
  border-radius: 0 0 var(--vw-radius) var(--vw-radius);
}
.vw-chat-input textarea {
  flex: 1;
  border: 1px solid var(--vw-border);
  border-radius: 999px;
  padding: 10px 16px;
  font-size: 13.5px;
  resize: none;
  outline: none;
  font-family: var(--vw-font-body);
  background: var(--vw-bg);
  color: var(--vw-fg);
  transition: border-color .18s, box-shadow .18s;
  line-height: 1.4;
  max-height: 80px;
}
.vw-chat-input textarea:focus {
  border-color: var(--vw-red);
  box-shadow: 0 0 0 3px var(--vw-red-soft);
}
.vw-chat-input textarea::placeholder { color: var(--vw-muted); }
/* Send button — dark red circle */
.vw-chat-input button {
  background: var(--vw-red);
  color: #fff;
  border: none;
  border-radius: 50%;
  width: 42px; height: 42px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .18s, transform .18s;
  flex-shrink: 0;
}
.vw-chat-input button:hover {
  background: var(--vw-red-dark);
  transform: translateY(-1px);
}
.vw-chat-input button:active { transform: scale(.93); }
.vw-chat-input button svg { width: 19px; height: 19px; }

/* ============================================================
   LEAD FORM
   ============================================================ */
#vw-chat-leadform {
  border-top: 1px solid var(--vw-border);
  padding: 14px 16px;
  background: var(--vw-card);
}
.vw-leadform { position: relative; }
.vw-leadform h4 {
  font-family: var(--vw-font-head);
  font-size: 13.5px;
  margin: 0 0 10px;
  color: var(--vw-fg);
}
.vw-leadform input,
.vw-leadform textarea {
  width: 100%;
  box-sizing: border-box;
  padding: 9px 12px;
  margin-bottom: 8px;
  border: 1px solid var(--vw-border);
  border-radius: 10px;
  font-size: 13px;
  font-family: var(--vw-font-body);
  background: var(--vw-bg);
  color: var(--vw-fg);
  outline: none;
  transition: border-color .18s, box-shadow .18s;
}
.vw-leadform input:focus,
.vw-leadform textarea:focus {
  border-color: var(--vw-red);
  box-shadow: 0 0 0 3px var(--vw-red-soft);
}
.vw-leadform button[type=submit] {
  width: 100%;
  padding: 10px;
  background: var(--vw-red);
  color: #fff;
  border: none;
  border-radius: 999px;
  cursor: pointer;
  font-family: var(--vw-font-head);
  font-weight: 600;
  font-size: 13.5px;
  transition: background .18s;
}
.vw-leadform button[type=submit]:hover { background: var(--vw-red-dark); }
.vw-lead-close {
  position: absolute;
  top: -10px; right: -6px;
  background: none;
  border: none;
  font-size: 20px;
  cursor: pointer;
  color: var(--vw-muted);
  line-height: 1;
}

/* ============================================================
   SCROLLBAR
   ============================================================ */
#vw-chat-body::-webkit-scrollbar { width: 5px; }
#vw-chat-body::-webkit-scrollbar-track { background: transparent; }
#vw-chat-body::-webkit-scrollbar-thumb {
  background: var(--vw-border);
  border-radius: 5px;
}
#vw-chat-body::-webkit-scrollbar-thumb:hover { background: var(--vw-muted); }

/* ============================================================
   DARK THEME — follows [data-theme="dark"]
   ============================================================ */
[data-theme="dark"] .vw-chat-panel {
  --vw-bg: #111;
  --vw-bg-alt: #0d0b0b;
  --vw-card: #181414;
  --vw-fg: #edebeb;
  --vw-muted: #888;
  --vw-border: #2a2323;
  --vw-red-soft: rgba(139, 26, 26, .18);
  --vw-shadow: 0 2px 12px rgba(0,0,0,.25);
  --vw-shadow-lg: 0 12px 40px rgba(0,0,0,.4);
}
[data-theme="dark"] .vw-msg-bot .vw-msg-txt {
  background: #222;
  border-color: #333;
  color: #edebeb;
}
[data-theme="dark"] .vw-msg-system {
  background: #1a1616;
  border-color: #2a2323;
}
[data-theme="dark"] .vw-chat-input textarea,
[data-theme="dark"] .vw-leadform input,
[data-theme="dark"] .vw-leadform textarea { background: #111; }

@media (prefers-color-scheme: dark) {
  html:not([data-theme="light"]) .vw-chat-panel {
    --vw-bg: #111;
    --vw-bg-alt: #0d0b0b;
    --vw-card: #181414;
    --vw-fg: #edebeb;
    --vw-muted: #888;
    --vw-border: #2a2323;
    --vw-red-soft: rgba(139, 26, 26, .18);
    --vw-shadow: 0 2px 12px rgba(0,0,0,.25);
    --vw-shadow-lg: 0 12px 40px rgba(0,0,0,.4);
  }
  html:not([data-theme="light"]) .vw-msg-bot .vw-msg-txt {
    background: #222; border-color: #333; color: #edebeb;
  }
  html:not([data-theme="light"]) .vw-msg-system {
    background: #1a1616; border-color: #2a2323;
  }
  html:not([data-theme="light"]) .vw-chat-input textarea,
  html:not([data-theme="light"]) .vw-leadform input,
  html:not([data-theme="light"]) .vw-leadform textarea { background: #111; }
}

/* ============================================================
   MOBILE ADJUSTMENTS
   ============================================================ */
@media (max-width: 480px) {
  .vw-chat-panel {
    bottom: 0; right: 0;
    width: 100vw; max-width: 100vw;
    height: 100vh; max-height: 100vh;
    border-radius: 0;
  }
  .vw-chat-header { border-radius: 0; }
  .vw-chat-btn { bottom: 18px; right: 16px; width: 54px; height: 54px; }
}
