/* ============================================================
   CASAI Chat — Conversational Funnel
   Embedded as a card inside a Hero section to match the rest of
   the site's visual language (markenvergleich.php style).
   ============================================================ */

/* ----- Hero wrapper around the chat card ---------------------- */
.chat-hero {
  position: relative;
  padding: 140px 0 80px;
  overflow: hidden;
}

.chat-hero__container {
  position: relative;
  z-index: 2;
  max-width: 820px;
}

.chat-hero__intro {
  text-align: center;
  margin-bottom: 2.5rem;
}

.chat-hero__label {
  display: inline-block;
  font-size: 0.875rem;
  font-weight: 700;
  letter-spacing: 2px;
  text-transform: uppercase;
  color: var(--accent-pink);
  margin-bottom: 1rem;
}

.chat-hero__title {
  font-size: clamp(1.75rem, 3.5vw, 2.75rem);
  line-height: 1.2;
  letter-spacing: -0.02em;
  margin: 0 0 1rem;
}

.chat-hero__subline {
  font-size: 1.0625rem;
  color: var(--text-muted);
  max-width: 560px;
  margin: 0 auto;
  line-height: 1.55;
}

/* ----- Floating background shapes (same idea as markenvergleich) ----- */
.chat-hero-bg {
  position: absolute;
  inset: 0;
  z-index: 1;
  overflow: hidden;
  pointer-events: none;
}

.chat-hero-shape {
  position: absolute;
  border-radius: 50%;
  filter: blur(60px);
  opacity: 0.4;
  animation-timing-function: ease-in-out;
  animation-iteration-count: infinite;
}

.chat-hero-shape--1 {
  width: 380px;
  height: 380px;
  background: radial-gradient(circle, rgba(255, 38, 185, 0.3) 0%, rgba(255, 38, 185, 0) 70%);
  top: -120px;
  left: 8%;
  animation: chatFloat1 20s infinite;
}

.chat-hero-shape--2 {
  width: 300px;
  height: 300px;
  background: radial-gradient(circle, rgba(29, 86, 232, 0.3) 0%, rgba(29, 86, 232, 0) 70%);
  top: 45%;
  right: 6%;
  animation: chatFloat2 25s infinite;
}

.chat-hero-shape--3 {
  width: 320px;
  height: 320px;
  background: radial-gradient(circle, rgba(203, 108, 230, 0.22) 0%, rgba(203, 108, 230, 0) 70%);
  bottom: -80px;
  left: 30%;
  animation: chatFloat3 30s infinite;
}

@keyframes chatFloat1 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  25% { transform: translate(30px, -40px) scale(1.1); }
  50% { transform: translate(-20px, -60px) scale(0.9); }
  75% { transform: translate(20px, -30px) scale(1.05); }
}

@keyframes chatFloat2 {
  0%, 100% { transform: translate(0, 0) rotate(0deg); }
  33% { transform: translate(-40px, 30px) rotate(120deg); }
  66% { transform: translate(30px, -40px) rotate(240deg); }
}

@keyframes chatFloat3 {
  0%, 100% { transform: translate(0, 0) scale(1); }
  30% { transform: translate(-50px, 20px) scale(1.15); }
  60% { transform: translate(40px, -30px) scale(0.85); }
}

/* ----- Chat Card (the actual conversation surface) ----- */
.chat-card {
  background: rgba(255, 255, 255, 0.03);
  border: 1px solid rgba(255, 255, 255, 0.1);
  border-radius: var(--radius-lg, 16px);
  box-shadow: 0 24px 60px rgba(0, 0, 0, 0.35);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  min-height: 540px;
}

/* ----- Card header (avatar + name) ----- */
.chat-card__header {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.02);
}

.chat-header__avatar {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--accent-pink) 0%, var(--accent-purple) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 1rem;
  color: white;
  letter-spacing: 0.5px;
  flex-shrink: 0;
}

