/* Faragallah AI Assistant 0.5.0 — كل الأسماء تبدأ بـ fg-assistant- لتجنب التعارض مع القالب */
#fg-assistant-root{
 --fg-navy:#061b42;--fg-yellow:#ffb900;--fg-ink:#102b53;
 --fg-green-dark:#07863b;--fg-user-bg:#d9f7e4;
 --fg-z-mascot:999991;--fg-z-hide:999992;--fg-z-greeting:999993;--fg-z-launcher:999995;--fg-z-panel:999996;
 --fg-mh:clamp(240px,calc(var(--fg-hn) * 1vh),600px);
 --fg-mw:calc(var(--fg-mh) * .5601);
 --fg-off:calc(var(--fg-off-n) * 1%);
 --fg-kb:0px;--fg-vvh:100dvh;
 position:fixed;inset:0;width:100%;height:100%;pointer-events:none;z-index:var(--fg-z-mascot);
 direction:rtl;text-align:right;color:var(--fg-ink);font-family:inherit;font-size:16px;line-height:1.5;
}
@supports (color:color-mix(in srgb,red,blue)){
 #fg-assistant-root{--fg-green-dark:color-mix(in srgb,var(--fg-green) 78%,#000);--fg-user-bg:color-mix(in srgb,var(--fg-green) 16%,#fff)}
}
#fg-assistant-root *,#fg-assistant-root *::before,#fg-assistant-root *::after{box-sizing:border-box}
#fg-assistant-root button,#fg-assistant-root textarea{font-family:inherit;margin:0;text-transform:none;letter-spacing:normal;text-shadow:none;-webkit-appearance:none;appearance:none;-webkit-tap-highlight-color:transparent}
#fg-assistant-root button{cursor:pointer;line-height:1.3}
#fg-assistant-root img{max-width:none;border:0;box-shadow:none;margin:0;-webkit-user-select:none;user-select:none}
#fg-assistant-root :focus-visible{outline:3px solid #2b7de9;outline-offset:2px}

/* ---------- الماسكوت ---------- */
#fg-assistant-root .fg-assistant-mascot{
 position:fixed;right:0;top:calc(var(--fg-y) * 1%);width:var(--fg-mw);height:var(--fg-mh);
 transform:translate(var(--fg-off),-50%);z-index:var(--fg-z-mascot);pointer-events:none;
 transition:transform .52s cubic-bezier(.22,.75,.25,1),opacity .32s ease,visibility 0s;
 animation:fgaa-peek 1.05s cubic-bezier(.2,.8,.2,1) .35s backwards;
}
#fg-assistant-root .fg-assistant-mascot-inner{position:relative;width:100%;height:100%;filter:drop-shadow(0 6px 10px rgba(6,23,53,.22))}
#fg-assistant-root .fg-assistant-mascot-img{display:block;width:100%;height:100%;object-fit:contain}
#fg-assistant-root .fg-assistant-eye{position:absolute;display:block;overflow:hidden;pointer-events:none;
 -webkit-mask-size:100% 100%;mask-size:100% 100%;-webkit-mask-repeat:no-repeat;mask-repeat:no-repeat}
#fg-assistant-root .fg-assistant-eye--l{left:33.609%;top:15.374%;width:11.834%;height:5.302%}
#fg-assistant-root .fg-assistant-eye--r{left:44.142%;top:13.585%;width:11.834%;height:5.302%}
#fg-assistant-root .fg-assistant-iris{position:absolute;display:block;pointer-events:none;will-change:transform}
#fg-assistant-root .fg-assistant-eye--l .fg-assistant-iris{left:30%;top:31.25%;width:38%;height:47.5%}
#fg-assistant-root .fg-assistant-eye--r .fg-assistant-iris{left:29%;top:27.5%;width:41%;height:51.25%}

