/* ==========================================
   الشام الذهبي | المجيب الآلي bot.css
   ========================================== */

:root {
  --bg-main: #0c0c0e;
  --panel-bg: rgba(22, 22, 26, 0.95);
  --card-bg: #18181d;
  --gold-primary: #d4af37;
  --gold-gradient: linear-gradient(135deg, #bf953f, #fcf6ba, #b38728, #fbf5b7, #aa771c);
  --gold-glow: 0 4px 20px rgba(212, 175, 55, 0.25);
  --text-light: #f5f5f7;
  --text-muted: #a1a1a8;
  --border-gold: rgba(212, 175, 55, 0.3);
  --radius: 14px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Cairo', sans-serif;
}

body {
  background-color: var(--bg-main);
  background-image: radial-gradient(circle at 50% 0%, rgba(212, 175, 55, 0.08), transparent 70%);
  color: var(--text-light);
  direction: rtl;
  display: flex;
  flex-direction: column;
  height: 100vh;
  overflow: hidden;
}

/* ==================== الهيدر ==================== */
.bot-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 18px;
  background: var(--panel-bg);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid var(--border-gold);
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.45);
  flex-shrink: 0;
}

/* قائمة تنقل المستخدم المشتركة */
.bot-header .menu-btn {
  flex: 0 0 auto;
  padding: 9px 13px;
  border: 1px solid var(--border-gold);
  border-radius: 10px;
  background: transparent;
  color: var(--gold-primary);
  cursor: pointer;
}
body:has(.bot-header) .side-menu {
  position: fixed; top: 0; right: -330px; z-index: 1200;
  width: min(310px, 86vw); height: 100vh; padding: 24px; overflow: auto;
  border-left: 1px solid var(--border-gold); background: var(--card-bg); transition: right .3s;
}
body:has(.bot-header) .side-menu.open { right: 0; }
body:has(.bot-header) .side-menu h2 {
  margin: 0 0 18px; background: var(--gold-gradient); -webkit-background-clip: text;
  background-clip: text; color: transparent;
}
body:has(.bot-header) .side-menu a {
  display: block; margin: 5px 0; padding: 11px; border-radius: 10px;
  color: var(--text-light); text-decoration: none;
}
body:has(.bot-header) .side-menu a:hover { background: rgba(212,175,55,.1); }
body:has(.bot-header) .side-menu-group-title { margin: 16px 0 7px; color: var(--gold-primary); font-weight: 800; }
body:has(.bot-header) .side-menu-divider { height: 1px; margin: 17px 0 12px; border: 0; background: var(--border-gold); }
body:has(.bot-header) .close-menu { width: 100%; margin-bottom: 12px; }
body:has(.bot-header) .overlay {
  position: fixed; inset: 0; z-index: 1100; background: rgba(0,0,0,.65);
  opacity: 0; pointer-events: none; transition: .3s;
}
body:has(.bot-header) .overlay.show { opacity: 1; pointer-events: auto; }

.back-btn {
  color: var(--gold-primary);
  text-decoration: none;
  font-weight: 700;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: 0.25s;
}

.back-btn:hover {
  transform: translateX(4px);
}

.bot-brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 800;
  font-size: 1.05rem;
  background: var(--gold-gradient);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.gold-icon {
  color: var(--gold-primary);
  -webkit-text-fill-color: initial;
}

.robot-brand-icon {
  display: inline-grid;
  place-items: center;
  width: 36px;
  height: 36px;
  border: 1px solid var(--border-gold);
  border-radius: 50%;
  background: rgba(212, 175, 55, 0.1);
  font-size: 1.25rem;
  -webkit-text-fill-color: initial;
}

