/* ============================================================
   Eltrus pre-sales chat widget styles.
   Warm-paper palette, Fraunces display, Inter body.
   Ink #0F1115, emerald #16A34A accent, cream surfaces.
   ============================================================ */

.eltrus-chat-launcher,
.eltrus-chat-panel {
  --el-ink: var(--ink, #0F1115);
  --el-bg: var(--bg, #fafaf7);
  --el-bg-alt: var(--bg-alt, #f3f0e8);
  --el-card: var(--bg-card, #ffffff);
  --el-rule: var(--rule, #e6e2d8);
  --el-mute: var(--ink-mute, #6a6a64);
  --el-accent: #16A34A;
  --el-accent-tint: rgba(22, 163, 74, 0.12);
  --el-tx: 220ms;
  --el-ease: cubic-bezier(0.16, 1, 0.3, 1);
}

/* Launcher: clean circle */
.eltrus-chat-launcher {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 9000;
  width: 60px;
  height: 60px;
  padding: 0;
  border: none;
  border-radius: 50%;
  background: var(--el-ink);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 10px 30px rgba(15, 17, 21, 0.28);
  transition: transform var(--el-tx) var(--el-ease), box-shadow var(--el-tx) var(--el-ease), opacity var(--el-tx) var(--el-ease);
}
.eltrus-chat-launcher:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 16px 38px rgba(15, 17, 21, 0.34);
}
.eltrus-chat-launcher:focus-visible {
  outline: 2px solid var(--el-accent);
  outline-offset: 3px;
}
.eltrus-chat-launcher.is-hidden {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.8) translateY(8px);
}
.eltrus-chat-launcher__icon {
  width: 60px;
  height: 60px;
  border-radius: 50%;
  display: block;
  pointer-events: none;
}
.eltrus-chat-launcher__pulse {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 11px;
  height: 11px;
  border-radius: 50%;
  background: var(--el-accent);
  border: 2px solid var(--el-ink);
  box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.5);
  animation: eltrus-pulse 2.4s infinite;
}
@keyframes eltrus-pulse {
  0% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0.5); }
  70% { box-shadow: 0 0 0 7px rgba(22, 163, 74, 0); }
  100% { box-shadow: 0 0 0 0 rgba(22, 163, 74, 0); }
}

/* Panel */
.eltrus-chat-panel {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 9001;
  width: 384px;
  max-width: calc(100vw - 32px);
  height: 580px;
  max-height: calc(100vh - 48px);
  background: var(--el-bg);
  border: 1px solid var(--el-rule);
  border-radius: 18px;
  box-shadow: 0 28px 70px rgba(15, 17, 21, 0.26);
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: var(--font-body, 'Inter', system-ui, sans-serif);
  color: var(--el-ink);
  transform-origin: bottom right;
  transform: translateY(12px) scale(0.96);
  opacity: 0;
  transition: opacity var(--el-tx) var(--el-ease), transform var(--el-tx) var(--el-ease);
}
.eltrus-chat-panel.is-mounted,
.eltrus-chat-panel.is-open,
.eltrus-chat-panel.is-closing {
  display: flex;
}
.eltrus-chat-panel.is-open {
  opacity: 1;
  transform: translateY(0) scale(1);
}
.eltrus-chat-panel.is-closing {
  opacity: 0;
  transform: translateY(12px) scale(0.96);
}

/* Header */
.eltrus-chat-header {
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px 48px 16px 18px;
  border-bottom: 1px solid var(--el-rule);
  background: var(--el-bg-alt);
}
.eltrus-chat-header__avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  flex: 0 0 auto;
  box-shadow: 0 2px 8px rgba(15, 17, 21, 0.18);
}
.eltrus-chat-header__text {
  min-width: 0;
}
.eltrus-chat-header__title {
  font-family: var(--font-display, 'Fraunces', Georgia, serif);
  font-size: 19px;
  font-weight: 600;
  letter-spacing: -0.01em;
  color: var(--el-ink);
  line-height: 1.1;
}
.eltrus-chat-header__sub {
  margin-top: 3px;
  font-size: 12px;
  color: var(--el-mute);
}
.eltrus-chat-close {
  position: absolute;
  top: 12px;
  right: 12px;
  width: 30px;
  height: 30px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border: none;
  background: transparent;
  color: var(--el-mute);
  cursor: pointer;
  border-radius: 8px;
  transition: background 150ms ease, color 150ms ease;
}
.eltrus-chat-close:hover {
  background: rgba(15, 17, 21, 0.07);
  color: var(--el-ink);
}

/* Log */
.eltrus-chat-log {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 16px 16px 10px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  background: var(--el-bg);
  scroll-behavior: smooth;
}

.eltrus-chat-msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.eltrus-chat-msg--user {
  justify-content: flex-end;
}
.eltrus-chat-msg--assistant {
  justify-content: flex-start;
}
.eltrus-chat-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  flex: 0 0 auto;
  align-self: flex-start;
  box-shadow: 0 1px 4px rgba(15, 17, 21, 0.15);
}

.eltrus-chat-stack {
  display: flex;
  flex-direction: column;
  gap: 6px;
  min-width: 0;
  max-width: 84%;
}