/* فتح الشات: ينزلق الماسكوت خلف الحافة ويختفي بالكامل */
#fg-assistant-root.fg-assistant-chat-open .fg-assistant-mascot{transform:translate(118%,-50%);opacity:0;visibility:hidden;transition:transform .52s cubic-bezier(.22,.75,.25,1),opacity .32s ease .12s,visibility 0s linear .52s}
#fg-assistant-root.fg-assistant-no-mascot-page .fg-assistant-mascot,
#fg-assistant-root.fg-assistant-no-mascot-page .fg-assistant-hide,
#fg-assistant-root.fg-assistant-no-mascot-page .fg-assistant-greeting,
#fg-assistant-root.fg-assistant-no-mascot-page .fg-assistant-restore,
#fg-assistant-root.fg-assistant-mascot-failed .fg-assistant-mascot,
#fg-assistant-root.fg-assistant-mascot-failed .fg-assistant-hide,
#fg-assistant-root:not(.fg-assistant-ready) .fg-assistant-mascot,
#fg-assistant-root:not(.fg-assistant-ready) .fg-assistant-hide{display:none}

/* زر إخفاء المساعد + زر الإعادة */
#fg-assistant-root .fg-assistant-hide{
 position:fixed;right:12px;top:calc(var(--fg-y) * 1% - var(--fg-mh) / 2 - 38px);pointer-events:auto;z-index:var(--fg-z-hide);
 border:1px solid #dfe6ef;background:#fff;color:#4a5a72;border-radius:20px;padding:6px 12px;font-size:12px;min-height:30px;
 box-shadow:0 3px 12px rgba(6,23,53,.14);transition:opacity .3s ease,visibility 0s;
}
#fg-assistant-root .fg-assistant-hide:hover{color:var(--fg-navy);border-color:#c8d3e1}
#fg-assistant-root .fg-assistant-restore{
 position:fixed;right:0;top:calc(var(--fg-y) * 1%);transform:translate(0,-50%);display:none;pointer-events:auto;z-index:var(--fg-z-hide);
 width:46px;height:46px;border:2px solid var(--fg-yellow);border-right:0;background:#fff;border-radius:23px 0 0 23px;padding:0 0 0 4px;
 box-shadow:0 4px 14px rgba(6,23,53,.22);align-items:center;justify-content:center;
}
#fg-assistant-root .fg-assistant-restore img{width:30px;height:30px;border-radius:50%;object-fit:cover;background:#eef3f8}
#fg-assistant-root.fg-assistant-mascot-off:not(.fg-assistant-chat-open) .fg-assistant-restore{display:flex}
#fg-assistant-root.fg-assistant-mascot-off .fg-assistant-mascot,
#fg-assistant-root.fg-assistant-mascot-off .fg-assistant-hide,
#fg-assistant-root.fg-assistant-mascot-off .fg-assistant-greeting{display:none}
#fg-assistant-root.fg-assistant-chat-open .fg-assistant-hide{opacity:0;visibility:hidden}

