/* SANKHYANVESH website assistant ("Anvi") */
.anvi {
  --anvi-blue: var(--blue, #1769e0);
  --anvi-navy: var(--navy, #0b1f3a);
  --anvi-bg: #ffffff;
  --anvi-soft: var(--sky, #eaf3ff);
  --anvi-line: var(--line, #dce3ec);
  --anvi-text: var(--text, #14243a);
  --anvi-muted: var(--muted, #5c6b7d);
  position: fixed;
  right: 20px;
  bottom: 20px;
  z-index: 80;
  font-family: Inter, "Segoe UI", Arial, sans-serif;
  color: var(--anvi-text);
}
.anvi *, .anvi *::before, .anvi *::after { box-sizing: border-box; }
.anvi-sr { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }

/* launcher */
.anvi-launch {
  display: flex; align-items: center; gap: 10px;
  margin-left: auto;
  padding: 6px 18px 6px 6px;
  border: 0; border-radius: 999px;
  background: var(--anvi-navy); color: #fff;
  font: inherit; font-weight: 800; font-size: 0.95rem;
  box-shadow: 0 12px 30px rgba(11, 31, 58, 0.28);
  cursor: pointer;
  transition: transform .18s ease, box-shadow .18s ease;
}
.anvi-launch:hover { transform: translateY(-2px); box-shadow: 0 16px 36px rgba(11, 31, 58, 0.34); }
.anvi-launch:focus-visible, .anvi-chip:focus-visible, .anvi-icon:focus-visible, .anvi-send:focus-visible { outline: 3px solid #8ab8ff; outline-offset: 2px; }
.anvi.is-open .anvi-launch { display: none; }

.anvi-avatar { display: block; flex: none; }
.anvi-avatar--launch { width: 46px; height: 46px; animation: anvi-bob 3.2s ease-in-out infinite; }
.anvi-avatar--head { width: 44px; height: 44px; }
.anvi-avatar--msg { width: 30px; height: 30px; margin-top: 2px; }

.anvi-eyes { transform-origin: 32px 29px; animation: anvi-blink 4.6s infinite; }
.anvi-dot { animation: anvi-pulse 2.4s ease-in-out infinite; }
.anvi-mouth rect { transform-box: fill-box; transform-origin: bottom; }
.is-talking .anvi-mouth .b1 { animation: anvi-bar .5s ease-in-out infinite; }
.is-talking .anvi-mouth .b2 { animation: anvi-bar .5s ease-in-out .15s infinite; }
.is-talking .anvi-mouth .b3 { animation: anvi-bar .5s ease-in-out .3s infinite; }

@keyframes anvi-blink { 0%, 92%, 100% { transform: scaleY(1); } 95% { transform: scaleY(0.1); } }
@keyframes anvi-pulse { 0%, 100% { opacity: 1; } 50% { opacity: .45; } }
@keyframes anvi-bob { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-2px); } }
@keyframes anvi-bar { 0%, 100% { transform: scaleY(1); } 50% { transform: scaleY(0.45); } }
@keyframes anvi-rise { from { opacity: 0; transform: translateY(6px); } to { opacity: 1; transform: none; } }
@keyframes anvi-typing { 0%, 80%, 100% { opacity: .25; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

/* panel */
.anvi-panel {
  display: flex; flex-direction: column;
  width: 380px; height: min(600px, calc(100vh - 40px));
  border: 1px solid var(--anvi-line); border-radius: 18px;
  background: var(--anvi-bg);
  box-shadow: 0 24px 60px rgba(11, 31, 58, 0.22);
  overflow: hidden;
  animation: anvi-rise .2s ease-out;
}
.anvi-panel[hidden] { display: none; }

.anvi-head {
  display: flex; align-items: center; gap: 10px;
  padding: 12px 10px 12px 14px;
  background: linear-gradient(135deg, var(--anvi-navy), #173d72);
  color: #fff;
}
.anvi-title { flex: 1; min-width: 0; line-height: 1.25; }
.anvi-title strong { display: block; font-size: 1.05rem; }
.anvi-title span { display: block; font-size: 0.76rem; color: #c9dbf5; }
.anvi-icon {
  display: grid; place-items: center;
  width: 34px; height: 34px; padding: 0;
  border: 0; border-radius: 9px;
  background: transparent; color: #dbe8fb; cursor: pointer;
}
.anvi-icon:hover { background: rgba(255, 255, 255, 0.12); color: #fff; }
.anvi-icon svg { width: 19px; height: 19px; }

.anvi-log {
  flex: 1; overflow-y: auto;
  padding: 16px 14px 8px;
  background: var(--bg, #f5f7fb);
  scroll-behavior: smooth;
}
.anvi-row { display: flex; gap: 8px; margin-bottom: 10px; align-items: flex-start; }
.anvi-row.anvi-in { animation: anvi-rise .22s ease-out; }
.anvi-row--me { justify-content: flex-end; }
.anvi-bubble {
  max-width: 84%;
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 0.92rem; line-height: 1.5;
  overflow-wrap: anywhere;
}
.anvi-row--bot .anvi-bubble { background: #fff; border: 1px solid var(--anvi-line); border-top-left-radius: 4px; }
.anvi-row--me .anvi-bubble { background: var(--anvi-blue); color: #fff; border-top-right-radius: 4px; }
.anvi-bubble p { margin: 0 0 8px; }
.anvi-bubble p:last-child, .anvi-bubble ul:last-child, .anvi-bubble ol:last-child { margin-bottom: 0; }
.anvi-bubble ul, .anvi-bubble ol { margin: 0 0 8px; padding-left: 18px; }
.anvi-bubble li { margin: 3px 0; }
.anvi-bubble a { color: var(--anvi-blue); font-weight: 700; }
.anvi-email {
  display: inline-block; margin-top: 10px;
  padding: 7px 11px; border-radius: 9px;
  background: var(--anvi-soft); text-decoration: none;
  font-size: 0.85rem;
}
.anvi-email:hover { background: #d8e8ff; }

.anvi-typing .anvi-bubble { display: flex; gap: 4px; padding: 13px 14px; }
.anvi-typing .anvi-bubble span { width: 7px; height: 7px; border-radius: 50%; background: var(--anvi-muted); animation: anvi-typing 1s infinite; }
.anvi-typing .anvi-bubble span:nth-child(2) { animation-delay: .15s; }
.anvi-typing .anvi-bubble span:nth-child(3) { animation-delay: .3s; }

.anvi-chips { display: flex; flex-wrap: wrap; gap: 6px; margin: -2px 0 14px 38px; }
.anvi-chip {
  padding: 6px 11px;
  border: 1px solid #b9d3fb; border-radius: 999px;
  background: #fff; color: var(--anvi-blue);
  font: inherit; font-size: 0.82rem; font-weight: 700; line-height: 1.3;
  cursor: pointer; text-align: left;
}
.anvi-chip:hover { background: var(--anvi-soft); border-color: var(--anvi-blue); }

.anvi-form { display: flex; gap: 8px; padding: 10px 12px; border-top: 1px solid var(--anvi-line); background: #fff; }
.anvi-input {
  flex: 1; min-width: 0;
  padding: 10px 12px;
  border: 1px solid var(--anvi-line); border-radius: 11px;
  font: inherit; font-size: 0.95rem; color: var(--anvi-text);
}
.anvi-input:focus { outline: none; border-color: var(--anvi-blue); box-shadow: 0 0 0 3px rgba(23, 105, 224, 0.15); }
.anvi-send {
  display: grid; place-items: center;
  width: 42px; flex: none;
  border: 0; border-radius: 11px;
  background: var(--anvi-blue); color: #fff; cursor: pointer;
}
.anvi-send:hover { background: var(--blue-dark, #0d4fae); }
.anvi-send svg { width: 18px; height: 18px; }
.anvi-foot { margin: 0; padding: 0 12px 9px; background: #fff; color: var(--anvi-muted); font-size: 0.72rem; text-align: center; }

@media (max-width: 520px) {
  .anvi { right: 12px; bottom: 12px; }
  .anvi-launch-text { display: none; }
  .anvi-launch { padding: 5px; }
  .anvi.is-open { left: 0; right: 0; bottom: 0; top: 0; }
  .anvi-panel { width: 100%; height: 100%; border-radius: 0; border: 0; }
}

@media (prefers-reduced-motion: reduce) {
  .anvi *, .anvi *::before, .anvi *::after { animation: none !important; transition: none !important; }
}

@media print { .anvi { display: none; } }
