/* Smart ChatBot Pro – Frontend Chat */
@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@400;500;600;700&display=swap');

#scb-widget { position: fixed; bottom: 28px; z-index: 99999; font-family: 'Cairo', Tahoma, sans-serif; }
#scb-widget.scb-pos-right { right: 28px; }
#scb-widget.scb-pos-left  { left:  28px; }

/* LTR (English) overrides */
#scb-widget[dir="ltr"] { font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif; }
#scb-widget[dir="ltr"] .scb-msg-bubble { text-align: left; }
#scb-widget[dir="ltr"] .scb-msg-bot  .scb-msg-bubble { border-bottom-right-radius: 18px; border-bottom-left-radius: 4px; }
#scb-widget[dir="ltr"] .scb-msg-user .scb-msg-bubble { border-bottom-left-radius: 18px; border-bottom-right-radius: 4px; }
#scb-widget[dir="ltr"] .scb-suggestion-btn { text-align: left; }
#scb-widget[dir="ltr"] #scb-input { direction: ltr; }
#scb-widget[dir="ltr"] #scb-fallback p { text-align: left; }

/* ── Toggle Button ── */
#scb-toggle-btn {
  width: 60px; height: 60px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  cursor: pointer; box-shadow: 0 6px 24px rgba(0,0,0,.18);
  transition: transform .3s cubic-bezier(.34,1.56,.64,1), box-shadow .2s;
  border: none; position: relative; overflow: hidden;
}
#scb-toggle-btn:hover { transform: scale(1.08); box-shadow: 0 8px 32px rgba(0,0,0,.22); }
#scb-toggle-btn .scb-icon-chat,
#scb-toggle-btn .scb-icon-close {
  position: absolute; font-size: 26px; transition: transform .3s, opacity .3s;
}
#scb-toggle-btn .scb-icon-close { opacity: 0; transform: rotate(90deg) scale(.6); }
#scb-widget.scb-open #scb-toggle-btn .scb-icon-chat  { opacity: 0; transform: rotate(-90deg) scale(.6); }
#scb-widget.scb-open #scb-toggle-btn .scb-icon-close { opacity: 1; transform: rotate(0) scale(1); }

/* ── Chat Window ── */
#scb-chat-window {
  position: absolute; bottom: 76px;
  width: 360px; border-radius: 20px;
  background: #fff; display: flex; flex-direction: column;
  box-shadow: 0 16px 60px rgba(0,0,0,.16), 0 4px 16px rgba(0,0,0,.08);
  overflow: hidden; max-height: 0; opacity: 0; pointer-events: none;
  transition: max-height .4s cubic-bezier(.4,0,.2,1), opacity .3s ease, transform .3s ease;
  transform: translateY(16px) scale(.96);
}
#scb-widget.scb-pos-right #scb-chat-window { right: 0; }
#scb-widget.scb-pos-left  #scb-chat-window { left: 0; }
#scb-widget.scb-open #scb-chat-window {
  max-height: 600px; opacity: 1; pointer-events: all;
  transform: translateY(0) scale(1);
}

/* ── Chat Header ── */
#scb-chat-header {
  padding: 16px 20px; display: flex; align-items: center; gap: 12px;
  color: #fff;
}
.scb-avatar {
  width: 40px; height: 40px; border-radius: 50%;
  background: rgba(255,255,255,.25); display: flex; align-items: center;
  justify-content: center; font-size: 20px; flex-shrink: 0;
}
.scb-header-info { flex: 1; }
.scb-header-info h4 { margin: 0; font-size: 15px; font-weight: 700; }
.scb-header-info span { font-size: 12px; opacity: .85; display: flex; align-items: center; gap: 4px; }
.scb-online-dot { width: 8px; height: 8px; background: #4ade80; border-radius: 50%; display: inline-block; animation: pulse 2s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.5} }

/* ── Messages ── */
#scb-messages {
  flex: 1; overflow-y: auto; padding: 16px; display: flex;
  flex-direction: column; gap: 12px; max-height: 340px;
  scroll-behavior: smooth;
}
#scb-messages::-webkit-scrollbar { width: 4px; }
#scb-messages::-webkit-scrollbar-track { background: transparent; }
#scb-messages::-webkit-scrollbar-thumb { background: #e2e8f0; border-radius: 4px; }

.scb-msg { display: flex; gap: 8px; align-items: flex-end; animation: msgIn .25s ease; }
@keyframes msgIn { from{opacity:0;transform:translateY(8px)} to{opacity:1;transform:none} }

.scb-msg-bot  { flex-direction: row; }
.scb-msg-user { flex-direction: row-reverse; }

