/* Aevix live chat widget */
:root {
  --chat-bg: oklch(6% 0.006 95 / 0.82);
  --chat-bg-strong: oklch(5% 0.004 95 / 0.96);
  --chat-surface: oklch(12% 0.006 95 / 0.7);
  --chat-line: oklch(92% 0 0 / 0.12);
  --chat-text: oklch(92% 0 0);
  --chat-muted: oklch(70% 0 0);
  --chat-faint: oklch(92% 0 0 / 0.06);
  --chat-accent: oklch(70% 0.12 188);
  --chat-accent-soft: oklch(70% 0.12 188 / 0.1);
  --chat-shadow: 0 16px 40px rgb(0 0 0 / 0.34);
  --chat-radius: 10px;
  --chat-ease: cubic-bezier(0.23, 1, 0.32, 1);
  --chat-drawer: cubic-bezier(0.32, 0.72, 0, 1);
}

[data-theme="light"] {
  --chat-bg: oklch(99% 0.008 95 / 0.78);
  --chat-bg-strong: oklch(99% 0.008 95 / 0.96);
  --chat-surface: oklch(94% 0.012 95 / 0.74);
  --chat-line: oklch(20% 0.02 95 / 0.12);
  --chat-text: oklch(19% 0.02 95);
  --chat-muted: oklch(43% 0.015 95);
  --chat-faint: oklch(20% 0.02 95 / 0.06);
  --chat-shadow: 0 18px 48px rgb(15 24 32 / 0.16);
}

.aevix-chat {
  position: fixed;
  right: max(1.25rem, env(safe-area-inset-right));
  bottom: max(1.25rem, env(safe-area-inset-bottom));
  z-index: 120;
  font-family: var(--sans, 'Albert Sans', 'Avenir Next', system-ui, sans-serif);
  color: var(--chat-text);
}

.aevix-chat * {
  box-sizing: border-box;
}

.aevix-chat__button {
  width: 3.7rem;
  height: 3.7rem;
  display: grid;
  place-items: center;
  border: 1px solid var(--chat-line);
  border-radius: 999px;
  color: var(--chat-text);
  cursor: pointer;
  background:
    linear-gradient(145deg, oklch(100% 0 0 / 0.08), transparent 44%),
    var(--chat-bg);
  box-shadow: var(--chat-shadow);
  -webkit-backdrop-filter: blur(18px) saturate(1.25);
  backdrop-filter: blur(18px) saturate(1.25);
  transition:
    transform 180ms var(--chat-ease),
    border-color 180ms ease,
    background 220ms ease,
    opacity 180ms ease;
}

.aevix-chat__button:hover,
.aevix-chat__button:focus-visible {
  border-color: oklch(70% 0.12 188 / 0.48);
  transform: translateY(-2px);
  outline: none;
}

.aevix-chat__button:active {
  transform: scale(0.97);
}

.aevix-chat.is-open .aevix-chat__button {
  opacity: 0;
  pointer-events: none;
  transform: scale(0.92);
}

.aevix-chat__button svg {
  width: 1.55rem;
  height: 1.55rem;
  stroke-width: 1.35;
}

.aevix-chat__logo {
  width: 1.42rem;
  height: 1.42rem;
  object-fit: contain;
  display: block;
  filter: none;
}

.aevix-chat__badge {
  position: absolute;
  top: 0.15rem;
  right: 0.15rem;
  min-width: 1.15rem;
  height: 1.15rem;
  display: grid;
  place-items: center;
  border-radius: 999px;
  background: var(--chat-accent);
  color: oklch(8% 0.004 188);
  font: 600 0.62rem/1 var(--mono, ui-monospace, monospace);
  opacity: 0;
  transform: scale(0.88);
  transition: opacity 160ms ease, transform 160ms var(--chat-ease);
}

.aevix-chat.has-unread .aevix-chat__badge {
  opacity: 1;
  transform: scale(1);
}

