/* ====================================================================
   ChatDemo — animowany widget agenta AI (case: obsługa klienta)
   Odgrywa rozmowę: wiadomość klienta -> "pisze..." -> odpowiedź bota.
   ==================================================================== */

.cd-stage {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  padding: 0;
  background: transparent;
}

/* ---- okno czatu (telefon) ---- */
.cd-phone {
  width: 100%;
  max-width: 384px;
  height: min(74vh, 640px);
  display: flex;
  flex-direction: column;
  background: #fff;
  border-radius: 22px;
  overflow: hidden;
  box-shadow:
    0 2px 4px rgba(15, 23, 42, .06),
    0 24px 60px -18px rgba(20, 34, 80, .45);
  font-family: var(--f-sans, system-ui, sans-serif);
}

/* ---- nagłówek ---- */
.cd-head {
  display: flex;
  align-items: center;
  gap: 11px;
  padding: 13px 14px;
  background: linear-gradient(135deg, #26345f 0%, #18213f 100%);
  color: #fff;
  flex: 0 0 auto;
}
.cd-head-avatar {
  width: 38px; height: 38px;
  flex: 0 0 38px;
  border-radius: 11px;
  background: #fff;
  display: grid; place-items: center;
  color: #26345f;
}
.cd-head-avatar svg { width: 24px; height: 24px; }
.cd-head-meta { flex: 1 1 auto; min-width: 0; line-height: 1.2; }
.cd-head-title { font-size: 15px; font-weight: 700; letter-spacing: -.01em; }
.cd-head-sub {
  font-size: 11.5px; font-weight: 500;
  color: rgba(255,255,255,.66);
  display: flex; align-items: center; gap: 5px; margin-top: 2px;
}
.cd-head-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: #34d399;
  box-shadow: 0 0 0 0 rgba(52,211,153,.6);
  animation: cd-pulse 2s infinite;
}
.cd-head-actions { display: flex; gap: 4px; color: rgba(255,255,255,.7); }
.cd-head-actions svg { width: 18px; height: 18px; }

/* ---- lista wiadomości ---- */
.cd-body {
  flex: 1 1 auto;
  min-height: 0; /* pozwala liście scrollować się zamiast rozpychać stopkę */
  overflow: hidden; /* demo: brak ręcznego scrolla */
  padding: 16px 14px 8px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  background: #f6f7fb;
  scroll-behavior: smooth;
}

.cd-row { display: flex; gap: 8px; max-width: 100%; }
.cd-row--bot  { justify-content: flex-start; }
.cd-row--user { justify-content: flex-end; }

.cd-msg-avatar {
  width: 26px; height: 26px; flex: 0 0 26px;
  border-radius: 8px;
  background: #26345f;
  color: #fff;
  display: grid; place-items: center;
  align-self: flex-end;
  margin-bottom: 19px;
}
.cd-msg-avatar svg { width: 16px; height: 16px; }

.cd-stack { display: flex; flex-direction: column; max-width: 78%; }
.cd-row--user .cd-stack { align-items: flex-end; }