/* ==================== صندوق المحادثة ==================== */
.chat-box {
  flex: 1;
  padding: 18px;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

/* فقاعات الرسائل */
.message {
  display: flex;
  gap: 10px;
  max-width: 88%;
  min-width: 0;
}

.bot-message {
  align-self: flex-start;
}

.user-message {
  align-self: flex-end;
  flex-direction: row-reverse;
}

.avatar {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  font-size: 14px;
}

.avatar img {
  width: 100%;
  height: 100%;
  border-radius: 50%;
  object-fit: cover;
}

.avatar i {
  display: none;
}

.bot-message .avatar {
  background: rgba(212, 175, 55, 0.15);
  color: var(--gold-primary);
  border: 1px solid var(--border-gold);
}

.user-message .avatar {
  background: var(--gold-gradient);
  color: #000;
}

.text {
  min-width: 0;
  padding: 12px 16px;
  border-radius: 16px;
  font-size: 0.95rem;
  line-height: 1.55;
  word-wrap: break-word;
  overflow-wrap: anywhere;
}

.bot-message .text {
  max-width: min(380px, 100%);
  background: var(--card-bg);
  border: 1px solid var(--border-gold);
  border-top-right-radius: 4px;
  color: var(--text-light);
  box-shadow: 0 4px 14px rgba(0, 0, 0, 0.25);
}

.user-message .text {
  background: var(--gold-gradient);
  color: #0d0d0d;
  font-weight: 700;
  border-top-left-radius: 4px;
  box-shadow: var(--gold-glow);
}

/* توافق مع الكلاسات القديمة إن وُجدت */
.msg {
  max-width: 85%;
  padding: 14px 18px;
  border-radius: var(--radius);
  font-size: 0.95rem;
  line-height: 1.6;
}

.bot-msg {
  align-self: flex-start;
  background: var(--card-bg);
  border: 1px solid var(--border-gold);
  border-top-right-radius: 2px;
  color: var(--text-light);
}

.user-msg {
  align-self: flex-end;
  background: var(--gold-gradient);
  color: #0d0d0d;
  font-weight: 700;
  border-top-left-radius: 2px;
  box-shadow: var(--gold-glow);
}

/* ==================== الأزرار السريعة ==================== */
.quick-buttons-container {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 12px;
}

.quick-btn {
  background: rgba(212, 175, 55, 0.1);
  border: 1px solid var(--border-gold);
  color: var(--gold-primary);
  padding: 7px 14px;
  border-radius: 20px;
  font-size: 0.84rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  font-family: inherit;
}

.quick-btn:hover {
  background: var(--gold-gradient);
  color: #000;
  border-color: transparent;
  transform: translateY(-2px);
}

/* ==================== أزرار الإجراءات ==================== */
.action-btn-inline {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  margin-top: 10px;
  padding: 10px 18px;
  border-radius: 8px;
  text-decoration: none;
  font-weight: bold;
  font-size: 0.88rem;
  transition: transform 0.2s;
}

.action-btn-inline:hover {
  transform: scale(1.02);
}

.btn-whatsapp {
  background: #25d366;
  color: #fff;
}

.btn-gold {
  background: var(--gold-gradient);
  color: #000;
}

/* ==================== مؤشر الكتابة ==================== */
.typing {
  display: flex;
  gap: 5px;
  padding: 4px 2px;
  align-items: center;
}

.typing span {
  width: 7px;
  height: 7px;
  background: var(--gold-primary);
  border-radius: 50%;
  opacity: 0.35;
  animation: blink 1s infinite;
}

.typing span:nth-child(2) {
  animation-delay: 0.2s;
}

.typing span:nth-child(3) {
  animation-delay: 0.4s;
}

@keyframes blink {
  0%, 100% { opacity: 0.3; }
  50% { opacity: 1; }
}

/* ==================== شريط الإدخال ==================== */
.chat-input-bar {
  padding: 14px 18px;
  background: var(--panel-bg);
  border-top: 1px solid var(--border-gold);
  display: flex;
  gap: 10px;
  flex-shrink: 0;
}

.chat-input-bar input {
  flex: 1;
  background: var(--card-bg);
  border: 1px solid var(--border-gold);
  border-radius: 30px;
  padding: 12px 18px;
  color: #fff;
  font-size: 0.95rem;
  outline: none;
  font-family: inherit;
  transition: 0.25s;
}

.chat-input-bar input:focus {
  border-color: var(--gold-primary);
  box-shadow: var(--gold-glow);
}

.chat-input-bar button {
  background: var(--gold-gradient);
  border: none;
  width: 48px;
  height: 48px;
  border-radius: 50%;
  color: #000;
  font-size: 1.1rem;
  cursor: pointer;
  box-shadow: var(--gold-glow);
  transition: 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.chat-input-bar button:hover {
  transform: scale(1.05);
}

.chat-input-bar button:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

/* ==================== التمرير ==================== */
.chat-box::-webkit-scrollbar {
  width: 5px;
}

.chat-box::-webkit-scrollbar-track {
  background: transparent;
}

.chat-box::-webkit-scrollbar-thumb {
  background: rgba(212, 175, 55, 0.35);
  border-radius: 10px;
}

/* ==================== الموبايل ==================== */
@media (max-width: 480px) {
  .message {
    max-width: 92%;
  }

  .bot-header {
    padding: 12px 14px;
  }

  .bot-brand {
    font-size: 0.95rem;
  }

  .chat-box {
    padding: 14px;
  }

  .chat-input-bar {
    padding: 12px 14px;
  }

  .chat-input-bar button {
    width: 44px;
    height: 44px;
  }
}

/* Local robot avatar remains visible when external icon fonts fail. */
.bot-reply-avatar { display:inline-flex; align-items:center; justify-content:center; font-family:"Segoe UI Emoji","Apple Color Emoji",sans-serif; font-size:24px; line-height:1; }

body { height:100dvh; min-height:0; }
.chat-box { min-height:0; }
.bot-header { flex-wrap:wrap; gap:12px; }
.direct-chat-header,.btn-direct-chat { display:inline-flex; align-items:center; justify-content:center; min-height:44px; padding:9px 14px; border:1px solid var(--gold-primary); border-radius:10px; color:var(--gold-primary); text-decoration:none; }
.bot-message .btn-direct-chat { margin-top:12px; background:#30291b; color:#f1d58a; }
.message .text { overflow-wrap:anywhere; }
:where(a,button,input):focus-visible { outline:2px solid var(--gold-primary); outline-offset:3px; }
@media(prefers-reduced-motion:reduce){ *,*::before,*::after { animation:none!important; transition:none!important; } }