.aevix-chat__panel {
  position: fixed;
  right: max(1.25rem, env(safe-area-inset-right));
  bottom: calc(max(1.25rem, env(safe-area-inset-bottom)) + 4.85rem);
  width: min(24.5rem, calc(100vw - 2rem));
  height: min(34rem, calc(100vh - 7rem));
  height: min(34rem, calc(100dvh - 7rem));
  min-height: min(27rem, calc(100vh - 7rem));
  min-height: min(27rem, calc(100dvh - 7rem));
  max-height: calc(100vh - 7rem);
  max-height: calc(100dvh - 7rem);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  border: 1px solid var(--chat-line);
  border-radius: var(--chat-radius);
  background:
    linear-gradient(180deg, oklch(100% 0 0 / 0.045), transparent 10rem),
    var(--chat-bg-strong);
  box-shadow: var(--chat-shadow);
  -webkit-backdrop-filter: blur(22px) saturate(1.2);
  backdrop-filter: blur(22px) saturate(1.2);
  opacity: 0;
  pointer-events: none;
  transform: translateY(0.65rem) scale(0.97);
  transform-origin: bottom right;
  transition:
    opacity 190ms ease,
    transform 240ms var(--chat-drawer);
}

.aevix-chat.is-open .aevix-chat__panel {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0) scale(1);
}

.aevix-chat__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 0.9rem 0.95rem 0.78rem;
  border-bottom: 1px solid var(--chat-line);
}

.aevix-chat__identity {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 0;
}

.aevix-chat__orb {
  width: 2.15rem;
  height: 2.15rem;
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  border: 1px solid var(--chat-line);
  border-radius: 8px;
  background: oklch(100% 0 0 / 0.035);
  color: var(--chat-accent);
}

.aevix-chat__orb .aevix-chat__logo {
  width: 1.52rem;
  height: 1.52rem;
}

.aevix-chat__title {
  display: block;
  font: 500 0.86rem/1.2 var(--serif, Georgia, serif);
  letter-spacing: 0;
}

.aevix-chat__status {
  display: flex;
  align-items: center;
  gap: 0.4rem;
  margin-top: 0.18rem;
  color: var(--chat-muted);
  font: 500 0.56rem/1.2 var(--mono, ui-monospace, monospace);
  letter-spacing: 0.1em;
  text-transform: uppercase;
}

.aevix-chat__status::before {
  content: '';
  width: 0.42rem;
  height: 0.42rem;
  border-radius: 999px;
  background: var(--chat-accent);
  box-shadow: 0 0 10px oklch(70% 0.12 188 / 0.55);
}

.aevix-chat__close {
  width: 2rem;
  height: 2rem;
  display: grid;
  place-items: center;
  border: 1px solid transparent;
  border-radius: 999px;
  background: transparent;
  color: var(--chat-muted);
  cursor: pointer;
  transition: color 150ms ease, background 150ms ease, transform 150ms ease;
}

.aevix-chat__header-actions {
  display: flex;
  align-items: center;
  gap: 0.35rem;
  flex: 0 0 auto;
}

.aevix-chat__reset {
  border: 1px solid transparent;
  border-radius: 999px;
  padding: 0.4rem 0.55rem;
  background: transparent;
  color: var(--chat-muted);
  cursor: pointer;
  font: 500 0.55rem/1 var(--mono, ui-monospace, monospace);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  transition: color 150ms ease, background 150ms ease, transform 150ms ease;
}

.aevix-chat__reset:hover,
.aevix-chat__reset:focus-visible {
  color: var(--chat-text);
  background: var(--chat-faint);
  outline: none;
}

.aevix-chat__reset:active {
  transform: scale(0.97);
}

.aevix-chat__close:hover,
.aevix-chat__close:focus-visible {
  color: var(--chat-text);
  background: var(--chat-faint);
  outline: none;
}

.aevix-chat__close:active {
  transform: scale(0.96);
}

.aevix-chat__messages {
  flex: 1;
  overflow-y: auto;
  padding: 1rem;
  scrollbar-width: thin;
  scrollbar-color: oklch(92% 0 0 / 0.22) transparent;
}

