/* Parça Asistanı — canlı chat widget stilleri (tema uyumlu, bs tokenları). */

/* ---- Yuvarlak açma butonu (Esc-hint rozetiyle çakışmasın: bottom 5rem) ---- */
.pg-chat-toggle {
  position: fixed;
  right: 1.25rem;
  bottom: 5rem;
  z-index: 1045;
  width: 3.5rem;
  height: 3.5rem;
  border-radius: 50%;
  border: none;
  background: var(--pg-brand, #ea580c);
  color: #fff;
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0.5rem 1.25rem rgba(0, 0, 0, 0.25);
  transition: transform 0.15s ease, background-color 0.15s ease;
}
.pg-chat-toggle:hover {
  background: var(--pg-brand-hover, #c2410c);
  transform: scale(1.08);
}
.pg-chat-toggle:active { transform: scale(0.96); }

/* ---- Panel ---- */
.pg-chat-panel {
  position: fixed;
  right: 1.25rem;
  bottom: 9rem;
  z-index: 1046;
  width: 380px;
  max-width: calc(100vw - 2.5rem);
  height: 32rem;
  max-height: calc(100vh - 11rem);
  display: flex;
  flex-direction: column;
  background: var(--bs-body-bg);
  color: var(--bs-body-color);
  border: 1px solid var(--bs-border-color);
  border-radius: 1rem;
  box-shadow: 0 1rem 2.5rem rgba(0, 0, 0, 0.3);
  overflow: hidden;
}
.pg-chat-panel.d-none { display: none !important; }

@media (max-width: 575.98px) {
  .pg-chat-panel {
    right: 0.5rem;
    left: 0.5rem;
    width: auto;
    max-width: none;
    bottom: 9rem;
    height: 30rem;
    max-height: calc(100vh - 10rem);
  }
}

/* ---- Başlık ---- */
.pg-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  background: var(--pg-brand, #ea580c);
  color: #fff;
}
.pg-chat-avatar {
  width: 2.25rem;
  height: 2.25rem;
  border-radius: 50%;
  background: rgba(255, 255, 255, 0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.1rem;
}
.pg-chat-status {
  font-size: 0.75rem;
  opacity: 0.9;
}
.pg-chat-dot {
  display: inline-block;
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 50%;
  background: #4ade80;
  margin-right: 0.15rem;
  animation: pgChatPulse 2s infinite;
}
@keyframes pgChatPulse {
  0%, 100% { opacity: 1; }
  50% { opacity: 0.45; }
}

/* Kapat X — dönme efekti */
.pg-chat-close {
  border: none;
  background: transparent;
  color: #fff;
  font-size: 1.1rem;
  width: 2rem;
  height: 2rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: transform 0.3s ease, background-color 0.2s ease;
}
.pg-chat-close:hover {
  background: rgba(255, 255, 255, 0.15);
  transform: rotate(90deg);
}

/* ---- Mesaj listesi ---- */
.pg-chat-messages {
  flex: 1 1 auto;
  overflow-y: auto;
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  background: var(--bs-tertiary-bg, var(--bs-body-bg));
}
.pg-chat-msg {
  max-width: 85%;
  padding: 0.5rem 0.75rem;
  border-radius: 0.9rem;
  font-size: 0.875rem;
  line-height: 1.4;
  word-break: break-word;
  white-space: pre-line;
}
.pg-chat-msg a {
  color: inherit;
  font-weight: 600;
  text-decoration: underline;
}
.pg-chat-msg--user {
  align-self: flex-end;
  background: var(--pg-brand, #ea580c);
  color: #fff;
  border-bottom-right-radius: 0.25rem;
}
.pg-chat-msg--bot {
  align-self: flex-start;
  background: var(--bs-secondary-bg);
  color: var(--bs-body-color);
  border-bottom-left-radius: 0.25rem;
}
.pg-chat-msg--bot a { color: var(--pg-brand, #ea580c); }
.pg-chat-msg-time {
  font-size: 0.68rem;
  opacity: 0.65;
  margin-top: 0.15rem;
}
.pg-chat-msg img.pg-chat-msg-img {
  display: block;
  max-width: 100%;
  max-height: 10rem;
  border-radius: 0.5rem;
  margin-bottom: 0.35rem;
}

/* Bot yazıyor — üç nokta animasyonu */
.pg-chat-typing {
  align-self: flex-start;
  background: var(--bs-secondary-bg);
  border-radius: 0.9rem;
  border-bottom-left-radius: 0.25rem;
  padding: 0.65rem 0.9rem;
  display: flex;
  gap: 0.3rem;
}
.pg-chat-typing span {
  width: 0.45rem;
  height: 0.45rem;
  border-radius: 50%;
  background: var(--bs-secondary-color);
  animation: pgChatBlink 1.2s infinite;
}
.pg-chat-typing span:nth-child(2) { animation-delay: 0.2s; }
.pg-chat-typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes pgChatBlink {
  0%, 80%, 100% { opacity: 0.25; transform: translateY(0); }
  40% { opacity: 1; transform: translateY(-0.15rem); }
}

/* ---- Fotoğraf önizleme ---- */
.pg-chat-preview {
  position: relative;
  padding: 0.5rem 1rem 0;
  background: var(--bs-body-bg);
}
.pg-chat-preview img {
  height: 3.5rem;
  border-radius: 0.5rem;
  border: 1px solid var(--bs-border-color);
}
.pg-chat-preview button {
  position: absolute;
  top: 0.15rem;
  left: 3.9rem;
  width: 1.35rem;
  height: 1.35rem;
  border-radius: 50%;
  border: none;
  background: var(--bs-danger, #dc3545);
  color: #fff;
  font-size: 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ---- Alt giriş satırı ---- */
.pg-chat-inputbar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--bs-border-color);
  background: var(--bs-body-bg);
}
.pg-chat-inputbar .form-control {
  border-radius: 2rem;
  font-size: 0.875rem;
}
.pg-chat-attach {
  cursor: pointer;
  color: var(--bs-secondary-color);
  font-size: 1.2rem;
  margin-bottom: 0;
  display: flex;
  align-items: center;
  transition: color 0.15s ease;
}
.pg-chat-attach:hover { color: var(--pg-brand, #ea580c); }
.pg-chat-send {
  flex: 0 0 auto;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  border: none;
  background: var(--pg-brand, #ea580c);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.15s ease, transform 0.15s ease;
}
.pg-chat-send:hover { background: var(--pg-brand-hover, #c2410c); }
.pg-chat-send:disabled { opacity: 0.6; }

/* ============================================================
   WhatsApp-vari görünüm (pg-chat--wa) — chat_widget.html'de
   #pgChat'e "pg-chat--wa" sınıfı eklenerek devreye girer.
   ============================================================ */

/* ---- Tema değişkenleri (baloncuk renkleri, marka uyumlu) ---- */
.pg-chat--wa {
  --pg-wa-in: #ffffff;                 /* gelen (bot) baloncuk */
  --pg-wa-in-text: var(--bs-body-color);
  --pg-wa-out: #ffe4cc;                /* giden (kullanıcı) — marka-turuncu krem */
  --pg-wa-out-text: #3d2b1f;
  --pg-wa-tick-read: #53bdeb;          /* okundu mavisi */
}
[data-bs-theme="dark"] .pg-chat--wa {
  --pg-wa-in: #1f2c34;
  --pg-wa-in-text: #e9edef;
  --pg-wa-out: #5b3416;
  --pg-wa-out-text: #f5ede6;
}

/* ---- Mesaj alanı: saf CSS duvar kağıdı dokusu ---- */
.pg-chat--wa .pg-chat-messages {
  gap: 0.15rem; /* grup içi sıkı; gruplar arası boşluk margin ile */
  background-color: #f0e9e2;
  background-image:
    radial-gradient(rgba(120, 90, 60, 0.05) 1px, transparent 1.6px),
    radial-gradient(rgba(120, 90, 60, 0.035) 1px, transparent 1.6px);
  background-size: 24px 24px;
  background-position: 0 0, 12px 12px;
}
[data-bs-theme="dark"] .pg-chat--wa .pg-chat-messages {
  background-color: #0f171e;
  background-image:
    radial-gradient(rgba(255, 255, 255, 0.035) 1px, transparent 1.6px),
    radial-gradient(rgba(255, 255, 255, 0.02) 1px, transparent 1.6px);
}

/* ---- Baloncuklar ---- */
.pg-chat--wa .pg-chat-msg {
  position: relative;
  border-radius: 0.65rem;
  padding: 0.45rem 0.6rem 0.3rem;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.08);
}
.pg-chat--wa .pg-chat-msg--bot {
  background: var(--pg-wa-in);
  color: var(--pg-wa-in-text);
}
.pg-chat--wa .pg-chat-msg--user {
  background: var(--pg-wa-out);
  color: var(--pg-wa-out-text);
}
.pg-chat--wa .pg-chat-msg--user a { color: inherit; }
.pg-chat--wa .pg-chat-msg--bot a { color: var(--pg-brand, #ea580c); }

/* Grup aralığı: grup başlarken üstte nefes payı */
.pg-chat--wa .pg-chat-msg.pg-wa-grp-first,
.pg-chat--wa .pg-chat-msg.pg-wa-grp-single,
.pg-chat--wa .pg-chat-typing { margin-top: 0.45rem; }

/* Kuyruk (tail) — yalnız grubun ilk baloncuğunda */
.pg-chat--wa .pg-chat-msg.pg-wa-grp-first,
.pg-chat--wa .pg-chat-msg.pg-wa-grp-single { overflow: visible; }
.pg-chat--wa .pg-chat-msg--bot.pg-wa-grp-first,
.pg-chat--wa .pg-chat-msg--bot.pg-wa-grp-single { border-top-left-radius: 0; }
.pg-chat--wa .pg-chat-msg--user.pg-wa-grp-first,
.pg-chat--wa .pg-chat-msg--user.pg-wa-grp-single { border-top-right-radius: 0; }
.pg-chat--wa .pg-chat-msg--bot.pg-wa-grp-first::before,
.pg-chat--wa .pg-chat-msg--bot.pg-wa-grp-single::before {
  content: "";
  position: absolute;
  top: 0;
  left: -8px;
  width: 8px;
  height: 13px;
  background: var(--pg-wa-in);
  clip-path: polygon(100% 0, 100% 100%, 0 0);
}
.pg-chat--wa .pg-chat-msg--user.pg-wa-grp-first::before,
.pg-chat--wa .pg-chat-msg--user.pg-wa-grp-single::before {
  content: "";
  position: absolute;
  top: 0;
  right: -8px;
  width: 8px;
  height: 13px;
  background: var(--pg-wa-out);
  clip-path: polygon(0 0, 0 100%, 100% 0);
}

/* ---- Saat + tik meta satırı ---- */
.pg-chat--wa .pg-wa-meta {
  display: flex;
  justify-content: flex-end;
  align-items: center;
  gap: 0.2rem;
  font-size: 0.66rem;
  line-height: 1;
  opacity: 0.62;
  margin-top: 0.2rem;
  user-select: none;
}
.pg-chat--wa .pg-wa-ticks {
  font-size: 0.85rem;
  line-height: 1;
  color: currentColor;
  opacity: 0.75;
}
.pg-chat--wa .pg-wa-ticks.pg-wa-ticks--read {
  color: var(--pg-wa-tick-read);
  opacity: 1;
}

/* ---- Başlık: avatar + "yazıyor..." durumu ---- */
.pg-chat--wa .pg-chat-avatar {
  background: #fff;
  color: var(--pg-brand, #ea580c);
}
.pg-chat--wa .pg-chat-status.pg-wa-status--typing .pg-chat-dot { display: none; }
.pg-chat--wa .pg-chat-status.pg-wa-status--typing { font-style: italic; opacity: 1; }

/* ---- Typing balonu WA görünümü ---- */
.pg-chat--wa .pg-chat-typing {
  position: relative;
  background: var(--pg-wa-in);
  border-radius: 0.65rem;
  border-top-left-radius: 0;
  box-shadow: 0 1px 1px rgba(0, 0, 0, 0.08);
}
.pg-chat--wa .pg-chat-typing::before {
  content: "";
  position: absolute;
  top: 0;
  left: -8px;
  width: 8px;
  height: 13px;
  background: var(--pg-wa-in);
  clip-path: polygon(100% 0, 100% 100%, 0 0);
}
.pg-chat--wa .pg-chat-typing span { background: var(--bs-secondary-color); }

/* ---- Hareket azaltma tercihi ---- */
@media (prefers-reduced-motion: reduce) {
  .pg-chat--wa .pg-chat-dot,
  .pg-chat--wa .pg-chat-typing span { animation: none; }
}
