/* VOW AI Support — Frontend Chat Widget */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:ital,opsz,wght@0,9..40,100..1000;1,9..40,100..1000&family=Inter:ital,opsz,wght@0,14..32,100..900;1,14..32,100..900&family=Playfair+Display:ital,wght@0,400..900;1,400..900&display=swap');

:root {
  --vow-gradient: linear-gradient(to right, #C0D85B, #4A9EBF);
  --vow-lime: #C0D85B;
  --vow-lime-dim: #C0D85B33;
  --vow-bg:    #ffffff;
  --vow-card:  #f8fafc;
  --vow-border:#e2e8f0;
  --vow-text:  #0f172a;
  --vow-text-light: #ffffff;
  --vow-muted: #64748b;
  --vow-radius: 16px;
  --vow-accent: var(--vow-lime, #C0D85B);
  --vow-font-heading: 'Playfair Display', serif;
  --vow-font-sans: 'Inter', 'DM Sans', sans-serif;
  --vow-shadow: 0 12px 40px rgba(0,0,0,0.12);
}

@media (prefers-color-scheme: dark) {
  :root {
    --vow-bg:    #0f1117;
    --vow-card:  #1a1d23;
    --vow-border:#2a2d35;
    --vow-text:  #e2e8f0;
    --vow-text-light: #ffffff;
    --vow-muted: #94a3b8;
    --vow-lime-dim: #84cc1640;
    --vow-shadow: 0 24px 80px rgba(0,0,0,0.6);
  }
}

/* Dynamic accent injection via JS */
[data-vow-accent] { --vow-accent: attr(data-vow-accent); }

/* ── Reset ──────────────────────────────────────────────────────────────── */
.vow-ai-root *, .vow-ai-root *::before, .vow-ai-root *::after {
  box-sizing: border-box; margin: 0; padding: 0;
}

/* ── Widget container (floating) ────────────────────────────────────────── */
#vow-ai-widget { position: fixed; z-index: 9998; font-family: var(--vow-font-sans); }
#vow-ai-widget[data-position="bottom-right"] { right: 24px; bottom: 24px; }
#vow-ai-widget[data-position="bottom-left"]  { left:  24px; bottom: 24px; }

/* ── Trigger button ─────────────────────────────────────────────────────── */
.vow-trigger-btn {
  width: 60px; height: 60px;
  border-radius: 50%;
  background: var(--vow-gradient);
  border: none;
  cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  box-shadow: 0 8px 24px rgba(74, 158, 191, 0.4);
  transition: transform .3s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow .3s;
  position: relative;
}
.vow-trigger-btn:hover { transform: scale(1.08); box-shadow: 0 12px 32px rgba(74, 158, 191, 0.5); }
.vow-trigger-btn svg { width: 26px; height: 26px; color: #ffffff; }
.vow-trigger-badge {
  position: absolute; top: 0px; right: 0px;
  width: 18px; height: 18px;
  background: #ef4444;
  border-radius: 50%;
  border: 2px solid #fff;
  font-size: 10px; font-weight: 700;
  color: #fff;
  display: flex; align-items: center; justify-content: center;
  display: none;
}

/* ── Chat panel ─────────────────────────────────────────────────────────── */
.vow-chat-panel {
  position: absolute;
  bottom: 80px;
  width: 380px;
  max-height: 620px;
  background: var(--vow-bg);
  border-radius: var(--vow-radius);
  border: 1px solid var(--vow-border);
  box-shadow: var(--vow-shadow);
  display: flex; flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  transition: opacity .2s, transform .2s cubic-bezier(0.16, 1, 0.3, 1);
  font-family: var(--vow-font-sans);
}
#vow-ai-widget[data-position="bottom-right"] .vow-chat-panel { right: 0; transform-origin: bottom right; }
#vow-ai-widget[data-position="bottom-left"]  .vow-chat-panel { left: 0; transform-origin: bottom left; }
.vow-chat-panel.is-hidden { opacity: 0; transform: scale(0.92); pointer-events: none; }

/* Inline container */
.vow-ai-inline-container { font-family: var(--vow-font-sans); }
.vow-ai-inline-container .vow-chat-panel {
  position: relative; bottom: auto; right: auto; left: auto;
  width: 100%; max-height: 600px;
  box-shadow: var(--vow-shadow);
}

/* ── Header ─────────────────────────────────────────────────────────────── */
.vow-chat-header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 18px 20px;
  background: var(--vow-gradient);
  border-bottom: 1px solid rgba(0,0,0,0.05);
  flex-shrink: 0;
}
.vow-chat-header__avatar {
  width: 40px; height: 40px;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  border: 2px solid rgba(255,255,255,0.4);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px;
  flex-shrink: 0;
  box-shadow: 0 4px 10px rgba(0,0,0,0.1);
}
.vow-chat-header__info { flex: 1; min-width: 0; }
.vow-chat-header__title {
  font-size: 17px; font-weight: 700; color: #ffffff;
  font-family: var(--vow-font-heading);
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
  letter-spacing: 0.2px;
}
.vow-chat-header__status {
  display: flex; align-items: center; gap: 6px;
  font-size: 12px; color: rgba(255,255,255,0.85);
  font-weight: 500;
}
.vow-status-dot {
  width: 8px; height: 8px; border-radius: 50%;
  background: #22c55e;
  box-shadow: 0 0 0 2px rgba(34, 197, 94, 0.3);
  animation: vow-pulse 2s infinite;
}
@keyframes vow-pulse { 0%,100%{opacity:1} 50%{opacity:0.6} }
.vow-chat-header__actions { display: flex; gap: 6px; }
.vow-icon-btn {
  width: 32px; height: 32px;
  border-radius: 8px;
  background: transparent; border: none; cursor: pointer;
  color: rgba(255,255,255,0.8);
  display: flex; align-items: center; justify-content: center;
  transition: background .15s, color .15s;
  font-size: 16px;
}
.vow-icon-btn:hover { background: rgba(255,255,255,0.15); color: #ffffff; }

/* ── Health bar ─────────────────────────────────────────────────────────── */
.vow-health-bar-wrap {
  height: 3px;
  background: var(--vow-border);
  flex-shrink: 0;
}
.vow-health-bar {
  height: 100%;
  background: var(--vow-gradient);
  transition: width .5s ease, background .5s ease;
}

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

/* Welcome state */
.vow-welcome {
  display: flex; flex-direction: column; align-items: center;
  padding: 30px 16px;
  text-align: center;
  gap: 16px;
}
.vow-welcome__icon { font-size: 42px; filter: drop-shadow(0 4px 8px rgba(0,0,0,0.1)); }
.vow-welcome__title { font-size: 22px; font-weight: 700; color: var(--vow-text); font-family: var(--vow-font-heading); }
.vow-welcome__sub { font-size: 14px; color: var(--vow-muted); line-height: 1.6; max-width: 280px; }
.vow-welcome__prompts { display: flex; flex-direction: column; gap: 8px; width: 100%; margin-top: 8px; }
.vow-prompt-btn {
  background: var(--vow-card);
  border: 1px solid var(--vow-border);
  border-radius: 12px;
  padding: 12px 16px;
  font-size: 13px;
  font-weight: 500;
  color: var(--vow-text);
  cursor: pointer;
  text-align: left;
  transition: all .2s ease;
  box-shadow: 0 2px 4px rgba(0,0,0,0.02);
}
.vow-prompt-btn:hover { border-color: #4A9EBF; color: #4A9EBF; transform: translateY(-1px); box-shadow: 0 4px 12px rgba(74,158,191,0.1); }

/* ── Message bubbles ────────────────────────────────────────────────────── */
.vow-msg { display: flex; gap: 10px; }
.vow-msg--user { flex-direction: row-reverse; }
.vow-msg__avatar {
  width: 32px; height: 32px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; flex-shrink: 0; margin-top: 2px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}
.vow-msg--ai    .vow-msg__avatar { background: var(--vow-card); border: 1px solid var(--vow-border); }
.vow-msg--user  .vow-msg__avatar { background: var(--vow-gradient); color: #fff; }
.vow-msg__content { max-width: 82%; display: flex; flex-direction: column; gap: 6px; }
.vow-msg__bubble {
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.6;
  color: var(--vow-text);
  box-shadow: 0 2px 8px rgba(0,0,0,0.04);
}
.vow-msg--ai   .vow-msg__bubble { background: var(--vow-card); border: 1px solid var(--vow-border); border-radius: 4px 16px 16px 16px; }
.vow-msg--user .vow-msg__bubble { background: var(--vow-gradient); color: #ffffff; border: none; border-radius: 16px 4px 16px 16px; box-shadow: 0 4px 12px rgba(74,158,191,0.2); }

/* System / inline HTML messages */
.vow-msg--system .vow-msg__bubble { background: transparent; border: none; box-shadow: none; font-size: 12px; color: var(--vow-muted); font-family: monospace; }

/* Intent badge */
.vow-intent-badge {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.5px;
  padding: 3px 8px;
  border-radius: 99px;
  align-self: flex-start;
  text-transform: uppercase;
}
.vow-intent--GENERAL    { background: #e2e8f0; color: #475569; }
.vow-intent--NAVIGATION { background: #dbeafe; color: #2563eb; }
.vow-intent--CONCEPT    { background: #dcfce7; color: #16a34a; }
.vow-intent--FRUSTRATION{ background: #fee2e2; color: #dc2626; }
.vow-intent--OOB        { background: #fef3c7; color: #d97706; }
.vow-intent-cached      { font-size: 10px; color: #64748b; margin-left: 6px; font-weight: 500; }
@media (prefers-color-scheme: dark) {
  .vow-intent--GENERAL    { background: #1e293b; color: #94a3b8; }
  .vow-intent--NAVIGATION { background: #1e3a8a; color: #60a5fa; }
  .vow-intent--CONCEPT    { background: #14532d; color: #4ade80; }
  .vow-intent--FRUSTRATION{ background: #7f1d1d; color: #f87171; }
  .vow-intent--OOB        { background: #78350f; color: #fbbf24; }
}

/* Markdown basic styles inside bubble */
.vow-msg__bubble p    { margin-bottom: 8px; }
.vow-msg__bubble p:last-child { margin-bottom: 0; }
.vow-msg__bubble strong { font-weight: 600; }
.vow-msg--user .vow-msg__bubble strong { color: #fff; }
.vow-msg__bubble ul, .vow-msg__bubble ol { margin: 8px 0 8px 20px; }
.vow-msg__bubble li { margin-bottom: 4px; }
.vow-msg__bubble a  { color: #4A9EBF; font-weight: 500; text-decoration: none; }
.vow-msg__bubble a:hover { text-decoration: underline; }
.vow-msg--user .vow-msg__bubble a { color: #fff; text-decoration: underline; }
.vow-msg__bubble code { background: rgba(0,0,0,0.05); padding: 3px 6px; border-radius: 6px; font-size: 12.5px; font-family: monospace; }
.vow-msg--user .vow-msg__bubble code { background: rgba(255,255,255,0.2); }

/* ── Typing indicator ───────────────────────────────────────────────────── */
.vow-typing { display: flex; gap: 5px; align-items: center; padding: 10px 14px; }
.vow-typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--vow-muted);
  animation: vow-bounce 1.4s infinite ease-in-out both;
}
.vow-typing span:nth-child(1) { animation-delay: -0.32s; }
.vow-typing span:nth-child(2) { animation-delay: -0.16s; }
@keyframes vow-bounce { 0%, 80%, 100% { transform: scale(0); } 40% { transform: scale(1); } }

/* ── Flow diagram ───────────────────────────────────────────────────────── */
.vow-diagram { margin-top: 12px; }
.vow-diagram__toggle {
  width: 100%;
  display: flex; align-items: center; justify-content: space-between;
  padding: 12px 14px;
  background: var(--vow-card);
  border: 1px solid var(--vow-border);
  border-radius: 10px;
  cursor: pointer;
  color: var(--vow-text);
  font-size: 13px; font-weight: 500;
  transition: all .2s ease;
}
.vow-diagram__toggle:hover { border-color: #4A9EBF; background: rgba(74,158,191,0.05); }
.vow-diagram__toggle-title { display: flex; align-items: center; gap: 10px; font-weight: 600; }
.vow-diagram__icon { width: 24px; height: 24px; border-radius: 50%; background: var(--vow-gradient); display: flex; align-items: center; justify-content: center; font-size: 12px; color: #fff; }
.vow-diagram__chevron { font-size: 12px; color: var(--vow-muted); transition: transform .3s; }
.vow-diagram__toggle.is-open .vow-diagram__chevron { transform: rotate(180deg); }
.vow-diagram__body {
  margin-top: 8px;
  border: 1px solid var(--vow-border);
  border-radius: 10px;
  padding: 16px;
  background: var(--vow-bg);
  display: none;
}
.vow-diagram__body.is-visible { display: block; animation: vowFadeIn 0.3s ease; }
@keyframes vowFadeIn { from { opacity: 0; transform: translateY(-4px); } to { opacity: 1; transform: translateY(0); } }
.vow-diagram__steps { display: flex; flex-direction: column; gap: 0; }
.vow-step {
  display: flex; align-items: flex-start; gap: 12px;
  padding-bottom: 20px; position: relative;
}
.vow-step:last-child { padding-bottom: 0; }
.vow-step__track { display: flex; flex-direction: column; align-items: center; flex-shrink: 0; }
.vow-step__num {
  width: 28px; height: 28px; border-radius: 50%;
  background: var(--vow-gradient);
  display: flex; align-items: center; justify-content: center;
  font-size: 13px; font-weight: 700; color: #fff;
  box-shadow: 0 2px 6px rgba(74,158,191,0.3);
}
.vow-step__line {
  width: 2px; flex: 1; background: var(--vow-border);
  margin-top: 6px; min-height: 16px; border-radius: 2px;
}
.vow-step:last-child .vow-step__line { display: none; }
.vow-step__body { flex: 1; padding-top: 4px; }
.vow-step__label { font-size: 14px; font-weight: 600; color: var(--vow-text); margin-bottom: 4px; }
.vow-step__hint  { font-size: 13px; color: var(--vow-muted); line-height: 1.5; }
.vow-step__tag   { display: inline-block; font-size: 11px; font-weight: 600; color: #4A9EBF; margin-top: 6px; padding: 2px 8px; background: rgba(74,158,191,0.1); border-radius: 6px; }

/* ── Transfer prompt ────────────────────────────────────────────────────── */
.vow-transfer-card {
  background: var(--vow-card);
  border: 1px solid var(--vow-border);
  border-radius: 12px;
  padding: 16px;
  box-shadow: 0 4px 12px rgba(0,0,0,0.03);
}
.vow-transfer-card__title { font-size: 15px; font-weight: 600; color: var(--vow-text); margin-bottom: 6px; }
.vow-transfer-card__body  { font-size: 13px; color: var(--vow-muted); margin-bottom: 14px; line-height: 1.5; }
.vow-transfer-card__actions { display: flex; gap: 10px; flex-wrap: wrap; }
.vow-btn {
  padding: 8px 16px;
  border-radius: 8px;
  font-size: 13px; font-weight: 600;
  border: none; cursor: pointer;
  transition: all .2s ease;
  font-family: inherit;
}
.vow-btn--primary { background: var(--vow-gradient); color: #ffffff; box-shadow: 0 2px 8px rgba(74,158,191,0.3); text-decoration: none; display: inline-block; }
.vow-btn--primary:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(74,158,191,0.4); text-decoration: none; color: #ffffff; }
.vow-btn--ghost   { background: transparent; border: 1px solid var(--vow-border); color: var(--vow-muted); }
.vow-btn--ghost:hover { border-color: var(--vow-muted); color: var(--vow-text); }

/* ── Input area ─────────────────────────────────────────────────────────── */
.vow-input-area {
  padding: 16px 20px;
  border-top: 1px solid var(--vow-border);
  background: var(--vow-bg);
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.vow-input-row {
  display: flex;
  gap: 10px;
  align-items: flex-end;
}
.vow-input {
  flex: 1;
  background: var(--vow-card);
  border: 1px solid var(--vow-border);
  border-radius: 12px;
  padding: 12px 16px;
  color: var(--vow-text);
  font-size: 14px;
  resize: none;
  outline: none;
  font-family: inherit;
  line-height: 1.5;
  max-height: 120px;
  overflow-y: auto;
  transition: border-color .2s, box-shadow .2s;
  box-shadow: inset 0 2px 4px rgba(0,0,0,0.01);
}
.vow-input::placeholder { color: var(--vow-muted); font-weight: 400; }
.vow-input:focus { border-color: #4A9EBF; box-shadow: 0 0 0 3px rgba(74,158,191,0.15); }
.vow-send-btn {
  width: 46px; height: 46px; flex-shrink: 0;
  border-radius: 12px;
  background: var(--vow-gradient);
  border: none; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  color: #ffffff; font-size: 18px;
  transition: all .2s;
  box-shadow: 0 2px 8px rgba(74,158,191,0.3);
}
.vow-send-btn:hover { transform: translateY(-1px); box-shadow: 0 4px 12px rgba(74,158,191,0.4); }
.vow-send-btn:active { transform: scale(0.96); }
.vow-send-btn:disabled { opacity: 0.5; cursor: not-allowed; transform: none; box-shadow: none; filter: grayscale(50%); }
.vow-input-hint { font-size: 11px; color: var(--vow-muted); text-align: center; font-weight: 500; }

/* ── Locked overlay ─────────────────────────────────────────────────────── */
.vow-locked-overlay {
  position: absolute; inset: 0;
  background: rgba(255,255,255,0.95);
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  gap: 12px;
  border-radius: var(--vow-radius);
  z-index: 10;
  backdrop-filter: blur(4px);
}
@media (prefers-color-scheme: dark) {
  .vow-locked-overlay { background: rgba(15,17,23,0.95); }
}
.vow-locked-overlay__icon { font-size: 40px; }
.vow-locked-overlay__title { font-size: 18px; font-weight: 700; color: #ef4444; font-family: var(--vow-font-heading); }
.vow-locked-overlay__body  { font-size: 14px; color: var(--vow-muted); text-align: center; max-width: 260px; line-height: 1.5; margin-bottom: 8px; }

/* ── Responsive ─────────────────────────────────────────────────────────── */
@media (max-width: 440px) {
  .vow-chat-panel { width: calc(100vw - 24px) !important; max-height: calc(100vh - 100px); bottom: 74px; border-radius: 16px; }
  #vow-ai-widget[data-position="bottom-right"] { right: 12px; bottom: 12px; }
  #vow-ai-widget[data-position="bottom-left"]  { left: 12px;  bottom: 12px; }
}
