/**
 * Mersal Assistant — front-end chat widget.
 * Scoped under #mersal-widget-root to avoid theme conflicts.
 */
#mersal-widget-root, #mersal-widget-root * { box-sizing: border-box; }
#mersal-widget-root {
	--mw-accent: #5B5BD6;
	--mw-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
	font-family: var(--mw-font);
}
#mersal-widget-root .mw-panel,
#mersal-widget-root .mw-panel * { font-family: var(--mw-font); }

.mw-fab {
	position: fixed; bottom: 24px; width: 56px; height: 56px; border-radius: 50%;
	background: var(--mw-accent); border: none; cursor: pointer; z-index: 2147483000;
	box-shadow: 0 12px 30px rgba(0,0,0,.28); display: flex; align-items: center; justify-content: center;
	transition: transform .15s ease;
}
.mw-fab:hover { transform: scale(1.05); }
.mw-fab.is-left { left: 24px; }
.mw-fab.is-right { right: 24px; }

.mw-panel {
	position: fixed; bottom: 92px; width: 372px; max-width: calc(100vw - 32px);
	height: 560px; max-height: calc(100vh - 120px);
	background: #fff; border-radius: 18px; overflow: hidden; z-index: 2147483000;
	box-shadow: 0 24px 70px rgba(22,20,31,.3); display: flex; flex-direction: column;
	animation: mwIn .2s ease;
}
.mw-panel.is-left { left: 24px; }
.mw-panel.is-right { right: 24px; }
.mw-panel.is-dark { background: #16141F; color: #EDEBF6; }
@keyframes mwIn { from { opacity: 0; transform: translateY(8px); } to { opacity: 1; transform: none; } }

.mw-header { background: var(--mw-accent); color: #fff; padding: 16px 18px; display: flex; align-items: center; gap: 11px; }
.mw-header__avatar { width: 38px; height: 38px; border-radius: 50%; background: rgba(255,255,255,.2); display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.mw-header__title { font-size: 15px; font-weight: 700; }
.mw-header__status { font-size: 11.5px; opacity: .85; display: flex; align-items: center; gap: 5px; }
.mw-header__status .dot { width: 7px; height: 7px; border-radius: 50%; background: #5EEAD4; }
.mw-header__close { margin-left: auto; background: rgba(255,255,255,.18); border: none; width: 28px; height: 28px; border-radius: 8px; color: #fff; cursor: pointer; display: flex; align-items: center; justify-content: center; }

.mw-body { flex: 1; overflow-y: auto; padding: 16px; display: flex; flex-direction: column; gap: 12px; background: #F7F8FC; }
.mw-panel.is-dark .mw-body { background: #1B1A24; }

.mw-msg { max-width: 85%; padding: 10px 13px; font-size: 13.5px; line-height: 1.5; word-wrap: break-word; white-space: pre-wrap; }
.mw-msg.is-bot { align-self: flex-start; background: #fff; border: 1px solid #ECECF2; color: #3A384C; border-radius: 14px 14px 14px 4px; }
.mw-msg.is-user { align-self: flex-end; background: var(--mw-accent); color: #fff; border-radius: 14px 14px 4px 14px; }
.mw-panel.is-dark .mw-msg.is-bot { background: #2A2838; border-color: #3A384C; color: #EDEBF6; }
.mw-shape-square .mw-msg { border-radius: 6px !important; }
.mw-shape-pill .mw-msg { border-radius: 18px !important; }

.mw-sources { display: flex; flex-wrap: wrap; gap: 6px; margin-top: 8px; }
.mw-source { font-size: 11px; color: var(--mw-accent); text-decoration: none; background: #EDEBFB; padding: 2px 8px; border-radius: 20px; }
.mw-suggestions { display: flex; flex-direction: column; gap: 6px; align-self: flex-start; max-width: 90%; }
.mw-suggestion { text-align: left; font-size: 12.5px; color: var(--mw-accent); background: #fff; border: 1px solid #DEDCFB; border-radius: 12px; padding: 8px 12px; cursor: pointer; }

.mw-typing { align-self: flex-start; display: flex; gap: 4px; padding: 12px 14px; background: #fff; border: 1px solid #ECECF2; border-radius: 14px; }
.mw-typing span { width: 7px; height: 7px; border-radius: 50%; background: #C9C7D4; animation: mwBounce 1.2s infinite; }
.mw-typing span:nth-child(2) { animation-delay: .2s; }
.mw-typing span:nth-child(3) { animation-delay: .4s; }
@keyframes mwBounce { 0%,60%,100% { transform: translateY(0); opacity: .5; } 30% { transform: translateY(-4px); opacity: 1; } }

.mw-footer { padding: 12px 14px; border-top: 1px solid #ECECF2; display: flex; align-items: center; gap: 10px; background: #fff; }
.mw-panel.is-dark .mw-footer { background: #16141F; border-color: #2C2940; }
.mw-input { flex: 1; border: 1px solid #E2E1EA; border-radius: 10px; padding: 10px 12px; font-size: 13.5px; font-family: inherit; outline: none; resize: none; max-height: 90px; }
.mw-input:focus { border-color: var(--mw-accent); }
.mw-send { width: 36px; height: 36px; border-radius: 10px; background: var(--mw-accent); border: none; cursor: pointer; display: flex; align-items: center; justify-content: center; flex-shrink: 0; }
.mw-send:disabled { opacity: .5; cursor: not-allowed; }

.mw-consent { padding: 16px; background: #fff; border: 1px solid #ECECF2; border-radius: 12px; font-size: 12.5px; color: #5C5A70; line-height: 1.5; }
.mw-consent button { margin-top: 10px; background: var(--mw-accent); color: #fff; border: none; border-radius: 8px; padding: 8px 14px; font-size: 12.5px; font-weight: 700; cursor: pointer; }
.mw-error { align-self: center; font-size: 12px; color: #C2363B; background: #FCE9E9; padding: 6px 12px; border-radius: 8px; }

.mw-searchbar { padding: 12px 14px 4px; background: #F7F8FC; }
.mw-searchbar input { width: 100%; border: 1.5px solid #E2E1EA; border-radius: 999px; padding: 9px 14px; font-size: 13px; outline: none; font-family: inherit; }

/* ---- product cards (rich answers) ---- */
.mw-products { align-self: flex-start; width: 100%; display: flex; flex-direction: column; gap: 10px; margin-top: 2px; }
.mw-product {
	display: flex; align-items: center; gap: 12px;
	background: #fff; border: 1px solid #ECECF2; border-radius: 14px; padding: 10px;
	box-shadow: 0 4px 14px rgba(22,20,31,.05);
	color: inherit;
}
.mw-panel.is-dark .mw-product { background: #2A2838; border-color: #3A384C; }
.mw-product__img {
	width: 60px; height: 60px; border-radius: 10px; object-fit: cover; flex-shrink: 0;
	background: #F2F1F6; border: 1px solid #ECECF2;
}
.mw-product__img--ph { display: flex; align-items: center; justify-content: center; color: var(--mw-accent); }
.mw-product__meta { flex: 1; min-width: 0; }
.mw-product__name {
	font-size: 13px; font-weight: 700; color: #1B1A24; line-height: 1.3;
	display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.mw-panel.is-dark .mw-product__name { color: #EDEBF6; }
.mw-product__desc {
	font-size: 11.5px; color: #6E6A86; line-height: 1.45; margin-top: 2px;
	display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.mw-panel.is-dark .mw-product__desc { color: #A7A2C2; }
.mw-product__price { font-size: 13px; font-weight: 700; color: var(--mw-accent); margin-top: 3px; }
.mw-product__stock { font-size: 11px; color: #6E6A86; margin-top: 1px; }
.mw-product__actions {
	flex-shrink: 0; display: flex; flex-direction: column; gap: 6px; min-width: 108px;
}
.mw-product__view,
.mw-product__cart {
	display: flex; align-items: center; justify-content: center;
	text-decoration: none; font-size: 11.5px; font-weight: 700;
	padding: 7px 10px; border-radius: 10px; white-space: nowrap; text-align: center;
}
.mw-product__view {
	background: #fff; color: var(--mw-accent); border: 1.5px solid var(--mw-accent);
}
.mw-product__view:hover { background: #F5F4FF; }
.mw-product__cart {
	background: var(--mw-accent); color: #fff; border: none;
}
.mw-product__cart:hover { filter: brightness(1.05); }
.mw-panel.is-dark .mw-product__view { background: #2A2838; }
.mw-shape-square .mw-product, .mw-shape-square .mw-product__img, .mw-shape-square .mw-product__view, .mw-shape-square .mw-product__cart { border-radius: 6px !important; }
[dir="rtl"] .mw-product__name, [dir="rtl"] .mw-product__meta, [dir="rtl"] .mw-product__desc { text-align: right; }

/* ---- reply feedback (thumbs up/down) ---- */
.mw-feedback { display: flex; align-items: center; gap: 6px; margin-top: 6px; align-self: flex-start; }
.mw-feedback__btn {
	display: inline-flex; align-items: center; justify-content: center;
	width: 28px; height: 28px; padding: 0; border-radius: 8px; cursor: pointer;
	background: transparent; border: 1px solid #ECECF2; color: #9794A8; transition: color .12s, border-color .12s, background .12s;
}
.mw-feedback__btn:hover { color: var(--mw-accent); border-color: var(--mw-accent); }
.mw-feedback__btn.is-on { color: #fff; background: var(--mw-accent); border-color: var(--mw-accent); }
.mw-feedback.is-voted .mw-feedback__btn:not(.is-on) { opacity: .4; pointer-events: none; }
.mw-feedback__thanks { font-size: 11.5px; color: #6E6A86; margin-inline-start: 4px; }
.mw-panel.is-dark .mw-feedback__btn { border-color: #3A384C; color: #A7A2C2; }
.mw-panel.is-dark .mw-feedback__thanks { color: #A7A2C2; }

/* ---- character themes (personas) ------------------------------------ */
/* Colors come from --mwp-* variables set on #mersal-widget-root by widget.js
   from window.MersalCharacters, so one rule set skins every persona. */

/* animated mascot bits (used by the launcher, header avatar and admin picker) */
.mw-char .ch-fig { animation: mwCharFloat 3.4s ease-in-out infinite; }
.mw-char .ch-shadow { transform-box: fill-box; transform-origin: center; animation: mwCharShadow 3.4s ease-in-out infinite; }
.mw-char .ch-eye { transform-box: fill-box; transform-origin: center; animation: mwCharBlink 4.6s infinite; }
.mw-char .ch-wave { transform-box: fill-box; transform-origin: 12% 88%; animation: mwCharWave 3.8s ease-in-out infinite; }
@keyframes mwCharFloat { 0%, 100% { transform: translateY(0); } 50% { transform: translateY(-6px); } }
@keyframes mwCharShadow { 0%, 100% { transform: scaleX(1); opacity: .85; } 50% { transform: scaleX(.8); opacity: .55; } }
@keyframes mwCharBlink { 0%, 91%, 97%, 100% { transform: scaleY(1); } 94% { transform: scaleY(.08); } }
@keyframes mwCharWave { 0%, 40%, 100% { transform: rotate(0deg); } 10% { transform: rotate(16deg); } 20% { transform: rotate(-5deg); } 30% { transform: rotate(12deg); } }

/* launcher becomes the mascot itself */
.mw-fab.mw-fab--char {
	width: 104px; height: 112px; bottom: 10px;
	background: transparent; border-radius: 0; box-shadow: none;
	transition: transform .15s ease, width .2s ease, height .2s ease, bottom .2s ease;
}
.mw-fab--char.is-left { left: 14px; }
.mw-fab--char.is-right { right: 14px; }
.mw-fab--char:hover { transform: scale(1.05); }
.mw-fab--char svg { width: 100%; height: 100%; overflow: visible; filter: drop-shadow(0 14px 20px rgba(0,0,0,.35)); }
/* while the panel is open the mascot shrinks into the gap below it */
.mw-fab--char.is-open { width: 78px; height: 84px; bottom: 4px; z-index: 2147482999; }

/* panel skin */
.mw-panel.mw-persona {
	background: linear-gradient(168deg, var(--mwp-bg1) 0%, var(--mwp-bg2) 55%, var(--mwp-bg1) 100%);
	border: 1px solid var(--mwp-line);
	border-radius: 22px;
	box-shadow: 0 24px 70px rgba(0,0,0,.55), 0 0 34px var(--mwp-glow);
	color: #EAF0FA;
}
.mw-panel.mw-persona .mw-header { background: rgba(255,255,255,.04); border-bottom: 1px solid var(--mwp-line); }
.mw-panel.mw-persona .mw-header__avatar {
	background: rgba(255,255,255,.07); border: 1px solid var(--mwp-line);
	box-shadow: 0 0 14px var(--mwp-glow);
}
.mw-header__avatar--char { overflow: hidden; align-items: flex-start; }
.mw-header__avatar--char svg { width: 62px; height: 66px; flex-shrink: 0; margin-top: 1px; }
.mw-header__avatar--char .ch-shadow { display: none; }
.mw-panel.mw-persona .mw-header__status .dot { background: #34F5C6; box-shadow: 0 0 8px #34F5C6; }
.mw-panel.mw-persona .mw-header__close { background: rgba(255,255,255,.1); }
.mw-panel.mw-persona .mw-body { background: transparent; }
.mw-panel.mw-persona .mw-msg.is-bot { background: rgba(255,255,255,.08); border-color: var(--mwp-line); color: #EAF0FA; }
.mw-panel.mw-persona .mw-msg.is-user {
	background: linear-gradient(135deg, var(--mwp-ac1), var(--mwp-ac2));
	color: var(--mwp-usertx); box-shadow: 0 6px 18px var(--mwp-glow);
}
.mw-panel.mw-persona .mw-typing { background: rgba(255,255,255,.08); border-color: var(--mwp-line); }
.mw-panel.mw-persona .mw-typing span { background: var(--mwp-ac1); }
.mw-panel.mw-persona .mw-suggestions { flex-direction: row; flex-wrap: wrap; gap: 8px; max-width: 100%; }
.mw-panel.mw-persona .mw-suggestion {
	background: rgba(255,255,255,.06); border: 1px solid var(--mwp-line);
	color: #EAF0FA; border-radius: 999px; padding: 8px 14px; font-weight: 600;
	transition: border-color .12s, color .12s, box-shadow .12s;
}
.mw-panel.mw-persona .mw-suggestion:hover { border-color: var(--mwp-ac1); color: var(--mwp-ac1); box-shadow: 0 0 12px var(--mwp-glow); }
.mw-panel.mw-persona .mw-footer { background: transparent; border-top: 1px solid var(--mwp-line); }
.mw-panel.mw-persona .mw-input {
	background: rgba(255,255,255,.06); border: 1px solid var(--mwp-line);
	color: #EAF0FA; border-radius: 999px; padding: 10px 16px;
}
.mw-panel.mw-persona .mw-input::placeholder { color: rgba(234,240,250,.45); }
.mw-panel.mw-persona .mw-input:focus { border-color: var(--mwp-ac1); box-shadow: 0 0 0 3px var(--mwp-glow); }
.mw-panel.mw-persona .mw-send {
	border-radius: 50%;
	background: linear-gradient(135deg, var(--mwp-ac1), var(--mwp-ac2));
	box-shadow: 0 6px 18px var(--mwp-glow);
}
.mw-panel.mw-persona .mw-powered {
	text-align: center; font-size: 9.5px; font-weight: 700; letter-spacing: .18em;
	color: rgba(234,240,250,.35); padding: 0 0 10px;
}
.mw-panel.mw-persona .mw-searchbar { background: transparent; }
.mw-panel.mw-persona .mw-searchbar input { background: rgba(255,255,255,.06); border-color: var(--mwp-line); color: #EAF0FA; }
.mw-panel.mw-persona .mw-consent { background: rgba(255,255,255,.06); border-color: var(--mwp-line); color: #C9D2E4; }
.mw-panel.mw-persona .mw-source { background: rgba(255,255,255,.08); color: var(--mwp-ac1); }
.mw-panel.mw-persona .mw-product { background: rgba(255,255,255,.06); border-color: var(--mwp-line); }
.mw-panel.mw-persona .mw-product__name { color: #EAF0FA; }
.mw-panel.mw-persona .mw-product__desc, .mw-persona .mw-product__stock { color: #A9B2C6; }
.mw-panel.mw-persona .mw-product__price { color: var(--mwp-ac1); }
.mw-panel.mw-persona .mw-product__view { background: transparent; color: var(--mwp-ac1); border-color: var(--mwp-ac1); }
.mw-panel.mw-persona .mw-product__cart { background: linear-gradient(135deg, var(--mwp-ac1), var(--mwp-ac2)); color: var(--mwp-usertx); }
.mw-panel.mw-persona .mw-feedback__btn { border-color: var(--mwp-line); color: #8B93A7; }
.mw-panel.mw-persona .mw-feedback__btn.is-on { background: var(--mwp-ac2); border-color: var(--mwp-ac2); color: #fff; }
.mw-panel.mw-persona .mw-feedback__thanks { color: #A9B2C6; }
