/* Alryx chat widget — matches site black UI */

.alryx-chat {
  --chat-bg: #090909;
  --chat-panel: #0e0e0e;
  --chat-elevated: #141414;
  --chat-text: #f4f4f4;
  --chat-muted: #8e8e8e;
  --chat-dim: #6b6b6b;
  --chat-border: rgba(255, 255, 255, 0.1);
  --chat-border-strong: rgba(255, 255, 255, 0.2);
  --chat-field: rgba(255, 255, 255, 0.04);
  --chat-accent: #2f6bff;
  --chat-danger: #ff6b6b;
  --chat-font: "Inter", "Segoe UI", system-ui, sans-serif;

  position: fixed;
  right: max(1.25rem, env(safe-area-inset-right));
  bottom: max(1.25rem, env(safe-area-inset-bottom));
  z-index: 120;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
  gap: 12px;
  font-family: var(--chat-font);
  -webkit-font-smoothing: antialiased;
}

.alryx-chat *,
.alryx-chat *::before,
.alryx-chat *::after {
  box-sizing: border-box;
}

.alryx-chat__panel {
  display: flex;
  flex-direction: column;
  width: min(100vw - 2.5rem, 380px);
  height: min(72vh, 540px);
  overflow: hidden;
  border: 1px solid var(--chat-border);
  border-radius: 20px;
  background: linear-gradient(180deg, #121212 0%, var(--chat-bg) 42%);
  box-shadow:
    0 24px 64px rgba(0, 0, 0, 0.55),
    0 0 0 1px rgba(255, 255, 255, 0.03) inset;
  opacity: 0;
  transform: translateY(12px) scale(0.98);
  pointer-events: none;
  transition:
    opacity 0.22s cubic-bezier(0.22, 1, 0.36, 1),
    transform 0.22s cubic-bezier(0.22, 1, 0.36, 1);
}

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

.alryx-chat__header {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  flex-shrink: 0;
  padding: 14px 14px 14px 16px;
  border-bottom: 1px solid var(--chat-border);
}

.alryx-chat__header::before {
  content: "";
  position: absolute;
  inset-inline: 18px;
  top: 0;
  height: 1px;
  background: linear-gradient(
    90deg,
    transparent,
    rgba(255, 255, 255, 0.28),
    transparent
  );
}

.alryx-chat__brand {
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 0;
}

.alryx-chat__avatar {
  display: grid;
  place-items: center;
  width: 38px;
  height: 38px;
  flex-shrink: 0;
  border-radius: 12px;
  border: 1px solid var(--chat-border-strong);
  background: #fff;
  color: #111;
}

.alryx-chat__brand-copy {
  min-width: 0;
}

.alryx-chat__title {
  margin: 0;
  color: var(--chat-text);
  font-size: 14px;
  font-weight: 600;
  letter-spacing: -0.02em;
  line-height: 1.2;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.alryx-chat__subtitle {
  margin: 3px 0 0;
  color: var(--chat-muted);
  font-size: 11px;
  font-weight: 450;
  letter-spacing: 0.01em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.alryx-chat__header-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  flex-shrink: 0;
}

.alryx-chat__icon-btn {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--chat-muted);
  cursor: pointer;
  transition: background 0.18s ease, color 0.18s ease;
}

.alryx-chat__icon-btn:hover {
  background: rgba(255, 255, 255, 0.06);
  color: var(--chat-text);
}

.alryx-chat__messages {
  flex: 1;
  min-height: 0;
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 14px 14px 8px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.18) transparent;
}

.alryx-chat__messages::-webkit-scrollbar {
  width: 6px;
}

.alryx-chat__messages::-webkit-scrollbar-thumb {
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.14);
}

