/* ==========================================================================
   YEÇED — Asistan widget'ı
   --------------------------------------------------------------------------
   Ayrı dosyadır ve YALNIZCA asistan açıkken yüklenir; kapalıyken ziyaretçi
   tek bir bayt indirmez. Tüm ölçüler panelden gelen CSS değişkenleriyle
   sürülür (--yc-w/h/x/y/radius/accent), böylece görünüm koda dokunmadan
   değişebilir.

   Kırılma noktaları:
     ≥ 641px  köşede yüzen panel (sürüklenebilir, tam ekran yapılabilir)
     ≤ 640px  ekranı kaplayan sayfa (tarayıcı çubuklarına saygılı, dvh)
   ========================================================================== */

.yc-chat {
  --yc-accent: var(--brand, #0e7a45);
  /* Vurgu zemininde okunan yazı. Sabit beyaz yazılırsa açık bir marka/vurgu
     renginde açma düğmesi ve kullanıcı balonu okunmaz olur. */
  --yc-on: var(--on-brand, #fff);
  --yc-ink: #16221d;
  --yc-line: #e3e9e6;
  --yc-bg: #fff;
  --yc-soft: #f4f7f5;
  position: fixed;
  z-index: 120;
  inset-block-end: var(--yc-y, 24px);
  font-size: 15px;
  line-height: 1.55;
}
.yc-chat[data-side="right"] { inset-inline-end: var(--yc-x, 24px); }
.yc-chat[data-side="left"]  { inset-inline-start: var(--yc-x, 24px); }
.yc-chat[hidden] { display: none; }
.yc-chat svg { width: 20px; height: 20px; fill: none; stroke: currentColor; stroke-width: 1.9; stroke-linecap: round; stroke-linejoin: round; }
.yc-sr {
  position: absolute; width: 1px; height: 1px; overflow: hidden;
  clip: rect(0 0 0 0); clip-path: inset(50%); white-space: nowrap;
}

/* ── Açma düğmesi ─────────────────────────────────────────────────────── */
.yc-launch {
  display: inline-flex; align-items: center; gap: .55rem;
  padding: .8rem 1.15rem;
  background: var(--yc-accent); color: var(--yc-on);
  border: 0; border-radius: 999px; cursor: pointer;
  font: inherit; font-weight: 700;
  box-shadow: 0 10px 28px rgb(0 0 0 / .22);
  transition: transform .18s ease, box-shadow .18s ease;
}
.yc-launch:hover { transform: translateY(-2px); box-shadow: 0 14px 34px rgb(0 0 0 / .26); }
.yc-launch:focus-visible { outline: 3px solid var(--yc-accent); outline-offset: 3px; }
.yc-launch svg { stroke-width: 2; }
.yc-ic-close { display: none; }
.yc-chat.is-open .yc-ic-open { display: none; }
.yc-chat.is-open .yc-ic-close { display: block; }
.yc-chat.is-open .yc-launch-label { display: none; }
.yc-chat.is-open .yc-launch { padding: .8rem; }

/* ── Panel ────────────────────────────────────────────────────────────── */
.yc-panel {
  position: absolute; inset-block-end: calc(100% + .7rem);
  width: min(var(--yc-w, 400px), calc(100vw - 2rem));
  /* dvh yedeği: desteklemeyen tarayıcı bildirimin TAMAMINI atar ve panel
     yüksekliği auto'ya düşerdi. Önce vh yazılır, sonra dvh ile ezilir. */
  height: min(var(--yc-h, 560px), calc(100vh - 8rem));
  height: min(var(--yc-h, 560px), calc(100dvh - 8rem));
  display: flex; flex-direction: column; overflow: hidden;
  background: var(--yc-bg); color: var(--yc-ink);
  border: 1px solid var(--yc-line);
  border-radius: var(--yc-radius, 18px);
  box-shadow: 0 24px 60px rgb(0 0 0 / .24);
  animation: yc-in .2s ease both;
}
.yc-chat[data-side="right"] .yc-panel { inset-inline-end: 0; }
.yc-chat[data-side="left"]  .yc-panel { inset-inline-start: 0; }
.yc-panel[hidden] { display: none; }
@keyframes yc-in { from { opacity: 0; transform: translateY(10px) } to { opacity: 1; transform: none } }

/* Sürüklendiğinde konum artık düğmeye değil ekrana göredir */
.yc-chat.is-moved .yc-panel {
  position: fixed; inset: auto;
  animation: none;
}
/* Tam ekran: yer değiştirme ve köşe yarıçapı iptal olur */
.yc-chat.is-full .yc-panel {
  position: fixed; inset: 1rem; left: 1rem !important; top: 1rem !important;
  width: auto; height: auto; border-radius: calc(var(--yc-radius, 18px) - 6px);
}
.yc-ic-min { display: none; }
.yc-chat.is-full .yc-ic-max { display: none; }
.yc-chat.is-full .yc-ic-min { display: block; }

/* ── Başlık ───────────────────────────────────────────────────────────── */
.yc-head {
  display: flex; align-items: center; gap: .6rem;
  padding: .7rem .8rem; flex: none;
  background: var(--yc-accent); color: var(--yc-on);
  cursor: grab; user-select: none;
}
.yc-head.is-drag { cursor: grabbing; }
.yc-avatar {
  width: 30px; height: 30px; flex: none;
  display: grid; place-items: center;
  background: rgb(255 255 255 / .18); border-radius: 50%;
}
.yc-avatar svg { width: 17px; height: 17px; fill: currentColor; stroke: none; }
.yc-title { font-weight: 700; flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.yc-actions { display: flex; gap: .15rem; flex: none; }
.yc-btn {
  width: 32px; height: 32px; display: grid; place-items: center;
  background: transparent; color: inherit; border: 0; border-radius: 8px;
  cursor: pointer; opacity: .85;
}
.yc-btn:hover { background: rgb(255 255 255 / .16); opacity: 1; }
.yc-btn:focus-visible { outline: 2px solid #fff; outline-offset: 1px; }

/* ── Mesaj akışı ──────────────────────────────────────────────────────── */
.yc-log {
  flex: 1; min-height: 0; overflow-y: auto;
  padding: .9rem .8rem; display: flex; flex-direction: column; gap: .7rem;
  overscroll-behavior: contain;      /* panelin sonunda sayfa kaymasın */
  scrollbar-width: thin;
}
.yc-msg { display: flex; flex-direction: column; max-width: 88%; }
.yc-user { align-self: flex-end; align-items: flex-end; }
.yc-bot  { align-self: flex-start; }
.yc-bubble {
  padding: .6rem .8rem; border-radius: 14px;
  background: var(--yc-soft); border: 1px solid var(--yc-line);
  overflow-wrap: anywhere;
}
.yc-user .yc-bubble { background: var(--yc-accent); border-color: transparent; color: var(--yc-on); }
.yc-bubble p { margin: 0 0 .5rem; }
.yc-bubble p:last-child { margin-bottom: 0; }
.yc-err .yc-bubble { background: #fdecec; border-color: #f3c9c9; color: #7d2020; }

/* Kaynaklar — asistanın "nereden buldum" kanıtı; gizlenmemeli */
.yc-src { margin-top: .4rem; font-size: .82rem; }
.yc-src-t { color: #5f6f68; font-weight: 700; }
.yc-src ul { margin: .2rem 0 0; padding-inline-start: 1.05rem; display: grid; gap: .1rem; }
.yc-src a { color: var(--yc-accent); }
/* Adresi olmayan kaynak (yüklenen belge) — tıklanamaz ama görünür */
.yc-src-doc { color: #5f6f68; }
.yc-src-doc::before { content: "📄 "; }

.yc-tools { display: flex; gap: .25rem; margin-top: .35rem; }
.yc-tool {
  width: 28px; height: 28px; display: grid; place-items: center;
  background: transparent; color: #5f6f68;
  border: 1px solid var(--yc-line); border-radius: 8px; cursor: pointer;
}
.yc-tool svg { width: 15px; height: 15px; }
.yc-tool:hover { color: var(--yc-ink); background: var(--yc-soft); }
.yc-tool.is-on, .yc-tool.is-done { color: var(--yc-on); background: var(--yc-accent); border-color: var(--yc-accent); }
.yc-tool:focus-visible { outline: 2px solid var(--yc-accent); outline-offset: 1px; }

/* Bekleme göstergesi */
.yc-wait .yc-bubble { display: flex; align-items: center; gap: .5rem; color: #5f6f68; }
.yc-wait-t { font-size: .85rem; }
.yc-dots { width: 26px; height: 8px; position: relative; flex: none; }
.yc-dots::before, .yc-dots::after,
.yc-wait .yc-bubble::before {
  content: ""; position: absolute; top: 0;
  width: 6px; height: 6px; border-radius: 50%; background: currentColor;
  animation: yc-bounce 1.1s infinite ease-in-out;
}
.yc-wait .yc-bubble::before { left: .8rem; }
.yc-dots::before { left: 10px; animation-delay: .16s; }
.yc-dots::after  { left: 20px; animation-delay: .32s; }
@keyframes yc-bounce { 0%,60%,100% { opacity: .35; transform: none } 30% { opacity: 1; transform: translateY(-3px) } }

/* ── Hazır sorular ────────────────────────────────────────────────────── */
.yc-quick {
  flex: none; display: flex; gap: .35rem; flex-wrap: wrap;
  padding: 0 .8rem .6rem;
}
.yc-quick[hidden] { display: none; }
.yc-chip {
  font: inherit; font-size: .84rem;
  padding: .35rem .7rem; cursor: pointer;
  background: #fff; color: var(--yc-ink);
  border: 1px solid var(--yc-line); border-radius: 999px;
}
.yc-chip:hover { border-color: var(--yc-accent); color: var(--yc-accent); }

/* ── Giriş ────────────────────────────────────────────────────────────── */
.yc-form {
  flex: none; display: flex; align-items: flex-end; gap: .35rem;
  padding: .6rem .7rem; border-top: 1px solid var(--yc-line); background: #fff;
}
.yc-form textarea {
  flex: 1; min-width: 0; resize: none; font: inherit;
  padding: .55rem .7rem; max-height: 120px;
  border: 1px solid var(--yc-line); border-radius: 12px;
  background: var(--yc-soft); color: var(--yc-ink);
}
.yc-form textarea:focus { outline: 2px solid var(--yc-accent); outline-offset: -1px; background: #fff; }
.yc-icon {
  width: 38px; height: 38px; flex: none; display: grid; place-items: center;
  border: 1px solid var(--yc-line); border-radius: 12px;
  background: #fff; color: #56675f; cursor: pointer;
}
.yc-icon:hover { color: var(--yc-ink); }
.yc-icon.is-on { background: #fdecec; border-color: #f3c9c9; color: #a52a2a; }
.yc-send { background: var(--yc-accent); border-color: var(--yc-accent); color: var(--yc-on); }
.yc-chat.is-busy .yc-send { opacity: .55; pointer-events: none; }
.yc-icon:focus-visible, .yc-chip:focus-visible { outline: 2px solid var(--yc-accent); outline-offset: 2px; }

.yc-note {
  flex: none; margin: 0; padding: .45rem .8rem .6rem;
  font-size: .72rem; line-height: 1.45; color: #5f6f68; background: #fff;
}

/* Kısa bildirim (kopyalandı / teşekkürler / dinleniyor) */
.yc-live {
  position: absolute; inset-inline: 0; bottom: 3.6rem;
  margin-inline: auto; width: max-content; max-width: 90%;
  padding: .3rem .7rem; font-size: .78rem;
  background: var(--yc-ink); color: #fff; border-radius: 999px;
  opacity: 0; transform: translateY(6px); pointer-events: none;
  transition: opacity .18s ease, transform .18s ease;
}
.yc-live.is-on { opacity: .95; transform: none; }

/* ── Tablet ───────────────────────────────────────────────────────────── */
@media (max-width: 900px) and (min-width: 641px) {
  .yc-panel { width: min(var(--yc-w, 400px), calc(100vw - 3rem)); }
}

/* ── Mobil: tam sayfa ─────────────────────────────────────────────────── */
@media (max-width: 640px) {
  .yc-chat { inset-block-end: max(var(--yc-y, 24px), 1rem); }
  .yc-launch { padding: .75rem; }
  .yc-launch-label { display: none; }

  /* dvh: adres çubuğu açılıp kapanırken panel zıplamasın */
  .yc-panel,
  .yc-chat.is-full .yc-panel,
  .yc-chat.is-moved .yc-panel {
    position: fixed; inset: 0 !important;
    width: auto; height: auto; max-height: 100dvh;
    border: 0; border-radius: 0;
  }
  .yc-msg { max-width: 94%; }
  /* Tam ekran düğmesi mobilde anlamsız: panel zaten tam ekran */
  .yc-only-wide { display: none; }
  /* iOS'ta 16px altındaki yazı, alana dokunulunca sayfayı yakınlaştırır */
  .yc-form textarea { font-size: 16px; }
}

/* ── Diğer yüzen öğelerle çakışma ─────────────────────────────────────────
   "Yukarı çık" düğmesi de sağ altta durur ve varsayılan konumda asistanın
   altında kalırdı. Sınıf JS ile eklenir (:has() yerine): eski tarayıcılarda da
   çalışsın diye. */
body.has-chat-right .to-top { bottom: calc(1.1rem + 74px); }
@media (max-width: 767px) {
  /* Mobil alt çubuk varken açma düğmesi onun üstünde durur */
  body.has-mobilebar .yc-chat { inset-block-end: calc(62px + env(safe-area-inset-bottom, 0px) + .6rem); }
  body.has-chat-right.has-mobilebar .to-top { bottom: calc(72px + env(safe-area-inset-bottom, 0px) + 62px); }
  body.has-chat-right .to-top { bottom: calc(1.1rem + 66px); }
}

@media (prefers-reduced-motion: reduce) {
  .yc-panel { animation: none; }
  .yc-launch { transition: none; }
  .yc-dots::before, .yc-dots::after, .yc-wait .yc-bubble::before { animation: none; }
}
