/* مساعد مهارات — floating AI chat */
.m-ai { --ai-gap: 20px; --ai-bottom: 96px; position: fixed; z-index: 9990; left: var(--ai-gap); bottom: var(--ai-bottom); font-family: var(--m-font-body, inherit); direction: rtl; }
[dir="ltr"] .m-ai { left: auto; right: var(--ai-gap); }
@media (max-width: 1180px) { .m-ai { --ai-bottom: calc(var(--m-bnav-h, 64px) + 92px + env(safe-area-inset-bottom)); --ai-gap: 16px; } }

.m-ai__fab { position: relative; display: grid; place-items: center; width: 58px; height: 58px; padding: 0 !important; border: 0; border-radius: 50%; cursor: pointer; color: #fff;
	background: linear-gradient(135deg, var(--m-primary, #1B75BB), #4AA3E0); box-shadow: 0 10px 26px rgba(27, 117, 187, .38), 0 0 0 4px rgba(255, 255, 255, .85); transition: transform .2s, box-shadow .2s; }
.m-ai__fab:hover { transform: translateY(-2px) scale(1.03); box-shadow: 0 14px 30px rgba(27, 117, 187, .45), 0 0 0 4px #fff; }
.m-ai__fab:focus-visible { outline: 3px solid var(--m-accent, #F6A64B); outline-offset: 3px; }
.m-ai__fab-dot { position: absolute; top: 4px; inset-inline-end: 4px; width: 12px; height: 12px; border-radius: 50%; background: var(--m-accent, #F6A64B); box-shadow: 0 0 0 2px #fff; }
.m-ai.is-open .m-ai__fab-dot, .m-ai.is-open .m-ai__fab::after { display: none; }
.m-ai.is-hint:not(.is-open) .m-ai__fab::after { content: "اسألني عن طفلك ✨"; position: absolute; inset-inline-start: calc(100% + 10px); top: 50%; transform: translateY(-50%); white-space: nowrap; padding: .45rem .8rem; border-radius: 12px; background: #fff; color: var(--m-primary-800, #0D3D66); font: 600 .82rem/1.2 var(--m-font-body, inherit); box-shadow: 0 8px 22px rgba(13, 61, 102, .14); animation: m-ai-pop .35s ease both; }
@keyframes m-ai-pop { from { opacity: 0; transform: translateY(-50%) scale(.9); } }

.m-ai__panel { position: absolute; bottom: calc(100% + 14px); left: 0; width: min(380px, calc(100vw - 32px)); height: min(600px, calc(100vh - var(--ai-bottom) - 110px)); display: flex; flex-direction: column;
	background: #fff; border-radius: 22px; box-shadow: 0 24px 60px rgba(13, 61, 102, .22), 0 0 0 1px rgba(13, 61, 102, .06); overflow: hidden; transform-origin: bottom left; animation: m-ai-in .22s cubic-bezier(.22, 1, .36, 1); }
[dir="ltr"] .m-ai__panel { left: auto; right: 0; transform-origin: bottom right; }
.m-ai__panel[hidden] { display: none; }
@keyframes m-ai-in { from { opacity: 0; transform: translateY(10px) scale(.97); } }

.m-ai__head { display: flex; align-items: center; gap: 10px; padding: 14px 14px 12px; background: linear-gradient(135deg, var(--m-primary, #1B75BB), #3E95D6); color: #fff; }
.m-ai__avatar { display: grid; place-items: center; width: 38px; height: 38px; border-radius: 50%; background: rgba(255, 255, 255, .2); flex: none; }
.m-ai__who { flex: 1; min-width: 0; display: grid; line-height: 1.25; }
.m-ai__who strong { font-size: 1rem; }
.m-ai__who small { font-size: .74rem; opacity: .9; display: flex; align-items: center; gap: 6px; }
.m-ai__online { width: 7px; height: 7px; border-radius: 50%; background: #7CF2A6; display: inline-block; }
.m-site .m-ai button.m-ai__icon, .m-ai__icon { display: grid; place-items: center; width: 36px; height: 36px; padding: 0; border: 0; border-radius: 50%; background: rgba(255, 255, 255, .14); color: #fff; cursor: pointer; min-height: 0; box-shadow: none; }
.m-ai__icon:hover { background: rgba(255, 255, 255, .26); }

.m-ai__log { flex: 1; overflow-y: auto; padding: 16px 14px 8px; display: flex; flex-direction: column; gap: 10px; background: #F5F9FD; overscroll-behavior: contain; }
.m-ai__msg { max-width: 86%; padding: 10px 14px; border-radius: 18px; font-size: .93rem; line-height: 1.75; white-space: pre-wrap; overflow-wrap: anywhere; }
.m-ai__msg--bot { align-self: flex-start; background: #fff; color: #23384F; border-start-start-radius: 6px; box-shadow: 0 2px 8px rgba(13, 61, 102, .06); }
.m-ai__msg--me { align-self: flex-end; background: var(--m-primary, #1B75BB); color: #fff; border-start-end-radius: 6px; }
.m-ai__msg.is-error { background: #FFF1F0; color: #9B2C2C; }
.m-ai__typing { display: inline-flex; gap: 5px; align-items: center; }
.m-ai__typing span { width: 7px; height: 7px; border-radius: 50%; background: #9DB4CC; animation: m-ai-dot 1s infinite ease-in-out; }
.m-ai__typing span:nth-child(2) { animation-delay: .15s; }
.m-ai__typing span:nth-child(3) { animation-delay: .3s; }
@keyframes m-ai-dot { 0%, 80%, 100% { opacity: .35; transform: translateY(0); } 40% { opacity: 1; transform: translateY(-3px); } }

.m-ai__chips { display: flex; flex-wrap: wrap; gap: 8px; }
.m-site .m-ai button.m-ai__chip, .m-ai__chip { padding: 8px 12px; min-height: 0; border: 1.5px solid #CFE0F0; border-radius: 999px; background: #fff; color: var(--m-primary-800, #0D3D66); font: 600 .82rem/1.3 var(--m-font-body, inherit); cursor: pointer; box-shadow: none; text-align: start; }
.m-ai__chip:hover { border-color: var(--m-primary, #1B75BB); background: var(--m-primary-50, #E8F2FA); }

.m-ai__cards { display: grid; gap: 8px; }
.m-ai__card { display: flex; gap: 10px; padding: 8px; background: #fff; border: 1px solid #DCE8F3; border-radius: 14px; }
.m-ai__card-img { flex: none; width: 72px; height: 72px; border-radius: 10px; overflow: hidden; background: #EEF4FA; }
.m-ai__card-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.m-ai__card-body { flex: 1; min-width: 0; display: grid; gap: 3px; align-content: start; }
.m-ai__tag { justify-self: start; padding: 1px 8px; border-radius: 999px; font-size: .68rem; font-weight: 700; background: var(--m-primary-50, #E8F2FA); color: var(--m-primary, #1B75BB); }
.m-ai__tag--product { background: #FFF4E8; color: #B4621F; }
.m-ai__tag--consultation { background: #E9F0E1; color: #4D6B33; }
.m-ai__card-title { font-weight: 700; font-size: .86rem; line-height: 1.45; color: var(--m-primary-800, #0D3D66) !important; text-decoration: none; display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden; }
.m-ai__price { font-weight: 700; font-size: .85rem; color: #1E8E5A; }
.m-ai__card-actions { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 2px; }
.m-ai .m-ai__btn { display: inline-flex; align-items: center; justify-content: center; min-height: 30px; padding: 4px 12px; border-radius: 999px; font: 700 .76rem/1 var(--m-font-body, inherit); text-decoration: none; background: var(--m-accent, #F6A64B); color: #23384F !important; border: 0; }
.m-ai .m-ai__btn--ghost { background: transparent; color: var(--m-primary, #1B75BB) !important; border: 1.5px solid #CFE0F0; }
.m-ai .m-ai__btn.added::after { display: none; }
.m-ai .added_to_cart { display: none !important; }
.m-ai__wa { align-self: flex-start; display: inline-flex; align-items: center; gap: 8px; padding: 9px 14px; border-radius: 999px; background: #25D366; color: #fff !important; font-weight: 700; font-size: .84rem; text-decoration: none; }

.m-ai__form { position: relative; display: flex; align-items: flex-end; gap: 8px; padding: 10px 12px; border-top: 1px solid #E3ECF5; background: #fff; }
.m-ai__hp { position: absolute !important; left: -9999px !important; width: 1px !important; height: 1px !important; opacity: 0 !important; }
.m-ai__form textarea { flex: 1; resize: none; min-height: 44px; max-height: 110px; padding: 11px 14px; border: 1.5px solid #DCE8F3; border-radius: 22px; background: #F8FBFE; font: 400 .93rem/1.5 var(--m-font-body, inherit); color: #23384F; outline: none; }
.m-ai__form textarea:focus { border-color: var(--m-primary, #1B75BB); background: #fff; }
.m-site .m-ai button.m-ai__send, .m-ai__send { flex: none; display: grid; place-items: center; width: 44px; height: 44px; padding: 0; min-height: 0; border: 0; border-radius: 50%; background: var(--m-primary, #1B75BB); color: #fff; cursor: pointer; box-shadow: none; }
.m-ai__form.is-busy .m-ai__send { opacity: .5; pointer-events: none; }
.m-ai__note { margin: 0; padding: 0 14px 10px; background: #fff; font-size: .68rem; line-height: 1.5; color: #7D8FA3; text-align: center; }

/* Phones: full-screen sheet */
@media (max-width: 600px) {
	.m-ai__panel { position: fixed; inset: auto 8px calc(8px + env(safe-area-inset-bottom)) 8px; width: auto; height: min(78vh, calc(100vh - 90px)); border-radius: 20px; }
	html.m-ai-open .m-ai__fab { opacity: 0; pointer-events: none; }
	html.m-ai-open .m-bnav, html.m-ai-open #ht-ctc-chat, html.m-ai-open .ht-ctc { visibility: hidden; }
}
/* Stay out of the way of the side cart / popups */
html.m-scart-open .m-ai, html.m-promo-open .m-ai { visibility: hidden; }
@media print { .m-ai { display: none !important; } }
@media (prefers-reduced-motion: reduce) { .m-ai__panel, .m-ai__typing span, .m-ai.is-hint .m-ai__fab::after { animation: none !important; } }

/* Custom icon image (المساعد الذكي ← الإعدادات ← صورة أيقونة المساعد) */
.m-ai__fab-img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.m-ai__fab.has-img { background: #fff; }
.m-ai__avatar img { width: 100%; height: 100%; border-radius: 50%; object-fit: cover; display: block; }
.m-ai__avatar.has-img { padding: 0; overflow: hidden; background: #fff; }
