/* ══ Root ══════════════════════════════════════════════════ */
:root{
  --vago-primary:#6c5ce7;
  --vago-accent:#9b8bfa;
}
#jv-root {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2147483646;
  font-family: -apple-system, BlinkMacSystemFont, 'DM Sans', 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
}
*{box-sizing:border-box}

/* ══ Launcher ══════════════════════════════════════════════ */
#jv-btn {
  width: 62px;
  height: 62px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--vago-accent), var(--vago-primary));
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow: 0 4px 20px rgba(108,92,231,.35), 0 2px 8px rgba(0,0,0,.15);
  transition: opacity .2s, transform .2s;
  position: relative;
  outline: none;
}
#jv-btn:hover { opacity: .92; transform: scale(1.06); }

#jv-badge {
  position: absolute;
  top: 0;
  right: 0;
  min-width: 20px;
  height: 20px;
  background: #e53935;
  color: #fff;
  border-radius: 999px;
  font-size: 11px;
  font-weight: 700;
  border: 2px solid #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 4px;
  box-sizing: border-box;
}

/* ══ Window ════════════════════════════════════════════════ */
#jv-win {
  position: absolute;
  bottom: 74px;
  right: 0;
  width: 370px;
  height: 530px;
  background: #fff;
  border-radius: 18px;
  box-shadow: 0 12px 48px rgba(0,0,0,.18), 0 4px 16px rgba(0,0,0,.1);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* Hidden state */
  opacity: 0;
  transform: scale(.94) translateY(12px);
  pointer-events: none;
  transition: opacity .22s ease, transform .22s ease;
}
#jv-win.jv-open {
  opacity: 1;
  transform: scale(1) translateY(0);
  pointer-events: all;
}
#jv-win.jv-drag-over::after{
  content:'Drop image to send'; position:absolute; inset:10px; z-index:20;
  display:flex; align-items:center; justify-content:center; text-align:center;
  background:rgba(255,255,255,.94); border:2px dashed var(--vago-accent); border-radius:16px;
  color:var(--vago-primary); font-weight:700; font-size:14px; pointer-events:none;
}

/* ══ Header ════════════════════════════════════════════════ */
.jv-hd {
  background: #1a1614;
  padding: 16px 16px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
#jv-x-btn {
  background: rgba(255,255,255,.12);
  border: none;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  color: rgba(255,255,255,.8);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background .15s;
  order: 3;
  margin-left: auto;
}
#jv-x-btn:hover { background: rgba(255,255,255,.22); color: #fff; }

.jv-hd-av-wrap {
  position: relative;
  flex-shrink: 0;
}
.jv-hd-img {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255,255,255,.25);
  display: block;
}
.jv-hd-init {
  width: 46px;
  height: 46px;
  border-radius: 50%;
  background: var(--vago-primary);
  border: 2px solid rgba(255,255,255,.25);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 20px;
  font-weight: 700;
  color: #fff;
}
.jv-online-dot {
  position: absolute;
  bottom: 1px;
  right: 1px;
  width: 12px;
  height: 12px;
  background: #4ade80;
  border-radius: 50%;
  border: 2px solid #1a1614;
}
.jv-hd-meta { flex: 1; min-width: 0; }
.jv-hd-name {
  font-size: 15px;
  font-weight: 700;
  color: #fff;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.jv-hd-title {
  font-size: 12px;
  color: rgba(255,255,255,.6);
  margin-top: 2px;
}

/* ══ Messages ══════════════════════════════════════════════ */
#jv-msgs {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px 8px;
  background: #f7f5f2;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
#jv-msgs::-webkit-scrollbar { width: 4px; }
#jv-msgs::-webkit-scrollbar-thumb { background: #ddd; border-radius: 2px; }