.eltrus-chat-bubble {
  padding: 10px 13px;
  border-radius: 14px;
  font-size: 14px;
  line-height: 1.5;
  white-space: pre-wrap;
  overflow-wrap: anywhere;
  animation: eltrus-bubble-in 240ms var(--el-ease);
}
.eltrus-chat-msg--user .eltrus-chat-bubble {
  max-width: 84%;
  background: var(--el-ink);
  color: #fafaf7;
  border-bottom-right-radius: 5px;
}
.eltrus-chat-msg--assistant .eltrus-chat-bubble {
  background: var(--el-card);
  border: 1px solid var(--el-rule);
  color: var(--el-ink);
  border-bottom-left-radius: 5px;
}
@keyframes eltrus-bubble-in {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Tool-call status chips */
.eltrus-chat-chips {
  display: flex;
  flex-direction: column;
  gap: 5px;
}
.eltrus-chat-chips:empty {
  display: none;
}
.eltrus-chat-chip-status {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  align-self: flex-start;
  padding: 6px 11px 6px 9px;
  font-size: 12px;
  font-weight: 500;
  color: #166534;
  background: var(--el-accent-tint);
  border: 1px solid rgba(22, 163, 74, 0.22);
  border-radius: 999px;
  animation: eltrus-bubble-in 220ms var(--el-ease);
  transition: opacity 200ms ease, color 200ms ease;
}
.eltrus-chat-chip-status.is-done {
  color: #15803d;
}
.eltrus-chat-chip-spinner {
  width: 13px;
  height: 13px;
  flex: 0 0 auto;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  border: 2px solid rgba(22, 163, 74, 0.3);
  border-top-color: var(--el-accent);
  animation: eltrus-spin 0.7s linear infinite;
}
.eltrus-chat-chip-spinner.is-check {
  border: none;
  color: var(--el-accent);
  animation: none;
}
@keyframes eltrus-spin {
  to { transform: rotate(360deg); }
}

/* Inline typing dots (before first delta) */
.eltrus-chat-typing-inline {
  display: inline-flex;
  gap: 4px;
  padding: 2px 2px;
}
.eltrus-chat-typing-inline span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--el-mute);
  animation: eltrus-bounce 1.2s infinite ease-in-out;
}
.eltrus-chat-typing-inline span:nth-child(2) { animation-delay: 0.15s; }
.eltrus-chat-typing-inline span:nth-child(3) { animation-delay: 0.3s; }
@keyframes eltrus-bounce {
  0%, 80%, 100% { transform: translateY(0); opacity: 0.4; }
  40% { transform: translateY(-3px); opacity: 1; }
}

/* Form */
.eltrus-chat-form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px;
  border-top: 1px solid var(--el-rule);
  background: var(--el-bg-alt);
}
.eltrus-chat-input-wrap {
  flex: 1 1 auto;
  min-width: 0;
}
.eltrus-chat-input {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  font-family: inherit;
  font-size: 14px;
  line-height: 1.4;
  color: var(--el-ink);
  background: var(--el-card);
  border: 1px solid var(--el-rule);
  border-radius: 12px;
  resize: none;
  max-height: 120px;
  overflow-y: hidden;
  transition: border-color 150ms ease, box-shadow 150ms ease;
}
.eltrus-chat-input:focus {
  outline: none;
  border-color: var(--el-accent);
  box-shadow: 0 0 0 3px var(--el-accent-tint);
}
.eltrus-chat-input:disabled {
  opacity: 0.6;
}
.eltrus-chat-input::placeholder {
  color: var(--el-mute);
}
.eltrus-chat-send {
  flex: 0 0 auto;
  width: 40px;
  height: 40px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fafaf7;
  background: var(--el-ink);
  border: none;
  border-radius: 12px;
  cursor: pointer;
  transition: background 150ms ease, transform 120ms ease, opacity 150ms ease;
}
.eltrus-chat-send:hover:not(:disabled) {
  background: var(--el-accent);
  transform: translateY(-1px);
}
.eltrus-chat-send:disabled {
  opacity: 0.45;
  cursor: default;
}

/* Mobile */
@media (max-width: 480px) {
  .eltrus-chat-panel {
    right: 12px;
    left: 12px;
    bottom: 12px;
    width: auto;
    max-width: none;
    height: calc(100vh - 24px);
    max-height: calc(100vh - 24px);
    border-radius: 14px;
  }
  .eltrus-chat-launcher {
    right: 16px;
    bottom: 16px;
  }
}

/* Respect reduced motion: no transforms, fade only */
@media (prefers-reduced-motion: reduce) {
  .eltrus-chat-panel {
    transition: opacity 150ms linear;
    transform: none !important;
  }
  .eltrus-chat-panel.is-closing {
    transform: none !important;
  }
  .eltrus-chat-launcher {
    transition: opacity 150ms linear;
  }
  .eltrus-chat-launcher:hover {
    transform: none;
  }
  .eltrus-chat-launcher__pulse,
  .eltrus-chat-typing-inline span,
  .eltrus-chat-chip-spinner,
  .eltrus-chat-bubble,
  .eltrus-chat-chip-status {
    animation: none;
  }
}
