/* ==========================================================================
   MEDIAFELD — chat.css
   Beratungs-Assistent, unten rechts. Hochwertige Messenger-Oberfläche
   mit echtem Ansprechpartner-Foto, Sprechblasen und Präsenz-Anzeige.
   ========================================================================== */
.chat { position: fixed; right: 1.5rem; bottom: 1.5rem; z-index: 200; }

/* ── Start-Sprechblase (Teaser) ────────────────────────────────────────── */
.chat__teaser {
  position: absolute; right: 74px; bottom: 6px;
  width: max-content; max-width: 232px;
  display: flex; align-items: center; gap: .6rem;
  padding: .7rem .9rem .7rem .7rem;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 18px 18px 4px 18px;
  box-shadow: 0 22px 45px -20px rgba(10,24,36,.5);
  opacity: 0; transform: translateY(8px) scale(.9);
  transform-origin: bottom right;
  transition: opacity .4s var(--ease), transform .45s var(--ease-b);
  pointer-events: none;
}
.chat__teaser.is-in { opacity: 1; transform: none; pointer-events: auto; }
.chat__teaser img { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; flex: none; }
.chat__teaser p { font-size: .82rem; line-height: 1.4; color: var(--text-soft); }
.chat__teaser b { color: var(--text); }
.chat__teaser-x {
  position: absolute; top: -8px; right: -8px;
  width: 22px; height: 22px; border-radius: 50%;
  display: grid; place-items: center;
  background: var(--navy); color: #fff; font-size: .6rem;
  box-shadow: var(--shadow-s);
}

/* ── Knopf mit Foto ────────────────────────────────────────────────────── */
.chat__toggle {
  position: relative;
  display: grid; place-items: center;
  width: 66px; height: 66px;
  border-radius: 50%;
  background: linear-gradient(140deg, var(--cyan), var(--blue) 55%, var(--blue-deep));
  color: #fff;
  padding: 3px;
  box-shadow: 0 18px 40px -14px rgba(27,146,209,.9);
  transition: transform .4s var(--ease-b), box-shadow .35s var(--ease);
}
.chat__toggle:hover { transform: scale(1.07) translateY(-3px); box-shadow: 0 24px 55px -14px rgba(34,184,232,1); }
.chat__toggle-photo {
  width: 100%; height: 100%; border-radius: 50%;
  object-fit: cover; border: 2px solid var(--paper);
  transition: opacity .3s var(--ease), transform .4s var(--ease-b);
}
.chat__toggle .chat__icon-close {
  position: absolute; inset: 0; margin: auto;
  width: 26px; height: 26px; display: grid; place-items: center;
  font-size: 1.5rem; opacity: 0; transform: rotate(-90deg) scale(.5);
  transition: opacity .3s var(--ease), transform .4s var(--ease-b);
}
.chat__toggle.is-open .chat__toggle-photo { opacity: 0; transform: scale(.4); }
.chat__toggle.is-open .chat__icon-close { opacity: 1; transform: none; }

.chat__presence {
  position: absolute; right: 2px; bottom: 3px;
  width: 15px; height: 15px; border-radius: 50%;
  background: #2BD96F; border: 3px solid var(--paper);
}
.chat__badge {
  position: absolute; top: -3px; right: -3px;
  display: grid; place-items: center;
  min-width: 22px; height: 22px; padding: 0 5px;
  border-radius: 999px;
  background: var(--orange); color: #fff;
  font-size: .68rem; font-weight: 700;
  border: 2px solid var(--paper);
}
.chat__badge[hidden] { display: none; }

.chat__toggle.is-pulsing { animation: chatPulse 1.6s var(--ease) 3; }
@keyframes chatPulse {
  0%, 100% { box-shadow: 0 18px 40px -14px rgba(27,146,209,.9), 0 0 0 0 rgba(34,184,232,.5); }
  50%      { box-shadow: 0 18px 40px -14px rgba(27,146,209,.9), 0 0 0 18px rgba(34,184,232,0); }
}

/* ── Fenster ───────────────────────────────────────────────────────────── */
.chat__panel {
  position: absolute;
  right: 0; bottom: 82px;
  width: min(408px, calc(100vw - 3rem));
  height: min(660px, calc(100vh - 8rem));
  display: flex; flex-direction: column;
  background: var(--paper);
  border: 1px solid var(--line);
  border-radius: 26px;
  box-shadow: 0 50px 100px -30px rgba(10,24,36,.55);
  overflow: hidden;
  opacity: 0; transform: translateY(20px) scale(.95);
  transform-origin: bottom right;
  transition: opacity .3s var(--ease), transform .45s var(--ease-b);
}
.chat__panel.is-open { opacity: 1; transform: none; }
.chat__panel[hidden] { display: none; }