/* Message bubbles */
.jv-msg {
  display: flex;
  flex-direction: column;
  max-width: 78%;
  animation: jvMsgIn .18s ease both;
}
@keyframes jvMsgIn {
  from { opacity:0; transform:translateY(6px); }
  to   { opacity:1; transform:none; }
}
.jv-msg-text {
  padding: 10px 14px;
  border-radius: 18px;
  font-size: 13.5px;
  line-height: 1.55;
  word-break: break-word;
  white-space: pre-wrap;
}
.jv-msg-time {
  font-size: 10px;
  color: #aaa;
  margin-top: 4px;
}
.jv-msg-img {
  max-width: 100%;
  border-radius: 12px;
  display: block;
  cursor: pointer;
}
.jv-msg-file {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 13px;
  text-decoration: none;
  font-weight: 500;
}

/* Agent messages (left) */
.jv-msg.jv-agent {
  align-self: flex-start;
  align-items: flex-start;
}
.jv-msg.jv-agent .jv-msg-text {
  background: #fff;
  color: #1a1614;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}
.jv-msg.jv-agent .jv-msg-file { color: #1a1614; }

/* Visitor messages (right) */
.jv-msg.jv-visitor {
  align-self: flex-end;
  align-items: flex-end;
}
.jv-msg.jv-visitor .jv-msg-text {
  background: var(--vago-primary);
  color: #fff;
  border-bottom-right-radius: 4px;
}
.jv-msg.jv-visitor .jv-msg-file { color: #fff; }
.jv-msg.jv-visitor .jv-msg-time { text-align: right; }

/* System messages */
.jv-msg.jv-system {
  align-self: center;
  max-width: 90%;
}
.jv-msg.jv-system .jv-msg-text {
  background: transparent;
  color: #aaa;
  font-size: 11px;
  font-style: italic;
  padding: 2px 0;
  box-shadow: none;
}

/* Agent avatar in messages */
.jv-msg-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.jv-msg-av {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex-shrink: 0;
  overflow: hidden;
  background: var(--vago-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 12px;
  font-weight: 700;
  color: #fff;
}
.jv-msg-av img { width: 100%; height: 100%; object-fit: cover; }

/* ══ Quick replies ══════════════════════════════════════════ */
#jv-qr {
  padding: 4px 14px 10px;
  background: #f7f5f2;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  flex-shrink: 0;
}
.jv-qr-btn {
  background: #fff;
  border: 1.5px solid var(--vago-primary);
  color: var(--vago-primary);
  padding: 8px 15px;
  border-radius: 999px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  font-family: inherit;
  transition: all .15s;
  animation: jvMsgIn .25s ease both;
}
.jv-qr-btn:hover { background: var(--vago-primary); color: #fff; }

/* ══ Typing indicator ══════════════════════════════════════ */
#jv-typing {
  padding: 0 14px 10px;
  background: #f7f5f2;
  flex-shrink: 0;
}
.jv-typing-bbl {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #fff;
  padding: 10px 14px;
  border-radius: 18px;
  border-bottom-left-radius: 4px;
  box-shadow: 0 1px 4px rgba(0,0,0,.08);
}
.jv-td {
  width: 7px;
  height: 7px;
  background: #ccc;
  border-radius: 50%;
  animation: jvTd 1.4s infinite;
}
.jv-td:nth-child(2) { animation-delay: .2s; }
.jv-td:nth-child(3) { animation-delay: .4s; }
@keyframes jvTd {
  0%,60%,100% { transform:translateY(0); background:#ccc; }
  30%          { transform:translateY(-5px); background:var(--vago-primary); }
}

/* ══ Ended bar ═════════════════════════════════════════════ */
#jv-ended {
  padding: 12px 14px;
  background: #fff8f6;
  border-top: 1px solid #f0e8e4;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 8px;
}
#jv-ended > span { font-size: 12px; color: #888; }
.jv-rate-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 12px;
  color: #888;
}
.jv-rate-btn {
  background: #fff;
  border: 1px solid #e0d8d4;
  border-radius: 8px;
  padding: 4px 12px;
  cursor: pointer;
  font-size: 16px;
  transition: all .12s;
}
.jv-rate-btn:hover, .jv-rate-btn.chosen { background: var(--vago-primary); border-color: var(--vago-primary); }
#jv-reconnect {
  background: var(--vago-primary);
  color: #fff;
  border: none;
  padding: 8px 16px;
  border-radius: 999px;
  font-size: 12px;
  font-weight: 700;
  cursor: pointer;
  font-family: inherit;
  align-self: flex-start;
  transition: background .12s;
}
#jv-reconnect:hover { background: var(--vago-accent); }

/* ══ Emoji picker ══════════════════════════════════════════ */
#jv-ep {
  position: absolute;
  bottom: 60px;
  left: 10px;
  right: 10px;
  background: #fff;
  border: 1px solid #e8e2dc;
  border-radius: 12px;
  box-shadow: 0 4px 20px rgba(0,0,0,.12);
  padding: 10px;
  display: none;
  flex-wrap: wrap;
  gap: 4px;
  max-height: 200px;
  overflow-y: auto;
  z-index: 10;
}
#jv-ep button {
  background: none;
  border: none;
  font-size: 22px;
  cursor: pointer;
  width: 36px;
  height: 36px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .1s;
}
#jv-ep button:hover { background: #f0ebe7; }

