/* Athlory Landing Chat Widget — scoped under .athlory-chat
 * Brand-konform: dark BG, blau→lila→orange Gradient, Inter font.
 */

.athlory-chat {
  --chat-bg: #0f0f12;
  --chat-bg-elev: #18181b;
  --chat-border: rgba(255, 255, 255, 0.08);
  --chat-text: #fafafa;
  --chat-text-muted: #a1a1aa;
  --chat-text-faint: #71717a;
  --chat-accent: #8F79FA;
  --chat-accent-2: #3987E5;
  --chat-accent-3: #FFA001;
  --chat-gradient: linear-gradient(135deg, #3987E5 0%, #8F79FA 50%, #FFA001 100%);
  --chat-radius: 16px;
  --chat-shadow: 0 25px 60px -15px rgba(0, 0, 0, 0.6), 0 0 0 1px rgba(255,255,255,0.04);
  --chat-z: 2147483000;

  position: fixed;
  inset: auto 20px 20px auto;
  z-index: var(--chat-z);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  color: var(--chat-text);
  font-size: 14px;
  line-height: 1.5;
}

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

/* ── FAB ─────────────────────────────────────────────────────────── */

.athlory-chat__fab {
  position: relative;
  width: 60px;
  height: 60px;
  border-radius: 50%;
  border: none;
  cursor: pointer;
  background: var(--chat-gradient);
  color: white;
  box-shadow: 0 12px 30px -8px rgba(143, 121, 250, 0.55), 0 0 0 1px rgba(255,255,255,0.06);
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.18s ease, box-shadow 0.18s ease;
}
.athlory-chat__fab:hover {
  transform: translateY(-2px) scale(1.04);
  box-shadow: 0 18px 40px -10px rgba(143, 121, 250, 0.7), 0 0 0 1px rgba(255,255,255,0.1);
}
.athlory-chat__fab:focus-visible {
  outline: 2px solid var(--chat-accent);
  outline-offset: 3px;
}
.athlory-chat__fab-icon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity 0.2s ease, transform 0.2s ease;
}
.athlory-chat__fab-icon--close { opacity: 0; transform: rotate(-90deg) scale(0.6); }
.athlory-chat[data-state="open"] .athlory-chat__fab-icon--open  { opacity: 0; transform: rotate(90deg) scale(0.6); }
.athlory-chat[data-state="open"] .athlory-chat__fab-icon--close { opacity: 1; transform: rotate(0) scale(1); }

/* Subtle pulse on FAB until first interaction */
.athlory-chat[data-state="closed"] .athlory-chat__fab::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid rgba(143, 121, 250, 0.4);
  animation: athlory-fab-pulse 2.4s ease-out infinite;
  pointer-events: none;
}
@keyframes athlory-fab-pulse {
  0% { transform: scale(0.95); opacity: 0.8; }
  70% { transform: scale(1.25); opacity: 0; }
  100% { transform: scale(1.25); opacity: 0; }
}

/* ── Panel ───────────────────────────────────────────────────────── */

.athlory-chat__panel {
  position: absolute;
  right: 0;
  bottom: 76px;
  width: 380px;
  max-width: calc(100vw - 24px);
  height: 600px;
  max-height: calc(100vh - 100px);
  background: var(--chat-bg);
  border-radius: var(--chat-radius);
  border: 1px solid var(--chat-border);
  box-shadow: var(--chat-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  opacity: 0;
  transform: translateY(12px) scale(0.98);
  pointer-events: none;
  transition: opacity 0.22s ease, transform 0.22s ease;
}
.athlory-chat[data-state="open"] .athlory-chat__panel {
  opacity: 1;
  transform: translateY(0) scale(1);
  pointer-events: auto;
}

/* ── Header ──────────────────────────────────────────────────────── */

.athlory-chat__header {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 14px 14px 16px;
  border-bottom: 1px solid var(--chat-border);
  background: rgba(255, 255, 255, 0.02);
}
.athlory-chat__title { display: flex; flex-direction: column; line-height: 1.25; flex: 1; min-width: 0; }
.athlory-chat__title strong { font-size: 14px; font-weight: 600; }
.athlory-chat__subtitle { font-size: 12px; color: var(--chat-text-muted); margin-top: 2px; }
.athlory-chat__close {
  background: transparent;
  border: none;
  color: var(--chat-text-muted);
  width: 32px;
  height: 32px;
  border-radius: 8px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s ease, color 0.15s ease;
}
.athlory-chat__close:hover { background: rgba(255, 255, 255, 0.06); color: var(--chat-text); }

.athlory-chat__avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--chat-gradient);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  position: relative;
}
.athlory-chat__avatar-dot {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: var(--chat-bg);
  box-shadow: 0 0 0 2px rgba(255,255,255,0.5);
}
.athlory-chat__avatar--inline { width: 26px; height: 26px; }
.athlory-chat__avatar--inline .athlory-chat__avatar-dot { width: 8px; height: 8px; }