.cd-bubble {
  padding: 10px 13px;
  font-size: 13.5px;
  line-height: 1.5;
  border-radius: 16px;
  word-wrap: break-word;
}
.cd-row--bot .cd-bubble {
  background: #eceef4;
  color: #1f2733;
  border-bottom-left-radius: 5px;
}
.cd-row--user .cd-bubble {
  background: #4f7bff;
  color: #fff;
  border-bottom-right-radius: 5px;
}
.cd-bubble strong { font-weight: 700; }
.cd-ok { color: #16a34a; font-weight: 700; }

.cd-time {
  font-size: 11px;
  color: #9aa3b2;
  margin: 3px 4px 0;
}

/* wjazd wiadomości */
.cd-enter {
  animation: cd-in .3s cubic-bezier(.21,.9,.32,1.2) both;
}
@keyframes cd-in {
  from { opacity: 0; transform: translateY(9px) scale(.97); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

/* ---- wskaźnik "pisze..." ---- */
.cd-typing {
  display: inline-flex;
  gap: 4px;
  padding: 13px 14px;
  background: #eceef4;
  border-radius: 16px;
  border-bottom-left-radius: 5px;
}
.cd-typing span {
  width: 7px; height: 7px; border-radius: 50%;
  background: #9aa3b2;
  animation: cd-bounce 1.2s infinite ease-in-out;
}
.cd-typing span:nth-child(2) { animation-delay: .18s; }
.cd-typing span:nth-child(3) { animation-delay: .36s; }

/* ---- szybkie odpowiedzi (jedna linia) ---- */
.cd-chips {
  display: flex; flex-wrap: nowrap; gap: 6px;
  padding: 10px 12px 4px;
  background: #f6f7fb;
  overflow: hidden;
  flex: 0 0 auto; /* nie ściskaj się, gdy lista wiadomości rośnie */
}
.cd-chip {
  font-size: 11px; font-weight: 600;
  color: #3b5bdb;
  background: #fff;
  border: 1px solid #d8e0f5;
  border-radius: 999px;
  padding: 5px 9px;
  white-space: nowrap;
  flex: 0 0 auto;
}

/* ---- pole tekstowe ---- */
.cd-input {
  display: flex; align-items: center; gap: 9px;
  padding: 11px 14px 14px;
  background: #f6f7fb;
  flex: 0 0 auto; /* stała stopka, nie ściska się */
}
.cd-input-field {
  flex: 1 1 auto;
  min-width: 0;
  background: #fff;
  border: 1px solid #e2e7f1;
  border-radius: 999px;
  padding: 10px 14px;
  font-size: 13px;
  color: #9aa3b2;
}
/* wariant demo — informacja zamiast pola wpisywania */
.cd-input-field--demo {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; font-weight: 500;
  color: #97a0b0;
  background: #f0f2f7;
  border-style: dashed;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.cd-input-field--demo svg { width: 13px; height: 13px; flex: 0 0 13px; }
.cd-send {
  width: 38px; height: 38px; flex: 0 0 38px;
  border-radius: 50%;
  background: #4f7bff;
  color: #fff;
  display: grid; place-items: center;
}
.cd-send svg { width: 18px; height: 18px; }
.cd-send--off { background: #c7cedd; cursor: not-allowed; }

/* ====================================================================
   Układ hero case'a: tekst po lewej, czat po prawej, zdjecie pod spodem
   ==================================================================== */
.cs-hero-split {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 408px);
  gap: clamp(28px, 4.5vw, 60px);
  align-items: center;
  margin: 6px 0 36px;
}
.cs-hero-col-chat { display: flex; justify-content: center; }
.cs-hero-col-text .cs-h1 { margin-top: 12px; }

.cs-hero-shot {
  margin: 0 0 40px;
  text-align: center;
}
.cs-hero-shot img {
  display: block;
  width: 100%;
  max-width: 980px;
  height: auto;
  margin: 0 auto;
}

@media (max-width: 900px) {
  /* nadpisuje też .cs-hero-split z case-study-deezer.css (justify-items:start),
     który kurczyłby kolumny do treści i wypychał czat poza ekran */
  .cs-hero-split { grid-template-columns: minmax(0, 1fr); gap: 28px; justify-items: stretch; }
  .cs-hero-col-text, .cs-hero-col-chat { min-width: 0; width: 100%; }
  .cs-hero-col-chat { order: 2; }
}

@keyframes cd-bounce {
  0%, 60%, 100% { transform: translateY(0); opacity: .5; }
  30% { transform: translateY(-5px); opacity: 1; }
}
@keyframes cd-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(52,211,153,.55); }
  70%  { box-shadow: 0 0 0 7px rgba(52,211,153,0); }
  100% { box-shadow: 0 0 0 0 rgba(52,211,153,0); }
}

@media (prefers-reduced-motion: reduce) {
  .cd-enter, .cd-typing span, .cd-head-dot { animation: none; }
  .cd-body { scroll-behavior: auto; }
}

@media (max-width: 520px) {
  .cd-stage { padding: 16px; }
  .cd-phone { height: 78vh; max-width: 100%; }
}
