/* Arion design system default (--green) */
.arion-chat-root[hidden] {
  display: none !important;
}

.arion-chat-root {
  --arion-chat-accent: #16a34a;
  --arion-chat-close: #dc2626;
  --arion-chat-z: 2147483000;
  --arion-chat-panel-h: min(
    600px,
    calc(100vh - 120px),
    calc(100dvh - 120px)
  );
  position: fixed;
  bottom: 20px;
  z-index: var(--arion-chat-z);
  font-family: system-ui, -apple-system, "Segoe UI", Roboto, sans-serif;
}

.arion-chat-root--right {
  right: 20px;
}

.arion-chat-root--left {
  left: 20px;
}

.arion-chat-root .arion-chat-toggle {
  display: inline-flex !important;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 12px 18px;
  border: none !important;
  border-radius: 999px;
  background: var(--arion-chat-accent) !important;
  color: #fff !important;
  font-size: 15px;
  font-weight: 600;
  line-height: 1;
  cursor: pointer;
  pointer-events: auto;
  box-shadow: 0 4px 24px rgba(0, 0, 0, 0.18);
  transition:
    transform 0.2s ease,
    box-shadow 0.2s ease,
    padding 0.25s ease,
    width 0.25s ease,
    height 0.25s ease,
    border-radius 0.25s ease,
    left 0.25s ease,
    right 0.25s ease,
    top 0.25s ease,
    bottom 0.25s ease;
  min-height: 48px;
  min-width: 48px;
  position: relative;
  z-index: 2;
}

.arion-chat-root:not(.arion-chat-root--open) .arion-chat-toggle:hover {
  transform: translateY(-1px);
  box-shadow: 0 6px 28px rgba(0, 0, 0, 0.22);
}

.arion-chat-root .arion-chat-toggle:focus-visible {
  outline: 2px solid #fff;
  outline-offset: 2px;
}

.arion-chat-toggle__icon {
  position: relative;
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

/* Chat state: status dot + pulse on white circle only */
.arion-chat-toggle__dot {
  position: absolute;
  inset: 0;
  margin: auto;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #fff;
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.35);
  transition: opacity 0.2s ease, transform 0.25s ease;
  z-index: 1;
}

.arion-chat-root:not(.arion-chat-root--open) .arion-chat-toggle__dot::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 10px;
  height: 10px;
  margin: -5px 0 0 -5px;
  border-radius: 50%;
  background: #fff;
  pointer-events: none;
  animation: arion-chat-dot-pulse 2s ease-out infinite;
}

@keyframes arion-chat-dot-pulse {
  0% {
    transform: scale(1);
    opacity: 0.65;
  }
  70%,
  100% {
    transform: scale(3);
    opacity: 0;
  }
}

/* Close state: X */
.arion-chat-toggle__x {
  position: absolute;
  inset: 0;
  opacity: 0;
  transform: rotate(-90deg) scale(0.5);
  transition: opacity 0.2s ease, transform 0.25s ease;
}

.arion-chat-toggle__x::before,
.arion-chat-toggle__x::after {
  content: "";
  position: absolute;
  top: 50%;
  left: 50%;
  width: 20px;
  height: 2px;
  background: #fff;
  border-radius: 1px;
  transform-origin: center center;
}

.arion-chat-toggle__x::before {
  transform: translate(-50%, -50%) rotate(45deg);
}

.arion-chat-toggle__x::after {
  transform: translate(-50%, -50%) rotate(-45deg);
}

.arion-chat-toggle__label {
  display: inline-block;
  max-width: 120px;
  overflow: hidden;
  white-space: nowrap;
  transition: opacity 0.2s ease, max-width 0.25s ease, margin 0.25s ease;
}

/* Open: morph pill → circular close (icon centered), red */
.arion-chat-root.arion-chat-root--open .arion-chat-toggle {
  padding: 0 !important;
  width: 52px;
  height: 52px;
  min-width: 52px;
  border-radius: 50%;
  justify-content: center;
  align-items: center;
  gap: 0;
  background: var(--arion-chat-close) !important;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  z-index: 3;
}

.arion-chat-root--open .arion-chat-toggle__icon {
  position: absolute;
  inset: 0;
  width: auto;
  height: auto;
  margin: 0;
}

.arion-chat-root--open .arion-chat-toggle__dot {
  opacity: 0;
  transform: scale(0);
}

.arion-chat-root--open .arion-chat-toggle__x {
  opacity: 1;
  transform: none;
}

