/* ==================================================================
   Chatbot — sağ alt köşe asistanı
   Yeni yetenek eklendikçe yalnızca bu dosya ve chatbot.js büyür.
   ================================================================== */

.chatbot {
  position: fixed;
  right: 24px;
  bottom: 24px;
  z-index: 90;
}

/* "Yukarı dön" butonu chatbot'un üstünde kalır */
.to-top { bottom: 100px; right: 29px; }

/* ---------- Açma düğmesi ----------
   Maskot beyaz disk üzerinde; dış halka panelde seçilen tema renginden gelir
   (--rgb-brand / --rgb-pink), böylece palet değişince kenar rengi de değişir. */
.chatbot-fab {
  --chat-disc: #FFFFFF;
  position: relative;
  display: grid;
  place-items: center;
  width: 64px;
  height: 64px;
  padding: 5px;
  border: 0;
  border-radius: 50%;
  color: #fff;
  background: linear-gradient(140deg, rgb(var(--rgb-pink)) 0%, rgb(var(--rgb-brand)) 52%, rgb(var(--rgb-brand-deep)) 100%);
  box-shadow: 0 18px 36px -16px rgba(var(--rgb-brand-deep), .85);
  cursor: pointer;
  transition: transform .25s var(--ease), box-shadow .25s var(--ease), opacity .22s ease;
}
[data-theme="dark"] .chatbot-fab { --chat-disc: #F4EEFC; }
.chatbot-fab:hover { transform: translateY(-2px) scale(1.03); box-shadow: 0 24px 44px -18px rgba(var(--rgb-brand-deep), .95); }
.chatbot-fab:focus-visible { outline: 2px solid var(--violet); outline-offset: 3px; }

/* Maskot: beyaz disk, halkadan ince bir boşlukla ayrılır */
.chatbot-fab-img {
  width: 100%;
  height: 100%;
  padding: 4px 2px 2px;
  border-radius: 50%;
  background: var(--chat-disc);
  object-fit: contain;
  display: block;
  transition: transform .3s var(--ease);
}
.chatbot-fab:hover .chatbot-fab-img { transform: scale(1.05); }

/* Sağ alt rozet: kapalıyken sohbet balonu, açıkken kapatma ikonu */
.chatbot-fab-badge {
  position: absolute;
  right: -1px;
  bottom: -1px;
  display: grid;
  place-items: center;
  width: 26px;
  height: 26px;
  border-radius: 50%;
  background: linear-gradient(140deg, rgb(var(--rgb-brand)) 0%, rgb(var(--rgb-brand-deep)) 100%);
  box-shadow: 0 0 0 2.5px var(--chat-disc), 0 10px 18px -10px rgba(var(--rgb-brand-deep), .9);
}
.chatbot-fab-glyph { display: inline-flex; grid-area: 1 / 1; transition: opacity .2s, transform .3s var(--ease); }
.chatbot-fab-glyph--close { opacity: 0; transform: rotate(-90deg) scale(.7); }
.chatbot.is-open .chatbot-fab-glyph--chat { opacity: 0; transform: rotate(90deg) scale(.7); }
.chatbot.is-open .chatbot-fab-glyph--close { opacity: 1; transform: none; }
/* Panel açıkken düğme köşede kalır: panel sola kaydığı için görünür kalır */

.chatbot-fab-ping {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  background: #34D399;
  box-shadow: 0 0 0 2.5px var(--chat-disc);
  animation: chatPing 2.6s ease-out infinite;
}
.chatbot.is-seen .chatbot-fab-ping { display: none; }

@keyframes chatPing {
  0%, 100% { transform: scale(1); opacity: 1; }
  50% { transform: scale(1.28); opacity: .5; }
}

/* ---------- Panel ----------
   Yükseklik her zaman ekranın tamamı; sağ alttaki açma düğmesi panelin
   arkasında kalmasın diye panel 100px sola kayar, genişlik sabit kalır. */
.chatbot-panel {
  position: fixed;
  right: 100px;
  bottom: 16px;
  width: min(376px, calc(100vw - 132px));
  height: calc(100vh - 32px);
  height: calc(100dvh - 32px);
  display: flex;
  flex-direction: column;
  border: 1px solid var(--line);
  border-radius: 22px;
  background: rgb(var(--srf) / .97);
  backdrop-filter: blur(20px);
  box-shadow: 0 44px 90px -46px rgba(10, 4, 30, .95);
  overflow: hidden;
  opacity: 0;
  transform: translateX(24px) scale(.99);
  pointer-events: none;
  transition: opacity .24s ease, transform .34s var(--ease);
}
.chatbot-panel[hidden] { display: none; }
.chatbot-panel.is-open { opacity: 1; transform: none; pointer-events: auto; }

/* ---------- Başlık ---------- */
.chatbot-head {
  display: flex;
  align-items: center;
  gap: 11px;
  flex: none;
  padding: 13px 14px;
  border-bottom: 1px solid var(--line);
  background: linear-gradient(180deg, rgba(var(--rgb-brand), .14), transparent);
}
/* Profil görseli — açma düğmesindeki maskotun birebir aynısı */
.chatbot-head-avatar {
  flex: none;
  width: 38px;
  height: 38px;
  padding: 3px;
  border-radius: 12px;
  background: #F4EEFC;
  object-fit: contain;
  box-shadow: 0 10px 20px -14px rgba(var(--rgb-brand-deep), .95);
}
.chatbot-head-text { flex: 1 1 auto; min-width: 0; display: flex; flex-direction: column; gap: 2px; }
.chatbot-head-text strong { font-size: .92rem; line-height: 1.2; color: var(--ink); }
.chatbot-head-text em {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-style: normal;
  font-size: .71rem;
  color: var(--muted-2);
}
.chatbot-status-dot {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: #34D399;
  box-shadow: 0 0 0 3px rgba(52, 211, 153, .18);
}
.chatbot-close {
  flex: none;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color .2s, background .2s;
}
.chatbot-close:hover { color: var(--ink); background: rgba(var(--rgb-brand), .14); }
.chatbot-reset {
  flex: none;
  display: grid;
  place-items: center;
  width: 30px;
  height: 30px;
  border: 1px solid transparent;
  border-radius: 9px;
  background: transparent;
  color: var(--muted);
  cursor: pointer;
  transition: color .2s, background .2s, transform .35s var(--ease);
}
.chatbot-reset:hover { color: var(--ink); background: rgba(var(--rgb-brand), .14); transform: rotate(-45deg); }

/* ---------- Hızlı işlemler şeridi (giriş alanının üstünde) ---------- */
.chatbot-hub {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 6px;
  padding: 10px 12px;
  border-top: 1px solid var(--line);
  background: rgb(var(--srf) / .5);
}
.chat-hub-item {
  flex: none;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 11px 6px 7px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgb(var(--srf) / .78);
  color: var(--ink);
  font: inherit;
  font-size: .74rem;
  font-weight: 600;
  line-height: 1.2;
  white-space: nowrap;
  text-decoration: none;
  cursor: pointer;
  transition: color .2s, background .2s, border-color .2s, transform .2s var(--ease);
}
.chat-hub-ico {
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background: rgba(var(--rgb-brand), .16);
  transition: background .2s, color .2s;
}
.chat-hub-item:hover {
  transform: translateY(-1px);
  border-color: transparent;
  color: #fff;
  background: var(--grad);
}
.chat-hub-item:hover .chat-hub-ico { background: rgb(255 255 255 / .22); color: #fff; }

/* ---------- Mesaj akışı ---------- */
.chatbot-log {
  flex: 1 1 auto;
  min-height: 0;
  display: flex;
  flex-direction: column;
  gap: 9px;
  padding: 16px 14px;
  overflow-y: auto;
  overscroll-behavior: contain;
  scrollbar-width: thin;
}
.chat-msg { display: flex; align-items: flex-end; gap: 7px; animation: chatIn .35s var(--ease) both; }
.chat-msg--user { justify-content: flex-end; }
/* Bot mesajlarının solunda profil görseli (açma düğmesindeki maskot) */
.chat-av {
  flex: none;
  width: 26px;
  height: 26px;
  padding: 2px;
  border-radius: 9px;
  background: #F4EEFC;
}
.chat-av img { display: block; width: 100%; height: 100%; object-fit: contain; }
@keyframes chatIn {
  from { opacity: 0; transform: translateY(8px); }
  to   { opacity: 1; transform: none; }
}
.chat-bubble {
  max-width: 85%;
  padding: 10px 13px;
  border-radius: 15px;
  font-size: .87rem;
  line-height: 1.55;
  white-space: pre-line;
  overflow-wrap: anywhere;
}
.chat-msg--bot .chat-bubble {
  color: var(--ink-2);
  background: rgba(var(--rgb-brand), .10);
  border: 1px solid rgba(var(--rgb-brand), .18);
  border-bottom-left-radius: 6px;
}
.chat-msg--user .chat-bubble {
  color: #fff;
  background: linear-gradient(140deg, var(--violet-deep), var(--orchid));
  border-bottom-right-radius: 6px;
}
.chat-msg.is-typing .chat-bubble { display: inline-flex; align-items: center; gap: 4px; padding: 13px 14px; }
.chat-msg.is-typing i {
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--muted-2);
  animation: chatDot 1.1s ease-in-out infinite;
}
.chat-msg.is-typing i:nth-child(2) { animation-delay: .15s; }
.chat-msg.is-typing i:nth-child(3) { animation-delay: .3s; }

@keyframes chatDot {
  0%, 60%, 100% { opacity: .35; transform: translateY(0); }
  30% { opacity: 1; transform: translateY(-3px); }
}

/* ---------- Hızlı yanıtlar ---------- */
.chatbot-quick {
  flex: none;
  display: flex;
  flex-wrap: wrap;
  gap: 7px;
  max-height: min(38vh, 260px);
  overflow-y: auto;
  overscroll-behavior: contain;
  padding: 0 14px;
}
.chatbot-quick:not(:empty) { padding-bottom: 12px; }
.chat-chip {
  padding: 8px 13px;
  border: 1px solid var(--line-strong);
  border-radius: 999px;
  background: rgb(var(--srf) / .7);
  color: var(--ink);
  font: inherit;
  font-size: .8rem;
  font-weight: 500;
  line-height: 1.3;
  text-align: left;
  text-decoration: none;
  cursor: pointer;
  transition: color .2s, background .2s, border-color .2s, transform .2s var(--ease);
}
.chat-chip:hover { transform: translateY(-1px); border-color: transparent; color: #fff; background: var(--grad); }
.chat-chip--primary { border-color: transparent; color: #fff; background: var(--grad); }
.chat-chip--link { display: inline-flex; align-items: center; gap: 6px; }
.chat-chip--link::after { content: '↗'; font-size: .78rem; opacity: .75; }

.chat-stars { display: flex; flex-direction: row-reverse; justify-content: flex-end; gap: 2px; }
.chat-star {
  display: grid;
  place-items: center;
  width: 34px;
  height: 34px;
  padding: 0;
  border: 0;
  background: transparent;
  color: var(--line-strong);
  cursor: pointer;
  transition: color .18s, transform .18s var(--ease);
}
.chat-star svg { width: 22px; height: 22px; fill: currentColor; }
.chat-star:hover,
.chat-star:hover ~ .chat-star { color: #F5B841; transform: translateY(-1px); }

/* ---------- Giriş alanı ---------- */
.chatbot-form {
  flex: none;
  display: flex;
  align-items: flex-end;
  gap: 8px;
  padding: 10px 12px 12px;
  background: rgb(var(--srf) / .6);
}
.chatbot-form[hidden] { display: none; }
.chatbot-form textarea {
  flex: 1 1 auto;
  min-height: 40px;
  max-height: 96px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: 12px;
  background: rgb(var(--srf) / .85);
  color: var(--ink);
  font: inherit;
  font-size: .87rem;
  line-height: 1.5;
  resize: none;
}
.chatbot-form textarea:focus {
  outline: none;
  border-color: rgba(var(--rgb-brand), .55);
  box-shadow: 0 0 0 3px rgba(var(--rgb-brand), .16);
}
.chatbot-send {
  flex: none;
  display: grid;
  place-items: center;
  width: 40px;
  height: 40px;
  border: 0;
  border-radius: 12px;
  color: #fff;
  background: var(--grad);
  cursor: pointer;
  transition: transform .2s var(--ease);
}
.chatbot-send:hover { transform: translateY(-1px); }

/* ---------- Duyarlı ---------- */
@media (max-width: 520px) {
  .chatbot { right: 14px; bottom: 14px; }
  .to-top { bottom: 90px; right: 19px; }
  .chatbot-panel {
    position: fixed;
    right: 10px;
    left: 10px;
    bottom: 10px;
    width: auto;
    height: calc(100vh - 20px);
    height: calc(100dvh - 20px);
    border-radius: 18px;
  }
  /* Tam genişlikte panel düğmeyi kaçınılmaz olarak örter; kapatma başlıkta */
  .chatbot.is-open .chatbot-fab { opacity: 0; transform: scale(.9); pointer-events: none; }
  /* Dar ekranda işlem şeridi tek satırda yatay kayar */
  .chatbot-hub {
    flex-wrap: nowrap;
    overflow-x: auto;
    overscroll-behavior-x: contain;
    scrollbar-width: none;
  }
  .chatbot-hub::-webkit-scrollbar { display: none; }
  .chatbot-hub { padding: 9px 10px; }
}

@media (prefers-reduced-motion: reduce) {
  .chatbot-fab,
  .chatbot-panel,
  .chatbot-fab-glyph,
  .chat-msg,
  .chat-msg.is-typing i,
  .chatbot-fab-ping { animation: none !important; transition: none !important; }
}