/* wp-content/uploads/custom-chat/chat-style.css */
:root {
  --chat-bg: #0d0d0e;
  --panel-bg: #171719;
  --user-bubble: #2563eb;
  --ai-bubble: #212124;
  --text-main: #f3f4f6;
  --text-muted: #9ca3af;
  --border: rgba(255, 255, 255, 0.08);
  --accent: #3b82f6;
}

/* غیرفعال کردن زوم و فیکس کردن صفحه چت از پایین */
.chat-overlay {
  position: fixed;
  inset: 0;
  z-index: 999999;
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  touch-action: manipulation;
}
.chat-overlay.is-open { opacity: 1; pointer-events: auto; }

.chat-backdrop {
  position: absolute;
  inset: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(10px);
}

.chat-panel {
  position: relative;
  width: 100%;
  max-width: 500px;
  height: 100%;
  max-height: 100dvh; /* چسبیده کامل به پایین و پر کردن صفحه mobile */
  background: var(--panel-bg);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 -10px 40px rgba(0, 0, 0, 0.8);
  color: var(--text-main);
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
}

@media (min-width: 640px) {
  .chat-panel { height: 92vh; border-radius: 24px 24px 0 0; }
}

/* هدر چت */
.chat-header {
  height: 60px;
  padding: 0 16px;
  background: rgba(255, 255, 255, 0.02);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.chat-select {
  background: rgba(255, 255, 255, 0.05);
  color: var(--text-main);
  border: 1px solid var(--border);
  padding: 8px 12px;
  border-radius: 12px;
  font-size: 13px;
  outline: none;
}

.mini-btn {
  background: none;
  border: none;
  color: var(--text-muted);
  padding: 8px;
  cursor: pointer;
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.mini-btn:hover { color: #fff; background: rgba(255, 255, 255, 0.08); }
.mini-btn svg { width: 20px; height: 20px; }

/* بدنه چت و حباب‌ها */
.chat-body {
  flex: 1;
  padding: 16px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 16px;
  scroll-behavior: smooth;
}

.chat-welcome {
  margin: auto;
  text-align: center;
  color: var(--text-muted);
  font-size: 14px;
  line-height: 1.6;
}

.msg-wrap { display: flex; flex-direction: column; max-width: 85%; }
.msg-wrap.user { align-self: flex-end; }
.msg-wrap.assistant { align-self: flex-start; }

/* اصلاح کامل خوانایی پیام کاربر و پاسخ هوش مصنوعی */
.msg-bubble {
  position: relative;
  padding: 12px 16px;
  border-radius: 18px;
  font-size: 14px;
  line-height: 1.6;
  word-break: break-word;
}
.msg-wrap.user .msg-bubble {
  background: var(--user-bubble);
  color: #ffffff !important; /* ضمانت خوانایی پیام کاربر */
  border-bottom-left-radius: 4px;
  box-shadow: 0 2px 8px rgba(37, 99, 235, 0.3);
}
.msg-wrap.assistant .msg-bubble {
  background: var(--ai-bubble);
  color: #f3f4f6 !important; /* پاسخ واضح هوش مصنوعی */
  border: 1px solid var(--border);
  border-bottom-right-radius: 4px;
  padding-bottom: 28px;
}

/* آیکون مینیمال کپی */
.btn-copy-icon {
  position: absolute;
  bottom: 6px;
  left: 8px;
  background: transparent;
  border: none;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px;
  border-radius: 6px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: 0.2s;
}
.btn-copy-icon:hover { color: #fff; background: rgba(255, 255, 255, 0.1); }
.btn-copy-icon svg { width: 14px; height: 14px; }
.btn-copy-icon.copied { color: #10b981; transform: scale(1.1); }

/* کادر ورودی پایین */
.chat-input-container {
  padding: 12px 16px;
  background: var(--panel-bg);
  border-top: 1px solid var(--border);
}
.chat-input-box {
  display: flex;
  align-items: center;
  background: rgba(255, 255, 255, 0.04);
  border-radius: 24px;
  padding: 6px 12px;
  border: 1px solid var(--border);
}
.chat-input-box textarea {
  flex: 1;
  background: transparent;
  border: none;
  color: #fff;
  padding: 8px;
  resize: none;
  outline: none;
  font-size: 15px; /* جلوگیری از زوم خودکار iOS */
  max-height: 100px;
}

.send-btn {
  background: var(--accent);
  border: none;
  color: #fff;
  border-radius: 50%;
  width: 36px;
  height: 36px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
}
.send-btn.disabled { opacity: 0.3; pointer-events: none; }

/* کشوی تاریخچه حرفه‌ای */
.chat-drawer {
  position: absolute;
  inset: 0 0 0 -100%;
  width: 82%;
  background: #121214;
  z-index: 10;
  transition: left 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  padding: 18px;
  display: flex;
  flex-direction: column;
  border-right: 1px solid var(--border);
}
.chat-drawer.open { left: 0; }
.chat-drawer-overlay { position: absolute; inset: 0; background: rgba(0,0,0,0.6); display: none; z-index: 9; }

.cd-new-btn {
  background: rgba(255, 255, 255, 0.05);
  color: #fff;
  border: 1px solid var(--border);
  padding: 10px;
  border-radius: 12px;
  cursor: pointer;
  text-align: center;
  margin-bottom: 14px;
  font-size: 13px;
  font-weight: 500;
}
.cd-list { flex: 1; overflow-y: auto; display: flex; flex-direction: column; gap: 8px; }
.cd-item {
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255, 255, 255, 0.02);
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
}
.cd-item.active { background: var(--accent); color: #fff; }
.cd-title { font-size: 13px; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; flex: 1; }
.cd-del { background: none; border: none; color: #ef4444; padding: 6px; cursor: pointer; display: flex; border-radius: 6px; }
.cd-del svg { width: 18px; height: 18px; }

/* انیمیشن تایپینگ */
.typing-dots { display: flex; gap: 4px; padding: 12px 16px !important; }
.typing-dots span { width: 6px; height: 6px; background: var(--text-muted); border-radius: 50%; animation: pulse 1.2s infinite; }
.typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes pulse { 0%, 100% { transform: scale(1); opacity: 0.3; } 50% { transform: scale(1.4); opacity: 1; } }