.aevix-chat__messages::-webkit-scrollbar {
  width: 0.4rem;
}

.aevix-chat__messages::-webkit-scrollbar-thumb {
  background: oklch(92% 0 0 / 0.2);
  border-radius: 999px;
}

.aevix-chat__day {
  margin: 0.15rem 0 0.8rem;
  text-align: center;
  color: var(--chat-muted);
  font: 500 0.58rem/1.2 var(--mono, ui-monospace, monospace);
  letter-spacing: 0.12em;
  text-transform: uppercase;
}

.aevix-chat__assist {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 1px;
  margin: 0 0 0.9rem;
  overflow: hidden;
  border: 1px solid var(--chat-line);
  border-radius: 8px;
  background: var(--chat-line);
}

.aevix-chat__assist-row {
  min-width: 0;
  padding: 0.62rem 0.58rem;
  background: oklch(100% 0 0 / 0.028);
}

.aevix-chat__assist-row span,
.aevix-chat__assist-row strong {
  display: block;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.aevix-chat__assist-row span {
  color: var(--chat-muted);
  font: 500 0.52rem/1.2 var(--mono, ui-monospace, monospace);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.aevix-chat__assist-row strong {
  margin-top: 0.22rem;
  color: var(--chat-text);
  font: 500 0.68rem/1.25 var(--sans, system-ui, sans-serif);
}

.aevix-chat__message {
  display: flex;
  margin: 0 0 0.72rem;
}

.aevix-chat__message.is-user {
  justify-content: flex-end;
}

.aevix-chat__bubble {
  max-width: 82%;
  padding: 0.68rem 0.78rem;
  border: 1px solid var(--chat-line);
  border-radius: 8px;
  background: var(--chat-surface);
  color: var(--chat-text);
  font-size: 0.88rem;
  line-height: 1.5;
  overflow-wrap: anywhere;
}

.aevix-chat__bubble-text {
  display: block;
}

.aevix-chat__meta {
  display: block;
  margin-top: 0.48rem;
  color: var(--chat-muted);
  font: 500 0.5rem/1.25 var(--mono, ui-monospace, monospace);
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.aevix-chat__message.is-user .aevix-chat__bubble {
  border-color: oklch(70% 0.12 188 / 0.28);
  background: oklch(70% 0.12 188 / 0.09);
}

.aevix-chat__quick {
  display: flex;
  flex-wrap: wrap;
  gap: 0.45rem;
  margin: 0.15rem 0 0.9rem;
}

.aevix-chat__quick button {
  border: 1px solid var(--chat-line);
  border-radius: 8px;
  padding: 0.48rem 0.62rem;
  color: var(--chat-text);
  background: transparent;
  cursor: pointer;
  font: 500 0.72rem/1.2 var(--mono, ui-monospace, monospace);
  transition: background 150ms ease, border-color 150ms ease, transform 150ms ease;
}

.aevix-chat__quick button:hover,
.aevix-chat__quick button:focus-visible {
  border-color: oklch(70% 0.12 188 / 0.34);
  background: oklch(70% 0.12 188 / 0.08);
  outline: none;
}

.aevix-chat__quick button:active {
  transform: scale(0.97);
}

.aevix-chat__typing {
  display: none;
  align-items: center;
  gap: 0.35rem;
  margin: 0 0 0.72rem;
  padding-left: 0.1rem;
}

.aevix-chat.is-typing .aevix-chat__typing {
  display: flex;
}

.aevix-chat__typing span {
  width: 0.38rem;
  height: 0.38rem;
  border-radius: 999px;
  background: var(--chat-muted);
  animation: aevix-chat-dot 900ms ease-in-out infinite;
}

.aevix-chat__typing span:nth-child(2) {
  animation-delay: 120ms;
}

.aevix-chat__typing span:nth-child(3) {
  animation-delay: 240ms;
}

.aevix-chat__composer {
  padding: 0.75rem;
  border-top: 1px solid var(--chat-line);
  background: linear-gradient(180deg, transparent, oklch(0% 0 0 / 0.14));
}

.aevix-chat__contact {
  display: grid;
  grid-template-columns: minmax(0, 1fr) auto;
  gap: 0.55rem;
  align-items: center;
  margin-bottom: 0.55rem;
}

.aevix-chat__email {
  min-width: 0;
  height: 2.1rem;
  border: 1px solid var(--chat-line);
  border-radius: 8px;
  padding: 0 0.68rem;
  background: oklch(0% 0 0 / 0.18);
  color: var(--chat-text);
  font: 400 0.76rem/1 var(--sans, system-ui, sans-serif);
  outline: none;
}

.aevix-chat__email::placeholder {
  color: var(--chat-muted);
  opacity: 1;
}

.aevix-chat__email:focus {
  border-color: oklch(70% 0.12 188 / 0.42);
}

.aevix-chat__contact-state {
  color: var(--chat-muted);
  font: 500 0.52rem/1.2 var(--mono, ui-monospace, monospace);
  letter-spacing: 0.06em;
  text-transform: uppercase;
  white-space: nowrap;
}

.aevix-chat__field {
  display: grid;
  grid-template-columns: 1fr 2.35rem;
  gap: 0.55rem;
  align-items: end;
}

.aevix-chat__input {
  width: 100%;
  min-height: 2.35rem;
  max-height: 7rem;
  resize: none;
  border: 1px solid var(--chat-line);
  border-radius: 8px;
  padding: 0.68rem 0.78rem;
  color: var(--chat-text);
  background: oklch(0% 0 0 / 0.22);
  font: 400 0.88rem/1.35 var(--sans, system-ui, sans-serif);
  outline: none;
}

.aevix-chat__input::placeholder {
  color: var(--chat-muted);
  opacity: 1;
}

.aevix-chat__input:focus {
  border-color: oklch(70% 0.12 188 / 0.5);
}

.aevix-chat__send {
  width: 2.35rem;
  height: 2.35rem;
  display: grid;
  place-items: center;
  border: 1px solid oklch(70% 0.12 188 / 0.35);
  border-radius: 8px;
  color: var(--chat-accent);
  background: oklch(70% 0.12 188 / 0.1);
  cursor: pointer;
  transition: transform 150ms ease, opacity 150ms ease;
}

.aevix-chat__send:disabled {
  opacity: 0.45;
  cursor: not-allowed;
}

.aevix-chat__send:not(:disabled):active {
  transform: scale(0.96);
}

.aevix-chat__send svg {
  width: 1rem;
  height: 1rem;
}

.aevix-chat__note {
  margin-top: 0.48rem;
  color: var(--chat-muted);
  font: 500 0.58rem/1.5 var(--mono, ui-monospace, monospace);
  letter-spacing: 0.06em;
}

@keyframes aevix-chat-dot {
  0%, 100% { opacity: 0.35; transform: translateY(0); }
  50% { opacity: 1; transform: translateY(-0.16rem); }
}

@media (max-width: 520px) {
  .aevix-chat {
    right: 1rem;
    bottom: 1rem;
  }

  .aevix-chat__panel {
    position: fixed;
    inset: auto 0 0 0;
    width: 100%;
    height: min(82vh, 42rem);
    min-height: 28rem;
    border-right: 0;
    border-bottom: 0;
    border-left: 0;
    border-radius: 10px 10px 0 0;
    transform-origin: bottom center;
  }

  .aevix-chat__button {
    width: 3.55rem;
    height: 3.55rem;
  }

  .aevix-chat__assist {
    grid-template-columns: 1fr;
  }

  .aevix-chat__contact {
    grid-template-columns: 1fr;
    gap: 0.38rem;
  }
}

@media (prefers-reduced-motion: reduce) {
  .aevix-chat__panel,
  .aevix-chat__button,
  .aevix-chat__badge,
  .aevix-chat__typing span {
    animation: none;
    transition-duration: 1ms;
  }
}
