/* Koda-Support auf der Website (shared/support/website/*): Koda unten rechts + Chatfenster. Violettes Liquid Glass. */

/* ---------- Koda unten rechts ---------- */
.nx-koda {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: max(16px, env(safe-area-inset-bottom));
  z-index: 60;
  display: flex;
  align-items: flex-end;
  gap: 10px;
  pointer-events: none;
  opacity: 0;
  transform: translateY(18px) scale(0.92);
  transition:
    opacity 0.45s ease,
    transform 0.6s var(--nx-spring, cubic-bezier(0.22, 1, 0.36, 1));
}
.nx-koda.ready {
  opacity: 1;
  transform: none;
}
.nx-koda > * {
  pointer-events: auto;
}
.nx-koda-bubble {
  position: relative;
  max-width: 260px;
  margin-bottom: 18px;
  padding: 13px 34px 13px 15px;
  border-radius: 20px 20px 6px 20px;
  font: 400 13.5px/1.45 var(--body);
  color: var(--ink);
  border: 1px solid rgba(255, 255, 255, 0.22);
  background: linear-gradient(180deg, rgba(36, 28, 86, 0.82), rgba(18, 14, 48, 0.86));
  -webkit-backdrop-filter: blur(18px) saturate(160%);
  backdrop-filter: blur(18px) saturate(160%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.25),
    0 18px 40px -16px rgba(4, 2, 24, 0.7);
  transition:
    opacity 0.35s ease,
    transform 0.5s var(--nx-spring, cubic-bezier(0.22, 1, 0.36, 1));
}
.nx-koda-bubble b {
  display: block;
  margin-bottom: 2px;
  font-size: 12px;
  color: var(--violet-ink);
}
.nx-koda-bubble-close {
  position: absolute;
  top: 6px;
  right: 8px;
  width: 22px;
  height: 22px;
  border: 0;
  border-radius: 50%;
  background: transparent;
  color: var(--haze);
  font-size: 16px;
  line-height: 1;
  cursor: pointer;
}
.nx-koda-bubble-close:hover {
  color: var(--ink);
  background: var(--rim-low);
}
.nx-koda-bubble.swap {
  animation: nxKodaSwap 0.5s var(--nx-spring, cubic-bezier(0.22, 1, 0.36, 1));
}
.nx-koda.quiet .nx-koda-bubble,
.nx-koda.open .nx-koda-bubble {
  opacity: 0;
  transform: translateY(6px) scale(0.96);
  pointer-events: none;
}
.nx-koda-button {
  position: relative;
  width: 76px;
  height: 76px;
  padding: 4px;
  border: 0;
  border-radius: 50%;
  background: none;
  cursor: pointer;
  filter: drop-shadow(0 12px 18px rgba(20, 10, 60, 0.45));
  transition: transform 0.4s var(--nx-spring, cubic-bezier(0.22, 1, 0.36, 1));
  -webkit-tap-highlight-color: transparent;
}
.nx-koda-button::before {
  content: '';
  position: absolute;
  inset: 6px;
  z-index: -1;
  border-radius: 50%;
  background: radial-gradient(circle at 50% 40%, rgba(124, 92, 255, 0.42), rgba(124, 92, 255, 0) 70%);
  opacity: 0;
  transition: opacity 0.3s ease;
}
.nx-koda-button:hover {
  transform: translateY(-3px) scale(1.04);
}
.nx-koda-button:hover::before,
.nx-koda.open .nx-koda-button::before {
  opacity: 1;
}
.nx-koda-button:active {
  transform: scale(0.95);
}
.nx-koda-button:focus-visible {
  outline: 3px solid var(--violet-ink);
  outline-offset: 2px;
}
.nx-koda-face {
  display: block;
  width: 100%;
  height: 100%;
  object-fit: contain;
  animation: nxKodaFloat 4.6s ease-in-out infinite;
}
.nx-koda-badge {
  position: absolute;
  right: 2px;
  bottom: 6px;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border: 2px solid rgba(255, 255, 255, 0.85);
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(180deg, #8f74ff, #6a4ff0);
  box-shadow: 0 4px 12px rgba(80, 50, 200, 0.5);
}
.nx-koda.busy .nx-koda-badge {
  animation: nxKodaPulse 0.9s ease-in-out infinite alternate;
}
@keyframes nxKodaFloat {
  0%,
  100% {
    transform: translateY(0);
  }
  50% {
    transform: translateY(-6px);
  }
}
@keyframes nxKodaSwap {
  from {
    opacity: 0;
    transform: translateY(8px) scale(0.96);
  }
}
@keyframes nxKodaPulse {
  to {
    transform: scale(1.15);
  }
}

/* ---------- Chatfenster ---------- */
.nx-support {
  position: fixed;
  right: max(16px, env(safe-area-inset-right));
  bottom: calc(max(16px, env(safe-area-inset-bottom)) + 88px);
  z-index: 61;
  display: flex;
  flex-direction: column;
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  width: min(400px, calc(100vw - 32px));
  /* Nie über die Navigation oben ragen. */
  height: min(620px, calc(100dvh - 200px));
  overflow: hidden;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 28px;
  color: var(--ink);
  font-family: var(--body);
  background:
    radial-gradient(120% 60% at 20% -10%, rgba(124, 92, 255, 0.35), transparent 60%), linear-gradient(180deg, rgba(30, 24, 74, 0.72), rgba(14, 12, 40, 0.78));
  -webkit-backdrop-filter: blur(26px) saturate(170%);
  backdrop-filter: blur(26px) saturate(170%);
  box-shadow:
    inset 0 1px 0 rgba(255, 255, 255, 0.28),
    0 30px 80px -20px rgba(4, 2, 24, 0.75);
  opacity: 0;
  transform: translateY(16px) scale(0.97);
  transform-origin: 100% 100%;
  transition:
    opacity 0.25s ease,
    transform 0.45s var(--nx-spring, cubic-bezier(0.22, 1, 0.36, 1));
}
.nx-support.show {
  opacity: 1;
  transform: none;
}
.nx-support[hidden] {
  display: none;
}
.nx-support-head {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 12px 12px 14px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}
.nx-support-avatar {
  width: 44px;
  height: 42px;
}
.nx-support-title {
  flex: 1;
  display: grid;
  min-width: 0;
}
.nx-support-title strong {
  font: 700 15px/1.2 var(--display);
}
.nx-support-title span {
  font-size: 12.5px;
  color: var(--mist);
}
.nx-icon {
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 50%;
  color: var(--ink);
  background: rgba(255, 255, 255, 0.06);
  cursor: pointer;
}
.nx-icon:hover {
  background: rgba(255, 255, 255, 0.12);
}
.nx-icon:focus-visible,
.nx-chip:focus-visible,
.nx-send:focus-visible {
  outline: 3px solid var(--violet-ink);
  outline-offset: 2px;
}
.nx-support-body {
  flex: 1;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 14px 14px 8px;
  outline: none;
}
.nx-messages {
  display: grid;
  gap: 12px;
}
.nx-msg {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}
.nx-msg-user {
  justify-content: flex-end;
  padding-left: 40px;
}
.nx-msg-koda {
  padding-right: 18px;
}
.nx-msg-avatar {
  flex: none;
  width: 30px;
  height: 28px;
  margin-bottom: 2px;
}
.nx-bubble {
  min-width: 0;
  max-width: 100%;
  padding: 10px 13px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 20px 20px 20px 7px;
  font-size: 14.5px;
  line-height: 1.5;
  background: rgba(255, 255, 255, 0.07);
  overflow-wrap: anywhere;
}
.nx-msg-user .nx-bubble {
  border-color: rgba(190, 172, 255, 0.5);
  border-radius: 20px 20px 7px 20px;
  color: #fff;
  background: linear-gradient(180deg, rgba(132, 104, 255, 0.92), rgba(104, 76, 236, 0.9));
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.35);
}
.nx-bubble p {
  margin: 0;
  white-space: pre-line;
}
/* :not(:first-child) statt * + *, damit es gegen „.nx-bubble p { margin: 0 }“ gewinnt. */
.nx-bubble > :not(:first-child) {
  margin-top: 10px;
}
.nx-bubble strong {
  font-weight: 650;
}
.nx-inline-code {
  padding: 1px 5px;
  border-radius: 6px;
  font: 13.5px var(--mono);
  color: #7ff0dd;
  background: var(--code-bg);
}
.nx-code {
  margin: 0;
  padding: 10px 12px;
  overflow-x: auto;
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: 14px;
  font: 13px/1.5 var(--mono);
  color: #e9e6ff;
  background: var(--code-bg);
}
.nx-list {
  display: grid;
  gap: 4px;
  margin: 0;
  padding: 0;
  list-style: none;
}
.nx-list li {
  display: flex;
  gap: 8px;
}
.nx-marker {
  min-width: 14px;
  color: var(--mist);
}
.nx-error {
  margin: 0;
  color: #ffb3c8;
  font-size: 13.5px;
}
.nx-suggestions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  padding-left: 38px;
}
.nx-chip {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  min-height: 38px;
  padding: 8px 14px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 999px;
  font: 500 13.5px/1.2 var(--body);
  color: var(--ink);
  text-align: left;
  background: rgba(255, 255, 255, 0.08);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.18);
  cursor: pointer;
  transition:
    background 0.2s ease,
    transform 0.3s var(--nx-spring, cubic-bezier(0.22, 1, 0.36, 1));
}
.nx-chip:hover {
  background: rgba(124, 92, 255, 0.28);
  transform: translateY(-1px);
}
.nx-retry {
  margin-top: 8px;
}
.nx-typing {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  height: 22px;
}
.nx-typing i {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: var(--violet-ink);
  animation: nxTyping 1.1s ease-in-out infinite;
}
.nx-typing i:nth-child(2) {
  animation-delay: 0.16s;
}
.nx-typing i:nth-child(3) {
  animation-delay: 0.32s;
}
@keyframes nxTyping {
  0%,
  70%,
  100% {
    opacity: 0.45;
    transform: translateY(0) scale(0.82);
  }
  35% {
    opacity: 1;
    transform: translateY(-4px) scale(1);
  }
}
.nx-support-foot {
  display: grid;
  gap: 8px;
  padding: 8px 12px 12px;
}
.nx-support-foot:empty {
  display: none;
}
.nx-composer {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 5px 5px 5px 14px;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 24px;
  background: rgba(8, 8, 30, 0.45);
  box-shadow: inset 0 1px 0 rgba(255, 255, 255, 0.1);
}
.nx-composer:focus-within {
  border-color: rgba(196, 181, 255, 0.7);
}
.nx-input {
  flex: 1;
  min-height: 40px;
  max-height: 140px;
  padding: 9px 0;
  border: 0;
  resize: none;
  font: 400 15px/22px var(--body);
  color: var(--ink);
  background: transparent;
  outline: none;
}
.nx-input::placeholder {
  color: var(--haze);
}
.nx-send {
  display: grid;
  place-items: center;
  flex: none;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 50%;
  color: var(--haze);
  background: rgba(255, 255, 255, 0.08);
  cursor: pointer;
}
.nx-send.ready {
  color: #fff;
  background: linear-gradient(180deg, #8f74ff, #6a4ff0);
}
.nx-note {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 10px;
}
.nx-note small {
  font-size: 11.5px;
  line-height: 1.4;
  color: var(--haze);
}
.nx-note a {
  color: var(--mist);
}
.nx-team {
  flex: none;
  min-height: 34px;
  padding: 6px 12px;
  font-size: 12.5px;
}
.nx-card {
  display: grid;
  justify-items: center;
  gap: 10px;
  padding: 26px 10px;
  text-align: center;
}
.nx-card-koda {
  width: 96px;
  height: 90px;
  animation: nxKodaFloat 4.6s ease-in-out infinite;
}
.nx-card h3,
.nx-team-form h3 {
  margin: 0;
  font: 700 18px/1.25 var(--display);
}
.nx-card p,
.nx-team-form p {
  margin: 0;
  color: var(--mist);
  font-size: 14px;
  line-height: 1.5;
}
.nx-team-form {
  display: grid;
  gap: 12px;
}
.nx-team-text {
  width: 100%;
  box-sizing: border-box;
  padding: 12px;
  border: 1px solid rgba(255, 255, 255, 0.22);
  border-radius: 18px;
  font: 400 15px/1.45 var(--body);
  color: var(--ink);
  background: rgba(8, 8, 30, 0.45);
  resize: vertical;
}
.nx-check {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 13.5px;
  color: var(--mist);
}
.nx-check input {
  width: 18px;
  height: 18px;
  accent-color: var(--violet);
}
.nx-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 10px;
}
/* Einverständnis vor dem ersten Chat (einmal pro Gerät) */
.nx-consent {
  display: grid;
  gap: 8px;
  padding: 12px 14px;
  border: 1px solid rgba(196, 181, 255, 0.3);
  border-radius: 18px;
  background: rgba(124, 92, 255, 0.12);
}
.nx-consent strong {
  font: 700 15px/1.3 var(--display);
}
.nx-consent p {
  margin: 0;
  color: var(--mist);
  font-size: 13px;
  line-height: 1.45;
}
.nx-done {
  display: grid;
  gap: 2px;
  padding: 10px 13px;
  border: 1px solid rgba(168, 240, 90, 0.4);
  border-radius: 16px;
  font-size: 13.5px;
  background: rgba(168, 240, 90, 0.1);
}

