/* ============================================================
   rt-chat.css — Canlı Sohbet Drawer
   Temadaki CSS custom properties (--color-*, --radius-*, vb.)
   mevcut olduğunda otomatik uyum sağlar; yoksa fallback.
   ============================================================ */

/* ── Toggle butonu ─────────────────────────────────────────── */
.rt-chat-toggle {
  position: fixed;
  bottom: 90px;           /* Oynatıcının üstünde kalır */
  right: 20px;
  z-index: 9990;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 48px;
  height: 48px;
  border: none;
  border-radius: 50%;
  cursor: pointer;
  background: var(--color-accent, #e53e3e);
  color: #fff;
  box-shadow: 0 4px 16px rgba(0, 0, 0, .28);
  transition: transform .18s ease, background .18s ease;
}
.rt-chat-toggle:hover  { transform: scale(1.08); }
.rt-chat-toggle:active { transform: scale(.96);  }

/* Unread badge */
.rt-chat-badge {
  position: absolute;
  top: -4px;
  right: -4px;
  min-width: 18px;
  height: 18px;
  padding: 0 4px;
  border-radius: 9px;
  background: #fff;
  color: var(--color-accent, #e53e3e);
  font-size: 10px;
  font-weight: 700;
  line-height: 18px;
  text-align: center;
  pointer-events: none;
}

/* ── Overlay (mobil kapama) ────────────────────────────────── */
.rt-chat-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 9991;
  background: rgba(0, 0, 0, .45);
}
.rt-chat-overlay.is-active { display: block; }

/* ── Drawer ────────────────────────────────────────────────── */
.rt-chat-drawer {
  position: fixed;
  top: 0;
  right: 0;
  bottom: 0;
  z-index: 9992;
  width: 340px;
  max-width: 100vw;
  display: flex;
  flex-direction: column;
  background: var(--color-surface, #1a1a2e);
  color: var(--color-text, #e8e8f0);
  box-shadow: -4px 0 32px rgba(0, 0, 0, .4);
  transform: translateX(100%);
  transition: transform .28s cubic-bezier(.4, 0, .2, 1);
  overflow: hidden;
}
.rt-chat-drawer.is-open { transform: translateX(0); }

/* ── Başlık ────────────────────────────────────────────────── */
.rt-chat-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 14px 16px;
  background: var(--color-surface-2, #16213e);
  border-bottom: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0;
}
.rt-chat-header-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  overflow: hidden;
}
.rt-chat-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--color-text, #e8e8f0);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rt-chat-room-label {
  font-size: 11px;
  color: var(--color-text-muted, #888);
}
.rt-chat-room-label strong { color: var(--color-accent, #e53e3e); }

/* ── Online kullanıcı sayacı ───────────────────────────────── */
.rt-chat-online-toggle {
  display: flex;
  align-items: center;
  gap: 5px;
  flex-shrink: 0;
  background: rgba(255,255,255,.06);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 999px;
  padding: 4px 10px;
  cursor: pointer;
  color: var(--color-text, #e8e8f0);
  font-size: 12px;
  font-weight: 600;
  transition: background .15s;
}
.rt-chat-online-toggle:hover { background: rgba(255,255,255,.12); }
.rt-chat-online-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #48bb78;
  flex-shrink: 0;
  box-shadow: 0 0 0 0 rgba(72,187,120,.6);
  animation: rt-chat-online-pulse 2s infinite;
}
@keyframes rt-chat-online-pulse {
  0%   { box-shadow: 0 0 0 0 rgba(72,187,120,.5); }
  70%  { box-shadow: 0 0 0 5px rgba(72,187,120,0); }
  100% { box-shadow: 0 0 0 0 rgba(72,187,120,0); }
}

/* ── Online açılır panel ────────────────────────────────────── */
.rt-chat-online-panel {
  padding: 10px 12px;
  background: var(--color-surface-2, #16213e);
  border-bottom: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0;
  max-height: 180px;
  overflow-y: auto;
}
.rt-chat-online-empty {
  color: var(--color-text-muted, #666);
  font-size: 12px;
  text-align: center;
  margin: 4px 0;
}
.rt-chat-online-list {
  list-style: none;
  margin: 0;
  padding: 0;
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.rt-chat-online-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 8px;
  border-radius: var(--radius-sm, 6px);
  background: rgba(255,255,255,.04);
  font-size: 12px;
}
.rt-chat-online-station {
  color: var(--color-text, #e8e8f0);
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.rt-chat-online-badge {
  flex-shrink: 0;
  background: var(--color-accent, #e53e3e);
  color: #fff;
  font-weight: 700;
  font-size: 11px;
  padding: 1px 7px;
  border-radius: 999px;
}

.rt-chat-close {
  flex-shrink: 0;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--color-text-muted, #888);
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: color .15s;
}
.rt-chat-close:hover { color: var(--color-text, #e8e8f0); }

/* ── İsim alanı ────────────────────────────────────────────── */
.rt-chat-name-bar {
  padding: 10px 12px;
  background: var(--color-surface-2, #16213e);
  border-bottom: 1px solid rgba(255,255,255,.06);
  flex-shrink: 0;
}
.rt-chat-name-input {
  width: 100%;
  padding: 7px 10px;
  border-radius: var(--radius-sm, 6px);
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.06);
  color: var(--color-text, #e8e8f0);
  font-size: 13px;
  outline: none;
  transition: border-color .15s;
  box-sizing: border-box;
}
.rt-chat-name-input:focus { border-color: var(--color-accent, #e53e3e); }
.rt-chat-name-input::placeholder { color: var(--color-text-muted, #666); }

/* ── Mesajlar alanı ────────────────────────────────────────── */
.rt-chat-messages {
  flex: 1;
  overflow-y: auto;
  padding: 12px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
}
.rt-chat-messages::-webkit-scrollbar { width: 4px; }
.rt-chat-messages::-webkit-scrollbar-track { background: transparent; }
.rt-chat-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 2px; }

.rt-chat-empty {
  color: var(--color-text-muted, #666);
  font-size: 13px;
  text-align: center;
  margin: auto;
}

/* ── Tek mesaj ─────────────────────────────────────────────── */
/* .rt-chat-msg — aşağıda yeniden tanımlı */
.rt-chat-msg-meta {
  display: flex;
  align-items: baseline;
  gap: 6px;
}
.rt-chat-msg-name {
  font-size: 12px;
  font-weight: 700;
  color: var(--color-accent, #e53e3e);
}
.rt-chat-msg-time {
  font-size: 10px;
  color: var(--color-text-muted, #666);
}
.rt-chat-msg-text {
  background: var(--color-surface-2, #16213e);
  border-radius: 0 10px 10px 10px;
  padding: 8px 12px;
  font-size: 13px;
  line-height: 1.45;
  color: var(--color-text, #e8e8f0);
  word-break: break-word;
  border: 1px solid rgba(255,255,255,.06);
}

/* ── Input barı ────────────────────────────────────────────── */
.rt-chat-input-bar {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  background: var(--color-surface-2, #16213e);
  border-top: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0;
}
.rt-chat-text {
  flex: 1;
  padding: 9px 12px;
  border-radius: var(--radius-sm, 6px);
  border: 1px solid rgba(255,255,255,.12);
  background: rgba(255,255,255,.06);
  color: var(--color-text, #e8e8f0);
  font-size: 13px;
  outline: none;
  transition: border-color .15s;
  min-width: 0;
}
.rt-chat-text:focus { border-color: var(--color-accent, #e53e3e); }
.rt-chat-text::placeholder { color: var(--color-text-muted, #666); }

.rt-chat-send {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border: none;
  border-radius: var(--radius-sm, 6px);
  background: var(--color-accent, #e53e3e);
  color: #fff;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: opacity .15s, transform .12s;
}
.rt-chat-send:hover  { opacity: .88; }
.rt-chat-send:active { transform: scale(.93); }

/* ── Hata mesajı ───────────────────────────────────────────── */
.rt-chat-error {
  padding: 8px 12px;
  background: rgba(229, 62, 62, .15);
  color: #fc8181;
  font-size: 12px;
  text-align: center;
  flex-shrink: 0;
}

/* ── Responsive ────────────────────────────────────────────── */
@media (max-width: 400px) {
  .rt-chat-drawer { width: 100vw; }
  .rt-chat-toggle { bottom: 80px; right: 12px; }
}

/* ── Emoji Picker ───────────────────────────────────────────── */
.rt-chat-emoji-picker {
  display: flex;
  flex-wrap: wrap;
  gap: 2px;
  padding: 8px;
  background: var(--color-surface-2, #16213e);
  border-top: 1px solid rgba(255,255,255,.07);
  max-height: 160px;
  overflow-y: auto;
  flex-shrink: 0;
}
.rt-chat-emoji-picker::-webkit-scrollbar { width: 3px; }
.rt-chat-emoji-picker::-webkit-scrollbar-thumb { background: rgba(255,255,255,.15); border-radius: 2px; }

.rt-chat-emoji-btn {
  background: transparent;
  border: none;
  cursor: pointer;
  font-size: 20px;
  line-height: 1;
  padding: 4px;
  border-radius: 4px;
  transition: background .12s, transform .1s;
  width: 34px;
  height: 34px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.rt-chat-emoji-btn:hover {
  background: rgba(255,255,255,.1);
  transform: scale(1.2);
}

/* ── Emoji toggle butonu (input barında) ────────────────────── */
.rt-chat-emoji-toggle {
  flex-shrink: 0;
  width: 38px;
  height: 38px;
  border: none;
  border-radius: var(--radius-sm, 6px);
  background: rgba(255,255,255,.06);
  cursor: pointer;
  font-size: 18px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background .15s, transform .12s;
  line-height: 1;
}
.rt-chat-emoji-toggle:hover  { background: rgba(255,255,255,.12); }
.rt-chat-emoji-toggle:active { transform: scale(.93); }

/* ── Avatar ─────────────────────────────────────────────────── */
.rt-chat-msg {
  display: flex;
  flex-direction: row;
  align-items: flex-end;
  gap: 8px;
  max-width: 92%;
  align-self: flex-start;
}
.rt-chat-msg--own {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.rt-chat-avatar {
  flex-shrink: 0;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 11px;
  font-weight: 700;
  color: #fff;
  letter-spacing: .5px;
  user-select: none;
}

/* ── Balon wrapper ──────────────────────────────────────────── */
.rt-chat-bubble {
  display: flex;
  flex-direction: column;
  gap: 3px;
  position: relative;
}

/* Kendi mesajı sağda — metin balonunun köşesi farklı */
.rt-chat-msg--own .rt-chat-msg-text {
  border-radius: 10px 0 10px 10px;
  background: var(--color-accent, #e53e3e);
  color: #fff;
  border-color: transparent;
}
.rt-chat-msg--own .rt-chat-msg-name {
  text-align: right;
}
.rt-chat-msg--own .rt-chat-msg-meta {
  flex-direction: row-reverse;
}

/* ── Silme butonu ───────────────────────────────────────────── */
.rt-chat-del-btn {
  position: absolute;
  top: -8px;
  right: -8px;
  width: 20px;
  height: 20px;
  border: none;
  border-radius: 50%;
  background: rgba(0,0,0,.55);
  color: #fff;
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background .15s;
}
.rt-chat-del-btn:hover { background: #e53e3e; }
.rt-chat-bubble:hover .rt-chat-del-btn { display: flex; }

/* ── "Yazıyor..." göstergesi ───────────────────────────────── */
.rt-chat-typing {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 0 12px 8px;
  font-size: 12px;
  color: var(--color-text-muted, #888);
  flex-shrink: 0;
}
.rt-chat-typing-dots {
  display: inline-flex;
  align-items: center;
  gap: 3px;
}
.rt-chat-typing-dots span {
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: var(--color-text-muted, #888);
  animation: rt-chat-typing-bounce 1.2s infinite ease-in-out;
}
.rt-chat-typing-dots span:nth-child(2) { animation-delay: .15s; }
.rt-chat-typing-dots span:nth-child(3) { animation-delay: .3s; }

@keyframes rt-chat-typing-bounce {
  0%, 60%, 100% { transform: translateY(0);    opacity: .5; }
  30%           { transform: translateY(-3px); opacity: 1;  }
}

/* ── Cevapla butonu ─────────────────────────────────────────── */
.rt-chat-reply-btn {
  flex-shrink: 0;
  align-self: center;
  width: 26px;
  height: 26px;
  border: none;
  border-radius: 50%;
  background: transparent;
  color: var(--color-text-muted, #888);
  cursor: pointer;
  display: none;
  align-items: center;
  justify-content: center;
  padding: 0;
  transition: background .15s, color .15s;
  order: 10;
}
.rt-chat-reply-btn:hover {
  background: rgba(255,255,255,.1);
  color: var(--color-accent, #e53e3e);
}
.rt-chat-msg:hover .rt-chat-reply-btn { display: flex; }

/* Kendi mesajında buton solda çıksın */
.rt-chat-msg--own .rt-chat-reply-btn { order: -1; }

/* ── Alıntı kutusu (mesaj içinde) ──────────────────────────── */
.rt-chat-quote {
  display: flex;
  flex-direction: column;
  gap: 2px;
  padding: 5px 8px;
  border-left: 3px solid var(--color-accent, #e53e3e);
  background: rgba(255,255,255,.07);
  border-radius: 4px;
  margin-bottom: 4px;
  max-width: 100%;
  overflow: hidden;
}
.rt-chat-quote-name {
  font-size: 11px;
  font-weight: 700;
  color: var(--color-accent, #e53e3e);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.rt-chat-quote-text {
  font-size: 11px;
  color: var(--color-text-muted, #aaa);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Kendi mesajında alıntı renkleri */
.rt-chat-msg--own .rt-chat-quote {
  border-left-color: rgba(255,255,255,.5);
  background: rgba(0,0,0,.15);
}
.rt-chat-msg--own .rt-chat-quote-name { color: #fff; }
.rt-chat-msg--own .rt-chat-quote-text { color: rgba(255,255,255,.7); }

/* ── Reply preview bar (input üstü) ────────────────────────── */
.rt-chat-reply-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  padding: 6px 12px;
  background: var(--color-surface-2, #16213e);
  border-top: 1px solid rgba(255,255,255,.07);
  flex-shrink: 0;
}
.rt-chat-reply-bar[hidden] { display: none; }
.rt-chat-reply-bar-label {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--color-text-muted, #aaa);
  overflow: hidden;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.rt-chat-reply-bar-label strong {
  color: var(--color-accent, #e53e3e);
  margin-right: 2px;
}
.rt-chat-reply-cancel {
  flex-shrink: 0;
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--color-text-muted, #888);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2px;
  border-radius: 4px;
  transition: color .15s;
}
.rt-chat-reply-cancel:hover { color: var(--color-text, #e8e8f0); }
