/* VelaONE CRM Chat widget — self-contained, scoped under .vela-chat */
.vela-chat {
  --vela-accent: #4f46e5;
  --vela-scale: 1; /* grows on large screens (see media queries below) — scales the whole widget + text */
  --vela-canvas: #f4f5f8;
  --vela-surface: #ffffff;
  --vela-ink: #1b2030;
  --vela-muted: #6b7385;
  --vela-line: #e7e9f0;
  --vela-agent: #e6a817;
  --vela-radius: 20px;
  position: fixed;
  right: 22px;
  bottom: 22px;
  z-index: 2147483000;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  font-size: 15px;
  line-height: 1.5;
  color: var(--vela-ink);
}
.vela-chat * { box-sizing: border-box; }

/* Launcher — rounded-square (squircle) icon, bottom right */
.vela-launcher {
  display: inline-flex;
  align-items: center;
  gap: 10px;
  border: 0;
  cursor: pointer;
  padding: 0;
  width: 60px;
  height: 60px;
  border-radius: 19px;
  color: #fff;
  background: var(--vela-accent);
  box-shadow: 0 12px 28px rgba(31, 30, 90, 0.32);
  justify-content: center;
  transform: scale(var(--vela-scale));
  transform-origin: bottom right;
  transition: transform 0.14s ease, box-shadow 0.14s ease;
}
.vela-launcher:hover { transform: scale(calc(var(--vela-scale) * 1.04)); box-shadow: 0 16px 34px rgba(31, 30, 90, 0.38); }
.vela-launcher:focus-visible { outline: 3px solid color-mix(in srgb, var(--vela-accent) 45%, #fff); outline-offset: 3px; }
.vela-launcher-txt { display: none; }
.vela-launcher:has(.vela-launcher-txt) { width: auto; border-radius: 999px; padding: 0 22px; }
.vela-launcher:has(.vela-launcher-txt) .vela-launcher-txt { display: inline; font-weight: 600; font-size: 15px; }
.vela-is-open .vela-launcher { display: none; }

/* Panel */
.vela-panel {
  position: absolute;
  right: 0;
  bottom: 0;
  width: 384px;
  max-width: calc(100vw - 32px);
  height: 624px;
  max-height: calc(100vh - 44px);
  display: flex;
  flex-direction: column;
  background: var(--vela-canvas);
  border-radius: var(--vela-radius);
  overflow: hidden;
  box-shadow: 0 24px 60px rgba(20, 22, 50, 0.28);
  transform: scale(var(--vela-scale));
  transform-origin: bottom right;
}
.vela-panel[hidden] { display: none; }

/* Header — light bar with a floating agent pill */
.vela-header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 12px 14px;
  background: var(--vela-canvas);
  flex: 0 0 auto;
}
.vela-h-side { display: flex; gap: 6px; z-index: 2; }
.vela-h-icon {
  width: 34px; height: 34px; border: 0; border-radius: 50%;
  background: var(--vela-surface); color: #3a4152; cursor: pointer;
  display: flex; align-items: center; justify-content: center;
  font-size: 17px; line-height: 1; box-shadow: 0 1px 3px rgba(20, 22, 50, 0.1);
  transition: background 0.12s ease;
}
.vela-h-icon svg { width: 17px; height: 17px; }
.vela-h-icon:hover { background: #eef0f6; }
.vela-h-icon:focus-visible { outline: 2px solid var(--vela-accent); outline-offset: 2px; }

/* Floating agent pill */
.vela-agent-pill {
  position: absolute; left: 50%; top: 9px; transform: translateX(-50%);
  display: flex; align-items: center; gap: 9px;
  max-width: 55%;
  background: var(--vela-surface);
  border-radius: 999px;
  padding: 5px 15px 5px 6px;
  box-shadow: 0 6px 20px rgba(20, 22, 50, 0.14);
  z-index: 1;
}
.vela-ap-av {
  position: relative;
  width: 32px; height: 32px; flex: 0 0 32px; border-radius: 50%;
  background: var(--vela-agent); color: #4a3600;
  display: flex; align-items: center; justify-content: center;
  font-weight: 800; font-size: 14px;
}
.vela-ap-av::after {
  content: ""; position: absolute; right: -1px; top: -1px;
  width: 10px; height: 10px; border-radius: 50%;
  background: #22c55e; border: 2px solid var(--vela-surface);
}
.vela-ap-meta { min-width: 0; }
.vela-ap-name { font-weight: 700; font-size: 14px; line-height: 1.15; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.vela-ap-sub { font-size: 11.5px; color: var(--vela-muted); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }

/* Header dropdown menu */
.vela-menu-wrap { position: relative; }
.vela-menu {
  position: absolute; top: 40px; left: 0; min-width: 170px;
  background: var(--vela-surface); border-radius: 12px;
  box-shadow: 0 12px 30px rgba(20, 22, 50, 0.22); padding: 6px;
  z-index: 5;
}
.vela-menu[hidden] { display: none; }
.vela-menu-item {
  display: flex; align-items: center; gap: 9px; width: 100%;
  border: 0; background: none; cursor: pointer; text-align: left;
  padding: 9px 10px; border-radius: 8px; font-size: 14px; color: var(--vela-ink);
}
.vela-menu-item:hover { background: #f2f3f8; }

/* Body (scrolls) */
.vela-body { flex: 1; min-height: 0; display: flex; flex-direction: column; }

/* ── Pre-chat form ── */
.vela-form { padding: 18px 18px 8px; overflow-y: auto; }
.vela-form-intro { margin: 0 0 16px; color: var(--vela-muted); font-size: 14.5px; }
.vela-field-wrap { display: block; margin-bottom: 15px; }
.vela-field-label { display: block; font-size: 13px; font-weight: 600; color: #4a5265; margin-bottom: 6px; }
.vela-req { color: #e11d48; }
.vela-field {
  width: 100%; border: 1px solid #d8dce4; border-radius: 12px;
  padding: 12px 14px; font-size: 15px; outline: none; background: var(--vela-surface);
  color: var(--vela-ink); font-family: inherit;
}
.vela-field::placeholder { color: #9aa2b4; }
.vela-field:focus { border-color: var(--vela-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--vela-accent) 16%, transparent); }
.vela-radio { display: flex; align-items: center; gap: 9px; padding: 7px 2px; font-size: 14.5px; cursor: pointer; }
.vela-radio input { accent-color: var(--vela-accent); width: 17px; height: 17px; }
.vela-form-err { color: #e11d48; font-size: 13px; margin-bottom: 10px; }
.vela-btn {
  width: 100%; border: 0; background: var(--vela-accent); color: #fff;
  border-radius: 12px; padding: 13px; font-size: 15.5px; font-weight: 600; cursor: pointer;
  transition: filter 0.12s ease;
}
.vela-btn:hover { filter: brightness(1.06); }
.vela-btn:disabled { opacity: 0.7; cursor: default; }

/* ── Info card ── */
.vela-info {
  margin: 0 0 2px; align-self: flex-start; max-width: 82%;
  background: var(--vela-surface); border-radius: 16px; padding: 14px 16px;
  box-shadow: 0 2px 8px rgba(20, 22, 50, 0.06);
}
.vela-info-row { margin-bottom: 8px; }
.vela-info-extra .vela-info-row:first-child { margin-top: 8px; }
.vela-info-k { display: block; font-size: 12px; color: var(--vela-muted); }
.vela-info-v { display: block; font-size: 14.5px; color: var(--vela-ink); word-break: break-word; }
.vela-info-toggle { border: 0; background: none; color: var(--vela-accent); font-weight: 600; font-size: 13px; cursor: pointer; padding: 6px 0 0; }

/* ── Message log ── */
.vela-log { flex: 1; overflow-y: auto; padding: 16px 14px; display: flex; flex-direction: column; gap: 10px; }
.vela-msg { display: flex; gap: 8px; max-width: 86%; }
.vela-msg-col { display: flex; flex-direction: column; min-width: 0; }
.vela-msg-av {
  width: 28px; height: 28px; flex: 0 0 28px; border-radius: 50%;
  background: var(--vela-agent); color: #4a3600;
  display: flex; align-items: center; justify-content: center;
  font-size: 12px; font-weight: 800; margin-top: auto;
}
.vela-msg-name { font-size: 12px; color: var(--vela-muted); margin: 0 0 3px 3px; }
.vela-bubble { padding: 11px 14px; border-radius: 16px; font-size: 15px; white-space: pre-wrap; word-wrap: break-word; }
.vela-you { align-self: flex-end; }
.vela-you .vela-bubble { background: var(--vela-accent); color: #fff; border-bottom-right-radius: 5px; }
.vela-them { align-self: flex-start; }
.vela-them .vela-bubble { background: var(--vela-surface); color: var(--vela-ink); border-bottom-left-radius: 5px; box-shadow: 0 1px 3px rgba(20, 22, 50, 0.07); }
.vela-system { align-self: center; max-width: 100%; }
.vela-system .vela-bubble { background: transparent; color: var(--vela-muted); font-size: 12.5px; padding: 2px 6px; text-align: center; }
.vela-att { display: block; max-width: 200px; max-height: 200px; border-radius: 12px; margin-top: 5px; }
.vela-status { font-size: 11.5px; color: var(--vela-muted); margin-top: 4px; text-align: right; }
.vela-sending { opacity: 0.75; align-self: flex-end; }

/* ── Composer ── */
.vela-input {
  display: flex; align-items: center; gap: 8px; margin: 10px 12px 6px;
  padding: 6px 8px; background: var(--vela-surface);
  border: 1.5px solid var(--vela-line); border-radius: 999px;
  transition: border-color 0.12s ease, box-shadow 0.12s ease;
}
.vela-input:focus-within { border-color: var(--vela-accent); box-shadow: 0 0 0 3px color-mix(in srgb, var(--vela-accent) 14%, transparent); }
.vela-icon-btn {
  border: 0; background: none; color: var(--vela-muted); cursor: pointer;
  width: 36px; height: 36px; flex: 0 0 36px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; font-size: 24px; line-height: 1;
  transition: background 0.12s ease, color 0.12s ease;
}
.vela-icon-btn:hover { background: #f0f1f6; color: var(--vela-accent); }
.vela-icon-btn svg { width: 21px; height: 21px; }
.vela-input .vela-field {
  border: 0; background: none; box-shadow: none; padding: 8px 4px; flex: 1;
}
.vela-input .vela-field:focus { box-shadow: none; }
.vela-send {
  border: 0; background: var(--vela-accent); color: #fff; cursor: pointer;
  width: 38px; height: 38px; flex: 0 0 38px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  transition: filter 0.12s ease, opacity 0.12s ease;
}
.vela-send svg { width: 19px; height: 19px; }
.vela-send:hover { filter: brightness(1.08); }
.vela-send:disabled { background: #cdd2df; cursor: default; }

/* Emoji picker */
.vela-emoji {
  margin: 0 12px; padding: 10px; background: var(--vela-surface);
  border-radius: 16px; box-shadow: 0 8px 24px rgba(20, 22, 50, 0.16);
  display: grid; grid-template-columns: repeat(8, 1fr); gap: 2px;
}
.vela-emoji[hidden] { display: none; }
.vela-emoji button { border: 0; background: none; cursor: pointer; font-size: 20px; padding: 5px; border-radius: 8px; line-height: 1; }
.vela-emoji button:hover { background: #f0f1f6; }

/* Footer */
.vela-foot { flex: 0 0 auto; text-align: center; padding: 6px 0 10px; font-size: 11.5px; color: #9aa2b4; }
.vela-foot b { color: var(--vela-muted); font-weight: 700; }

/* Scale the whole widget (and its text) up on large, roomy screens — big-monitor
   users find the default too small. Gated on width AND height so a wide-but-short
   window never pushes the panel off-screen. */
@media (min-width: 1600px) and (min-height: 900px)  { .vela-chat { --vela-scale: 1.15; } }
@media (min-width: 2000px) and (min-height: 1120px) { .vela-chat { --vela-scale: 1.32; } }
@media (min-width: 2560px) and (min-height: 1320px) { .vela-chat { --vela-scale: 1.5; } }

@media (max-width: 480px) {
  .vela-chat { right: 12px; bottom: 12px; --vela-scale: 1; }
  .vela-panel { width: calc(100vw - 24px); height: calc(100dvh - 24px); }
}
@media (prefers-reduced-motion: reduce) {
  .vela-launcher, .vela-h-icon, .vela-icon-btn, .vela-send { transition: none; }
}