/* ── Kopf mit Ansprechpartner ──────────────────────────────────────────── */
.chat__head {
  position: relative;
  display: flex; align-items: center; gap: .85rem;
  padding: 1.05rem 1.1rem;
  background: linear-gradient(125deg, var(--black) 0%, var(--navy) 60%, var(--navy-2) 100%);
  color: #fff;
}
.chat__head::after {
  content: ""; position: absolute; left: 0; right: 0; bottom: 0; height: 1px;
  background: linear-gradient(90deg, transparent, rgba(34,184,232,.55), transparent);
}
.chat__head-photo { position: relative; flex: none; }
.chat__head-photo img {
  width: 46px; height: 46px; border-radius: 50%;
  object-fit: cover; border: 2px solid rgba(255,255,255,.25);
}
.chat__head-photo .chat__presence { width: 12px; height: 12px; right: 0; bottom: 0; border-width: 2px; border-color: var(--navy); }
.chat__who { flex: 1; display: grid; gap: .12rem; line-height: 1.3; }
.chat__who b { font-size: .96rem; letter-spacing: -.01em; }
.chat__who span { font-size: .74rem; color: rgba(255,255,255,.62); display: flex; align-items: center; gap: .4rem; }
.chat__dot { width: 7px; height: 7px; border-radius: 50%; background: #2BD96F; animation: chatDot 2s var(--ease) infinite; }
@keyframes chatDot { 0%,100% { opacity: 1; } 50% { opacity: .35; } }
.chat__close {
  display: grid; place-items: center;
  width: 34px; height: 34px; border-radius: 50%;
  color: rgba(255,255,255,.7);
  transition: background-color .2s var(--ease), color .2s var(--ease);
}
.chat__close:hover { background: rgba(255,255,255,.14); color: #fff; }

/* ── Verlauf ───────────────────────────────────────────────────────────── */
.chat__log {
  flex: 1; min-height: 0;
  overflow-y: auto;
  padding: 1.2rem 1.05rem .4rem;
  display: flex; flex-direction: column; gap: .55rem;
  background:
    radial-gradient(120% 60% at 100% 0%, rgba(34,184,232,.06), transparent 60%),
    var(--mist);
  scroll-behavior: smooth;
}
.chat__log::-webkit-scrollbar { width: 6px; }
.chat__log::-webkit-scrollbar-thumb { background: var(--line-2); border-radius: 999px; }

.chat__day {
  align-self: center;
  margin: .1rem 0 .5rem;
  padding: .2rem .7rem;
  font-size: .66rem; font-weight: 600; letter-spacing: .04em;
  color: var(--text-mute);
  background: rgba(255,255,255,.7);
  border: 1px solid var(--line);
  border-radius: 999px;
}

/* Nachricht (Zeile mit optionalem Avatar) */
.chat__row { display: flex; align-items: flex-end; gap: .5rem; max-width: 90%; }
.chat__row--bot { align-self: flex-start; }
.chat__row--user { align-self: flex-end; flex-direction: row-reverse; }
.chat__ava {
  width: 30px; height: 30px; border-radius: 50%; flex: none;
  object-fit: cover; border: 1.5px solid var(--paper); box-shadow: var(--shadow-s);
  align-self: flex-end;
}
.chat__ava--ghost { visibility: hidden; }

.chat__msg {
  padding: .78rem .95rem;
  border-radius: 18px;
  font-size: .9rem; line-height: 1.58;
  animation: chatIn .35s var(--ease);
}
@keyframes chatIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }
.chat__row--bot .chat__msg {
  background: var(--paper);
  border: 1px solid var(--line);
  border-bottom-left-radius: 5px;
  color: var(--text-soft);
  box-shadow: var(--shadow-s);
}
.chat__row--bot .chat__msg b { color: var(--text); font-weight: 700; }
.chat__row--user .chat__msg {
  background: linear-gradient(130deg, var(--blue), var(--blue-deep));
  border-bottom-right-radius: 5px;
  color: #fff;
}
.chat__time { display: block; margin-top: .3rem; font-size: .64rem; opacity: .55; }

.chat__typing { display: flex; gap: 5px; padding: .95rem 1rem; }
.chat__typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--text-mute); animation: chatType 1.2s var(--ease) infinite; }
.chat__typing span:nth-child(2) { animation-delay: .18s; }
.chat__typing span:nth-child(3) { animation-delay: .36s; }
@keyframes chatType { 0%,60%,100% { transform: translateY(0); opacity: .4; } 30% { transform: translateY(-5px); opacity: 1; } }