.chat-header__meta {
  display: flex;
  flex-direction: column;
  gap: 0.125rem;
}

.chat-header__name {
  font-weight: 700;
  font-size: 1rem;
  line-height: 1.2;
}

.chat-header__status {
  font-size: 0.8125rem;
  color: var(--text-muted);
  display: flex;
  align-items: center;
  gap: 0.5rem;
  line-height: 1.2;
}

.chat-header__status::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #1ec76b;
  box-shadow: 0 0 8px rgba(30, 199, 107, 0.5);
  flex-shrink: 0;
}

/* ----- Card body: scrollable message stream ----- */
.chat-card__stream {
  flex: 1;
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  gap: 0.875rem;
  overflow-y: auto;
  max-height: 60vh;
  min-height: 320px;
}

/* Custom scrollbar in the chat area */
.chat-card__stream::-webkit-scrollbar {
  width: 8px;
}
.chat-card__stream::-webkit-scrollbar-track {
  background: transparent;
}
.chat-card__stream::-webkit-scrollbar-thumb {
  background: rgba(255, 255, 255, 0.08);
  border-radius: 4px;
}
.chat-card__stream::-webkit-scrollbar-thumb:hover {
  background: rgba(255, 255, 255, 0.15);
}

/* ----- Single message rows ----- */
.chat-msg {
  display: flex;
  gap: 0.625rem;
  max-width: 85%;
  animation: chatMsgIn 0.35s cubic-bezier(0.2, 0.7, 0.3, 1);
}

.chat-msg--bot {
  align-self: flex-start;
}

.chat-msg--user {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.chat-msg__avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 0.75rem;
  color: white;
}

.chat-msg--bot .chat-msg__avatar {
  background: linear-gradient(135deg, var(--accent-pink) 0%, var(--accent-purple) 100%);
}

.chat-msg--user .chat-msg__avatar {
  background: rgba(255, 255, 255, 0.08);
  border: 1px solid rgba(255, 255, 255, 0.15);
  color: var(--text-muted);
}

.chat-msg__bubble {
  padding: 0.75rem 1rem;
  border-radius: 16px;
  line-height: 1.5;
  font-size: 0.9375rem;
  word-wrap: break-word;
}

.chat-msg--bot .chat-msg__bubble {
  background: rgba(255, 255, 255, 0.06);
  border: 1px solid rgba(255, 255, 255, 0.08);
  border-top-left-radius: 4px;
}

.chat-msg--user .chat-msg__bubble {
  background: linear-gradient(135deg, var(--accent-pink) 0%, var(--accent-purple) 100%);
  color: white;
  border-top-right-radius: 4px;
}

.chat-msg__hint {
  display: block;
  margin-top: 0.375rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
  font-style: italic;
}

@keyframes chatMsgIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ----- Typing indicator ----- */
.chat-typing {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  padding: 0.875rem 1rem;
}

.chat-typing__dot {
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: var(--text-muted);
  animation: chatTyping 1.2s infinite ease-in-out;
}

.chat-typing__dot:nth-child(2) { animation-delay: 0.15s; }
.chat-typing__dot:nth-child(3) { animation-delay: 0.3s; }

@keyframes chatTyping {
  0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
  30%           { transform: translateY(-4px); opacity: 1; }
}

/* ----- Quick-Reply buttons (inside the card footer area) ----- */
.chat-card__replies {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
  padding: 1.25rem 1.5rem;
  border-top: 1px solid rgba(255, 255, 255, 0.08);
  background: rgba(255, 255, 255, 0.015);
  min-height: 4.5rem;
  align-items: center;
}

.chat-card__replies:empty::before {
  content: '';
  display: block;
  width: 100%;
  height: 1px;
}

.chat-reply {
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.12);
  color: var(--text-main);
  padding: 0.625rem 1.125rem;
  border-radius: 999px;
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.chat-reply:hover {
  background: rgba(255, 38, 185, 0.1);
  border-color: var(--accent-pink);
  transform: translateY(-1px);
}

