/* === RTL (Arapça) DESTEĞİ === */
html[lang="ar"] .gtb-chat,
html[lang="ar"] .gtb-chat * {
  direction: rtl;
  text-align: right;
}

html[lang="ar"] .gtb-msg--user {
  margin-right: auto;
  margin-left: 0;
}

html[lang="ar"] .gtb-chat__footer {
  flex-direction: row-reverse;
}

html[lang="ar"] .gtb-chat__footer input {
  text-align: right;
}

/* === ANA CHAT KUTUSU === */
.gtb-chat {
  position: fixed;
  right: 30px;
  bottom: 90px;
  width: 360px;
  max-width: 92vw;
  height: 520px;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border-radius: 26px;
  box-shadow: 0 20px 45px rgba(0,0,0,0.20);
  font-family: "Inter", system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 14px;
  overflow: hidden; /* CRITICAL */
  z-index: 999999;
  transition: all .25s ease;
  opacity: 1;
  transform: translateY(0);
  pointer-events: auto;
}

/* GİZLİ DURUM */
.gtb-chat--hidden {
  opacity: 0;
  transform: translateY(20px) scale(0.96);
  pointer-events: none;
}

/* === HEADER === */
.gtb-chat__header {
  background: #f28b00;
  color: #fff;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.gtb-header-title-wrap {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.gtb-header-title {
  font-weight: 600;
  font-size: 17px;
}

.gtb-header-subtitle {
  font-size: 13px;
  opacity: .95;
}

/* minimize butonu */
.gtb-chat-close {
  background: transparent;
  border: none;
  color: #fff;
  font-size: 24px;
  line-height: 1;
  cursor: pointer;
  padding: 0;
  margin-left: 10px;
  opacity: 0.9;
}

.gtb-chat-close:hover {
  opacity: 1;
}

/* === BODY === */
.gtb-chat__body {
  flex: 1;
  padding: 18px 16px 10px;
  background: #f9fafb;
  overflow: hidden !important;  /* CRITICAL — scroll burada değil */
  position: relative;
}

/* === SCROLLING CONTAINER — FIX === */
#gtb-msg-list {
  height: 100%;
  overflow-y: auto;        /* Scroll artık burada */
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-bottom: 10px;
  scroll-behavior: smooth;
}

/* === BOT MESAJ BLOĞU (avatar + balon) === */
.gtb-msg--bot {
  max-width: 100%;
}

.gtb-msg--bot .gtb-agent-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 6px;
}

.gtb-msg--bot .gtb-agent-avatar {
  width: 28px;
  height: 28px;
  border-radius: 50%;
  background: #f28b00;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 16px;
  color: #fff;
}

.gtb-msg--bot .gtb-agent-name {
  font-weight: 600;
  font-size: 13px;
  color: #111827;
}

.gtb-msg--bot .gtb-agent-bubble {
  display: inline-block;
  background: #ffffff;
  border-radius: 20px;
  padding: 10px 16px;
  border: 1px solid #e5e7eb;
  box-shadow: 0 4px 12px rgba(0,0,0,0.06);
  color: #111827;
  line-height: 1.5;
  max-width: 90%;
  white-space: pre-line;
}

/* === USER MESAJLARI === */
.gtb-msg--user {
  background: #111827;
  color: #fff;
  margin-left: auto;
  margin-top: 4px;
  border-radius: 18px;
  padding: 9px 14px;
  max-width: 80%;
  line-height: 1.4;
  white-space: pre-line;
}

/* === FOOTER === */
.gtb-chat__footer {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 16px 16px;
  background: #ffffff;
  border-top: 1px solid #e5e7eb;
}

.gtb-chat__footer input {
  flex: 1;
  border-radius: 24px;
  border: 1px solid #d1d5db;
  padding: 11px 16px;
  font-size: 14px;
  outline: none;
  font-family: inherit;
}

.gtb-chat__footer input:focus {
  border-color: #111827;
}

.gtb-chat__footer button {
  flex-shrink: 0;
  background: #111827;
  color: #fff;
  border: none;
  border-radius: 24px;
  padding: 0 20px;
  height: 45px;
  font-weight: 500;
  cursor: pointer;
  font-size: 14px;
  transition: background .2s ease;
}

.gtb-chat__footer button:hover {
  background: #1f2937;
}

/* === SEND BUTTON DISABLED === */
.gtb-chat__footer button:disabled {
  background: #9ca3af !important;
  cursor: not-allowed !important;
  opacity: 0.7;
}

/* === LAUNCHER (balon) === */
#gtb-chat-launcher {
  position: fixed;
  right: 30px;
  bottom: 30px;
  width: 60px;
  height: 60px;
  background: #f28b00;
  color: #fff;
  border-radius: 50%;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:28px;
  cursor:pointer;
  box-shadow:0 8px 25px rgba(0,0,0,0.25);
  z-index:9999999;
  transition: transform .25s ease, box-shadow .25s ease;
}

#gtb-chat-launcher:hover {
  transform: translateY(-3px) scale(1.07);
  box-shadow:0 12px 30px rgba(0,0,0,0.35);
}

/* === MOBİL === */
@media (max-width: 768px) {
  .gtb-chat {
    right: 0;
    left: 0;
    bottom: 0;
    width: 100vw;
    height: 100dvh;
    max-width: 100vw;
    border-radius: 0;
    box-shadow: none;
  }

  #gtb-chat-launcher {
    bottom: 20px;
    right: 20px;
  }

  #gtb-msg-list {
    padding-bottom: 200px;
  }
}

/* === Typing Indicator === */
.gtb-typing {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 10px 0;
    padding: 10px 16px;
    background: #ffffff;
    border-radius: 18px;
    width: fit-content;
    box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}

.gtb-typing-avatar {
    font-size: 20px;
}

.gtb-typing-text {
    font-size: 14px;
    color: #555;
    margin-right: 6px;
}

.gtb-typing-dots {
    display: inline-flex;
    align-items: center;
    gap: 4px;
}

.gtb-typing-dots span {
    width: 6px;
    height: 6px;
    background: #999;
    border-radius: 50%;
    animation: gtb-dot 1.4s infinite ease-in-out;
}

.gtb-typing-dots span:nth-child(1) { animation-delay: 0; }
.gtb-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.gtb-typing-dots span:nth-child(3) { animation-delay: 0.4s; }

@keyframes gtb-dot {
    0%, 80%, 100% { opacity: .2; transform: translateY(0); }
    40% { opacity: 1; transform: translateY(-4px); }
}

/* === UNREAD BADGE === */
#gtb-chat-launcher {
  position: fixed;
  right: 30px;
  bottom: 30px;
  width: 60px;
  height: 60px;
  background: #f28b00;
  color: #fff;
  border-radius: 50%;
  display:flex;
  align-items:center;
  justify-content:center;
  font-size:28px;
  cursor:pointer;
  box-shadow:0 8px 25px rgba(0,0,0,0.25);
  z-index:9999999;
  transition: transform .25s ease, box-shadow .25s ease;
  /* badge için önemli */
  overflow: visible;
}

.gtb-unread-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 999px;
  background: #ef4444;
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 0 0 2px #ffffff;
  pointer-events: none;
}