/* Veya AI — chat widget. Uses brand tokens defined on :root in styles.css. */

.veya-chat-launcher {
  position: fixed;
  right: 28px;
  bottom: 28px;
  z-index: 60;
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px 14px 16px;
  background: var(--acid);
  color: var(--ink);
  border: 0;
  border-radius: 999px;
  font-family: var(--sans);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -.01em;
  cursor: pointer;
  box-shadow: 0 12px 30px rgba(0, 0, 0, .35);
  transition: transform .25s ease, box-shadow .25s ease, opacity .25s ease;
}
.veya-chat-launcher:hover { transform: translateY(-3px); box-shadow: 0 16px 36px rgba(0, 0, 0, .4); }
.veya-chat-launcher.is-near-footer { opacity: 0; transform: translateY(12px); pointer-events: none; }
.veya-chat-launcher:focus-visible { outline: 2px solid var(--paper); outline-offset: 3px; }
.veya-chat-launcher-mark {
  width: 20px; height: 20px;
  display: grid; place-items: center; flex-shrink: 0;
}
.veya-chat-launcher-mark img { width: 100%; height: 100%; display: block; }
.veya-chat-launcher-label { display: inline-flex; align-items: center; gap: 5px; }
.veya-chat-launcher.is-open { display: none; }

.veya-chat-backdrop {
  position: fixed; inset: 0; z-index: 58;
  background: rgba(6, 6, 7, .5);
  opacity: 0; pointer-events: none;
  transition: opacity .25s ease;
}
.veya-chat-backdrop.is-visible { opacity: 1; pointer-events: auto; }

.veya-chat-panel {
  position: fixed;
  right: 28px;
  bottom: 28px;
  z-index: 59;
  width: 400px;
  max-width: calc(100vw - 40px);
  height: min(660px, calc(100vh - 56px));
  background: var(--ink);
  color: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 30px 80px rgba(0, 0, 0, .5);
  opacity: 0;
  transform: translateY(18px) scale(.98);
  pointer-events: none;
  transition: opacity .28s cubic-bezier(.2,.8,.2,1), transform .28s cubic-bezier(.2,.8,.2,1);
}
.veya-chat-panel.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

.veya-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
  padding: 16px 16px 14px 18px;
  border-bottom: 1px solid var(--line);
  flex-shrink: 0;
}
.veya-chat-header-id { display: flex; align-items: center; gap: 10px; min-width: 0; }
.veya-chat-header-mark {
  width: 30px; height: 30px; border-radius: 50%; flex-shrink: 0;
  background: var(--acid); color: var(--ink);
  display: grid; place-items: center;
}
.veya-chat-header-mark img { width: 62%; height: 62%; display: block; }
.veya-chat-header-text { min-width: 0; }
.veya-chat-header-text .name { font-size: 14px; font-weight: 600; letter-spacing: -.01em; }
.veya-chat-header-text .status {
  font: 10px var(--mono); letter-spacing: .06em; text-transform: uppercase; color: var(--muted);
  display: flex; align-items: center; gap: 6px; margin-top: 2px;
}
.veya-chat-header-text .status .dot {
  width: 6px; height: 6px; border-radius: 50%; background: var(--acid);
  box-shadow: 0 0 0 3px rgba(216,255,54,.15);
}
.veya-chat-header-wordmark { height: 11px; width: auto; display: block; }

/* Inline wordmark used wherever "Veya" appears as running text.
   Default renders the real white-on-transparent asset for dark surfaces;
   .veya-wm-ink inverts it for the lime (--acid) surfaces (launcher, CTAs). */
.veya-wm { height: 12px; width: auto; display: inline-block; vertical-align: -2px; }
.veya-wm-ink { filter: invert(1); }
.veya-wm-tiny { height: 9px; vertical-align: -1px; }
.veya-wm-h3 { height: 13px; vertical-align: -2px; }
.veya-wm-sub { height: 10px; vertical-align: -1px; }
.veya-chat-header-actions { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }
.veya-chat-icon-btn {
  width: 32px; height: 32px; border-radius: 50%; border: 0; background: transparent;
  color: var(--muted); display: grid; place-items: center; cursor: pointer;
  transition: background .2s, color .2s;
}
.veya-chat-icon-btn:hover { background: rgba(242,240,235,.08); color: var(--paper); }
.veya-chat-icon-btn:focus-visible { outline: 2px solid var(--acid); outline-offset: 2px; }
.veya-chat-icon-btn svg { width: 16px; height: 16px; }

.veya-chat-messages {
  flex: 1;
  overflow-y: auto;
  /* Don't chain the log's scroll out to the page once it hits an end —
     reaching the top of the transcript should not start scrolling the site
     behind the open panel. */
  overscroll-behavior: contain;
  padding: 18px 18px 6px;
  display: flex;
  flex-direction: column;
  gap: 18px;
  scroll-behavior: smooth;
}
.veya-chat-messages:focus-visible { outline: none; }