.athlory-chat__avatar--pulse::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid rgba(143, 121, 250, 0.5);
  animation: athlory-avatar-pulse 1.4s ease-out infinite;
  pointer-events: none;
}
@keyframes athlory-avatar-pulse {
  0% { transform: scale(0.9); opacity: 0.9; }
  100% { transform: scale(1.4); opacity: 0; }
}

/* ── Body ────────────────────────────────────────────────────────── */

.athlory-chat__body {
  flex: 1;
  overflow-y: auto;
  padding: 20px 18px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  scrollbar-width: thin;
  scrollbar-color: rgba(255,255,255,0.15) transparent;
}
.athlory-chat__body::-webkit-scrollbar { width: 6px; }
.athlory-chat__body::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.15); border-radius: 3px; }
.athlory-chat__body::-webkit-scrollbar-track { background: transparent; }

.athlory-chat__greeting {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 8px;
}
.athlory-chat__greeting-time {
  font-size: 22px;
  font-weight: 700;
  background: var(--chat-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  line-height: 1.2;
}
.athlory-chat__greeting-q {
  font-size: 18px;
  font-weight: 600;
  color: var(--chat-text);
  line-height: 1.3;
}

/* ── Messages ────────────────────────────────────────────────────── */

.athlory-chat__msg {
  display: flex;
  animation: athlory-msg-in 0.25s ease-out;
}
@keyframes athlory-msg-in {
  from { opacity: 0; transform: translateY(6px); }
  to { opacity: 1; transform: translateY(0); }
}

.athlory-chat__msg--user {
  justify-content: flex-end;
}
.athlory-chat__msg--user .athlory-chat__bubble {
  background: var(--chat-bg-elev);
  color: var(--chat-text);
  border-radius: 16px 16px 4px 16px;
  padding: 10px 14px;
  max-width: 80%;
  word-wrap: break-word;
  white-space: pre-wrap;
  border: 1px solid var(--chat-border);
  font-size: 14px;
}

.athlory-chat__msg--bot {
  align-items: flex-start;
  gap: 10px;
  flex-wrap: wrap;
}
.athlory-chat__msg--bot .athlory-chat__text {
  flex: 1;
  min-width: 0;
  color: var(--chat-text);
  white-space: pre-wrap;
  word-wrap: break-word;
  padding-top: 2px;
}
.athlory-chat__msg--bot .athlory-chat__cta {
  margin-left: 36px;
  background: rgba(143, 121, 250, 0.12);
  border: 1px solid rgba(143, 121, 250, 0.4);
  color: var(--chat-text);
  border-radius: 999px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 500;
  cursor: pointer;
  transition: background 0.15s ease, transform 0.1s ease;
}
.athlory-chat__msg--bot .athlory-chat__cta:hover { background: rgba(143, 121, 250, 0.22); }
.athlory-chat__msg--bot .athlory-chat__cta:active { transform: scale(0.98); }

/* Typing indicator */
.athlory-chat__msg--typing { gap: 8px; align-items: center; }
.athlory-chat__dots {
  display: inline-flex;
  gap: 4px;
  padding: 8px 0;
}
.athlory-chat__dots span {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--chat-text-muted);
  animation: athlory-dots 1.2s ease-in-out infinite;
}
.athlory-chat__dots span:nth-child(2) { animation-delay: 0.15s; }
.athlory-chat__dots span:nth-child(3) { animation-delay: 0.3s; }
@keyframes athlory-dots {
  0%, 60%, 100% { opacity: 0.25; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}
.athlory-chat__status {
  font-size: 12px;
  color: var(--chat-text-faint);
  font-style: italic;
  padding-left: 8px;
}

/* ── Lead form ───────────────────────────────────────────────────── */

.athlory-chat__lead {
  background: rgba(143, 121, 250, 0.06);
  border: 1px solid rgba(143, 121, 250, 0.25);
  border-radius: 14px;
  padding: 16px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.athlory-chat__lead h4 { font-size: 15px; font-weight: 600; margin: 0; }
.athlory-chat__lead p { font-size: 13px; color: var(--chat-text-muted); margin: 0; }
.athlory-chat__lead label { display: flex; flex-direction: column; gap: 4px; font-size: 12px; color: var(--chat-text-muted); }
.athlory-chat__lead input,
.athlory-chat__lead textarea {
  background: var(--chat-bg);
  border: 1px solid var(--chat-border);
  color: var(--chat-text);
  border-radius: 10px;
  padding: 10px 12px;
  font: inherit;
  font-size: 14px;
  resize: vertical;
}
.athlory-chat__lead input:focus,
.athlory-chat__lead textarea:focus {
  outline: none;
  border-color: var(--chat-accent);
  box-shadow: 0 0 0 3px rgba(143, 121, 250, 0.18);
}
.athlory-chat__lead textarea { min-height: 64px; max-height: 160px; }
.athlory-chat__lead-actions { display: flex; gap: 8px; justify-content: flex-end; margin-top: 4px; }
.athlory-chat__lead-privacy { font-size: 11px; color: var(--chat-text-faint); margin-top: 4px; }
.athlory-chat__lead-privacy a { color: var(--chat-accent); text-decoration: none; }
.athlory-chat__lead-privacy a:hover { text-decoration: underline; }

.athlory-chat__btn {
  border: none;
  border-radius: 999px;
  padding: 9px 16px;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: transform 0.1s ease, opacity 0.15s ease;
}
.athlory-chat__btn:disabled { opacity: 0.5; cursor: not-allowed; }
.athlory-chat__btn--primary { background: var(--chat-gradient); color: white; }
.athlory-chat__btn--primary:hover:not(:disabled) { transform: translateY(-1px); }
.athlory-chat__btn--ghost { background: transparent; color: var(--chat-text-muted); border: 1px solid var(--chat-border); }
.athlory-chat__btn--ghost:hover { color: var(--chat-text); border-color: rgba(255,255,255,0.2); }

/* ── Form (input area) ───────────────────────────────────────────── */

.athlory-chat__form {
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 12px 14px;
  border-top: 1px solid var(--chat-border);
  background: rgba(255, 255, 255, 0.02);
}
.athlory-chat__form textarea {
  flex: 1;
  resize: none;
  background: var(--chat-bg-elev);
  border: 1px solid var(--chat-border);
  color: var(--chat-text);
  font: inherit;
  font-size: 14px;
  border-radius: 14px;
  padding: 10px 14px;
  max-height: 140px;
  line-height: 1.4;
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}
.athlory-chat__form textarea::placeholder { color: var(--chat-text-faint); }
.athlory-chat__form textarea:focus {
  outline: none;
  border-color: var(--chat-accent);
  box-shadow: 0 0 0 3px rgba(143, 121, 250, 0.18);
}
.athlory-chat__send {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  border: none;
  background: var(--chat-gradient);
  color: white;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: transform 0.1s ease, opacity 0.15s ease;
}
.athlory-chat__send:disabled { opacity: 0.4; cursor: not-allowed; }
.athlory-chat__send:hover:not(:disabled) { transform: translateY(-1px); }

.athlory-chat__disclaimer {
  font-size: 11px;
  color: var(--chat-text-faint);
  text-align: center;
  padding: 6px 14px 12px;
  margin: 0;
  background: rgba(255, 255, 255, 0.02);
}
.athlory-chat__disclaimer a { color: var(--chat-text-muted); }
.athlory-chat__disclaimer a:hover { color: var(--chat-accent); }

/* ── Mobile (full-screen panel) ──────────────────────────────────── */

@media (max-width: 520px) {
  .athlory-chat { inset: auto 16px 16px auto; }
  .athlory-chat__panel {
    position: fixed;
    inset: 0;
    width: 100vw;
    height: 100dvh;
    max-height: 100dvh;
    max-width: 100vw;
    border-radius: 0;
    border: none;
  }
  .athlory-chat[data-state="open"] .athlory-chat__fab { display: none; }
}

/* ── Reduced motion ──────────────────────────────────────────────── */

@media (prefers-reduced-motion: reduce) {
  .athlory-chat__panel,
  .athlory-chat__fab,
  .athlory-chat__msg,
  .athlory-chat__dots span,
  .athlory-chat__avatar--pulse::after,
  .athlory-chat[data-state="closed"] .athlory-chat__fab::after {
    transition: none !important;
    animation: none !important;
  }
}