.chat__cta {
  display: inline-flex; align-items: center; gap: .6rem;
  margin-top: .2rem;
  padding: .72rem 1.05rem;
  background: linear-gradient(130deg, var(--cyan), var(--blue-deep));
  color: #fff !important;
  border-radius: 999px;
  font-size: .85rem; font-weight: 600;
  box-shadow: 0 12px 26px -14px rgba(27,146,209,.9);
  transition: transform .3s var(--ease-b), box-shadow .3s var(--ease);
}
.chat__cta:hover { transform: translateY(-2px); box-shadow: 0 16px 30px -12px rgba(27,146,209,1); }
.chat__cta .fa-arrow-right { font-size: .7rem; margin-left: .2rem; }

.chat__contact { display: flex; gap: .5rem; flex-wrap: wrap; margin-top: .2rem; }
.chat__contact a {
  display: inline-flex; align-items: center; gap: .45rem;
  padding: .58rem .85rem;
  background: var(--paper);
  border: 1px solid var(--line-2);
  border-radius: 999px;
  font-size: .8rem; font-weight: 600; color: var(--text-soft);
  transition: transform .3s var(--ease-b), border-color .25s var(--ease), background-color .25s var(--ease);
}
.chat__contact a:hover { transform: translateY(-2px); border-color: var(--blue); background: var(--sky); }
.chat__contact i { color: var(--blue-deep); }
.chat__contact .fa-whatsapp { color: #12A94F; }

/* ── Schnellauswahl (Chips) ────────────────────────────────────────────── */
.chat__opts {
  display: flex; flex-wrap: wrap; gap: .35rem;
  padding: .55rem .9rem .1rem;
  background: var(--mist);
}
.chat__opt {
  padding: .34rem .7rem;
  background: var(--paper);
  border: 1px solid var(--blue-soft);
  border-radius: 999px;
  color: var(--blue-deep);
  font-size: .73rem; font-weight: 600; line-height: 1.15;
  transition: transform .3s var(--ease-b), background-color .25s var(--ease), color .25s var(--ease);
  animation: chatIn .35s var(--ease) backwards;
}
.chat__opt:nth-child(2) { animation-delay: .05s; }
.chat__opt:nth-child(3) { animation-delay: .1s; }
.chat__opt:nth-child(4) { animation-delay: .15s; }
.chat__opt:nth-child(5) { animation-delay: .2s; }
.chat__opt:hover {
  transform: translateY(-2px);
  background: linear-gradient(130deg, var(--cyan), var(--blue-deep));
  color: #fff; border-color: transparent;
}

/* ── Eingabe ───────────────────────────────────────────────────────────── */
.chat__form {
  display: flex; gap: .5rem; align-items: center;
  padding: .8rem 1.05rem;
  background: var(--mist);
  border-top: 1px solid var(--line);
}
.chat__form input {
  flex: 1;
  padding: .8rem 1rem;
  border: 1px solid var(--line-2);
  border-radius: 999px;
  background: var(--paper);
  font: inherit; font-size: .88rem;
}
.chat__form input:focus { outline: none; border-color: var(--blue); box-shadow: 0 0 0 3px rgba(27,146,209,.12); }
.chat__form button {
  display: grid; place-items: center;
  width: 44px; height: 44px; flex: none;
  border-radius: 50%;
  background: linear-gradient(140deg, var(--cyan), var(--blue-deep));
  color: #fff;
  transition: transform .3s var(--ease-b);
}
.chat__form button:hover { transform: scale(1.08); }

.chat__foot {
  display: flex; align-items: center; gap: .45rem;
  padding: .6rem 1.05rem;
  background: var(--paper);
  border-top: 1px solid var(--line);
  font-size: .68rem; color: var(--text-mute);
}
.chat__foot i { color: var(--green); }

/* WhatsApp-Knopf weicht dem Chat aus */
@media (max-width: 1024px) { .wa-float { bottom: 6.8rem; } }
@media (max-width: 640px) {
  .chat { right: 1rem; bottom: 1rem; }
  .chat__toggle { width: 60px; height: 60px; }
  .chat__panel { bottom: 74px; width: calc(100vw - 2rem); height: calc(100vh - 12rem); height: calc(100dvh - 12rem); }
  .chat__teaser { display: none; }
  .wa-float { bottom: 5.8rem; right: 1rem; }
}

@media (prefers-reduced-motion: reduce) {
  .chat__toggle, .chat__panel, .chat__msg, .chat__opt, .chat__teaser { animation: none !important; transition: none !important; }
}
