/* ============ AI Assistant Pro Styles ============ */
:root{
  --ai-accent:#0073aa;
  --ai-radius:16px;
  --ai-text:#0f172a;
  --ai-muted:#475569;
  --ai-border:#e5e7eb;
  --ai-soft:#f8fafc;
  --ai-shadow:0 16px 40px rgba(0,0,0,.22);
}
@import url('https://fonts.googleapis.com/css2?family=Tajawal:wght@400;600;700;800&display=swap');

#ai-float-btn,.ai-popup,.ai-popup *,.ai-card,.ai-btn{
  font-family:'Tajawal',system-ui,-apple-system,Segoe UI,Arial,sans-serif;
}

/* زر عائم */
#ai-float-btn{
  position:fixed; bottom:140px; left:20px; z-index:2147483645;
  background:var(--ai-accent); color:#fff;
  padding:12px 16px; border-radius:24px;
  font-weight:800; font-size:15px;
  cursor:grab; user-select:none; touch-action:none;
  transition:transform .15s ease, box-shadow .15s ease;
  animation: ai-glow 2s ease-in-out infinite;
}
#ai-float-btn:hover{ transform:translateY(-2px) }
#ai-float-btn:active{ cursor:grabbing; transform:scale(.97) }
@keyframes ai-glow {
  0%   { box-shadow:0 0 0 rgba(37,211,102,0.0); }
  50%  { box-shadow:0 0 20px rgba(37,211,102,0.6), 0 0 35px rgba(37,211,102,0.4); }
  100% { box-shadow:0 0 0 rgba(37,211,102,0.0); }
}

/* نافذة المحادثة */
.ai-popup{
  position:fixed; bottom:88px; left:20px; z-index:2147483644;
  width:560px; max-width:96vw;
  background:#fff; border:2px solid var(--ai-accent);
  border-radius:var(--ai-radius); box-shadow:var(--ai-shadow);
  display:none; direction:rtl;
}
.ai-header{ display:flex; justify-content:space-between; align-items:center;
  padding:12px 14px; border-bottom:1px solid #eef2f7; font-weight:900; font-size:16px; }
#ai-close{ background:transparent;border:0;cursor:pointer;font-size:18px;width:32px;height:32px;border-radius:8px; }
#ai-close:hover{ background:#f1f5f9; }

/* الرسائل */
#ai-chat-window{ max-height:62vh; overflow:auto; background:var(--ai-soft); padding:14px; }
.ai-msg{ max-width:92%; padding:12px 14px; border-radius:14px; margin:12px 0; line-height:1.9; font-size:15px; }
.ai-msg.user{ background:#DCFCE7; margin-left:auto; border:1px solid #86efac; color:#064e3b; font-weight:700; }
.ai-msg.bot { background:#F1F5F9; margin-right:auto; border:1px solid #e2e8f0; color:var(--ai-text); }
.ai-msg.bot > strong{ display:block; margin-bottom:8px; }

/* الإدخال */
.ai-input{ display:grid; grid-template-columns:1fr auto auto; gap:10px; padding:12px; border-top:1px solid #eef2f7; background:#fff; }
.ai-input textarea{ resize:none; min-height:48px; max-height:140px; padding:12px 14px; border:1px solid #cbd5e1; border-radius:12px; font-size:15px; }
.ai-input button{ background:#111827;color:#fff;padding:11px 16px;border-radius:12px;cursor:pointer;font-weight:800; }
#ai-end-chat{ background:#ef4444 }

/* كروت المنتجات */
.ai-card{ display:grid; grid-template-columns:128px 1fr; gap:12px; border:1px solid var(--ai-border); background:#fff; border-radius:14px; padding:12px; margin:10px 0; }
.ai-card-img img{ width:128px; border-radius:12px; border:1px solid var(--ai-border); }
.ai-card-title{ font-weight:900; margin-bottom:4px; font-size:17px; }
.ai-card-price{ margin:6px 0 8px; font-size:15px; color:#047857; font-weight:900; }
.ai-card-actions{ margin-top:10px; display:flex; gap:8px; flex-wrap:wrap }
.ai-btn{ padding:9px 13px; border-radius:10px; font-size:13px; font-weight:800; text-decoration:none; display:inline-flex; align-items:center; gap:6px; }
.ai-btn-link{ background:#eef2ff; color:#1f2937 }
.ai-btn-cart{ background:#dcfce7; color:#065f46 }
.ai-btn-wa{
  background:#25D366; color:#fff !important; border:1px solid #1DA851;
  font-weight:900; font-size:14px; padding:10px 16px; border-radius:999px;
  box-shadow:0 3px 8px rgba(0,0,0,.18);
}
.ai-btn-wa::before{
  content:''; display:inline-block; width:18px; height:18px;
  background:url('https://upload.wikimedia.org/wikipedia/commons/6/6b/WhatsApp.svg') no-repeat center/contain;
}
.ai-btn-wa:hover{ background:#1DA851 }

/* نتائج إضافية */
.ai-more-item-wrap{ margin:6px 0 }
.ai-more-item{ display:none; }
.ai-show-more{
  margin-top:10px; background:#eef2ff; color:#1f2937;
  border:1px solid var(--ai-border); padding:9px 13px; border-radius:12px;
  cursor:pointer; font-weight:800; font-size:13.5px;
}
.ai-show-more:hover{ filter:brightness(.96) }

/* Lead Overlay */
#ai-lead-overlay{position:fixed; inset:0; z-index:2147483646; display:none; background:rgba(0,0,0,.35); backdrop-filter:saturate(110%) blur(2px)}
#ai-lead-box{width:min(92vw,440px); background:#fff; border-radius:16px; border:1px solid #e5e7eb; box-shadow:0 16px 40px rgba(0,0,0,.22); padding:18px; direction:rtl; position:absolute; left:50%; top:50%; transform:translate(-50%,-50%)}
#ai-lead-box h3{ margin:0 0 10px; font-weight:900 }
.ai-field{ display:flex; flex-direction:column; gap:6px; margin:10px 0 }
.ai-field input{ border:1px solid #cbd5e1; border-radius:12px; padding:12px 14px; font-size:15px }
.ai-actions{ display:flex; gap:10px; margin-top:10px }
#ai-lead-close{ background:#f1f5f9; border:1px solid #e5e7eb; border-radius:12px; padding:10px 14px; cursor:pointer }
#ai-lead-save{ background:#111827; color:#fff; border:0; border-radius:12px; padding:10px 16px; cursor:pointer; font-weight:800 }
.ai-hint{ color:#64748b; font-size:13px }
.ai-err{ color:#dc2626; font-size:13px; margin-top:4px; display:none }

/* موبايل */
@media (max-width:600px){
  .ai-popup{ left:10px; right:10px; width:auto; }
  .ai-card{ grid-template-columns:1fr; }
  .ai-card-img img{ width:100%; }
  .ai-btn{ width:100%; justify-content:center }
}

/* Admin buttons tweaks */
.wrap .button-primary{ background:#111827; border-color:#111827 }
.wrap .button:hover{ filter:brightness(.98) }