.veya-chat-msg { max-width: 92%; }
.veya-chat-msg.user { align-self: flex-end; max-width: 84%; }
.veya-chat-msg.assistant { align-self: flex-start; }

.veya-chat-msg .label {
  font: 10px var(--mono); letter-spacing: .07em; text-transform: uppercase;
  color: var(--muted); margin-bottom: 6px; display: block;
}
.veya-chat-msg.user .label { text-align: right; }

.veya-chat-bubble {
  font-size: 14px; line-height: 1.55; white-space: pre-wrap; word-break: break-word;
}
.veya-chat-msg.assistant .veya-chat-bubble { color: #e8e6e1; }
.veya-chat-msg.user .veya-chat-bubble {
  background: var(--acid); color: var(--ink);
  padding: 10px 14px; border-radius: 14px 14px 4px 14px;
  font-weight: 500;
}
.veya-chat-bubble b { font-weight: 600; color: var(--paper); }
.veya-chat-msg.user .veya-chat-bubble b { color: var(--ink); }
.veya-chat-bubble ul { margin: 8px 0; padding-left: 18px; }
.veya-chat-bubble li { margin: 3px 0; }

.veya-chat-brief-cta {
  margin-top: 10px;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  background: var(--acid);
  color: var(--ink);
  border: 0;
  padding: 10px 16px;
  border-radius: 999px;
  font-family: var(--sans);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: transform .2s ease;
}
.veya-chat-brief-cta:hover { transform: translateY(-2px); }
.veya-chat-brief-cta:focus-visible { outline: 2px solid var(--paper); outline-offset: 2px; }

.veya-chat-typing {
  display: flex; align-items: center; gap: 4px; padding: 4px 0 4px 2px;
}
.veya-chat-typing span {
  width: 5px; height: 5px; border-radius: 50%; background: var(--muted);
  animation: veya-typing 1.1s infinite ease-in-out;
}
.veya-chat-typing span:nth-child(2) { animation-delay: .15s; }
.veya-chat-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes veya-typing {
  0%, 60%, 100% { opacity: .25; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-2px); }
}

.veya-chat-error {
  font-size: 13px; color: #ff9b9b;
  background: rgba(255, 90, 90, .08);
  border: 1px solid rgba(255, 90, 90, .25);
  border-radius: 10px;
  padding: 10px 12px;
  line-height: 1.5;
}
.veya-chat-error .retry {
  display: inline-block; margin-top: 6px;
  color: var(--acid); text-decoration: underline; cursor: pointer;
  background: none; border: 0; font: inherit; padding: 0;
}

.veya-chat-starters {
  display: flex; flex-wrap: wrap; gap: 8px;
  padding: 4px 18px 14px;
  flex-shrink: 0;
}
.veya-chat-starter-btn {
  font-family: var(--sans); font-size: 12.5px; color: var(--paper);
  background: rgba(242,240,235,.06);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 8px 13px;
  cursor: pointer;
  transition: border-color .2s, background .2s;
  text-align: left;
}
.veya-chat-starter-btn:hover { border-color: var(--acid); background: rgba(216,255,54,.06); }
.veya-chat-starter-btn:focus-visible { outline: 2px solid var(--acid); outline-offset: 2px; }