/* ---------- فقاعة الترحيب ---------- */
#fg-assistant-root .fg-assistant-greeting{
 position:fixed;width:250px;max-width:calc(100vw - 24px);pointer-events:none;z-index:var(--fg-z-greeting);
 right:calc(var(--fg-mw) * (1 - var(--fg-off-n) / 100) + 14px);
 top:calc(var(--fg-y) * 1% - var(--fg-mh) / 2 + var(--fg-mh) * .06);
 background:#fff;border:2px solid var(--fg-yellow);border-radius:20px;padding:15px 16px 13px;
 box-shadow:0 12px 32px rgba(6,23,53,.18);display:flex;flex-direction:column;gap:8px;
 opacity:0;visibility:hidden;transform:translateX(10px) scale(.97);transition:opacity .35s ease,transform .35s ease,visibility 0s linear .35s;
}
#fg-assistant-root .fg-assistant-greeting.is-visible{opacity:1;visibility:visible;transform:none;pointer-events:auto;transition:opacity .35s ease,transform .35s ease,visibility 0s}
#fg-assistant-root .fg-assistant-greeting::after{content:"";position:absolute;right:-9px;top:30px;width:16px;height:16px;background:#fff;border-top:2px solid var(--fg-yellow);border-right:2px solid var(--fg-yellow);transform:rotate(45deg);border-radius:0 3px 0 0}
#fg-assistant-root .fg-assistant-greeting strong{display:block;font-size:15px;line-height:1.6;color:var(--fg-navy);padding-left:22px;font-weight:700}
#fg-assistant-root .fg-assistant-greeting span{display:block;font-size:13px;line-height:1.8;color:#314766}
#fg-assistant-root .fg-assistant-greeting-close{position:absolute;left:6px;top:6px;width:32px;height:32px;border:0;background:transparent;font-size:22px;line-height:1;color:#6b7b92;border-radius:50%;padding:0}
#fg-assistant-root .fg-assistant-greeting-close:hover{background:#eef3f8}
#fg-assistant-root .fg-assistant-start{width:100%;border:0;border-radius:24px;background:var(--fg-green);color:#fff;font-weight:700;font-size:14px;padding:10px 14px;min-height:44px}
#fg-assistant-root .fg-assistant-start:hover{background:var(--fg-green-dark)}
/* بدون ماسكوت (صفحة مستثناة أو فشل الصورة): الفقاعة فوق الزر */
#fg-assistant-root.fg-assistant-mascot-failed .fg-assistant-greeting{right:22px;top:auto;bottom:100px}
#fg-assistant-root.fg-assistant-mascot-failed .fg-assistant-greeting::after{right:28px;top:auto;bottom:-9px;transform:rotate(135deg)}

/* ---------- زر الشات ---------- */
#fg-assistant-root .fg-assistant-launcher{
 position:fixed;right:22px;bottom:22px;width:64px;height:64px;padding:0;border:3px solid #fff;border-radius:50%;
 background:linear-gradient(145deg,var(--fg-green),var(--fg-green-dark));box-shadow:0 8px 24px rgba(6,23,53,.30);
 display:grid;place-items:center;pointer-events:auto;z-index:var(--fg-z-launcher);transition:transform .22s ease,box-shadow .22s ease;
}
#fg-assistant-root:not(.fg-assistant-ready) .fg-assistant-launcher{display:none}
#fg-assistant-root .fg-assistant-launcher:hover{transform:scale(1.06);box-shadow:0 10px 30px rgba(6,23,53,.4)}
#fg-assistant-root .fg-assistant-launcher svg{width:34px;height:34px;display:block}
#fg-assistant-root .fg-assistant-dot{fill:var(--fg-green)}

