/* Aimatic public chat widget — matches marketing site (teal, high contrast). */
:root {
  --amchat-ink: #04161c;
  --amchat-panel: #0a242c;
  --amchat-line: rgba(244, 251, 248, 0.14);
  --amchat-text: #f4fbf8;
  --amchat-mute: rgba(244, 251, 248, 0.62);
  --amchat-teal: #0b9a84;
  --amchat-teal-2: #077a69;
  --amchat-mint: #8ef0d4;
  --amchat-safe-b: env(safe-area-inset-bottom, 0px);
  --amchat-safe-r: env(safe-area-inset-right, 0px);
  --amchat-dock-clearance: 84px;
}

.amchat-launcher {
  position: fixed;
  right: max(16px, var(--amchat-safe-r));
  bottom: calc(22px + var(--amchat-safe-b));
  z-index: 60;
  width: 60px;
  height: 60px;
  border-radius: 18px;
  background: var(--amchat-teal);
  border: 2px solid rgba(255, 255, 255, 0.35);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  box-shadow:
    0 12px 28px rgba(11, 154, 132, 0.45),
    0 0 0 6px rgba(11, 154, 132, 0.16);
  transition: transform 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}

.amchat-launcher::after {
  content: "Chat";
  position: absolute;
  right: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  padding: 7px 10px;
  border-radius: 999px;
  background: var(--amchat-ink);
  color: #fff;
  font: 700 12px/1 "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
  letter-spacing: 0.02em;
  white-space: nowrap;
  box-shadow: 0 8px 20px rgba(4, 22, 28, 0.25);
  pointer-events: none;
}

.amchat-launcher:hover {
  background: var(--amchat-teal-2);
  transform: translateY(-2px);
  box-shadow:
    0 16px 32px rgba(11, 154, 132, 0.5),
    0 0 0 7px rgba(11, 154, 132, 0.18);
}

.amchat-launcher:focus-visible {
  outline: 3px solid rgba(11, 154, 132, 0.45);
  outline-offset: 3px;
}

.amchat-launcher svg {
  width: 26px;
  height: 26px;
}

.amchat-panel {
  position: fixed;
  right: max(16px, var(--amchat-safe-r));
  bottom: calc(96px + var(--amchat-safe-b));
  z-index: 61;
  width: min(380px, calc(100vw - 28px));
  height: min(560px, calc(100dvh - 140px));
  background: var(--amchat-panel);
  border: 1px solid var(--amchat-line);
  border-radius: 18px;
  box-shadow: 0 24px 60px rgba(4, 22, 28, 0.45);
  display: none;
  flex-direction: column;
  overflow: hidden;
  font-family: "Bricolage Grotesque", ui-sans-serif, system-ui, sans-serif;
}

.amchat-panel.amchat-open { display: flex; }

.amchat-head {
  padding: 14px 16px;
  background: linear-gradient(135deg, rgba(11, 154, 132, 0.28), rgba(4, 22, 28, 0.2));
  border-bottom: 1px solid var(--amchat-line);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
}

.amchat-head-title {
  color: var(--amchat-text);
  font-weight: 750;
  font-size: 15px;
}

.amchat-head-sub {
  color: var(--amchat-mute);
  font-size: 11px;
  margin-top: 2px;
}

.amchat-close {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid var(--amchat-line);
  border-radius: 10px;
  color: var(--amchat-mute);
  cursor: pointer;
  font-size: 16px;
  line-height: 1;
  width: 34px;
  height: 34px;
}

.amchat-close:hover { color: var(--amchat-text); background: rgba(255, 255, 255, 0.1); }

