/* ===================== AVA — ASSISTANT WIDGET =====================
 * Matches the AgentWorks Studio industry-ambassador widget pattern
 * (avatar launcher pill, avatar header, spoken replies, mic input)
 * using this site's tokens from styles.css.
 * ================================================================== */

.ava {
  --ava-panel-w: 388px;
  --ava-panel-h: min(620px, calc(100vh - 140px));
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 900;
  font-family: var(--font-sans);
}

/* ---------- launcher ---------- */
.ava-launcher {
  position: relative;
  display: flex; align-items: center; gap: 10px;
  padding: 8px 22px 8px 8px;
  border: 0; border-radius: 999px;
  background: linear-gradient(135deg, var(--navy-700) 0%, var(--navy-900) 100%);
  color: var(--white);
  font-family: inherit; font-size: 0.95rem; font-weight: 600;
  cursor: pointer;
  box-shadow: 0 14px 34px rgba(11, 31, 51, 0.32);
  transition: transform .18s ease, box-shadow .2s ease;
}
.ava-launcher:hover { transform: translateY(-2px); box-shadow: 0 18px 40px rgba(11, 31, 51, 0.4); }
.ava-launcher:focus-visible { outline: 3px solid var(--heron-light); outline-offset: 3px; }
.ava-launcher img {
  width: 44px; height: 44px; flex: none;
  border-radius: 999px; object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.7);
}
.ava-launcher-label { white-space: nowrap; }

/* Presence dot — a quiet "someone's here" signal. */
.ava-launcher::after {
  content: ''; position: absolute; left: 40px; bottom: 8px;
  width: 12px; height: 12px; border-radius: 999px;
  background: #34d399; border: 2.5px solid var(--navy-800);
}

.ava.is-open .ava-launcher { display: none; }

/* ---------- proactive nudge ---------- */
.ava-nudge {
  position: absolute; right: 0; bottom: 74px;
  width: 280px;
  display: flex; gap: 10px; align-items: flex-start;
  padding: 14px 16px;
  background: var(--white); color: var(--ink);
  border: 1px solid var(--line); border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: 0.9rem; line-height: 1.5;
  text-align: left; cursor: pointer;
  animation: ava-rise .38s cubic-bezier(.2,.8,.3,1) both;
}
.ava-nudge p { margin: 0; }
.ava-nudge strong { display: block; font-weight: 600; }
.ava-nudge-dismiss {
  flex: none; margin: -4px -6px 0 0; padding: 4px;
  background: none; border: 0; color: var(--slate-light);
  font-size: 1rem; line-height: 1; cursor: pointer; border-radius: 6px;
}
.ava-nudge-dismiss:hover { color: var(--ink); background: var(--bg-soft); }

/* ---------- panel ---------- */
.ava-panel {
  position: absolute; right: 0; bottom: 0;
  display: none; flex-direction: column;
  width: var(--ava-panel-w); height: var(--ava-panel-h);
  background: var(--white);
  border: 1px solid var(--line); border-radius: 20px;
  box-shadow: var(--shadow-lg);
  overflow: hidden;
}
.ava.is-open .ava-panel { display: flex; animation: ava-rise .28s cubic-bezier(.2,.8,.3,1) both; }

@keyframes ava-rise {
  from { opacity: 0; transform: translateY(12px) scale(.98); }
  to   { opacity: 1; transform: none; }
}

/* ---------- header ---------- */
.ava-header {
  flex: none; display: flex; align-items: center; gap: 12px;
  padding: 14px 16px;
  background: linear-gradient(135deg, var(--navy-900) 0%, var(--navy-700) 100%);
  color: var(--white);
}
.ava-portrait { position: relative; flex: none; width: 42px; height: 42px; }
.ava-portrait img {
  width: 42px; height: 42px; border-radius: 999px; object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.6);
}
/* Pulsing ring while she is speaking. */
.ava-portrait::after {
  content: ''; position: absolute; inset: -3px;
  border-radius: 999px; border: 2px solid var(--heron-light);
  opacity: 0; pointer-events: none;
}
.ava.is-speaking .ava-portrait::after { animation: ava-pulse 1.5s ease-out infinite; }
@keyframes ava-pulse {
  0%   { opacity: .9; transform: scale(1); }
  100% { opacity: 0;  transform: scale(1.35); }
}

.ava-identity { min-width: 0; }
.ava-identity h2 {
  font-family: var(--font-display); font-size: 1rem; font-weight: 700;
  margin: 0; color: var(--white);
}
.ava-identity p {
  margin: 1px 0 0; font-size: 0.74rem; line-height: 1.4;
  color: rgba(255, 255, 255, 0.68);
}
.ava-head-actions { margin-left: auto; display: flex; gap: 6px; }
.ava-ic {
  display: grid; place-items: center;
  width: 32px; height: 32px; padding: 0;
  background: rgba(255, 255, 255, 0.12); border: 0; border-radius: 8px;
  color: var(--white); cursor: pointer;
  transition: background .15s ease;
}
.ava-ic:hover { background: rgba(255, 255, 255, 0.24); }
.ava-ic svg { width: 16px; height: 16px; }
.ava-ic[aria-pressed="true"] { background: var(--heron); }
.ava-ic .ava-icon-muted { display: none; }
.ava-ic[aria-pressed="false"] .ava-icon-muted { display: block; }
.ava-ic[aria-pressed="false"] .ava-icon-loud { display: none; }