/* ---------- نافذة المحادثة ---------- */
#fg-assistant-root .fg-assistant-panel{
 position:fixed;right:22px;bottom:98px;width:min(var(--fg-cw),calc(100vw - 28px));height:min(640px,calc(100dvh - 122px));
 background:#fff;border:1px solid #dce5f0;border-radius:24px;box-shadow:0 20px 65px rgba(6,23,53,.30);overflow:hidden;
 display:flex;flex-direction:column;pointer-events:auto;z-index:var(--fg-z-panel);
 opacity:0;visibility:hidden;transform:translateY(14px) scale(.985);transform-origin:bottom right;
 transition:opacity .26s ease,transform .26s ease,visibility 0s linear .26s;
}
#fg-assistant-root.fg-assistant-chat-open .fg-assistant-panel{opacity:1;visibility:visible;transform:none;transition:opacity .28s ease .08s,transform .3s ease .08s,visibility 0s}
#fg-assistant-root .fg-assistant-header{flex:0 0 auto;min-height:84px;background:linear-gradient(125deg,#061735,#092b5b);color:#fff;display:flex;align-items:center;gap:12px;padding:12px 16px}
#fg-assistant-root .fg-assistant-avatar{width:56px;height:56px;border-radius:50%;object-fit:cover;background:#fff;border:3px solid var(--fg-yellow);flex:0 0 56px}
#fg-assistant-root .fg-assistant-title{display:flex;flex-direction:column;gap:2px;flex:1;min-width:0}
#fg-assistant-root .fg-assistant-title strong{font-size:17px;line-height:1.4;font-weight:700;color:#fff}
#fg-assistant-root .fg-assistant-title small{font-size:12px;opacity:.88;color:#fff}
#fg-assistant-root .fg-assistant-title em{font-style:normal;opacity:.8}
#fg-assistant-root .fg-assistant-winbtn{flex:0 0 40px;width:40px;height:40px;border:0;border-radius:50%;background:rgba(255,255,255,.08);color:#fff;display:grid;place-items:center;padding:0;transition:background .2s}
#fg-assistant-root .fg-assistant-winbtn:hover{background:rgba(255,255,255,.2)}
#fg-assistant-root .fg-assistant-messages{flex:1;min-height:0;overflow-y:auto;overscroll-behavior:contain;padding:16px 14px;background:linear-gradient(#f9fbfd,#fff);display:flex;flex-direction:column;gap:12px;scroll-behavior:smooth}
#fg-assistant-root .fg-assistant-msg{max-width:90%;font-size:14px;line-height:1.85;padding:11px 15px;border-radius:18px;overflow-wrap:anywhere;white-space:pre-wrap;text-align:right}
#fg-assistant-root .fg-assistant-bot{align-self:flex-start;background:#eef3f8;color:var(--fg-ink);border-top-right-radius:5px}
#fg-assistant-root .fg-assistant-user{align-self:flex-end;background:var(--fg-user-bg);color:#103a27;border-top-left-radius:5px}
#fg-assistant-root .fg-assistant-typing{display:flex;gap:5px;align-items:center;padding:15px 16px}
#fg-assistant-root .fg-assistant-typing i{width:7px;height:7px;border-radius:50%;background:#8b9bb2;animation:fgaa-dot 1s ease-in-out infinite}
#fg-assistant-root .fg-assistant-typing i:nth-child(2){animation-delay:.15s}
#fg-assistant-root .fg-assistant-typing i:nth-child(3){animation-delay:.3s}
#fg-assistant-root .fg-assistant-quick{display:grid;grid-template-columns:1fr 1fr;gap:9px}
#fg-assistant-root .fg-assistant-quick button{min-height:72px;display:flex;flex-direction:column;align-items:center;justify-content:center;gap:6px;border:1px solid #dbe5f0;background:linear-gradient(#f8fafc,#edf3f8);border-radius:16px;padding:10px 6px;color:var(--fg-navy);font-size:13px;font-weight:600;transition:border-color .2s,transform .2s,background .2s}
#fg-assistant-root .fg-assistant-quick button:hover{border-color:var(--fg-green);transform:translateY(-1px);background:#f2faf5}
#fg-assistant-root .fg-assistant-qicon{width:26px;height:26px;color:var(--fg-green-dark)}
#fg-assistant-root .fg-assistant-form{flex:0 0 auto;display:flex;align-items:flex-end;gap:9px;padding:12px 14px;border-top:1px solid #e7edf3;background:#fff;margin:0}
#fg-assistant-root .fg-assistant-form textarea{flex:1;min-width:0;height:52px;min-height:52px;max-height:120px;resize:none;border:1px solid #d8e2ee;border-radius:26px;padding:14px 18px;font-size:14px;line-height:1.6;color:var(--fg-ink);background:#fff;outline:none;direction:rtl;text-align:right;box-shadow:none;margin:0;overflow-y:auto}
#fg-assistant-root .fg-assistant-form textarea:focus{border-color:var(--fg-green);box-shadow:0 0 0 3px rgba(11,163,74,.14)}
#fg-assistant-root .fg-assistant-send{flex:0 0 52px;width:52px;height:52px;border:0;border-radius:50%;background:var(--fg-green);color:#fff;display:grid;place-items:center;padding:0;transition:background .2s,opacity .2s}
#fg-assistant-root .fg-assistant-send svg{transform:scaleX(-1)}
#fg-assistant-root .fg-assistant-send:hover{background:var(--fg-green-dark)}
#fg-assistant-root .fg-assistant-send[disabled]{opacity:.55;cursor:default}
#fg-assistant-root .fg-assistant-note{flex:0 0 auto;font-size:11px;line-height:1.6;text-align:center;color:#6b7a90;background:#fff;padding:0 12px 10px}