/* ---------- Handy: Vollbild, Koda tritt beiseite ---------- */
@media (max-width: 620px) {
  .nx-koda-button {
    width: 64px;
    height: 64px;
  }
  .nx-koda-bubble {
    max-width: 210px;
    font-size: 12.5px;
  }
  .nx-support {
    inset: 0;
    width: auto;
    height: auto;
    border-radius: 0;
    border: 0;
    padding-top: env(safe-area-inset-top);
    padding-bottom: env(safe-area-inset-bottom);
    transform-origin: 50% 100%;
  }
  .nx-koda.open {
    opacity: 0;
    pointer-events: none;
  }
  .nx-koda.open > * {
    pointer-events: none;
  }
  html.nx-support-open,
  html.nx-support-open body {
    overflow: hidden;
  }
  /* Letzte Links der Fußzeile nicht unter Koda verstecken. */
  footer {
    padding-bottom: 84px;
  }
}

/* ---------- Barrierefreiheit ---------- */
:root[data-motion='reduce'] .nx-koda-face,
:root[data-motion='reduce'] .nx-card-koda,
:root[data-motion='reduce'] .nx-typing i,
:root[data-perf='lite'] .nx-koda-face,
:root[data-perf='lite'] .nx-card-koda {
  animation: none;
}
@media (prefers-reduced-motion: reduce) {
  .nx-koda-face,
  .nx-card-koda,
  .nx-typing i {
    animation: none;
  }
  .nx-support,
  .nx-koda {
    transition: opacity 0.2s ease;
  }
}
/* Transparenz reduziert / Sparmodus: dichtes, violett getöntes Glas statt Echtzeit-Unschärfe. */
@media (prefers-reduced-transparency: reduce) {
  .nx-support {
    -webkit-backdrop-filter: none;
    backdrop-filter: none;
    background: radial-gradient(120% 60% at 20% -10%, rgba(124, 92, 255, 0.4), transparent 60%), linear-gradient(180deg, #1d1747, #110e30);
  }
}
:root[data-perf='lite'] .nx-support {
  -webkit-backdrop-filter: none;
  backdrop-filter: none;
  background: linear-gradient(180deg, #1d1747, #110e30);
}
@media (forced-colors: active) {
  .nx-support,
  .nx-bubble,
  .nx-chip,
  .nx-composer {
    border: 1px solid CanvasText;
  }
}