.chat-reply:active {
  transform: translateY(0);
}

.chat-reply--selected {
  background: linear-gradient(135deg, var(--accent-pink) 0%, var(--accent-purple) 100%);
  border-color: transparent;
  color: white;
  pointer-events: none;
}

/* ----- Result card (drops into the stream when the chat completes) ----- */
.chat-result {
  margin-top: 1rem;
  padding: 1.75rem;
  background: rgba(255, 255, 255, 0.04);
  border: 1px solid rgba(255, 255, 255, 0.12);
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  gap: 1.25rem;
  animation: chatMsgIn 0.5s cubic-bezier(0.2, 0.7, 0.3, 1);
}

.chat-result__brand-header {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.chat-result__logo {
  height: 40px;
  width: auto;
  object-fit: contain;
}

.chat-result__brand-name {
  font-size: 1.5rem;
  font-weight: 700;
  margin: 0;
  line-height: 1.2;
}

.chat-result__match {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  margin-top: 0.25rem;
  font-size: 0.8125rem;
  color: var(--text-muted);
}

.chat-result__match-bar {
  width: 60px;
  height: 4px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 2px;
  overflow: hidden;
}

.chat-result__match-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--accent-pink) 0%, var(--accent-purple) 100%);
  border-radius: 2px;
  transition: width 0.6s cubic-bezier(0.2, 0.7, 0.3, 1);
}

.chat-result__reason {
  color: var(--text-muted);
  line-height: 1.55;
  font-size: 0.9375rem;
  margin: 0;
}

.chat-result__cta {
  width: 100%;
  text-align: center;
  background: linear-gradient(135deg, var(--accent-pink) 0%, var(--accent-purple) 100%);
  color: white;
  padding: 1rem 1.5rem;
  border-radius: 12px;
  text-decoration: none;
  font-weight: 700;
  font-size: 1rem;
  transition: transform 0.2s, box-shadow 0.2s;
  border: none;
  cursor: pointer;
  display: inline-block;
}

.chat-result__cta:hover {
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(255, 38, 185, 0.35);
}

.chat-result__secondary {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  justify-content: center;
}

.chat-result__secondary a {
  font-size: 0.875rem;
  color: var(--text-muted);
  text-decoration: none;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding-bottom: 2px;
  transition: color 0.2s, border-color 0.2s;
}

.chat-result__secondary a:hover {
  color: var(--text-main);
  border-color: var(--accent-pink);
}

/* ----- Error fallback ----- */
.chat-error {
  padding: 1rem 1.25rem;
  background: rgba(255, 100, 100, 0.08);
  border: 1px solid rgba(255, 100, 100, 0.2);
  border-radius: 12px;
  color: var(--text-muted);
  font-size: 0.9375rem;
}

/* ----- Mobile tuning ----- */
@media (max-width: 768px) {
  .chat-hero {
    padding: 110px 0 40px;
  }

  .chat-hero__intro {
    margin-bottom: 1.5rem;
  }

  .chat-hero-shape {
    filter: blur(40px);
    opacity: 0.3;
  }

  .chat-card {
    min-height: 480px;
    border-radius: 14px;
  }

  .chat-card__header,
  .chat-card__replies {
    padding-left: 1rem;
    padding-right: 1rem;
  }

  .chat-card__stream {
    padding: 1.25rem 1rem;
    max-height: 55vh;
  }

  .chat-msg {
    max-width: 92%;
  }

  .chat-result {
    padding: 1.25rem;
  }

  .chat-result__brand-name {
    font-size: 1.25rem;
  }
}

/* Very small screens — chat takes more vertical room */
@media (max-width: 480px) {
  .chat-hero {
    padding: 100px 0 28px;
  }

  .chat-hero__title {
    font-size: 1.5rem;
  }

  .chat-hero__subline {
    font-size: 1rem;
  }
}
