/* =============================================
   Baztab AI Chat – Styles
   ============================================= */

:root {
  --bc-primary: #C0392B;
  --bc-primary-dark: #96281B;
  --bc-bg: #ffffff;
  --bc-surface: #f7f7f8;
  --bc-border: #e5e5e5;
  --bc-text: #1a1a1a;
  --bc-text-muted: #6b7280;
  --bc-user-bg: var(--bc-primary);
  --bc-user-text: #ffffff;
  --bc-bot-bg: #f0f0f0;
  --bc-bot-text: #1a1a1a;
  --bc-shadow: 0 8px 40px rgba(0,0,0,0.18);
  --bc-radius: 18px;
  --bc-btn-size: 60px;
}

/* ── Floating Button ── */
#baztab-chat-root {
  position: fixed;
  z-index: 999999;
  font-family: 'Segoe UI', Tahoma, 'Vazirmatn', 'IRANSans', sans-serif;
}

#baztab-chat-root.bc-pos-bottom-right {
  bottom: 24px;
  right: 24px;
}
#baztab-chat-root.bc-pos-bottom-left {
  bottom: 24px;
  left: 24px;
}

#bc-toggle-btn {
  width: var(--bc-btn-size);
  height: var(--bc-btn-size);
  border-radius: 50%;
  background: var(--bc-primary);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 20px rgba(192,57,43,0.45);
  transition: transform 0.2s, box-shadow 0.2s;
  outline: none;
  position: relative;
}
#bc-toggle-btn:hover {
  transform: scale(1.08);
  box-shadow: 0 6px 28px rgba(192,57,43,0.55);
}
#bc-toggle-btn svg {
  width: 28px;
  height: 28px;
  fill: #fff;
  transition: opacity 0.2s, transform 0.2s;
}
#bc-toggle-btn .bc-icon-close {
  display: none;
}

#baztab-chat-root.bc-open #bc-toggle-btn .bc-icon-chat {
  display: none;
}
#baztab-chat-root.bc-open #bc-toggle-btn .bc-icon-close {
  display: block;
}

/* Pulse ring */
#bc-toggle-btn::after {
  content: '';
  position: absolute;
  inset: -4px;
  border-radius: 50%;
  border: 2px solid var(--bc-primary);
  opacity: 0;
  animation: bc-pulse 2.5s ease-out infinite;
}
@keyframes bc-pulse {
  0%   { transform: scale(1); opacity: 0.6; }
  100% { transform: scale(1.6); opacity: 0; }
}

/* ── Chat Window ── */
#bc-window {
  position: absolute;
  bottom: calc(var(--bc-btn-size) + 14px);
  width: 380px;
  max-width: calc(100vw - 32px);
  height: 560px;
  max-height: calc(100vh - 120px);
  background: var(--bc-bg);
  border-radius: var(--bc-radius);
  box-shadow: var(--bc-shadow);
  display: flex;
  flex-direction: column;
  overflow: hidden;
  transform-origin: bottom right;
  transform: scale(0.85) translateY(20px);
  opacity: 0;
  pointer-events: none;
  transition: transform 0.25s cubic-bezier(.34,1.56,.64,1), opacity 0.2s ease;
  border: 1px solid var(--bc-border);
  direction: rtl;
}

#baztab-chat-root.bc-pos-bottom-right #bc-window {
  right: 0;
  transform-origin: bottom right;
}
#baztab-chat-root.bc-pos-bottom-left #bc-window {
  left: 0;
  transform-origin: bottom left;
}

#baztab-chat-root.bc-open #bc-window {
  transform: scale(1) translateY(0);
  opacity: 1;
  pointer-events: all;
}

/* ── Header ── */
#bc-header {
  background: var(--bc-primary);
  color: #fff;
  padding: 14px 18px;
  display: flex;
  align-items: center;
  gap: 12px;
  flex-shrink: 0;
}
#bc-header-avatar {
  width: 38px;
  height: 38px;
  border-radius: 50%;
  background: rgba(255,255,255,0.2);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
#bc-header-avatar svg {
  width: 22px;
  height: 22px;
  fill: #fff;
}
#bc-header-info {
  flex: 1;
}
#bc-header-title {
  font-size: 15px;
  font-weight: 700;
  margin: 0;
  line-height: 1.2;
}
#bc-header-status {
  font-size: 12px;
  opacity: 0.85;
  margin-top: 2px;
  display: flex;
  align-items: center;
  gap: 5px;
}
#bc-header-status::before {
  content: '';
  width: 7px;
  height: 7px;
  border-radius: 50%;
  background: #4ade80;
  display: inline-block;
}