.scb-msg-avatar {
  width: 30px; height: 30px; border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-size: 14px; flex-shrink: 0;
}
.scb-msg-bot  .scb-msg-avatar { background: #eff6ff; }
.scb-msg-user .scb-msg-avatar { background: #f1f5f9; }

.scb-msg-bubble {
  max-width: 72%; padding: 10px 14px; border-radius: 18px;
  font-size: 14px; line-height: 1.5; direction: rtl; text-align: right;
}
.scb-msg-bot  .scb-msg-bubble { background: #f1f5f9; color: #1e293b; border-bottom-right-radius: 4px; }
.scb-msg-user .scb-msg-bubble { color: #fff; border-bottom-left-radius: 4px; }

/* ── Typing Indicator ── */
.scb-typing-bubble { padding: 12px 16px !important; }
.scb-typing { display: flex; gap: 4px; align-items: center; }
.scb-typing span { width: 7px; height: 7px; background: #94a3b8; border-radius: 50%; animation: bounce .8s infinite; }
.scb-typing span:nth-child(2) { animation-delay: .15s; }
.scb-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes bounce { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-5px)} }

/* ── Suggestions ── */
#scb-suggestions { padding: 0 16px 12px; }
#scb-suggestions p { font-size: 12px; color: #9ca3af; margin: 0 0 8px; }
.scb-suggestions-wrap { display: flex; flex-direction: column; gap: 6px; }
.scb-suggestion-btn {
  background: #f8fafc; border: 1.5px solid #e2e8f0; border-radius: 12px;
  padding: 9px 14px; font-size: 13px; cursor: pointer; text-align: right;
  font-family: inherit; color: #374151; transition: all .2s; direction: rtl;
}
.scb-suggestion-btn:hover { background: #eff6ff; border-color: #bfdbfe; color: #1d4ed8; }

/* ── Fallback ── */
#scb-fallback { padding: 12px 16px; background: #fff7ed; border-top: 1px solid #fed7aa; display: none; }
#scb-fallback p { font-size: 13px; color: #92400e; margin: 0 0 10px; text-align: right; direction: rtl; }
.scb-contact-row { display: flex; gap: 10px; }
.scb-contact-btn {
  flex: 1; padding: 10px; border-radius: 12px; border: none; font-size: 13px;
  font-weight: 600; font-family: inherit; cursor: pointer; text-decoration: none;
  text-align: center; display: flex; align-items: center; justify-content: center; gap: 6px;
  transition: opacity .2s;
}
.scb-contact-btn:hover { opacity: .88; }
.scb-btn-phone { background: #2563eb; color: #fff; }
.scb-btn-wa    { background: #16a34a; color: #fff; }

/* ── Input ── */
#scb-input-area {
  padding: 12px 16px; border-top: 1px solid #f1f5f9;
  display: flex; gap: 10px; align-items: flex-end;
}
#scb-input {
  flex: 1; border: 1.5px solid #e2e8f0; border-radius: 14px;
  padding: 10px 14px; font-size: 14px; font-family: inherit; resize: none;
  max-height: 100px; outline: none; direction: rtl; color: #1e293b;
  transition: border .2s, box-shadow .2s; line-height: 1.5;
}
#scb-input:focus { border-color: #2563eb; box-shadow: 0 0 0 3px rgba(37,99,235,.1); }
#scb-input::placeholder { color: #cbd5e1; }

#scb-send-btn {
  width: 42px; height: 42px; border-radius: 12px; border: none;
  cursor: pointer; display: flex; align-items: center; justify-content: center;
  font-size: 18px; transition: transform .15s, opacity .2s; flex-shrink: 0;
}
#scb-send-btn:hover { transform: scale(1.08); }
#scb-send-btn:disabled { opacity: .5; cursor: not-allowed; }

/* ── Notification Badge ── */
#scb-notif-badge {
  position: absolute; top: -4px; right: -4px; width: 18px; height: 18px;
  background: #ef4444; border-radius: 50%; display: none;
  align-items: center; justify-content: center; font-size: 10px;
  font-weight: 700; color: #fff; border: 2px solid #fff;
}

/* ── Mobile ── */
@media (max-width: 480px) {
  #scb-widget { bottom: 16px; }
  #scb-widget.scb-pos-right { right: 16px; }
  #scb-widget.scb-pos-left  { left: 16px; }
  #scb-chat-window { width: calc(100vw - 32px); right: -16px !important; left: auto !important; }
  #scb-widget.scb-pos-left #scb-chat-window { left: -16px !important; right: auto !important; }
}