.amchat-body {
  flex: 1;
  overflow-y: auto;
  padding: 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.amchat-msg {
  max-width: 88%;
  padding: 10px 12px;
  border-radius: 12px;
  font-size: 13px;
  line-height: 1.45;
  white-space: pre-wrap;
  word-wrap: break-word;
}

.amchat-msg-bot {
  align-self: flex-start;
  background: rgba(244, 251, 248, 0.08);
  color: var(--amchat-text);
  border: 1px solid var(--amchat-line);
}

.amchat-msg-user {
  align-self: flex-end;
  background: var(--amchat-teal);
  color: #fff;
  font-weight: 600;
}

.amchat-msg-err {
  align-self: flex-start;
  background: rgba(220, 80, 80, 0.14);
  color: #f0b4b4;
  border: 1px solid rgba(220, 80, 80, 0.25);
}

.amchat-typing {
  align-self: flex-start;
  color: var(--amchat-mute);
  font-size: 12px;
  padding: 2px 12px;
}

.amchat-foot {
  border-top: 1px solid var(--amchat-line);
  padding: 10px;
  display: flex;
  gap: 8px;
}

.amchat-input {
  flex: 1;
  background: #04161c;
  border: 1px solid var(--amchat-line);
  border-radius: 10px;
  color: var(--amchat-text);
  padding: 10px 12px;
  font-size: 16px;
  font-family: inherit;
  outline: none;
  resize: none;
}

.amchat-input:focus { border-color: var(--amchat-teal); }

.amchat-send {
  background: var(--amchat-teal);
  border: none;
  border-radius: 10px;
  color: #fff;
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
}

.amchat-send:disabled { opacity: 0.5; cursor: default; }

.amchat-body::-webkit-scrollbar { width: 6px; }
.amchat-body::-webkit-scrollbar-thumb {
  background: rgba(244, 251, 248, 0.18);
  border-radius: 3px;
}

.amchat-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  padding: 0 14px 12px;
}

.amchat-chip {
  background: rgba(244, 251, 248, 0.06);
  border: 1px solid var(--amchat-line);
  color: var(--amchat-text);
  border-radius: 999px;
  padding: 7px 11px;
  font-size: 12px;
  cursor: pointer;
  line-height: 1.3;
  text-align: left;
  font-family: inherit;
}

.amchat-chip:hover {
  background: rgba(11, 154, 132, 0.18);
  border-color: rgba(142, 240, 212, 0.45);
}

.amchat-cta { display: none; padding: 0 14px 12px; }
.amchat-cta.amchat-cta-visible { display: block; }

.amchat-cta-btn,
.amchat-handoff-submit {
  width: 100%;
  border: 0;
  border-radius: 12px;
  padding: 11px 12px;
  font-weight: 750;
  font-size: 13px;
  cursor: pointer;
  background: var(--amchat-teal);
  color: #fff;
  font-family: inherit;
}

.amchat-handoff {
  display: none;
  padding: 0 14px 12px;
  gap: 8px;
  flex-direction: column;
}

.amchat-handoff.amchat-open { display: flex; }

.amchat-handoff input {
  background: #04161c;
  border: 1px solid var(--amchat-line);
  border-radius: 10px;
  color: var(--amchat-text);
  padding: 10px 12px;
  font-size: 16px;
  font-family: inherit;
}

.amchat-sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  border: 0;
}

/* Sit above mobile dock; keep label visible on larger screens only */
@media (max-width: 979px) {
  .amchat-launcher {
    bottom: calc(var(--amchat-dock-clearance) + var(--amchat-safe-b));
    width: 56px;
    height: 56px;
  }

  .amchat-launcher::after { display: none; }

  .amchat-panel {
    right: 12px;
    left: 12px;
    width: auto;
    bottom: calc(var(--amchat-dock-clearance) + 68px + var(--amchat-safe-b));
    height: min(520px, calc(100dvh - 180px));
  }
}

@media (max-width: 979px) and (orientation: landscape) {
  .amchat-launcher {
    bottom: max(12px, var(--amchat-safe-b));
    right: max(12px, var(--amchat-safe-r));
  }

  .amchat-panel {
    left: auto;
    right: max(12px, var(--amchat-safe-r));
    width: min(360px, 48vw);
    bottom: 76px;
    height: calc(100dvh - 96px);
  }
}

/* Hide chat under open app sheets so UX does not fight itself */
body:has(.app.is-open) .amchat-launcher,
body:has(.app.is-open) .amchat-panel {
  opacity: 0;
  pointer-events: none;
  visibility: hidden;
}

@media (prefers-reduced-motion: reduce) {
  .amchat-launcher { transition: none; }
}