.veya-chat-attachments {
  display: flex; flex-wrap: wrap; gap: 6px;
  padding: 10px 14px 0;
  flex-shrink: 0;
}
.veya-chat-attachment-chip {
  display: inline-flex; align-items: center; gap: 6px;
  background: rgba(242,240,235,.06); border: 1px solid var(--line); border-radius: 999px;
  padding: 5px 6px 5px 10px;
  font-family: var(--sans); font-size: 11.5px; color: var(--paper);
}
.veya-chat-attachment-chip .name { max-width: 160px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.veya-chat-attachment-chip .remove {
  width: 18px; height: 18px; border-radius: 50%; border: 0; background: transparent;
  color: var(--muted); display: grid; place-items: center; cursor: pointer; flex-shrink: 0;
  transition: background .2s, color .2s;
}
.veya-chat-attachment-chip .remove:hover { background: rgba(242,240,235,.1); color: var(--paper); }
.veya-chat-attachment-chip .remove svg { width: 11px; height: 11px; }
.veya-chat-attachment-error {
  font-family: var(--sans); font-size: 11.5px; color: #f8b4b4;
  display: flex; align-items: center;
}

.veya-chat-msg-files { display: flex; flex-wrap: wrap; gap: 5px; margin-bottom: 6px; justify-content: flex-end; }
.veya-chat-msg.assistant .veya-chat-msg-files { justify-content: flex-start; }
.veya-chat-msg-file {
  font-family: var(--sans); font-size: 11px; color: var(--muted);
  border: 1px solid var(--line); border-radius: 999px; padding: 3px 9px;
}

.veya-chat-inputrow {
  display: flex; align-items: flex-end; gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
}
.veya-chat-attach-btn {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  background: transparent; color: var(--muted); border: 1px solid var(--line);
  display: grid; place-items: center; cursor: pointer;
  transition: border-color .2s, color .2s;
}
.veya-chat-attach-btn:hover { border-color: var(--acid); color: var(--paper); }
.veya-chat-attach-btn:focus-visible { outline: 2px solid var(--acid); outline-offset: 2px; }
.veya-chat-attach-btn svg { width: 16px; height: 16px; }
.veya-chat-input {
  flex: 1;
  resize: none;
  max-height: 120px;
  background: rgba(242,240,235,.05);
  border: 1px solid var(--line);
  border-radius: 12px;
  color: var(--paper);
  font-family: var(--sans);
  font-size: 14px;
  line-height: 1.4;
  padding: 10px 12px;
  outline: none;
  transition: border-color .2s;
}
.veya-chat-input::placeholder { color: var(--muted); }
.veya-chat-input:focus { border-color: var(--acid); }

.veya-chat-send {
  width: 38px; height: 38px; border-radius: 50%; flex-shrink: 0;
  background: var(--acid); color: var(--ink); border: 0;
  display: grid; place-items: center; cursor: pointer;
  transition: transform .2s ease, opacity .2s ease;
}
.veya-chat-send:hover { transform: translateY(-2px); }
.veya-chat-send:disabled { opacity: .4; cursor: not-allowed; transform: none; }
.veya-chat-send:focus-visible { outline: 2px solid var(--paper); outline-offset: 2px; }
.veya-chat-send svg { width: 16px; height: 16px; }

.veya-chat-foot {
  font: 10px var(--mono); color: var(--muted);
  text-align: center; padding: 0 14px 12px;
  flex-shrink: 0;
}

/* Lead form */
.veya-chat-lead {
  padding: 16px 18px 18px;
  border-top: 1px solid var(--line);
  flex-shrink: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
}
.veya-chat-lead h3 { font-size: 15px; margin: 0 0 4px; letter-spacing: -.01em; }
.veya-chat-lead p.sub { font-size: 12px; color: var(--muted); margin: 0 0 14px; line-height: 1.5; }
.veya-chat-lead-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 10px 12px; }
.veya-chat-lead label {
  display: flex; flex-direction: column; gap: 5px;
  font: 10px var(--mono); letter-spacing: .05em; text-transform: uppercase; color: var(--muted);
}
.veya-chat-lead .full { grid-column: 1 / -1; }
.veya-chat-lead input, .veya-chat-lead textarea {
  font-family: var(--sans); font-size: 13.5px; color: var(--paper);
  background: rgba(242,240,235,.05); border: 1px solid var(--line); border-radius: 8px;
  padding: 8px 10px; outline: none; transition: border-color .2s; resize: vertical;
}
.veya-chat-lead input:focus, .veya-chat-lead textarea:focus { border-color: var(--acid); }
.veya-chat-lead-submit {
  margin-top: 14px; width: 100%;
  background: var(--acid); color: var(--ink); border: 0;
  padding: 11px 16px; border-radius: 10px;
  font-family: var(--sans); font-size: 13.5px; font-weight: 600;
  cursor: pointer; transition: transform .2s ease;
}
.veya-chat-lead-submit img.veya-wm { margin-left: 5px; }
.veya-chat-lead-submit:hover { transform: translateY(-2px); }
.veya-chat-lead-submit:disabled { opacity: .5; cursor: not-allowed; transform: none; }
.veya-chat-lead-cancel {
  display: block; width: 100%; text-align: center;
  margin-top: 8px; background: none; border: 0; color: var(--muted);
  font-family: var(--sans); font-size: 12px; cursor: pointer; padding: 6px;
}
.veya-chat-lead-success {
  text-align: center; padding: 8px 4px 4px;
}
.veya-chat-lead-success .mark {
  width: 40px; height: 40px; border-radius: 50%; background: var(--acid); color: var(--ink);
  display: grid; place-items: center; margin: 0 auto 12px; font-size: 18px;
}
.veya-chat-lead-success h3 { margin: 0 0 6px; font-size: 15px; }
.veya-chat-lead-success p { margin: 0; font-size: 12.5px; color: var(--muted); line-height: 1.5; }

@media (max-width: 720px) {
  .veya-chat-launcher { right: 16px; bottom: 16px; padding: 13px 18px 13px 14px; }
  .veya-chat-panel {
    right: 0; left: 0; bottom: 0; top: 0;
    width: 100%; max-width: 100%; height: 100%;
    border-radius: 0; border: 0;
    transform: translateY(100%);
  }
  .veya-chat-panel.is-open { transform: translateY(0); }
  .veya-chat-lead-grid { grid-template-columns: 1fr; }
}

@media (prefers-reduced-motion: reduce) {
  .veya-chat-panel, .veya-chat-launcher, .veya-chat-brief-cta, .veya-chat-send, .veya-chat-starter-btn, .veya-chat-lead-submit {
    transition-duration: .01ms !important;
  }
  .veya-chat-typing span { animation: none; opacity: .7; }
}