/* ── Messages ── */
#bc-messages {
  flex: 1;
  overflow-y: auto;
  padding: 16px 14px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  scroll-behavior: smooth;
  background: var(--bc-bg);
}
#bc-messages::-webkit-scrollbar { width: 4px; }
#bc-messages::-webkit-scrollbar-thumb { background: #ddd; border-radius: 4px; }

.bc-msg {
  display: flex;
  flex-direction: column;
  max-width: 82%;
  animation: bc-fadein 0.22s ease;
}
@keyframes bc-fadein {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

.bc-msg-bot  { align-self: flex-end; align-items: flex-end; }
.bc-msg-user { align-self: flex-start; align-items: flex-start; }

.bc-bubble {
  padding: 10px 14px;
  border-radius: 16px;
  font-size: 14px;
  line-height: 1.65;
  word-break: break-word;
}
.bc-msg-bot  .bc-bubble {
  background: var(--bc-bot-bg);
  color: var(--bc-bot-text);
  border-bottom-right-radius: 4px;
}
.bc-msg-user .bc-bubble {
  background: var(--bc-user-bg);
  color: var(--bc-user-text);
  border-bottom-left-radius: 4px;
}
.bc-time {
  font-size: 11px;
  color: var(--bc-text-muted);
  margin-top: 3px;
  padding: 0 4px;
}

/* Typing dots */
.bc-typing-dots {
  display: flex;
  gap: 5px;
  padding: 12px 14px;
  background: var(--bc-bot-bg);
  border-radius: 16px;
  border-bottom-right-radius: 4px;
  width: fit-content;
}
.bc-typing-dots span {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  background: #aaa;
  animation: bc-dot 1.2s ease-in-out infinite;
}
.bc-typing-dots span:nth-child(2) { animation-delay: 0.2s; }
.bc-typing-dots span:nth-child(3) { animation-delay: 0.4s; }
@keyframes bc-dot {
  0%, 80%, 100% { transform: scale(0.6); opacity: 0.5; }
  40%           { transform: scale(1.0); opacity: 1;   }
}

/* ── Input Area ── */
#bc-input-area {
  padding: 12px 14px;
  border-top: 1px solid var(--bc-border);
  display: flex;
  align-items: flex-end;
  gap: 10px;
  background: var(--bc-bg);
  flex-shrink: 0;
}
#bc-input {
  flex: 1;
  border: 1.5px solid var(--bc-border);
  border-radius: 12px;
  padding: 10px 14px;
  font-size: 14px;
  font-family: inherit;
  direction: rtl;
  resize: none;
  outline: none;
  max-height: 120px;
  min-height: 42px;
  line-height: 1.5;
  color: var(--bc-text);
  background: var(--bc-surface);
  transition: border-color 0.2s;
  overflow-y: auto;
}
#bc-input:focus {
  border-color: var(--bc-primary);
  background: #fff;
}
#bc-input::placeholder { color: #aaa; }

#bc-send-btn {
  width: 42px;
  height: 42px;
  border-radius: 50%;
  background: var(--bc-primary);
  border: none;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  transition: background 0.2s, transform 0.15s;
  outline: none;
}
#bc-send-btn:hover  { background: var(--bc-primary-dark); transform: scale(1.05); }
#bc-send-btn:active { transform: scale(0.95); }
#bc-send-btn:disabled { background: #ccc; cursor: not-allowed; transform: none; }
#bc-send-btn svg { width: 20px; height: 20px; fill: #fff; }

/* ── Powered by ── */
#bc-footer {
  text-align: center;
  font-size: 11px;
  color: #bbb;
  padding: 6px;
  border-top: 1px solid var(--bc-border);
  background: var(--bc-bg);
}

/* ── Mobile ── */
@media (max-width: 480px) {
  #baztab-chat-root.bc-pos-bottom-right,
  #baztab-chat-root.bc-pos-bottom-left {
    bottom: 16px;
    right: 16px;
    left: auto;
  }
  #bc-window {
    position: fixed !important;
    bottom: 0 !important;
    right: 0 !important;
    left: 0 !important;
    top: auto !important;
    width: 100vw !important;
    max-width: 100vw !important;
    height: 85vh !important;
    max-height: 85vh !important;
    border-radius: 20px 20px 0 0 !important;
    transform-origin: bottom center !important;
  }
  #baztab-chat-root.bc-open #bc-window {
    transform: translateY(0) !important;
  }
  #baztab-chat-root #bc-window {
    transform: translateY(100%) !important;
    opacity: 1 !important;
  }
}