.alryx-chat__thread {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.alryx-chat__row {
  display: flex;
}

.alryx-chat__row--user {
  justify-content: flex-end;
}

.alryx-chat__row--assistant {
  justify-content: flex-start;
}

.alryx-chat__bubble {
  max-width: 88%;
  padding: 10px 13px;
  border-radius: 16px;
  font-size: 13.5px;
  line-height: 1.55;
  letter-spacing: -0.01em;
  white-space: pre-wrap;
  word-break: break-word;
}

.alryx-chat__bubble--user {
  border-radius: 16px 16px 5px 16px;
  background: #fff;
  color: #111;
}

.alryx-chat__bubble--assistant {
  border: 1px solid var(--chat-border);
  border-radius: 16px 16px 16px 5px;
  background: rgba(255, 255, 255, 0.03);
  color: #e8e8e8;
}

.alryx-chat__assistant-label {
  display: flex;
  align-items: center;
  gap: 6px;
  margin-bottom: 6px;
  color: var(--chat-muted);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.alryx-chat__bubble p {
  margin: 0;
}

.alryx-chat__bubble strong {
  font-weight: 600;
  color: inherit;
}

.alryx-chat__link {
  color: #9db5ff;
  text-decoration: underline;
  text-underline-offset: 2px;
  word-break: break-all;
}

.alryx-chat__link:hover {
  color: #c4d2ff;
}

.alryx-chat__cta {
  margin-top: 12px;
  padding-top: 12px;
  border-top: 1px solid var(--chat-border);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.alryx-chat__cta-primary {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  height: 40px;
  padding: 0 16px;
  border-radius: 999px;
  background: #fff;
  color: #111;
  font-size: 13px;
  font-weight: 600;
  text-decoration: none;
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.12),
    0 0 20px rgba(255, 255, 255, 0.16);
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.alryx-chat__cta-primary:hover {
  transform: translateY(-1px);
  box-shadow:
    0 0 0 1px rgba(255, 255, 255, 0.18),
    0 0 26px rgba(255, 255, 255, 0.28);
}

.alryx-chat__cta-secondary {
  display: inline-flex;
  justify-content: center;
  color: var(--chat-muted);
  font-size: 11px;
  text-decoration: none;
  transition: color 0.18s ease;
}

.alryx-chat__cta-secondary:hover {
  color: #c8c8c8;
}

.alryx-chat__loading {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-left: 2px;
  color: var(--chat-muted);
  font-size: 13px;
}

.alryx-chat__spinner {
  width: 14px;
  height: 14px;
  border: 1.5px solid rgba(255, 255, 255, 0.15);
  border-top-color: #fff;
  border-radius: 50%;
  animation: spin 0.7s linear infinite;
}

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

.alryx-chat__error {
  margin: 0;
  padding: 9px 11px;
  border: 1px solid rgba(255, 107, 107, 0.28);
  border-radius: 10px;
  background: rgba(255, 107, 107, 0.08);
  color: #ffb4b4;
  font-size: 12.5px;
  line-height: 1.4;
}

.alryx-chat__prompts {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  flex-shrink: 0;
  padding: 0 14px 10px;
}

.alryx-chat__prompt {
  max-width: 100%;
  padding: 6px 10px;
  border: 1px solid var(--chat-border);
  border-radius: 999px;
  background: rgba(255, 255, 255, 0.03);
  color: #cfcfcf;
  font-family: inherit;
  font-size: 11px;
  line-height: 1.3;
  text-align: left;
  cursor: pointer;
  transition: border-color 0.18s ease, color 0.18s ease, background 0.18s ease;
}

.alryx-chat__prompt:hover {
  border-color: var(--chat-border-strong);
  background: rgba(255, 255, 255, 0.06);
  color: #fff;
}

.alryx-chat__composer {
  flex-shrink: 0;
  padding: 12px;
  border-top: 1px solid var(--chat-border);
  background: rgba(0, 0, 0, 0.35);
}

.alryx-chat__composer-row {
  display: flex;
  align-items: flex-end;
  gap: 8px;
}

.alryx-chat__textarea {
  flex: 1;
  min-height: 42px;
  max-height: 112px;
  resize: none;
  padding: 11px 12px;
  border: 1px solid var(--chat-border);
  border-radius: 14px;
  background: var(--chat-field);
  color: var(--chat-text);
  font-family: inherit;
  font-size: 13.5px;
  line-height: 1.4;
  outline: none;
  transition: border-color 0.18s ease, background 0.18s ease, box-shadow 0.18s ease;
}

.alryx-chat__textarea::placeholder {
  color: var(--chat-dim);
}

.alryx-chat__textarea:focus {
  border-color: rgba(255, 255, 255, 0.32);
  background: rgba(255, 255, 255, 0.06);
  box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.05);
}

.alryx-chat__textarea:disabled {
  opacity: 0.55;
}

.alryx-chat__send {
  display: grid;
  place-items: center;
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  border: 0;
  border-radius: 14px;
  background: #fff;
  color: #111;
  cursor: pointer;
  transition: opacity 0.18s ease, transform 0.18s ease;
}

.alryx-chat__send:hover:not(:disabled) {
  transform: translateY(-1px);
}

.alryx-chat__send:disabled {
  opacity: 0.35;
  cursor: not-allowed;
}

.alryx-chat__flow-hint {
  margin: 8px 0 0;
  color: var(--chat-dim);
  font-size: 10.5px;
  text-align: center;
}

.alryx-chat__flow-hint span {
  color: var(--chat-muted);
}

.alryx-chat__book {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  width: 100%;
  height: 36px;
  margin-top: 8px;
  border: 1px solid var(--chat-border);
  border-radius: 999px;
  background: transparent;
  color: #ddd;
  font-size: 12px;
  font-weight: 500;
  text-decoration: none;
  transition: border-color 0.18s ease, background 0.18s ease, color 0.18s ease;
}

.alryx-chat__book:hover {
  border-color: var(--chat-border-strong);
  background: rgba(255, 255, 255, 0.04);
  color: #fff;
}

.alryx-chat__hint {
  display: none;
  align-items: center;
  gap: 8px;
  padding: 9px 14px;
  border: 1px solid var(--chat-border);
  border-radius: 999px;
  background: rgba(14, 14, 14, 0.92);
  color: #ddd;
  font-size: 13px;
  font-weight: 500;
  backdrop-filter: blur(10px);
  box-shadow: 0 10px 28px rgba(0, 0, 0, 0.35);
  cursor: pointer;
  transition: border-color 0.18s ease, color 0.18s ease, transform 0.18s ease;
}

.alryx-chat__hint:hover {
  border-color: var(--chat-border-strong);
  color: #fff;
  transform: translateY(-1px);
}

.alryx-chat__hint.is-visible {
  display: inline-flex;
}

.alryx-chat__fab {
  position: relative;
  display: grid;
  place-items: center;
  width: 56px;
  height: 56px;
  border: 1px solid rgba(255, 255, 255, 0.14);
  border-radius: 50%;
  background: #fff;
  color: #111;
  box-shadow:
    0 12px 32px rgba(0, 0, 0, 0.35),
    0 0 0 1px rgba(255, 255, 255, 0.04);
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.alryx-chat__fab:hover {
  transform: translateY(-2px) scale(1.03);
  box-shadow:
    0 16px 36px rgba(0, 0, 0, 0.42),
    0 0 0 1px rgba(255, 255, 255, 0.08);
}

.alryx-chat__fab:active {
  transform: scale(0.96);
}

.alryx-chat__fab.is-open {
  background: #141414;
  color: #fff;
  border-color: var(--chat-border-strong);
}

@media (max-width: 640px) {
  .alryx-chat {
    right: max(0.85rem, env(safe-area-inset-right));
    bottom: max(0.85rem, env(safe-area-inset-bottom));
  }

  .alryx-chat__panel {
    width: min(100vw - 1.7rem, 380px);
    height: min(70vh, 520px);
  }

  .alryx-chat__hint.is-visible {
    display: none;
  }
}

@media (prefers-reduced-motion: reduce) {
  .alryx-chat__panel,
  .alryx-chat__fab,
  .alryx-chat__send,
  .alryx-chat__cta-primary,
  .alryx-chat__prompt,
  .alryx-chat__icon-btn,
  .alryx-chat__hint {
    transition: none;
  }

  .alryx-chat__spinner {
    animation: none;
  }
}
