/* 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: 0;
  padding: 0 !important;
  width: 44px;
  height: 44px;
  min-width: 44px;
  min-height: 44px;
  border: none !important;
  border-radius: 50%;
  background: var(--arion-chat-accent) !important;
  color: #fff !important;
  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,
    background 0.25s ease;
  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: 22px;
  height: 22px;
  flex-shrink: 0;
}

.arion-chat-toggle__chat {
  position: absolute;
  inset: 0;
  width: 22px;
  height: 22px;
  color: #fff;
  display: block;
  transform: scaleX(-1);
  transition: opacity 0.2s ease, transform 0.25s ease;
  z-index: 1;
}

/* 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: 16px;
  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);
}

/* Open: circular close (icon centered), red */
.arion-chat-root.arion-chat-root--open .arion-chat-toggle {
  width: 44px;
  height: 44px;
  min-width: 44px;
  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__chat {
  opacity: 0;
  transform: scaleX(-1) scale(0);
}

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

.arion-chat-panel {
  position: absolute;
  bottom: 56px;
  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 wave logo loader (vanilla embed; React FAB uses ArionLoader) */
.arion-chat-loading__logo {
  display: block;
  width: 40px;
  height: 15px;
  overflow: visible;
}

.arion-chat-loading__logo-base,
.arion-chat-loading__logo-sweep {
  fill: none;
  stroke-width: 6;
  stroke-linecap: round;
  stroke-linejoin: round;
}

.arion-chat-loading__logo-base {
  stroke: #0a0a0a;
}

.arion-chat-loading__logo-sweep {
  stroke: var(--arion-chat-accent);
  stroke-dasharray: 1;
  stroke-dashoffset: 1;
  animation: arion-chat-wave-draw 1.75s ease-in-out infinite;
}

@keyframes arion-chat-wave-draw {
  0% {
    stroke-dashoffset: 1;
  }
  70% {
    stroke-dashoffset: 0;
  }
  100% {
    stroke-dashoffset: 0;
  }
}

@media (prefers-reduced-motion: reduce) {
  .arion-chat-loading__logo-sweep {
    animation: none;
    stroke-dashoffset: 0;
  }
}

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

@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;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    max-width: none;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    border: 0;
    pointer-events: auto;
    animation: arion-chat-sheet-in 0.32s ease;
  }

  @supports (height: 100svh) {
    .arion-chat-panel {
      height: 100svh;
      max-height: 100svh;
    }
  }

  @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: 12px;
    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) - 22px);
    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);
  }
}