@keyframes fgaa-peek{from{transform:translate(110%,-50%);opacity:0}to{transform:translate(var(--fg-off),-50%);opacity:1}}
@keyframes fgaa-dot{0%,80%,100%{transform:translateY(0);opacity:.5}40%{transform:translateY(-4px);opacity:1}}

/* ---------- الهاتف ---------- */
@media (max-width:600px){
 #fg-assistant-root{--fg-mh:clamp(200px,calc(var(--fg-hn) * .6vh),290px);--fg-off:calc(var(--fg-off-n) * 1% + 12%)}
 #fg-assistant-root .fg-assistant-launcher{right:14px;bottom:14px;width:60px;height:60px}
 #fg-assistant-root .fg-assistant-greeting{width:min(236px,calc(100vw - var(--fg-mw) * (1 - (var(--fg-off-n) + 12) / 100) - 28px));padding:14px 13px 12px;right:calc(var(--fg-mw) * (1 - (var(--fg-off-n) + 12) / 100) + 12px)}
 #fg-assistant-root .fg-assistant-greeting strong{font-size:14px}
 #fg-assistant-root .fg-assistant-greeting span{font-size:12.5px}
 #fg-assistant-root .fg-assistant-hide{right:8px;padding:7px 12px;min-height:34px}
 #fg-assistant-root .fg-assistant-panel{right:8px;left:8px;width:auto;bottom:calc(8px + var(--fg-kb));height:min(680px,calc(var(--fg-vvh) - 16px));max-height:calc(var(--fg-vvh) - 16px);border-radius:20px}
 #fg-assistant-root.fg-assistant-chat-open .fg-assistant-launcher{opacity:0;visibility:hidden;pointer-events:none}
 #fg-assistant-root .fg-assistant-header{min-height:74px;padding:10px 12px}
 #fg-assistant-root .fg-assistant-avatar{width:48px;height:48px;flex-basis:48px}
 #fg-assistant-root .fg-assistant-title strong{font-size:15px}
 #fg-assistant-root .fg-assistant-messages{padding:12px 10px}
 #fg-assistant-root .fg-assistant-msg{font-size:13.5px}
 #fg-assistant-root .fg-assistant-form{padding:10px}
 #fg-assistant-root .fg-assistant-form textarea{font-size:16px} /* يمنع تكبير iOS عند التركيز */
 #fg-assistant-root .fg-assistant-note{font-size:10.5px;padding-bottom:8px}
}
@media (max-height:520px) and (min-width:601px){
 #fg-assistant-root .fg-assistant-panel{bottom:10px;right:96px;height:calc(100dvh - 20px)}
}
@media (prefers-reduced-motion:reduce){
 #fg-assistant-root .fg-assistant-mascot,#fg-assistant-root .fg-assistant-greeting,#fg-assistant-root .fg-assistant-panel,
 #fg-assistant-root .fg-assistant-launcher,#fg-assistant-root .fg-assistant-typing i,#fg-assistant-root .fg-assistant-hide{animation:none!important;transition:none!important}
 #fg-assistant-root .fg-assistant-messages{scroll-behavior:auto}
}

/* Admin-configured WhatsApp follow-up */
.fg-assistant-whatsapp{flex:0 0 auto;margin:0 14px 8px;padding:11px 15px;border:0;border-radius:22px;background:#128c4a;color:#fff;font:inherit;font-size:13px;font-weight:700;cursor:pointer}
.fg-assistant-whatsapp[hidden]{display:none!important}
.fg-assistant-whatsapp:hover{filter:brightness(.96)}
