/* =============================================================
   Jivaha Demo Widget — modal + chat UI
   Self-contained styles. Uses .jvd- prefix to avoid collisions
   with existing page namespaces (ln-, vf-, cb-, va-, s-).
   ============================================================= */

.jvd-root {
  position: fixed; inset: 0; z-index: 10000;
  display: none; align-items: center; justify-content: center;
  font-family: 'DM Sans', system-ui, -apple-system, sans-serif;
  -webkit-font-smoothing: antialiased;
}
.jvd-root.is-open { display: flex; }

body.jvd-locked { overflow: hidden; }

.jvd-backdrop {
  position: absolute; inset: 0;
  background: rgba(2, 1, 12, 0.78);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  animation: jvdFadeIn .25s ease-out;
}
@keyframes jvdFadeIn { from { opacity: 0; } to { opacity: 1; } }
@keyframes jvdSlideUp {
  from { opacity: 0; transform: translateY(20px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.jvd-modal {
  position: relative; z-index: 1;
  width: min(640px, calc(100vw - 32px));
  max-height: min(720px, calc(100vh - 48px));
  display: flex; flex-direction: column;
  background: linear-gradient(160deg, rgba(20,16,40,0.96) 0%, rgba(10,8,22,0.98) 100%);
  border: 1px solid rgba(167,139,250,0.18);
  border-radius: 20px;
  box-shadow:
    0 40px 100px rgba(0,0,0,0.6),
    0 0 80px rgba(167,139,250,0.08),
    inset 0 1px 0 rgba(255,255,255,0.06);
  overflow: hidden;
  animation: jvdSlideUp .35s cubic-bezier(0.16,1,0.3,1);
}

/* ---------- Header ---------- */
.jvd-head {
  display: flex; align-items: center; justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid rgba(167,139,250,0.1);
  flex-shrink: 0;
}
.jvd-head-brand { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.jvd-head-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #22c55e; box-shadow: 0 0 10px rgba(34,197,94,0.7);
  animation: jvdPulse 1.8s ease-in-out infinite;
}
@keyframes jvdPulse { 0%,100% { opacity: 1; } 50% { opacity: 0.4; } }
.jvd-head-title { font-size: 14px; font-weight: 700; color: white; letter-spacing: -0.01em; }
.jvd-head-sub   { font-size: 11px; color: rgba(255,255,255,0.4); margin-left: 4px; }
.jvd-close {
  background: rgba(255,255,255,0.05); color: rgba(255,255,255,0.7);
  border: 1px solid rgba(255,255,255,0.08); border-radius: 50%;
  width: 32px; height: 32px;
  font-size: 22px; line-height: 1; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  transition: all .2s ease;
}
.jvd-close:hover { background: rgba(255,255,255,0.1); color: white; border-color: rgba(255,255,255,0.18); }

/* ---------- Body ---------- */
.jvd-body { flex: 1; min-height: 0; display: flex; flex-direction: column; overflow: hidden; }
.jvd-pane { padding: 24px; overflow-y: auto; flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* ---------- Lead form ---------- */
.jvd-step  { margin-bottom: 18px; }
.jvd-h     { font-family: 'Inter', sans-serif; font-size: 22px; font-weight: 800; color: white; letter-spacing: -0.02em; line-height: 1.15; }
.jvd-p     { font-size: 14px; color: rgba(255,255,255,0.55); line-height: 1.6; margin-top: 6px; }

.jvd-field-label {
  display: block; font-size: 11px; font-weight: 600;
  text-transform: uppercase; letter-spacing: 1.2px;
  color: rgba(196,181,253,0.85); margin-bottom: 8px;
}

.jvd-ind-grid {
  display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; margin-bottom: 4px;
}
.jvd-ind {
  display: flex; flex-direction: column; align-items: flex-start; gap: 6px;
  padding: 14px 14px;
  background: rgba(255,255,255,0.03);
  border: 1px solid rgba(255,255,255,0.07);
  border-radius: 12px;
  cursor: pointer; text-align: left;
  font-family: inherit; color: white;
  transition: all .2s ease;
}
.jvd-ind:hover { background: rgba(167,139,250,0.06); border-color: rgba(167,139,250,0.25); }
.jvd-ind.is-active {
  background: rgba(167,139,250,0.12);
  border-color: rgba(167,139,250,0.45);
  box-shadow: 0 0 24px rgba(167,139,250,0.12);
}
.jvd-ind-icon {
  width: 30px; height: 30px; border-radius: 8px;
  background: rgba(167,139,250,0.1);
  display: flex; align-items: center; justify-content: center;
  color: #c4b5fd;
}
.jvd-ind-icon svg { width: 16px; height: 16px; }
.jvd-ind-label { font-size: 14px; font-weight: 700; color: white; }
.jvd-ind-desc  { font-size: 11px; color: rgba(255,255,255,0.4); }

.jvd-form { margin-top: 18px; display: flex; flex-direction: column; gap: 14px; }
.jvd-field { display: flex; flex-direction: column; }
.jvd-field input {
  width: 100%; padding: 11px 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  color: white; font-size: 14px; font-family: inherit;
  transition: border-color .2s, background .2s;
}
.jvd-field input::placeholder { color: rgba(255,255,255,0.3); }
.jvd-field input:focus {
  outline: none;
  border-color: rgba(167,139,250,0.5);
  background: rgba(255,255,255,0.06);
}

.jvd-err {
  font-size: 11px; color: #fca5a5; margin-top: 4px; min-height: 14px;
}

.jvd-actions {
  display: flex; gap: 10px; margin-top: 6px; justify-content: flex-end;
}
.jvd-btn {
  display: inline-flex; align-items: center; gap: 8px;
  padding: 11px 22px; border-radius: 10px;
  font-family: inherit; font-size: 14px; font-weight: 600;
  cursor: pointer; border: none; text-decoration: none;
  transition: all .25s cubic-bezier(0.16,1,0.3,1);
}
.jvd-btn-primary {
  background: linear-gradient(135deg, #a78bfa, #8b5cf6); color: white;
  box-shadow: 0 6px 22px rgba(139,92,246,0.35);
}
.jvd-btn-primary:hover { transform: translateY(-1px); box-shadow: 0 10px 32px rgba(139,92,246,0.5); }
.jvd-btn-primary:disabled { opacity: 0.6; cursor: wait; transform: none; }
.jvd-btn-ghost {
  background: rgba(255,255,255,0.04); color: rgba(255,255,255,0.85);
  border: 1px solid rgba(255,255,255,0.1);
}
.jvd-btn-ghost:hover { background: rgba(255,255,255,0.08); border-color: rgba(255,255,255,0.2); }

.jvd-fineprint { font-size: 11px; color: rgba(255,255,255,0.3); margin-top: 16px; line-height: 1.5; }

/* ---------- Chat ---------- */
.jvd-chat { padding: 0; }
.jvd-chat-topbar {
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 18px; border-bottom: 1px solid rgba(167,139,250,0.1);
  background: rgba(167,139,250,0.04);
}
.jvd-chat-meta { display: flex; align-items: center; gap: 10px; }
.jvd-chat-ind-icon {
  width: 28px; height: 28px; border-radius: 8px;
  background: rgba(167,139,250,0.12);
  display: flex; align-items: center; justify-content: center; color: #c4b5fd;
}
.jvd-chat-ind-icon svg { width: 14px; height: 14px; }
.jvd-chat-ind-name { font-size: 13px; font-weight: 700; color: white; }
.jvd-chat-status {
  display: inline-flex; align-items: center; gap: 5px;
  padding: 3px 9px; border-radius: 999px;
  background: rgba(34,197,94,0.1); border: 1px solid rgba(34,197,94,0.25);
  font-size: 10px; font-weight: 600; color: rgba(134,239,172,0.95); text-transform: uppercase; letter-spacing: 1px;
}
.jvd-chat-live-dot { width: 5px; height: 5px; background: #22c55e; border-radius: 50%; animation: jvdPulse 1.5s ease-in-out infinite; }
.jvd-chat-end {
  background: transparent; color: rgba(255,255,255,0.5);
  border: 1px solid rgba(255,255,255,0.1); border-radius: 8px;
  padding: 6px 12px; font-size: 12px; font-weight: 600; cursor: pointer; font-family: inherit;
  transition: all .2s ease;
}
.jvd-chat-end:hover { color: #fca5a5; border-color: rgba(252,165,165,0.3); background: rgba(252,165,165,0.05); }

.jvd-transcript {
  flex: 1; min-height: 240px; max-height: 480px;
  overflow-y: auto; padding: 18px 18px 12px;
  display: flex; flex-direction: column; gap: 8px;
  scroll-behavior: smooth;
}
.jvd-transcript::-webkit-scrollbar { width: 6px; }
.jvd-transcript::-webkit-scrollbar-thumb { background: rgba(167,139,250,0.2); border-radius: 6px; }

.jvd-bubble {
  max-width: 82%;
  padding: 10px 14px; border-radius: 14px;
  font-size: 13.5px; line-height: 1.55;
  word-wrap: break-word; overflow-wrap: break-word;
  animation: jvdBubbleIn .35s cubic-bezier(0.16,1,0.3,1);
}
@keyframes jvdBubbleIn { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: translateY(0); } }
.jvd-bubble strong { font-weight: 700; color: white; }
.jvd-bubble em     { font-style: italic; }
.jvd-bubble a      { color: #c4b5fd; text-decoration: underline; word-break: break-all; }
.jvd-bubble ul     { margin: 6px 0 6px 16px; padding: 0; }
.jvd-bubble li     { margin: 2px 0; list-style: disc; }

.jvd-bubble.jvd-user {
  align-self: flex-end;
  background: linear-gradient(135deg, rgba(167,139,250,0.32), rgba(139,92,246,0.18));
  border: 1px solid rgba(167,139,250,0.28);
  color: rgba(255,255,255,0.95);
  border-bottom-right-radius: 4px;
}
.jvd-bubble.jvd-bot {
  align-self: flex-start;
  background: rgba(255,255,255,0.05);
  border: 1px solid rgba(255,255,255,0.07);
  color: rgba(255,255,255,0.85);
  border-bottom-left-radius: 4px;
}

.jvd-typing {
  display: flex; align-items: center; gap: 5px;
  padding: 0 22px 8px;
  font-size: 11px; color: rgba(196,181,253,0.7);
}
.jvd-typing .d {
  width: 5px; height: 5px; background: rgba(196,181,253,0.7); border-radius: 50%;
  animation: jvdTyping 1.4s ease-in-out infinite;
}
.jvd-typing .d:nth-child(2) { animation-delay: .2s; }
.jvd-typing .d:nth-child(3) { animation-delay: .4s; }
.jvd-typing .t { margin-left: 6px; }
@keyframes jvdTyping {
  0%,60%,100% { transform: translateY(0); opacity: .4; }
  30%         { transform: translateY(-3px); opacity: 1; }
}

.jvd-input-row {
  display: flex; gap: 8px; align-items: center;
  padding: 14px 18px;
  border-top: 1px solid rgba(167,139,250,0.1);
  background: rgba(167,139,250,0.03);
}
.jvd-input {
  flex: 1; min-width: 0;
  padding: 11px 14px;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 10px;
  color: white; font-size: 14px; font-family: inherit;
}
.jvd-input::placeholder { color: rgba(255,255,255,0.3); }
.jvd-input:focus {
  outline: none;
  border-color: rgba(167,139,250,0.5);
  background: rgba(255,255,255,0.06);
}
.jvd-send {
  flex-shrink: 0; width: 42px; height: 42px;
  border-radius: 10px; border: none; cursor: pointer;
  background: linear-gradient(135deg, #a78bfa, #8b5cf6); color: white;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 4px 14px rgba(139,92,246,0.35);
  transition: all .2s ease;
}
.jvd-send:hover { transform: translateY(-1px); box-shadow: 0 6px 18px rgba(139,92,246,0.5); }
.jvd-send:disabled { opacity: 0.5; cursor: wait; transform: none; }

/* ---------- Ended / Limit ---------- */
.jvd-ended, .jvd-limit { text-align: center; padding: 40px 28px; align-items: center; gap: 14px; }
.jvd-ended .jvd-actions, .jvd-limit-actions { justify-content: center; margin-top: 14px; }
.jvd-limit-icon { color: rgba(252,211,77,0.85); margin-bottom: 6px; }
.jvd-limit-title { font-family: 'Inter', sans-serif; font-size: 22px; font-weight: 800; color: white; letter-spacing: -0.02em; }
.jvd-limit-msg   { font-size: 14px; color: rgba(255,255,255,0.6); line-height: 1.6; max-width: 420px; margin: 0 auto; }

/* ---------- Mobile ---------- */
@media (max-width: 600px) {
  .jvd-modal {
    width: 100vw; max-height: 100vh; height: 100vh;
    border-radius: 0; border: none;
  }
  .jvd-pane { padding: 18px; }
  .jvd-ind-grid { grid-template-columns: 1fr; }
  .jvd-h { font-size: 20px; }
  .jvd-actions { flex-direction: column-reverse; }
  .jvd-actions .jvd-btn { width: 100%; justify-content: center; }
  .jvd-transcript { padding: 14px; }
  .jvd-input-row { padding: 12px 14px; }
}

/* ---------- Light theme (matches index.html theme toggle) ---------- */
[data-theme="light"] .jvd-backdrop { background: rgba(15,10,31,0.55); }
[data-theme="light"] .jvd-modal {
  background: linear-gradient(160deg, #ffffff 0%, #f5f3ff 100%);
  border-color: rgba(167,139,250,0.3);
  box-shadow: 0 40px 100px rgba(15,10,31,0.18), 0 0 60px rgba(167,139,250,0.12);
}
[data-theme="light"] .jvd-head { border-bottom-color: rgba(15,10,31,0.08); }
[data-theme="light"] .jvd-head-title { color: #0f0a1f; }
[data-theme="light"] .jvd-head-sub   { color: rgba(15,10,31,0.5); }
[data-theme="light"] .jvd-close { background: rgba(15,10,31,0.04); color: rgba(15,10,31,0.7); border-color: rgba(15,10,31,0.1); }
[data-theme="light"] .jvd-close:hover { background: rgba(15,10,31,0.08); color: #0f0a1f; }
[data-theme="light"] .jvd-h, [data-theme="light"] .jvd-limit-title, [data-theme="light"] .jvd-ind-label, [data-theme="light"] .jvd-chat-ind-name { color: #0f0a1f; }
[data-theme="light"] .jvd-p, [data-theme="light"] .jvd-limit-msg { color: rgba(15,10,31,0.6); }
[data-theme="light"] .jvd-field-label { color: rgba(124,58,237,0.95); }
[data-theme="light"] .jvd-ind { background: rgba(15,10,31,0.02); border-color: rgba(15,10,31,0.08); color: #0f0a1f; }
[data-theme="light"] .jvd-ind:hover { background: rgba(167,139,250,0.08); border-color: rgba(167,139,250,0.4); }
[data-theme="light"] .jvd-ind.is-active { background: rgba(167,139,250,0.14); border-color: rgba(124,58,237,0.5); }
[data-theme="light"] .jvd-ind-desc { color: rgba(15,10,31,0.5); }
[data-theme="light"] .jvd-field input, [data-theme="light"] .jvd-input {
  background: white; border-color: rgba(15,10,31,0.12); color: #0f0a1f;
}
[data-theme="light"] .jvd-field input::placeholder, [data-theme="light"] .jvd-input::placeholder { color: rgba(15,10,31,0.35); }
[data-theme="light"] .jvd-btn-ghost { background: rgba(15,10,31,0.04); color: rgba(15,10,31,0.85); border-color: rgba(15,10,31,0.12); }
[data-theme="light"] .jvd-btn-ghost:hover { background: rgba(15,10,31,0.08); }
[data-theme="light"] .jvd-fineprint { color: rgba(15,10,31,0.4); }
[data-theme="light"] .jvd-chat-topbar { background: rgba(167,139,250,0.06); border-bottom-color: rgba(15,10,31,0.08); }
[data-theme="light"] .jvd-bubble.jvd-bot { background: rgba(15,10,31,0.04); border-color: rgba(15,10,31,0.08); color: rgba(15,10,31,0.85); }
[data-theme="light"] .jvd-bubble.jvd-bot strong { color: #0f0a1f; }
[data-theme="light"] .jvd-bubble.jvd-user { color: white; }
[data-theme="light"] .jvd-input-row { background: rgba(167,139,250,0.04); border-top-color: rgba(15,10,31,0.08); }
[data-theme="light"] .jvd-chat-end { color: rgba(15,10,31,0.55); border-color: rgba(15,10,31,0.12); }