/* ══ Footer ════════════════════════════════════════════════ */
.jv-ft {
  background: #fff;
  border-top: 1px solid #f0ebe7;
  flex-shrink: 0;
  padding: 10px 12px 10px;
}
#jv-inp {
  width: 100%;
  border: none;
  outline: none;
  font-size: 14px;
  font-family: inherit;
  color: #1a1614;
  background: transparent;
  padding: 4px 0 8px;
  line-height: 1.4;
  resize: none;
  display: block;
}
#jv-inp::placeholder { color: #bbb; }
.jv-ft-row {
  display: flex;
  align-items: center;
  gap: 6px;
  border-top: 1px solid #f5f0ec;
  padding-top: 8px;
}
.jv-ft-ico {
  background: none;
  border: none;
  color: #b0a89e;
  cursor: pointer;
  padding: 4px;
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .12s, color .12s;
}
.jv-ft-ico:hover { background: #f5f0ec; color: var(--vago-primary); }
.jv-send-btn {
  margin-left: auto;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  background: var(--vago-primary);
  border: none;
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, transform .1s;
  flex-shrink: 0;
}
.jv-send-btn:hover { background: var(--vago-accent); }
.jv-send-btn:active { transform: scale(.88); }

/* ══ Product / checkout action cards (sales quick-actions) ══ */
.jv-msg-product{background:#fff!important;box-shadow:0 1px 4px rgba(0,0,0,.08);padding:0!important;overflow:hidden;width:180px}
.jv-product-thumb{width:100%;height:100px;object-fit:cover;display:block;background:#f5f0ec}
.jv-product-name{font-size:12.5px;font-weight:700;color:#1a1614;padding:10px 12px 2px;
  overflow:hidden;text-overflow:ellipsis;display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical}
.jv-product-price{font-size:12px;color:var(--vago-primary);font-weight:700;padding:0 12px 10px}
.jv-product-btn{display:block;margin:0 12px 12px;text-align:center;background:linear-gradient(135deg,var(--vago-accent),var(--vago-primary));
  color:#fff!important;text-decoration:none!important;padding:7px 10px;border-radius:8px;font-size:12px;font-weight:700}

/* ══ Mobile: full-screen app-like window ══════════════════ */
@media (max-width: 480px) {
  #jv-root { right: 12px; bottom: max(16px, env(safe-area-inset-bottom)); }
  #jv-win {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    top: 0;
    width: auto;
    height: auto;
    border-radius: 0;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
  }
  #jv-btn { bottom: env(safe-area-inset-bottom); }
  /* The chat window goes full-screen at this width and already has its own
     close button (#jv-x-btn) in the header — without this, the floating
     launcher stays pinned on top of the footer controls and overlaps the
     send button, especially once the keyboard shifts the fixed viewport. */
  #jv-win.jv-open ~ #jv-btn { display: none; }

  /* iOS zooms the viewport when a focused input's font-size is under 16px. */
  #jv-inp { font-size: 16px; }
}

/* Remove the default mobile-browser tap highlight / focus ring — the
   widget already shows its own hover/active states. */
button,input,a{-webkit-tap-highlight-color:transparent}
button:focus,input:focus{outline:none}
button:focus-visible{outline:2px solid var(--vago-accent);outline-offset:2px}
