/* Müşteri sohbet penceresi (bağımsız sayfa veya iframe içinde widget) */
.chat-body { display: grid; place-items: center; min-height: 100%; padding: 24px 16px; }
.chat-app {
  width: 100%; max-width: 420px; height: min(680px, calc(100dvh - 48px));
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--surface); border: 1px solid var(--border); border-radius: 16px; box-shadow: var(--shadow-lg);
}
/* Widget içinde iframe'in tamamını kaplar */
.chat-body.embedded { padding: 0; display: block; background: var(--surface); }
.chat-body.embedded .chat-app { max-width: none; height: 100dvh; border: 0; border-radius: 0; box-shadow: none; }
@media (max-width: 480px) {
  .chat-body { padding: 0; display: block; }
  .chat-app { max-width: none; height: 100dvh; border: 0; border-radius: 0; box-shadow: none; }
}

.chat-header {
  display: flex; align-items: center; gap: 12px; padding: 14px 14px 14px 16px;
  background: var(--brand); color: var(--brand-text); flex: none;
}
.ch-avatar {
  width: 38px; height: 38px; border-radius: 50%; flex: none; display: grid; place-items: center;
  background: rgba(19, 15, 40, .12); font-weight: 600; font-size: 14px;
}
.ch-avatar svg { width: 18px; height: 18px; }
.ch-text { flex: 1; min-width: 0; display: flex; flex-direction: column; }
.ch-text strong { font-size: 15px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.ch-sub { display: flex; align-items: center; gap: 6px; font-size: 12px; opacity: .9; }
.ch-sub .dot { background: rgba(19, 15, 40, .35); }
.ch-sub .dot.on { background: #15803d; box-shadow: 0 0 0 2px rgba(253, 253, 253, .6); }
.ch-actions { display: flex; gap: 2px; }
.ch-icon {
  width: 34px; height: 34px; border: 0; border-radius: 8px; background: transparent; color: var(--brand-text); cursor: pointer;
  display: grid; place-items: center;
}
.ch-icon:hover { background: rgba(19, 15, 40, .12); }
#btn-visitor-sound .mute-line { display: none; }
#btn-visitor-sound.off .mute-line { display: inline; }
#btn-visitor-sound.off { opacity: .6; }
.ch-icon svg { width: 18px; height: 18px; }

.conn-banner { padding: 6px 12px; font-size: 12px; text-align: center; background: var(--warn-soft); color: var(--warn); }

.view { flex: 1; min-height: 0; display: flex; flex-direction: column; }
.view-loading { align-items: center; justify-content: center; }
.spinner {
  width: 28px; height: 28px; border-radius: 50%;
  border: 3px solid var(--border); border-top-color: var(--brand); animation: spin .8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
/* İlk bağlantı kurulamayınca dönüşün yerine geçen açıklama + "Tekrar dene" (chat.js). */
.loading-error {
  display: flex; flex-direction: column; align-items: center; gap: 12px;
  padding: 0 24px; text-align: center; font-size: 13px; color: var(--text-2);
}
.loading-error p { margin: 0; }

/* Sohbet öncesi ekran: isteğe bağlı başlık görseli (banner) ve arka plan görseli (panelde Ayarlar). */
.view-prechat { overflow-y: auto; padding: 0; background: var(--surface) center top / cover no-repeat; }
.prechat-banner { display: block; flex: none; width: 100%; height: auto; max-height: 220px; object-fit: cover; }
.prechat-card { flex: none; padding: 22px 20px; }
.view-prechat.has-bg .prechat-card {
  margin: 16px; padding: 18px 16px; border-radius: 14px; background: var(--surface); box-shadow: var(--shadow-lg);
}
.prechat-intro h2 { font-size: 20px; margin-bottom: 6px; }
.prechat-intro p { margin: 0 0 20px; color: var(--text-2); white-space: pre-line; }
/* Panelde Ayarlar > Sohbet öncesi ekran metni (değişkenler doldurulmuş halde gelir). */
.prechat-info {
  margin: -6px 0 20px; padding: 12px 14px; border-radius: var(--radius-sm);
  background: var(--surface-2); border: 1px solid var(--border);
  font-size: 13px; line-height: 1.55; white-space: pre-line; overflow-wrap: anywhere;
}
.prechat-info a { color: var(--brand-ink); }

.status-line {
  margin: 12px 14px 0; padding: 10px 12px; border-radius: var(--radius-sm);
  background: var(--brand-soft); color: var(--text-2); font-size: 13px; white-space: pre-line;
}
.messages { flex: 1; overflow-y: auto; padding: 16px 14px 8px; display: flex; flex-direction: column; gap: 2px; }

.msg { display: flex; flex-direction: column; max-width: 82%; margin-top: 10px; }
.msg.cont { margin-top: 2px; }
.msg.me { align-self: flex-end; align-items: flex-end; }
.msg.them { align-self: flex-start; align-items: flex-start; }
.msg-name { font-size: 12px; color: var(--text-3); margin: 0 4px 3px; }
.bubble { padding: 8px 12px 6px; border-radius: 16px; background: var(--bubble-visitor); }
.msg.me .bubble { background: var(--brand); color: var(--brand-text); border-bottom-right-radius: 4px; }
.msg.them .bubble { border-bottom-left-radius: 4px; }
.msg-time { display: block; font-size: 10.5px; opacity: .65; text-align: right; margin-top: 2px; }
.msg-retracted { font-style: italic; color: var(--text-3); }
.msg.system { align-self: center; max-width: 92%; margin: 12px 0 4px; }
.msg.system span {
  display: inline-block; padding: 4px 10px; border-radius: 999px;
  background: var(--surface-3); color: var(--text-3); font-size: 12px; text-align: center;
}

.quick-replies { display: flex; flex-wrap: wrap; gap: 6px; margin: 8px 0 4px; max-width: 92%; }
.quick-reply {
  padding: 6px 12px; border-radius: 999px; cursor: pointer; font-size: 13px;
  border: 1px solid var(--brand); background: var(--surface); color: var(--brand-ink);
}
.quick-reply:hover { background: var(--brand); color: var(--brand-text); }
/* Bot mesajındaki bağlantılar: metin içi bağlantı ("[görünen metin](adres)") ve balonun içindeki bağlantı butonları
   (yeni sekmede açılır, sohbete mesaj gitmez; hızlı yanıt çiplerinden ayrı durur, müşteri cevabı gibi görünmez) */
.msg-text a.msg-link { color: var(--brand-ink); font-weight: 600; }
.msg-actions { display: flex; flex-direction: column; gap: 6px; margin: 8px 0 2px; }
.msg-action {
  display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 36px; padding: 7px 14px;
  border-radius: 10px; background: var(--brand); color: var(--brand-text); font-size: 13.5px; font-weight: 600; text-decoration: none;
}
.msg-action::after { content: "↗"; font-size: 12px; opacity: .9; }
.msg-action:hover { filter: brightness(1.08); }
.msg-action:focus-visible { outline: 2px solid var(--brand-ink); outline-offset: 2px; }

.typing { display: flex; align-items: center; gap: 8px; padding: 2px 18px 8px; font-size: 12px; color: var(--text-3); }
.typing-dots { display: inline-flex; gap: 3px; }
.typing-dots i { width: 5px; height: 5px; border-radius: 50%; background: var(--text-3); animation: blink 1.2s infinite; }
.typing-dots i:nth-child(2) { animation-delay: .2s; }
.typing-dots i:nth-child(3) { animation-delay: .4s; }
@keyframes blink { 0%, 60%, 100% { opacity: .25; } 30% { opacity: 1; } }

.composer {
  display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px;
  border-top: 1px solid var(--border); background: var(--surface); flex: none;
}
.composer textarea {
  flex: 1; resize: none; max-height: 120px; min-height: 40px; padding: 9px 12px;
  border: 1px solid var(--border-strong); border-radius: 20px; background: var(--surface-2); outline: none; line-height: 1.4;
}
.composer textarea:focus { border-color: var(--brand); }
.attach-btn {
  width: 40px; height: 40px; flex: none; border: 0; border-radius: 50%; cursor: pointer;
  background: transparent; color: var(--text-3); display: grid; place-items: center;
}
.attach-btn:hover { background: var(--surface-3); color: var(--brand-ink); }
.attach-btn svg { width: 20px; height: 20px; }
.msg.me .att-file { background: rgba(19, 15, 40, .1); }
.send-btn {
  width: 40px; height: 40px; flex: none; border: 0; border-radius: 50%; cursor: pointer;
  background: var(--brand); color: var(--brand-text); display: grid; place-items: center;
}
.send-btn:hover { background: var(--brand-hover); }
.send-btn svg { width: 18px; height: 18px; }

.end-confirm {
  display: flex; align-items: center; justify-content: space-between; gap: 10px; flex-wrap: wrap;
  padding: 10px 14px; border-top: 1px solid var(--border); background: var(--danger-soft); font-size: 13px;
}
.end-confirm div { display: flex; gap: 6px; }

.ended-panel {
  display: flex; flex-direction: column; align-items: center; gap: 10px; text-align: center;
  padding: 16px; border-top: 1px solid var(--border); background: var(--surface-2); flex: none;
}
.ended-panel p { margin: 0; font-size: 13px; }
.ended-actions { display: flex; flex-wrap: wrap; justify-content: center; gap: 8px; }
#rating-form { display: flex; flex-direction: column; align-items: center; gap: 10px; width: 100%; }
#rating-form textarea { min-height: 56px; }
.stars { display: flex; gap: 4px; }
.star {
  width: 34px; height: 34px; border: 0; background: transparent; cursor: pointer; padding: 3px;
  color: var(--border-strong); transition: transform .1s, color .1s;
}
.star:hover { transform: scale(1.1); }
.star.on { color: #f59e0b; }
.star svg { width: 100%; height: 100%; }
.rating-thanks { color: var(--ok); font-weight: 500; }

.powered { flex: none; padding: 6px; text-align: center; font-size: 11px; color: var(--text-3); border-top: 1px solid var(--border); }

/* Hareket azaltma tercihi: dönüş / yanıp sönme animasyonları ve büyüme geçişi kapalı (chat.js kaydırmayı da anlık yapar). */
@media (prefers-reduced-motion: reduce) {
  .spinner { animation: none; }
  .typing-dots i { animation: none; opacity: .6; }
  .star { transition: none; }
  .star:hover { transform: none; }
}