.arion-chat-root--open .arion-chat-toggle__label {
  display: none;
}

.arion-chat-panel {
  position: absolute;
  bottom: 64px;
  width: min(380px, calc(100vw - 40px));
  height: var(--arion-chat-panel-h);
  max-height: var(--arion-chat-panel-h);
  border-radius: 16px;
  overflow: hidden;
  background: #fff;
  box-shadow: 0 12px 48px rgba(0, 0, 0, 0.2);
  border: 1px solid rgba(0, 0, 0, 0.08);
  z-index: 1;
  animation: arion-chat-panel-in 0.28s ease;
}

@keyframes arion-chat-panel-in {
  from {
    opacity: 0;
    transform: translateY(12px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

.arion-chat-root--right .arion-chat-panel {
  right: 0;
}

.arion-chat-root--left .arion-chat-panel {
  left: 0;
}

.arion-chat-loading {
  position: absolute;
  inset: 0;
  z-index: 2;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  background: #fafafa;
  animation: arion-chat-fade-in 0.2s ease;
}

.arion-chat-loading[hidden] {
  display: none !important;
}

.arion-chat-loading__spinner {
  width: 36px;
  height: 36px;
  border: 3px solid rgba(22, 163, 74, 0.15);
  border-top-color: var(--arion-chat-accent);
  border-radius: 50%;
  animation: arion-chat-spin 0.75s linear infinite;
}

.arion-chat-loading__text {
  margin: 0;
  font-size: 14px;
  font-weight: 500;
  color: #525252;
  letter-spacing: 0.01em;
}

@keyframes arion-chat-spin {
  to {
    transform: rotate(360deg);
  }
}

@keyframes arion-chat-fade-in {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.arion-chat-frame {
  display: block;
  width: 100%;
  height: 100%;
  border: 0;
  background: #fff;
  opacity: 1;
  transition: opacity 0.35s ease;
}

.arion-chat-frame--loading {
  opacity: 0;
  pointer-events: none;
}

.arion-chat-frame--ready {
  opacity: 1;
}

@media (max-width: 480px) {
  .arion-chat-root {
    bottom: 0;
    left: 0;
    right: 0;
    width: 100%;
    pointer-events: none;
  }

  .arion-chat-root--right,
  .arion-chat-root--left {
    left: 0;
    right: 0;
  }

  .arion-chat-root .arion-chat-toggle {
    pointer-events: auto;
    position: fixed;
    bottom: 16px;
    z-index: calc(var(--arion-chat-z) + 2);
  }

  .arion-chat-root--right .arion-chat-toggle {
    right: 16px;
    left: auto;
  }

  .arion-chat-root--left .arion-chat-toggle {
    left: 16px;
    right: auto;
  }

  .arion-chat-panel {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: none;
    height: min(92dvh, 100dvh);
    max-height: 100dvh;
    border-radius: 16px 16px 0 0;
    pointer-events: auto;
    animation: arion-chat-sheet-in 0.32s ease;
  }

  @keyframes arion-chat-sheet-in {
    from {
      opacity: 0;
      transform: translateY(100%);
    }
    to {
      opacity: 1;
      transform: translateY(0);
    }
  }

  /* Close (X): top-right corner of bottom sheet */
  .arion-chat-root--open .arion-chat-toggle {
    display: inline-flex !important;
    bottom: auto;
    top: calc(100dvh - min(92dvh, 100dvh) + 10px);
    left: auto;
    right: 12px;
    transform: none;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.2);
  }

  .arion-chat-root--open.arion-chat-root--left .arion-chat-toggle {
    left: 16px;
    right: auto;
  }

  .arion-chat-root--open .arion-chat-toggle:hover {
    transform: translateY(-1px);
  }
}

/* Desktop: close anchored to top corner of chat panel */
@media (min-width: 481px) {
  .arion-chat-panel {
    bottom: 0;
  }

  .arion-chat-root--open .arion-chat-toggle {
    position: absolute;
    top: auto;
    bottom: calc(var(--arion-chat-panel-h) - 26px);
    transform: none;
  }

  .arion-chat-root--open.arion-chat-root--right .arion-chat-toggle {
    left: auto;
    right: -14px;
  }

  .arion-chat-root--open.arion-chat-root--left .arion-chat-toggle {
    right: auto;
    left: -14px;
  }

  .arion-chat-root--open .arion-chat-toggle:hover {
    transform: translateY(-1px);
  }
}