/* ---------- message log ---------- */
.ava-log {
  flex: 1 1 auto; overflow-y: auto; overscroll-behavior: contain;
  padding: 18px; display: flex; flex-direction: column; gap: 12px;
  background: var(--bg-soft);
}
.ava-msg {
  max-width: 86%;
  padding: 10px 14px;
  font-size: 0.92rem; line-height: 1.55;
  border-radius: 16px;
  white-space: pre-wrap; overflow-wrap: anywhere;
}
.ava-msg-ava {
  align-self: flex-start;
  background: var(--white); color: var(--ink);
  border: 1px solid var(--line); border-bottom-left-radius: 5px;
}
.ava-msg-user {
  align-self: flex-end;
  background: var(--heron); color: var(--white);
  border-bottom-right-radius: 5px;
}
.ava-msg-note {
  align-self: center; max-width: 100%;
  background: #fff4e5; color: #7a4a00;
  border: 1px solid #ffd9a8; border-radius: 10px;
  font-size: 0.84rem;
}
.ava-msg a { color: var(--heron-dark); text-decoration: underline; }
.ava-msg-user a { color: var(--white); }

.ava-receipt {
  align-self: flex-start; max-width: 86%;
  display: flex; align-items: center; gap: 8px;
  padding: 8px 13px;
  background: #e8f7ef; color: #145c3a;
  border: 1px solid #b7e3cb; border-radius: 12px;
  font-size: 0.83rem; font-weight: 500;
}
.ava-receipt svg { flex: none; width: 15px; height: 15px; }

/* ---------- typing / status ---------- */
.ava-status {
  align-self: flex-start;
  display: flex; align-items: center; gap: 9px;
  padding: 10px 14px;
  background: var(--white); border: 1px solid var(--line);
  border-radius: 16px; border-bottom-left-radius: 5px;
  font-size: 0.85rem; color: var(--slate);
}
.ava-dots { display: inline-flex; gap: 4px; }
.ava-dots i {
  width: 6px; height: 6px; border-radius: 999px; background: var(--heron);
  animation: ava-bounce 1.3s infinite ease-in-out both;
}
.ava-dots i:nth-child(2) { animation-delay: .16s; }
.ava-dots i:nth-child(3) { animation-delay: .32s; }
@keyframes ava-bounce {
  0%, 70%, 100% { transform: translateY(0); opacity: .45; }
  35% { transform: translateY(-4px); opacity: 1; }
}

/* ---------- quick replies ---------- */
.ava-chips {
  flex: none; display: flex; flex-wrap: wrap; gap: 7px;
  padding: 0 18px 14px; background: var(--bg-soft);
}
.ava-chips:empty { display: none; }
.ava-chip {
  padding: 7px 13px;
  background: var(--white); color: var(--heron-dark);
  border: 1px solid var(--heron-light); border-radius: 999px;
  font: inherit; font-size: 0.82rem; font-weight: 500;
  cursor: pointer; transition: background .15s ease, color .15s ease;
}
.ava-chip:hover { background: var(--heron); color: var(--white); border-color: var(--heron); }

/* ---------- composer ---------- */
.ava-composer {
  flex: none; display: flex; align-items: flex-end; gap: 8px;
  padding: 12px; border-top: 1px solid var(--line); background: var(--white);
}
.ava-input {
  flex: 1 1 auto; resize: none;
  max-height: 120px; padding: 10px 12px;
  font: inherit; font-size: 0.92rem; line-height: 1.5; color: var(--ink);
  background: var(--bg-soft);
  border: 1px solid var(--line); border-radius: 12px;
}
.ava-input:focus { outline: none; border-color: var(--heron); background: var(--white); }
.ava-mic, .ava-send {
  flex: none; display: grid; place-items: center;
  width: 40px; height: 40px; padding: 0;
  border-radius: 12px; cursor: pointer;
  transition: background .15s ease, color .15s ease;
}
.ava-mic {
  background: var(--bg-soft); color: var(--slate);
  border: 1px solid var(--line);
}
.ava-mic:hover { background: var(--bg-tint); color: var(--heron-dark); }
.ava-mic[hidden] { display: none; }
.ava-mic.is-live {
  background: #c2493b; border-color: #c2493b; color: var(--white);
  animation: ava-mic-pulse 1.6s infinite;
}
@keyframes ava-mic-pulse {
  0%, 100% { box-shadow: 0 0 0 0 rgba(194, 73, 59, 0.45); }
  50%      { box-shadow: 0 0 0 8px rgba(194, 73, 59, 0); }
}
.ava-send { background: var(--heron); color: var(--white); border: 0; }
.ava-send:hover:not(:disabled) { background: var(--heron-dark); }
.ava-send:disabled { opacity: .4; cursor: not-allowed; }
.ava-mic svg, .ava-send svg { width: 17px; height: 17px; }

.ava-disclosure {
  flex: none; margin: 0; padding: 0 14px 12px;
  background: var(--white);
  font-size: 0.7rem; line-height: 1.5; color: var(--slate-light); text-align: center;
}
.ava-disclosure a { color: var(--slate); text-decoration: underline; }

/* ---------- responsive ---------- */
@media (max-width: 520px) {
  .ava { right: 16px; bottom: 16px; }
  .ava-launcher { padding: 8px 18px 8px 8px; font-size: 0.9rem; }
  .ava-panel {
    position: fixed; inset: 0;
    width: 100%; height: 100%; height: 100dvh;
    border: 0; border-radius: 0;
  }
  .ava-nudge { width: min(280px, calc(100vw - 48px)); }
}

@media (prefers-reduced-motion: reduce) {
  .ava-launcher, .ava-panel, .ava-nudge, .ava-dots i,
  .ava-portrait::after, .ava-mic.is-live { transition: none; animation: none; }
}
