/* Hamada Medical Assistant Bot - v1.2 Improved Colors & Layout */

:root {
	--hmab-primary: #0f766e;
	--hmab-primary-dark: #0d5c56;
	--hmab-primary-light: #14b8a6;
	--hmab-accent: #ea580c;
	--hmab-bg: #f0fdfa;
	--hmab-user-bg: #ccfbf1;
	--hmab-bot-bg: #ffffff;
	--hmab-text: #134e4a;
	--hmab-text-dark: #1e293b;
	--hmab-border: #99f6e4;
	--hmab-shadow: 0 10px 36px rgba(15, 118, 110, 0.2);
	--hmab-radius: 16px;
}

/* Floating Button */
#hmab-floating-btn {
	position: fixed;
	bottom: 22px;
	left: 22px;
	width: 60px;
	height: 60px;
	border-radius: 50%;
	background: linear-gradient(145deg, var(--hmab-primary-light), var(--hmab-primary));
	color: #fff;
	border: none;
	cursor: pointer;
	box-shadow: var(--hmab-shadow);
	z-index: 99998;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: transform 0.2s cubic-bezier(0.34, 1.56, 0.64, 1), box-shadow 0.2s;
	font-size: 24px;
	line-height: 1;
}

#hmab-floating-btn:hover {
	transform: scale(1.08);
	box-shadow: 0 14px 42px rgba(15, 118, 110, 0.35);
}

#hmab-cart-badge {
	position: absolute;
	top: -3px;
	right: -3px;
	background: var(--hmab-accent);
	color: #fff;
	font-size: 11px;
	font-weight: 700;
	min-width: 20px;
	height: 20px;
	border-radius: 10px;
	display: none;
	align-items: center;
	justify-content: center;
	padding: 0 5px;
	border: 2px solid #fff;
	box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

/* Overlay */
#hmab-chat-overlay {
	position: fixed;
	inset: 0;
	background: rgba(15, 23, 42, 0.45);
	z-index: 99999;
	display: none;
	align-items: stretch;
	justify-content: center;
	backdrop-filter: blur(5px);
	-webkit-backdrop-filter: blur(5px);
}

#hmab-chat-overlay.active {
	display: flex;
}

#hmab-chat-container {
	width: 100%;
	max-width: 440px;
	height: 100%;
	max-height: 100dvh;
	background: var(--hmab-bg);
	display: flex;
	flex-direction: column;
	box-shadow: var(--hmab-shadow);
	position: relative;
	animation: none;
	overflow: hidden;
	direction: rtl;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Tahoma, Arial, sans-serif;
}

@media (min-width: 520px) {
	#hmab-chat-container {
		height: 90vh;
		max-height: 760px;
		border-radius: 20px;
		margin: auto;
		border: 1px solid rgba(255,255,255,0.25);
	}
}

@keyframes hmabSlideUp {
	from { transform: translateY(40px) scale(0.97); opacity: 0; }
	to   { transform: translateY(0) scale(1); opacity: 1; }
}

/* Header */
.hmab-header {
	background: linear-gradient(135deg, #0f766e 0%, #0d9488 55%, #14b8a6 100%);
	color: #fff;
	padding: 13px 15px;
	display: flex;
	align-items: center;
	gap: 11px;
	flex-shrink: 0;
	box-shadow: 0 2px 10px rgba(15, 118, 110, 0.25);
}

.hmab-header-avatar {
	width: 44px;
	height: 44px;
	border-radius: 50%;
	background: rgba(255,255,255,0.2);
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 20px;
	flex-shrink: 0;
	border: 2px solid rgba(255,255,255,0.3);
}

.hmab-header-info {
	flex: 1;
	min-width: 0;
	text-align: right;
}

.hmab-header-info h3 {
	margin: 0;
	font-size: 15.5px;
	font-weight: 700;
	letter-spacing: -0.2px;
}

.hmab-header-info span {
	font-size: 11.5px;
	opacity: 0.9;
	display: flex;
	align-items: center;
	gap: 5px;
	justify-content: flex-start;
	flex-direction: row-reverse;
}

.hmab-header-info span::before {
	content: '';
	width: 7px;
	height: 7px;
	background: #4ade80;
	border-radius: 50%;
	display: inline-block;
	box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.35);
	order: 1;
}

.hmab-header-actions {
	display: flex;
	gap: 6px;
}

.hmab-header-btn {
	background: rgba(255,255,255,0.15);
	border: none;
	color: #fff;
	width: 34px;
	height: 34px;
	border-radius: 50%;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 15px;
	transition: background 0.15s;
	text-decoration: none;
}

.hmab-header-btn:hover {
	background: rgba(255,255,255,0.3);
	color: #fff;
}

/* Cart summary */
.hmab-cart-summary {
	display: none;
	background: #ecfdf5;
	border-bottom: 1px solid var(--hmab-border);
	padding: 8px 14px;
	font-size: 12.5px;
	color: var(--hmab-text);
	text-align: center;
}

.hmab-cart-summary.visible {
	display: block;
}

/* Messages area */
.hmab-messages {
	flex: 1;
	overflow-y: auto;
	padding: 14px 12px;
	display: flex;
	flex-direction: column;
	gap: 9px;
	scroll-behavior: auto;
	-webkit-overflow-scrolling: touch;
}

.hmab-msg {
	max-width: 85%;
	padding: 10px 14px;
	border-radius: var(--hmab-radius);
	font-size: 14px;
	line-height: 1.55;
	position: relative;
	word-wrap: break-word;
	animation: none;
}

@keyframes hmabMsgIn {
	from { opacity: 0; transform: translateY(6px); }
	to   { opacity: 1; transform: translateY(0); }
}

/* User = right side (RTL) */
.hmab-msg.user {
	align-self: flex-start;
	background: var(--hmab-user-bg);
	color: var(--hmab-text);
	border-bottom-right-radius: 4px;
	box-shadow: 0 1px 2px rgba(15, 118, 110, 0.08);
}

/* Bot = left side */
.hmab-msg.bot {
	align-self: flex-end;
	background: var(--hmab-bot-bg);
	color: var(--hmab-text-dark);
	border: 1px solid #e2e8f0;
	border-bottom-left-radius: 4px;
	box-shadow: 0 1px 6px rgba(0,0,0,0.04);
}

.hmab-msg.bot strong {
	color: var(--hmab-primary);
}

.hmab-msg .hmab-time {
	font-size: 10px;
	opacity: 0.5;
	margin-top: 4px;
	display: block;
}

.hmab-msg.user .hmab-time {
	text-align: left;
}

.hmab-msg.bot .hmab-time {
	text-align: right;
}

.hmab-msg img.hmab-preview {
	max-width: 100%;
	border-radius: 10px;
	margin-top: 6px;
	display: block;
}

/* Typing */
.hmab-typing {
	align-self: flex-end;
	padding: 10px 16px;
	background: #fff;
	border-radius: 16px;
	border: 1px solid #e2e8f0;
	display: none;
	margin: 0 12px 2px;
	gap: 4px;
}

.hmab-typing.active {
	display: flex;
	align-items: center;
}

.hmab-typing span {
	width: 7px;
	height: 7px;
	background: var(--hmab-primary-light);
	border-radius: 50%;
	animation: hmabDot 1.2s infinite ease-in-out;
}

.hmab-typing span:nth-child(2) { animation-delay: 0.15s; }
.hmab-typing span:nth-child(3) { animation-delay: 0.3s; }

@keyframes hmabDot {
	0%, 80%, 100% { transform: scale(0.7); opacity: 0.4; }
	40% { transform: scale(1); opacity: 1; }
}

/* Quick replies */
.hmab-quick-replies {
	display: flex;
	flex-wrap: wrap;
	gap: 7px;
	padding: 8px 12px 4px;
	flex-shrink: 0;
	justify-content: flex-start;
}

.hmab-chip {
	background: #fff;
	border: 1.5px solid var(--hmab-border);
	color: var(--hmab-primary);
	padding: 7px 13px;
	border-radius: 20px;
	font-size: 12.5px;
	cursor: pointer;
	transition: all 0.15s;
	white-space: nowrap;
	font-weight: 500;
}

.hmab-chip:hover {
	background: var(--hmab-primary);
	color: #fff;
	border-color: var(--hmab-primary);
}

/* Recording */
.hmab-recording {
	display: none;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 8px;
	background: #fef2f2;
	color: #b91c1c;
	font-size: 13px;
	flex-shrink: 0;
}

.hmab-recording.active {
	display: flex;
}

.hmab-rec-dot {
	width: 10px;
	height: 10px;
	background: #ef4444;
	border-radius: 50%;
	animation: hmabPulse 1s infinite;
}

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

/* Input area */
.hmab-input-area {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 10px 12px 12px;
	background: #fff;
	border-top: 1px solid #e2e8f0;
	flex-shrink: 0;
}

.hmab-input-tools {
	display: flex;
	gap: 3px;
	flex-shrink: 0;
	padding-bottom: 4px;
}

.hmab-tool-btn {
	width: 34px;
	height: 34px;
	border: none;
	background: #f1f5f9;
	border-radius: 50%;
	cursor: pointer;
	font-size: 15px;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background 0.15s;
	color: #475569;
}

.hmab-tool-btn:hover,
.hmab-tool-btn.active {
	background: var(--hmab-primary);
	color: #fff;
}

.hmab-input-wrap {
	flex: 1;
	min-width: 0;
}

#hmab-message-input {
	width: 100%;
	border: 1.5px solid #e2e8f0;
	border-radius: 22px;
	padding: 10px 14px;
	font-size: 14px;
	resize: none;
	max-height: 100px;
	min-height: 42px;
	line-height: 1.4;
	outline: none;
	font-family: inherit;
	background: #f8fafc;
	color: #1e293b;
	transition: border-color 0.15s, background 0.15s;
	direction: rtl;
	box-sizing: border-box;
}

#hmab-message-input:focus {
	border-color: var(--hmab-primary-light);
	background: #fff;
}

#hmab-message-input::placeholder {
	color: #94a3b8;
}

#hmab-send-btn {
	width: 42px;
	height: 42px;
	border-radius: 50%;
	border: none;
	background: linear-gradient(145deg, var(--hmab-primary-light), var(--hmab-primary));
	color: #fff;
	font-size: 16px;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	transition: transform 0.15s, box-shadow 0.15s;
	box-shadow: 0 3px 10px rgba(15, 118, 110, 0.3);
}

#hmab-send-btn:hover {
	transform: scale(1.06);
}

#hmab-send-btn:disabled {
	opacity: 0.55;
	cursor: not-allowed;
	transform: none;
}

/* Pending images */
.hmab-pending-images {
	padding: 6px 12px 0;
	display: flex;
	gap: 6px;
	flex-wrap: wrap;
}

.hmab-pending-images img {
	width: 56px;
	height: 56px;
	object-fit: cover;
	border-radius: 10px;
	border: 2px solid var(--hmab-border);
}

/* Hidden file inputs */
#hmab-image-input,
#hmab-camera-input {
	display: none;
}

/* Scrollbar */
.hmab-messages::-webkit-scrollbar {
	width: 4px;
}
.hmab-messages::-webkit-scrollbar-thumb {
	background: var(--hmab-border);
	border-radius: 4px;
}


/* v1.3.1 visual refresh: responsive, polished Arabic pharmacy assistant */
#hmab-floating-btn {
	width: auto; min-width: 64px; height: 58px; padding: 0 18px;
	border-radius: 999px; gap: 9px; flex-direction: row;
	background: linear-gradient(135deg,#10b981,#047857);
	box-shadow: 0 10px 28px rgba(4,120,87,.32);
}
.hmab-floating-icon { display:inline-flex; align-items:center; justify-content:center; width:30px; height:30px; border-radius:50%; background:rgba(255,255,255,.2); font-size:25px; font-weight:700; }
.hmab-floating-label { font-size:15px; font-weight:800; white-space:nowrap; }
#hmab-cart-badge { top:-5px; right:-4px; }
#hmab-chat-overlay { padding:16px; }
#hmab-chat-container { border-radius:26px; border:1px solid rgba(255,255,255,.85); background:linear-gradient(180deg,#f8fffe 0%,#effcf9 100%); }
.hmab-header { padding:16px 17px; min-height:82px; background:linear-gradient(120deg,#065f56 0%,#0d9488 58%,#14b8a6 100%); }
.hmab-header-avatar { width:49px; height:49px; font-size:30px; color:#fff; background:rgba(255,255,255,.16); border:2px solid rgba(255,255,255,.35); }
.hmab-header-info h3 { font-size:18px; margin-bottom:4px; }
.hmab-header-info span { font-size:12px; }
.hmab-header-btn { width:38px; height:38px; font-size:17px; }
.hmab-messages { padding:18px 15px; gap:12px; background-image:radial-gradient(circle at 15% 20%,rgba(20,184,166,.055) 0 2px,transparent 3px),radial-gradient(circle at 80% 70%,rgba(20,184,166,.05) 0 2px,transparent 3px); background-size:32px 32px,40px 40px; }
.hmab-msg { max-width:88%; padding:12px 15px; border-radius:20px; font-size:15px; line-height:1.7; }
.hmab-msg.user { background:linear-gradient(135deg,#d1fae5,#bbf7d0); border:1px solid #a7f3d0; border-bottom-right-radius:6px; }
.hmab-msg.bot { border:1px solid #e2eeec; border-bottom-left-radius:6px; box-shadow:0 5px 16px rgba(15,118,110,.055); }
.hmab-quick-replies { display:flex; flex-wrap:wrap; gap:8px; padding:10px 12px 12px; background:rgba(255,255,255,.86); border-top:1px solid #e2f3ef; }
.hmab-chip { padding:9px 13px; border:1px solid #b7eee3; border-radius:999px; font-size:13px; font-weight:700; box-shadow:0 2px 7px rgba(15,118,110,.04); }
.hmab-chip:focus-visible,.hmab-header-btn:focus-visible,.hmab-tool-btn:focus-visible,#hmab-send-btn:focus-visible { outline:3px solid #fbbf24; outline-offset:2px; }
.hmab-whatsapp-cta { padding:0 12px 12px; background:#fff; }
.hmab-whatsapp-cta a { display:flex; align-items:center; gap:11px; padding:11px 13px; text-decoration:none; border:1px solid #b6efcf; border-radius:17px; background:linear-gradient(100deg,#ecfdf5,#f0fdfa); color:#065f46; box-shadow:0 3px 10px rgba(16,185,129,.07); }
.hmab-whatsapp-cta a:hover { border-color:#34d399; background:#dcfce7; }
.hmab-wa-icon { display:flex; align-items:center; justify-content:center; width:40px; height:40px; border-radius:13px; color:#fff; background:#16a34a; font-size:24px; flex-shrink:0; }
.hmab-whatsapp-cta a strong,.hmab-whatsapp-cta a small { display:block; }
.hmab-whatsapp-cta a strong { font-size:13px; }
.hmab-whatsapp-cta a small { font-size:11px; margin-top:2px; color:#477568; }
.hmab-wa-arrow { margin-inline-start:auto; font-size:20px; }
.hmab-input-area { padding:11px 12px max(12px,env(safe-area-inset-bottom)); gap:7px; background:rgba(255,255,255,.97); }
.hmab-tool-btn { width:37px; height:37px; background:#edf7f5; color:#0f766e; }
#hmab-message-input { min-height:44px; background:#f8fbfb; border-color:#dceae7; border-radius:24px; padding:11px 15px; }
#hmab-send-btn { width:44px; height:44px; }
.hmab-typing { padding:0 15px 8px; }
@media (min-width:520px) {
	#hmab-chat-container { width:min(470px, calc(100vw - 32px)); height:min(88dvh,820px); max-height:820px; }
}
@media (max-width:519px) {
	#hmab-chat-overlay { padding:0; }
	#hmab-chat-container { width:100%; height:100%; height:100dvh; max-height:100dvh; border-radius:0; border:0; }
	.hmab-header { padding-top:max(13px,env(safe-area-inset-top)); }
	#hmab-floating-btn { bottom:max(18px,env(safe-area-inset-bottom)); left:16px; height:54px; padding:0 15px; }
	.hmab-floating-label { font-size:14px; }
	.hmab-quick-replies { gap:7px; }
	.hmab-chip { font-size:12px; padding:8px 11px; }
	.hmab-input-tools { gap:2px; }
	.hmab-tool-btn { width:32px; height:32px; font-size:14px; }
}
@media (prefers-reduced-motion: reduce) {
	#hmab-floating-btn,.hmab-msg,#hmab-chat-container { animation:none!important; transition:none!important; }
}


/* v1.3.2 responsive contrast and viewport repair */
:root {
 --hmab-primary:#087f6e; --hmab-primary-dark:#075e54; --hmab-primary-light:#16a995;
 --hmab-accent:#e85d35; --hmab-bg:#f4fbfa; --hmab-user-bg:#d9f8e8;
 --hmab-bot-bg:#ffffff; --hmab-text:#123f3b; --hmab-text-dark:#172b3a;
 --hmab-border:#b6e9dc; --hmab-shadow:0 16px 48px rgba(13,74,68,.24);
}
#hmab-chat-overlay { padding:clamp(0px,2.2vw,24px); box-sizing:border-box; align-items:center; justify-content:center; }
#hmab-chat-container {
 width:min(100%,560px); height:min( min(900px, calc(100dvh - 32px)), 94dvh);
 min-height:0; max-height:calc(100dvh - 32px); border-radius:24px; box-sizing:border-box;
 background:#f7fcfb; color:#172b3a; overflow:hidden; isolation:isolate;
}
.hmab-header { background:linear-gradient(115deg,#075e54 0%,#087f76 55%,#0cae9a 100%); color:#fff; }
.hmab-header-info h3 { color:#fff; font-size:clamp(16px,2vw,19px); }
.hmab-header-info span { color:#f0fffb; font-size:12px; }
.hmab-header-avatar { background:rgba(255,255,255,.16); color:#fff; }
.hmab-cart-summary { background:#e2f8ef; color:#124b42; border-color:#a8e2d3; font-weight:600; }
.hmab-messages { background:linear-gradient(180deg,#f2fbf9 0%,#f8fcfb 100%); min-height:0; overscroll-behavior:contain; }
.hmab-msg { max-width:min(88%,520px); font-size:clamp(14px,1.6vw,16px); color:#172b3a; }
.hmab-msg.bot { background:#fff; border:1px solid #d8e9e6; color:#172b3a; box-shadow:0 3px 12px rgba(19,68,62,.07); }
.hmab-msg.user { background:#d9f8e8; color:#123f3b; border:1px solid #b7ecd8; }
.hmab-quick-replies { background:#fff; border-top:1px solid #e1eeeb; padding:9px 12px; gap:7px; }
.hmab-chip { background:#fff; border:1px solid #91d9ca; color:#08685e; font-weight:700; box-shadow:0 1px 3px rgba(0,0,0,.035); }
.hmab-chip:focus-visible, .hmab-tool-btn:focus-visible, #hmab-send-btn:focus-visible, .hmab-header-btn:focus-visible { outline:3px solid #f59e0b; outline-offset:2px; }
.hmab-whatsapp-cta { padding:8px 12px; background:#fff; }
.hmab-whatsapp-cta a { display:flex; align-items:center; gap:12px; padding:13px 15px; border:1px solid #a8e6d2; border-radius:18px; background:#eafaf3; color:#075e54; text-decoration:none; box-shadow:0 2px 8px rgba(10,110,85,.06); }
.hmab-whatsapp-cta strong { display:block; color:#075e54; font-size:14px; }
.hmab-whatsapp-cta small { display:block; color:#426d66; margin-top:3px; font-size:12px; }
.hmab-wa-icon { display:flex; align-items:center; justify-content:center; flex:0 0 42px; width:42px; height:42px; border-radius:13px; background:#0b9f64; color:white; font-size:25px; }
.hmab-wa-arrow { margin-inline-start:auto; font-size:22px; color:#087f6e; }
.hmab-input-area { padding:10px 12px max(12px,env(safe-area-inset-bottom)); gap:8px; background:#fff; border-top:1px solid #dceae7; align-items:center; }
.hmab-input-tools { gap:5px; padding:0; }
.hmab-tool-btn { width:36px; height:36px; background:#eaf3f2; color:#315d58; font-size:17px; }
#hmab-message-input { background:#f8fbfb; border:1.5px solid #cbdedb; color:#172b3a; min-height:44px; max-height:120px; font-size:15px; }
#hmab-message-input::placeholder { color:#687e8d; opacity:1; }
#hmab-send-btn { width:44px; height:44px; background:linear-gradient(145deg,#10b9a5,#087f6e); }
#hmab-floating-btn { max-width:calc(100vw - 28px); min-height:54px; height:auto; padding:10px 16px; color:#fff; background:linear-gradient(135deg,#10b981,#087f6e); }
.hmab-floating-label { color:#fff; font-size:14px; }
#hmab-floating-btn, #hmab-chat-container { -webkit-tap-highlight-color:transparent; }
.hmab-content { overflow-wrap:anywhere; }
.hmab-content pre, .hmab-content code { white-space:pre-wrap; overflow-wrap:anywhere; }
@media (min-width:768px) {
 #hmab-chat-container { width:min(560px, calc(100vw - 48px)); height:min(860px, calc(100dvh - 48px)); max-height:calc(100dvh - 48px); }
 .hmab-header { padding:17px 20px; }
 .hmab-messages { padding:18px 18px; gap:12px; }
 .hmab-msg { padding:12px 16px; line-height:1.7; }
}
@media (max-width:767px) {
 #hmab-chat-overlay { padding:0; align-items:stretch; }
 #hmab-chat-container { width:100%; height:100dvh; max-height:100dvh; min-height:0; border-radius:0; border:0; }
 .hmab-header { padding:12px 13px; min-height:68px; }
 .hmab-header-avatar { width:40px; height:40px; }
 .hmab-quick-replies { max-height:116px; overflow-y:auto; }
 .hmab-chip { white-space:normal; font-size:12px; padding:8px 11px; }
 .hmab-input-tools { gap:3px; }
 .hmab-tool-btn { width:32px; height:32px; font-size:15px; }
 #hmab-floating-btn { bottom:max(16px,env(safe-area-inset-bottom)); left:14px; }
}
@media (max-height:600px) {
 #hmab-chat-container { height:100dvh; max-height:100dvh; }
 .hmab-header { min-height:58px; padding:8px 12px; }
 .hmab-header-avatar { width:34px; height:34px; }
 .hmab-quick-replies { padding:5px 9px; }
 .hmab-whatsapp-cta { padding:5px 9px; }
 .hmab-whatsapp-cta a { padding:7px 10px; }
 .hmab-input-area { padding:6px 9px; }
}


/* v1.3.3 - شاشة أكبر حسب الجهاز + أيقونة واتساب فقط */
body.hmab-open #hmab-floating-btn { display:none !important; }
#hmab-chat-overlay { position:fixed; inset:0; padding:0; align-items:center; justify-content:center; }
#hmab-chat-container {
 width:100%; max-width:none; height:100%; max-height:100%; border-radius:0; border:0;
}
@supports (height:100dvh) { #hmab-chat-container { height:100dvh; max-height:100dvh; } }
.hmab-msg { max-width:92%; font-size:clamp(15px,2.2vw,18px); line-height:1.75; }
#hmab-message-input { font-size:16px; } /* يمنع تكبير iOS التلقائي */
.hmab-chip { font-size:clamp(13px,1.9vw,15px); }
.hmab-quick-replies { flex-wrap:nowrap; overflow-x:auto; max-height:none; -webkit-overflow-scrolling:touch; scrollbar-width:none; }
.hmab-quick-replies::-webkit-scrollbar { display:none; }
.hmab-chip { white-space:nowrap; flex:0 0 auto; }
.hmab-wa-mini {
 display:inline-flex; align-items:center; justify-content:center; width:38px; height:38px;
 margin-top:8px; border-radius:50%; background:#25d366; box-shadow:0 2px 8px rgba(37,211,102,.45);
 text-decoration:none; float:left;
}
.hmab-wa-mini:hover { background:#1ebe5b; }
@media (min-width:768px) {
 #hmab-chat-overlay { padding:2vh 2vw; }
 #hmab-chat-container {
  width:min(96vw, 820px); height:min(96dvh, 1000px); max-height:96dvh; border-radius:26px;
 }
}
@media (min-width:1280px) {
 #hmab-chat-container { width:min(92vw, 900px); }
}

/* v1.3.4 - أزرار الكاميرا/الميكروفون/السلة ظاهرة دائماً بألوان واضحة */
.hmab-input-area {
	display: flex !important;
	align-items: center !important;
	gap: 6px !important;
	padding: 10px 10px max(12px, env(safe-area-inset-bottom)) !important;
	background: #ffffff !important;
	border-top: 1px solid #d0e8e2 !important;
	flex-shrink: 0 !important;
	z-index: 5;
}
.hmab-input-tools {
	display: flex !important;
	align-items: center !important;
	gap: 4px !important;
	flex-shrink: 0 !important;
	visibility: visible !important;
	opacity: 1 !important;
}
.hmab-tool-btn {
	display: inline-flex !important;
	align-items: center !important;
	justify-content: center !important;
	width: 38px !important;
	height: 38px !important;
	min-width: 38px !important;
	border: none !important;
	border-radius: 50% !important;
	background: #e8f5f2 !important;
	color: #0b6b5f !important;
	font-size: 18px !important;
	cursor: pointer !important;
	visibility: visible !important;
	opacity: 1 !important;
	position: relative;
	box-shadow: 0 1px 3px rgba(11, 107, 95, 0.12);
	transition: background 0.15s, transform 0.15s, color 0.15s;
}
.hmab-tool-btn:hover,
.hmab-tool-btn:active {
	background: #0d9488 !important;
	color: #fff !important;
	transform: scale(1.06);
}
.hmab-tool-btn.active {
	background: #dc2626 !important;
	color: #fff !important;
	animation: hmabPulse 1s ease-in-out infinite;
}
.hmab-tool-cart {
	background: #fef3c7 !important;
	color: #92400e !important;
}
.hmab-tool-cart:hover {
	background: #f59e0b !important;
	color: #fff !important;
}
.hmab-tool-cart-count {
	position: absolute;
	top: -4px;
	left: -4px;
	min-width: 16px;
	height: 16px;
	padding: 0 4px;
	border-radius: 8px;
	background: #ea580c;
	color: #fff;
	font-size: 10px;
	font-weight: 700;
	line-height: 16px;
	text-align: center;
	border: 1.5px solid #fff;
}
#hmab-message-input {
	font-size: 16px !important;
	min-height: 42px !important;
}
#hmab-send-btn {
	width: 44px !important;
	height: 44px !important;
	min-width: 44px !important;
	flex-shrink: 0 !important;
}
.hmab-recording {
	display: none;
	align-items: center;
	gap: 8px;
	padding: 8px 14px;
	background: #fef2f2;
	color: #b91c1c;
	font-size: 13px;
	font-weight: 600;
}
.hmab-recording.active {
	display: flex !important;
}
.hmab-rec-dot {
	width: 10px;
	height: 10px;
	border-radius: 50%;
	background: #ef4444;
	animation: hmabPulse 1s ease-in-out infinite;
}
.hmab-cart-summary {
	display: none;
	padding: 8px 14px;
	background: #e2f8ef;
	color: #124b42;
	font-size: 13px;
	border-bottom: 1px solid #a8e2d3;
}
.hmab-cart-summary.visible {
	display: block !important;
}
@media (max-width: 400px) {
	.hmab-tool-btn {
		width: 34px !important;
		height: 34px !important;
		min-width: 34px !important;
		font-size: 16px !important;
	}
	.hmab-input-tools { gap: 2px !important; }
}

/* v1.4.0 */
.hmab-pending-images { position: relative; display: inline-block; margin: 6px 4px 0; }
.hmab-pending-images img { display: block; }
.hmab-pending-remove {
  position: absolute; top: -6px; left: -6px; width: 22px; height: 22px;
  border: none; border-radius: 50%; background: #dc2626; color: #fff;
  font-size: 14px; line-height: 22px; cursor: pointer; box-shadow: 0 1px 4px rgba(0,0,0,.2);
}
.hmab-typing.active { display: flex !important; }


/* v1.7 - cart actions, TTS, reorder */
.hmab-cart-actions {
  display: flex; flex-wrap: wrap; gap: 8px; padding: 4px 12px 10px;
}
.hmab-cart-action-btn {
  border: none; cursor: pointer; border-radius: 999px; padding: 9px 14px;
  background: linear-gradient(135deg, #10b981, #0f766e); color: #fff;
  font-size: 13px; font-weight: 700; box-shadow: 0 3px 10px rgba(15,118,110,.25);
}
.hmab-cart-action-btn:active { transform: scale(.97); }
.hmab-msg-actions {
  display: flex; align-items: center; gap: 8px; margin-top: 8px; clear: both;
}
.hmab-tts-btn {
  width: 36px; height: 36px; border-radius: 50%; border: none; cursor: pointer;
  background: #e0f2fe; font-size: 16px;
}
.hmab-tts-btn:hover { background: #bae6fd; }
.hmab-wa-mini {
  display: inline-flex; align-items: center; justify-content: center;
  width: 36px; height: 36px; border-radius: 50%; background: #25d366;
  box-shadow: 0 2px 8px rgba(37,211,102,.4); text-decoration: none;
}

/* v1.8 trust, new chat, cart confirm, human CTA */
.hmab-trust-bar {
  flex-shrink: 0;
  padding: 8px 12px;
  background: #fff7ed;
  border-bottom: 1px solid #fed7aa;
  font-size: 12px;
  color: #9a3412;
  line-height: 1.45;
}
.hmab-trust-text { display: block; font-weight: 600; }
.hmab-hours-text { display: block; margin-top: 3px; color: #78716c; font-weight: 500; }
.hmab-human-cta {
  flex-shrink: 0;
  padding: 6px 12px 8px;
  background: #fff;
  border-top: 1px solid #e2e8f0;
  text-align: center;
}
.hmab-human-cta a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  background: #ecfdf5;
  border: 1px solid #6ee7b7;
  color: #065f46;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
}
.hmab-human-cta a:hover { background: #d1fae5; }
.hmab-cart-confirm {
  margin: 6px 12px 12px;
  padding: 12px 14px;
  border-radius: 14px;
  background: linear-gradient(180deg, #ecfdf5, #f0fdfa);
  border: 1px solid #6ee7b7;
  box-shadow: 0 4px 14px rgba(15, 118, 110, 0.1);
}
.hmab-cart-confirm-title { font-weight: 800; color: #065f46; margin-bottom: 4px; }
.hmab-cart-confirm-name { font-size: 14px; color: #134e4a; font-weight: 600; }
.hmab-cart-confirm-meta { font-size: 12px; color: #3f6f68; margin-top: 3px; }
.hmab-cart-confirm-link {
  display: inline-block; margin-top: 10px; padding: 8px 12px; border-radius: 999px;
  background: #0f766e; color: #fff !important; text-decoration: none; font-size: 13px; font-weight: 700;
}
.hmab-typing { display: none; align-items: center; gap: 8px; }
.hmab-typing.active { display: flex !important; }
.hmab-typing-label { font-size: 12px; color: #64748b; font-style: normal; }
#hmab-newchat-btn { font-size: 18px; line-height: 1; }

/* =========================================================
   v2.0 AI Chat UI — مظهر حديث شبيه بمساعدات الذكاء الاصطناعي
   ========================================================= */
:root {
  --hmab-primary: #0d9488;
  --hmab-primary-dark: #0f766e;
  --hmab-primary-light: #2dd4bf;
  --hmab-accent: #f97316;
  --hmab-bg: #f3faf8;
  --hmab-user-bg: #ccfbf1;
  --hmab-bot-bg: #ffffff;
  --hmab-text: #134e4a;
  --hmab-text-dark: #0f172a;
  --hmab-border: #99f6e4;
  --hmab-shadow: 0 20px 50px rgba(13, 148, 136, 0.18);
  --hmab-radius: 18px;
  --hmab-glass: rgba(255,255,255,0.72);
}

#hmab-chat-container {
  background:
    radial-gradient(1200px 400px at 100% -10%, rgba(45, 212, 191, 0.18), transparent 60%),
    radial-gradient(900px 360px at -10% 110%, rgba(13, 148, 136, 0.12), transparent 55%),
    linear-gradient(180deg, #f8fffd 0%, #eef9f6 48%, #f4fbfa 100%) !important;
  box-shadow: var(--hmab-shadow) !important;
}

.hmab-header {
  background: linear-gradient(120deg, #0f766e 0%, #0d9488 45%, #14b8a6 100%) !important;
  backdrop-filter: blur(8px);
  border-bottom: 1px solid rgba(255,255,255,0.12);
}

.hmab-header-avatar {
  background: linear-gradient(145deg, rgba(255,255,255,0.28), rgba(255,255,255,0.08)) !important;
  box-shadow: inset 0 0 0 1px rgba(255,255,255,0.25), 0 6px 16px rgba(0,0,0,0.12);
  font-size: 22px !important;
}

.hmab-header-info h3 {
  letter-spacing: -0.02em;
  font-weight: 800 !important;
}

.hmab-header-btn {
  background: rgba(255,255,255,0.14) !important;
  border: 1px solid rgba(255,255,255,0.18) !important;
  color: #fff !important;
  border-radius: 12px !important;
  transition: background .15s, transform .15s;
}
.hmab-header-btn:hover {
  background: rgba(255,255,255,0.28) !important;
  transform: translateY(-1px);
}

.hmab-messages {
  padding: 16px 14px 20px !important;
  gap: 14px !important;
  scroll-behavior: auto;
}

.hmab-msg {
  position: relative;
  max-width: min(92%, 560px) !important;
  border-radius: 18px !important;
  padding: 12px 14px 22px !important;
  line-height: 1.7 !important;
  font-size: clamp(14.5px, 2.1vw, 16px) !important;
  animation: hmabPop .28s cubic-bezier(.22,1,.36,1);
  box-shadow: 0 4px 18px rgba(15, 68, 62, 0.06);
}

@keyframes hmabPop {
  from { opacity: 0; transform: translateY(10px) scale(.98); }
  to   { opacity: 1; transform: translateY(0) scale(1); }
}

.hmab-msg.bot {
  background: var(--hmab-glass) !important;
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 1px solid rgba(167, 243, 208, 0.65) !important;
  color: var(--hmab-text-dark) !important;
  border-bottom-right-radius: 6px !important;
  margin-inline-end: auto;
}

.hmab-msg.user {
  background: linear-gradient(145deg, #5eead4, #99f6e4 40%, #ccfbf1) !important;
  border: 1px solid #5eead4 !important;
  color: #115e59 !important;
  border-bottom-left-radius: 6px !important;
  margin-inline-start: auto;
  font-weight: 500;
}

.hmab-msg .hmab-time {
  opacity: .55;
  font-size: 11px !important;
  bottom: 6px;
}

.hmab-msg.bot .hmab-content strong {
  color: #0f766e;
}

.hmab-typing {
  padding: 4px 16px 10px !important;
  gap: 10px !important;
}
.hmab-typing span {
  width: 8px; height: 8px;
  background: #2dd4bf;
  border-radius: 50%;
  animation: hmabDot 1.2s ease-in-out infinite;
}
.hmab-typing span:nth-child(2) { animation-delay: .15s; }
.hmab-typing span:nth-child(3) { animation-delay: .3s; }
@keyframes hmabDot {
  0%, 80%, 100% { transform: translateY(0); opacity: .35; }
  40% { transform: translateY(-5px); opacity: 1; }
}

.hmab-chip {
  background: rgba(255,255,255,0.9) !important;
  border: 1px solid #99f6e4 !important;
  color: #0f766e !important;
  border-radius: 999px !important;
  padding: 9px 14px !important;
  font-weight: 700 !important;
  box-shadow: 0 2px 8px rgba(13,148,136,0.08);
  transition: transform .15s, box-shadow .15s, background .15s;
}
.hmab-chip:hover {
  background: #ccfbf1 !important;
  transform: translateY(-1px);
  box-shadow: 0 6px 16px rgba(13,148,136,0.14);
}

.hmab-input-area {
  background: rgba(255,255,255,0.92) !important;
  backdrop-filter: blur(12px);
  border-top: 1px solid rgba(153,246,228,0.7) !important;
  box-shadow: 0 -8px 24px rgba(15,118,110,0.05);
}

#hmab-message-input {
  background: #f0fdfa !important;
  border: 1.5px solid #99f6e4 !important;
  border-radius: 22px !important;
  transition: border-color .15s, box-shadow .15s, background .15s;
}
#hmab-message-input:focus {
  background: #fff !important;
  border-color: #2dd4bf !important;
  box-shadow: 0 0 0 4px rgba(45, 212, 191, 0.18);
}

#hmab-send-btn {
  background: linear-gradient(145deg, #2dd4bf, #0d9488) !important;
  box-shadow: 0 8px 20px rgba(13, 148, 136, 0.35) !important;
}
#hmab-send-btn:hover { transform: scale(1.06); }

.hmab-tool-btn {
  background: #ecfdf5 !important;
  color: #0f766e !important;
  box-shadow: 0 1px 4px rgba(15,118,110,0.08);
}
.hmab-tool-btn:hover {
  background: #0d9488 !important;
  color: #fff !important;
}

#hmab-floating-btn {
  background: linear-gradient(135deg, #2dd4bf, #0f766e) !important;
  box-shadow: 0 14px 34px rgba(13, 148, 136, 0.4) !important;
  border: 1px solid rgba(255,255,255,0.25);
}
#hmab-floating-btn:hover {
  transform: translateY(-2px) scale(1.03);
}

.hmab-trust-bar {
  background: linear-gradient(90deg, #fff7ed, #ffedd5) !important;
  border-bottom: 1px solid #fdba74 !important;
}

.hmab-human-cta a {
  background: linear-gradient(135deg, #ecfdf5, #d1fae5) !important;
  box-shadow: 0 2px 10px rgba(16, 185, 129, 0.12);
}

.hmab-cart-action-btn {
  background: linear-gradient(135deg, #2dd4bf, #0f766e) !important;
  box-shadow: 0 6px 16px rgba(13,148,136,0.28) !important;
}

.hmab-cart-confirm {
  background: linear-gradient(160deg, rgba(236,253,245,0.95), rgba(204,251,241,0.9)) !important;
  border: 1px solid #5eead4 !important;
  backdrop-filter: blur(8px);
}

.hmab-msg-actions .hmab-tts-btn {
  background: #e0f2fe !important;
  box-shadow: 0 2px 6px rgba(14,165,233,0.15);
}
.hmab-wa-mini {
  box-shadow: 0 4px 12px rgba(37, 211, 102, 0.4) !important;
}

/* شريط حالة AI صغير */
.hmab-ai-status {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 11px;
  color: #f0fdfa;
  opacity: .9;
}
.hmab-ai-status i {
  width: 7px; height: 7px; border-radius: 50%;
  background: #6ee7b7;
  box-shadow: 0 0 0 0 rgba(110, 231, 183, 0.7);
  animation: hmabPulseDot 1.8s infinite;
}
@keyframes hmabPulseDot {
  0% { box-shadow: 0 0 0 0 rgba(110, 231, 183, 0.55); }
  70% { box-shadow: 0 0 0 8px rgba(110, 231, 183, 0); }
  100% { box-shadow: 0 0 0 0 rgba(110, 231, 183, 0); }
}
.hmab-bot-label {
  font-size: 11px;
  font-weight: 700;
  color: #0d9488;
  margin-bottom: 4px;
  letter-spacing: 0.02em;
  opacity: .85;
}

/* v1.9.2 patient UX */
.hmab-wait-actions {
  text-align: center;
  padding: 0 12px 10px;
}
.hmab-wait-actions a {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  border-radius: 999px;
  background: #dcfce7;
  border: 1px solid #86efac;
  color: #166534;
  font-size: 13px;
  font-weight: 700;
  text-decoration: none;
  animation: hmabPop .3s ease;
}
.hmab-catalog-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
  padding: 4px 12px 12px;
}
.hmab-catalog-card {
  background: #fff;
  border: 1px solid #99f6e4;
  border-radius: 14px;
  padding: 10px 12px;
  box-shadow: 0 3px 12px rgba(13,148,136,.08);
}
.hmab-catalog-name { font-weight: 700; color: #134e4a; font-size: 14px; }
.hmab-catalog-meta { font-size: 12.5px; color: #0f766e; margin-top: 3px; }
.hmab-catalog-add {
  margin-top: 8px;
  border: none;
  border-radius: 999px;
  padding: 7px 12px;
  background: linear-gradient(135deg,#2dd4bf,#0d9488);
  color: #fff;
  font-weight: 700;
  font-size: 12.5px;
  cursor: pointer;
}

/* v1.9.3 — أيقونات الشريط السفلي ظاهرة جداً (SVG بدل الإيموجي) + تنبيه آخر المحادثة */
.hmab-input-tools { gap: 6px !important; }
.hmab-tool-btn {
  width: 42px !important; height: 42px !important; min-width: 42px !important;
  padding: 0 !important; border: 0 !important; border-radius: 50% !important;
  color: #ffffff !important; box-shadow: 0 3px 8px rgba(0,0,0,.22) !important;
  display: inline-flex !important; align-items: center; justify-content: center;
  visibility: visible !important; opacity: 1 !important; position: relative;
}
.hmab-tool-btn .hmab-ico { width: 22px; height: 22px; display: block; stroke: #ffffff !important; color: #fff; }
#hmab-btn-camera { background: #0d9488 !important; }
#hmab-btn-upload { background: #2563eb !important; }
#hmab-btn-voice  { background: #7c3aed !important; }
#hmab-btn-cart   { background: #ea580c !important; }
.hmab-tool-btn:hover, .hmab-tool-btn:active { filter: brightness(1.1); transform: scale(1.06); color: #fff !important; }
.hmab-tool-btn.active { background: #dc2626 !important; }
.hmab-tool-cart-count {
  position: absolute; top: -5px; left: -5px; min-width: 18px; height: 18px; padding: 0 4px;
  border-radius: 9px; background: #dc2626; color: #fff !important; font-size: 11px; font-weight: 800;
  line-height: 18px; text-align: center; border: 2px solid #fff !important; box-sizing: content-box;
}
@media (max-width: 400px) {
  .hmab-tool-btn { width: 38px !important; height: 38px !important; min-width: 38px !important; }
  .hmab-tool-btn .hmab-ico { width: 20px; height: 20px; }
  .hmab-input-tools { gap: 4px !important; }
}


/* v1.9.3b — إخفاء زر الفتح أثناء المحادثة + أزرار المتابعة */
html body.hmab-open #hmab-floating-btn { display: none !important; visibility: hidden !important; pointer-events: none !important; }
.hmab-followups { display: flex; flex-wrap: wrap; gap: 6px; justify-content: flex-start; margin: 6px 12px 4px; }
.hmab-followup-chip {
  font-size: 12.5px; padding: 7px 12px; border-radius: 999px; cursor: pointer;
  background: #ecfdf5; color: #065f46; border: 1px solid #6ee7b7; font-weight: 700;
}
.hmab-followup-chip:active { background: #0d9488; color: #fff; }
.hmab-content { font-size: 15px; line-height: 1.75; }

/* تحسين زر الإرسال: حالة واضحة أثناء إرسال الرسالة */
#hmab-send-btn { min-width: 48px; min-height: 48px; font-size: 20px; position: relative; }
#hmab-send-btn.hmab-sending { opacity: 1; cursor: wait; transform: none; }
.hmab-send-spinner { display: inline-block; width: 19px; height: 19px; border: 2.5px solid rgba(255,255,255,.45); border-top-color: #fff; border-radius: 50%; animation: hmab-send-spin .7s linear infinite; }
@keyframes hmab-send-spin { to { transform: rotate(360deg); } }
@media (prefers-reduced-motion: reduce) { .hmab-send-spinner { animation-duration: 1.8s; } }
.hmab-human-cta { margin: 10px 12px; padding: 0; border: 0; background: transparent; text-align: center; }
.hmab-human-cta a { box-shadow: 0 3px 12px rgba(16,185,129,.16); }

/* v1.10.0: product source metadata and detail link */
.hmab-catalog-source{font-size:11px;line-height:1.5;color:#64748b;margin-top:4px}
.hmab-catalog-details{display:inline-block;margin:7px 8px 0 0;font-size:12px;text-decoration:underline;color:inherit}

/* v1.10.7 catalog usability and confidence labels */
.hmab-catalog-cards{display:grid;grid-template-columns:1fr;gap:10px;margin:12px 0;max-width:100%}.hmab-catalog-card{border:1px solid #d8dee8;border-radius:12px;padding:12px;background:#fff;min-width:0;overflow-wrap:anywhere}.hmab-catalog-name{font-weight:700;line-height:1.5;margin-bottom:6px}.hmab-catalog-meta{line-height:1.7}.hmab-catalog-source{font-size:12px;line-height:1.6;color:#596579;margin-top:5px}.hmab-match-confidence{font-weight:600;color:#374151}.hmab-catalog-details,.hmab-catalog-add{display:inline-block;margin-top:10px;margin-inline-end:8px;min-height:38px;padding:8px 12px;border-radius:8px}.hmab-catalog-add{border:0;cursor:pointer;background:#14532d;color:#fff}.hmab-catalog-add:disabled{opacity:.65;cursor:wait}

/* v1.11.8: clearer cart breakdown and accessible read-aloud controls */
.hmab-cart-summary { text-align: right; line-height: 1.6; max-height: 34vh; overflow-y: auto; }
.hmab-cart-summary-heading { font-weight: 800; margin-bottom: 5px; }
.hmab-cart-summary-items { list-style: none; padding: 0; margin: 5px 0; }
.hmab-cart-summary-items li { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; padding: 5px 0; border-bottom: 1px solid rgba(18,75,66,.12); }
.hmab-cart-summary-items li span { min-width: 0; overflow-wrap: anywhere; }
.hmab-cart-summary-items li small { flex: 0 0 auto; max-width: 48%; text-align: left; }
.hmab-cart-summary-total { font-weight: 800; margin-top: 7px; }
.hmab-cart-summary-notice { margin-top: 5px; color: #92400e; background: #fffbeb; padding: 7px; border-radius: 7px; font-size: 12px; }
.hmab-cart-summary-link { display: inline-block; margin-top: 6px; font-weight: 700; text-decoration: underline; }
.hmab-tts-btn { min-width: 38px; min-height: 34px; padding: 5px 9px; }
@media (max-width: 480px) { .hmab-cart-summary { font-size: 12px; max-height: 30vh; } .hmab-cart-summary-items li { gap: 6px; } }

/* v1.12.0: selectable quantities and external medicine-reference search links */
.hmab-catalog-add-row{display:flex;align-items:center;gap:8px;flex-wrap:wrap;margin-top:10px}.hmab-catalog-add-row label{display:inline-flex;align-items:center;gap:6px;font-size:13px}.hmab-catalog-quantity{min-width:64px;min-height:38px;border:1px solid #cbd5e1;border-radius:8px;background:#fff;padding:6px;color:#111827}.hmab-catalog-source-links{font-size:12px;line-height:1.8;margin-top:8px;color:#596579;overflow-wrap:anywhere}.hmab-catalog-source-links a{color:#14532d;text-decoration:underline}.hmab-catalog-add-row .hmab-catalog-add{margin-top:0}


/* v1.12.3: accessible polished interface and WooCommerce cart drawer */
.hmab-header-actions { gap: 6px; align-items: center; }
.hmab-header-btn { position: relative; display: inline-flex; align-items: center; justify-content: center; }
.hmab-header-cart-btn { min-width: 40px; }
.hmab-header-cart-count, .hmab-tool-cart-count { position: absolute; top: -4px; inset-inline-start: -4px; min-width: 18px; height: 18px; padding: 0 4px; border-radius: 99px; background: #f97316; color: #fff; border: 2px solid #fff; align-items: center; justify-content: center; font-size: 10px; font-weight: 800; line-height: 1; }
.hmab-tool-cart { position: relative; }
.hmab-cart-summary { position: relative; max-height: min(42vh, 360px); overflow-y: auto; padding: 12px; text-align: start; background: #f0fdf8; border-bottom: 1px solid #b7e4d7; box-shadow: 0 5px 15px rgba(15,118,110,.06); }
.hmab-cart-summary-top { display:flex; align-items:center; justify-content:space-between; gap:8px; margin-bottom:8px; }
.hmab-cart-summary-heading { font-size:14px; }
.hmab-cart-summary-close { border:0; background:transparent; font-size:24px; line-height:1; color:#334155; min-width:32px; min-height:32px; cursor:pointer; }
.hmab-cart-summary-items { margin:0; padding:0; list-style:none; }
.hmab-cart-item { display:flex; align-items:flex-start; justify-content:space-between; gap:10px; padding:10px 0; border-bottom:1px solid rgba(18,75,66,.13); }
.hmab-cart-item-details { display:flex; flex:1; min-width:0; flex-direction:column; gap:4px; }
.hmab-cart-item-name { font-size:13px; font-weight:750; overflow-wrap:anywhere; }
.hmab-cart-item-price,.hmab-cart-item-line { font-size:11px; line-height:1.5; color:#475569; }
.hmab-cart-item-controls { display:flex; align-items:center; justify-content:flex-start; gap:5px; flex-wrap:wrap; flex:0 0 auto; }
.hmab-cart-qty-btn { width:28px; height:28px; border:1px solid #b7d9d0; border-radius:8px; background:#fff; color:#065f56; font-weight:800; cursor:pointer; }
.hmab-cart-qty-value { min-width:18px; text-align:center; font-weight:800; }
.hmab-cart-remove-btn { min-height:28px; padding:3px 7px; border:1px solid #fecaca; border-radius:7px; background:#fff; color:#b91c1c; font-size:11px; cursor:pointer; }
.hmab-cart-summary-total { padding-top:9px; font-size:14px; font-weight:850; }
.hmab-cart-summary-notice { line-height:1.65; }
.hmab-cart-summary-link { display:flex; align-items:center; justify-content:center; min-height:42px; margin-top:10px; padding:9px 12px; border-radius:10px; background:#087f68; color:#fff !important; text-align:center; text-decoration:none !important; font-weight:800; }
.hmab-cart-empty { padding:12px 4px; text-align:center; color:#475569; }
.hmab-cart-summary[aria-busy="true"] { opacity:.72; pointer-events:none; }
.hmab-tts-btn { display:inline-flex; align-items:center; gap:5px; margin-top:6px; padding:4px 9px; min-height:28px; border:1px solid #cbd5e1; border-radius:8px; background:#fff; color:#334155; font-size:11px; cursor:pointer; }
.hmab-tts-btn:hover { background:#f0fdfa; border-color:#0d9488; }
.hmab-input-area { position:relative; flex-shrink:0; padding-bottom:max(12px,env(safe-area-inset-bottom)); }
.hmab-input-wrap textarea { min-height:42px; max-height:120px; resize:none; line-height:1.5; }
.hmab-tool-btn, #hmab-send-btn, .hmab-header-btn, .hmab-chip { touch-action:manipulation; }
.hmab-tool-btn:disabled, #hmab-send-btn:disabled { opacity:.55; cursor:wait; }
.hmab-catalog-card { box-shadow:0 2px 9px rgba(15,23,42,.04); }
.hmab-catalog-add:focus-visible, .hmab-cart-summary-link:focus-visible, .hmab-cart-qty-btn:focus-visible, .hmab-cart-remove-btn:focus-visible, .hmab-tts-btn:focus-visible { outline:3px solid #f59e0b; outline-offset:2px; }
@media (max-width:480px) {
 .hmab-cart-item { flex-direction:column; }
 .hmab-cart-item-controls { width:100%; }
 .hmab-cart-summary { max-height:34vh; }
 .hmab-header-cart-btn { min-width:34px; }
}
@media (prefers-reduced-motion:reduce) {
 #hmab-chat-container,.hmab-msg,#hmab-floating-btn { animation:none!important; transition:none!important; scroll-behavior:auto!important; }
}


/* ============================================================
   v1.12.8 STABILITY — no position:fixed on body, no overlay-click close,
   no enter animations, stable heights, no page shake.
   ============================================================ */

html.hmab-open,
html.hmab-open body,
body.hmab-open {
  overscroll-behavior: none !important;
  /* لا نغيّر overflow/position للصفحة حتى لا يعيد متصفح الهاتف حساب الـ viewport ويهتز. */
}

body.hmab-open #hmab-floating-btn {
  display: none !important;
  visibility: hidden !important;
  pointer-events: none !important;
}

#hmab-chat-overlay {
  box-sizing: border-box !important;
  position: fixed !important;
  top: 0 !important;
  left: 0 !important;
  right: 0 !important;
  bottom: 0 !important;
  width: 100% !important;
  height: 100% !important;
  max-width: none !important;
  max-height: none !important;
  margin: 0 !important;
  padding: 0 !important;
  overflow: hidden !important;
  overscroll-behavior: none !important;
  backdrop-filter: none !important;
  -webkit-backdrop-filter: none !important;
  z-index: 2147483000 !important;
  touch-action: none;
  -webkit-overflow-scrolling: auto;
}
#hmab-chat-overlay:not(.active) {
  display: none !important;
  pointer-events: none !important;
}
#hmab-chat-overlay.active {
  display: flex !important;
  align-items: stretch !important;
  justify-content: center !important;
  pointer-events: auto !important;
}

#hmab-chat-container {
  animation: none !important;
  transition: none !important;
  transform: none !important;
  will-change: auto !important;
  min-width: 0 !important;
  min-height: 0 !important;
  overflow: hidden !important;
  overscroll-behavior: contain !important;
  display: flex !important;
  flex-direction: column !important;
  box-sizing: border-box !important;
}

/* موبايل: ارتفاع ثابت 100% من الـ overlay — يلغي كل قواعد 100dvh السابقة */
@media (max-width: 767px) {
  #hmab-chat-overlay.active {
    padding: 0 !important;
    height: 100svh !important;
    min-height: 100svh !important;
  }
  #hmab-chat-container,
  #hmab-chat-overlay #hmab-chat-container {
    width: 100% !important;
    max-width: 100% !important;
    height: 100% !important;
    max-height: 100% !important;
    min-height: 0 !important;
    border-radius: 0 !important;
    margin: 0 !important;
    border: 0 !important;
  }
}
@media (min-width: 768px) {
  #hmab-chat-overlay.active {
    padding: 24px !important;
    align-items: center !important;
  }
  #hmab-chat-container {
    width: min(520px, 100%) !important;
    height: min(720px, 100%) !important;
    max-height: 100% !important;
    border-radius: 16px !important;
    margin: 0 auto !important;
  }
}

#hmab-chat-container .hmab-messages {
  flex: 1 1 auto !important;
  min-height: 0 !important;
  overflow-x: hidden !important;
  overflow-y: auto !important;
  overscroll-behavior: contain !important;
  overflow-anchor: none !important;
  scroll-behavior: auto !important;
  -webkit-overflow-scrolling: touch;
  touch-action: pan-y !important;
}
#hmab-chat-container .hmab-cart-summary {
  max-height: 240px !important;
  overflow-y: auto !important;
  overscroll-behavior: contain !important;
  scroll-behavior: auto !important;
  touch-action: pan-y !important;
}
#hmab-chat-container .hmab-msg {
  animation: none !important;
  transition: none !important;
}
#hmab-chat-container button,
#hmab-chat-container a,
#hmab-chat-container textarea {
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation;
}
#hmab-message-input {
  font-size: 16px !important;
}

/* ثبات المساحات: الكتابة لا توسّع الشاشة ولا تضغط الرسائل */
#hmab-chat-container .hmab-header,
#hmab-chat-container .hmab-trust-bar,
#hmab-chat-container .hmab-quick-replies,
#hmab-chat-container .hmab-input-area {
  flex-shrink: 0 !important;
}
#hmab-chat-container .hmab-messages {
  flex: 1 1 auto !important;
  min-height: 120px !important;
}
#hmab-chat-container .hmab-input-area {
  min-height: 58px !important;
  max-height: 100px !important;
  overflow: hidden !important;
  align-items: flex-end !important;
}
#hmab-chat-container .hmab-input-wrap {
  max-height: 72px !important;
  overflow: hidden !important;
  min-width: 0 !important;
}
#hmab-chat-container #hmab-message-input {
  min-height: 44px !important;
  max-height: 72px !important; /* سطران كحد أقصى */
  overflow-y: auto !important;
  resize: none !important;
  line-height: 1.4 !important;
  box-sizing: border-box !important;
}
#hmab-chat-container .hmab-typing:not(.active) {
  display: none !important;
  height: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  overflow: hidden !important;
}
#hmab-chat-container .hmab-cart-summary:not(.visible) {
  display: none !important;
  max-height: 0 !important;
  padding: 0 !important;
  margin: 0 !important;
  border: 0 !important;
  overflow: hidden !important;
}
#hmab-chat-container .hmab-cart-summary.visible {
  flex-shrink: 0 !important;
  max-height: 200px !important;
}

#hmab-floating-btn {
  transition: none !important;
  animation: none !important;
}
#hmab-floating-btn:hover {
  transform: none !important;
}

/* ============================================================
   v1.13.2 STABILITY CLEANUP
   - One collapse style only; no duplicated v1.9/v1.13 rules.
   - No global touchmove/wheel interception.
   - Mobile chat uses stable small viewport sizing.
   ============================================================ */
#hmab-chat-overlay {
  touch-action: none !important;
  overscroll-behavior: none !important;
}
#hmab-chat-container {
  min-height: 0 !important;
  max-height: 100% !important;
}
#hmab-chat-container .hmab-messages {
  min-height: 0 !important;
  touch-action: pan-y !important;
  overscroll-behavior: contain !important;
  overflow-anchor: none !important;
}
#hmab-chat-container .hmab-quick-replies {
  touch-action: pan-x !important;
  overscroll-behavior: contain !important;
}
#hmab-chat-container .hmab-content.hmab-collapsed {
  max-height: 7.5em !important;
  overflow: hidden !important;
  position: relative !important;
}
#hmab-chat-container .hmab-content.hmab-collapsed::after {
  content: '' !important;
  position: absolute !important;
  inset-inline: 0 !important;
  bottom: 0 !important;
  height: 2.5em !important;
  background: linear-gradient(to bottom, rgba(255,255,255,0), var(--hmab-glass, #fff)) !important;
  pointer-events: none !important;
}
#hmab-chat-container .hmab-more-btn {
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  min-height: 34px !important;
  padding: 5px 12px !important;
  margin-top: 7px !important;
  border: 1px solid rgba(13,148,136,.25) !important;
  border-radius: 999px !important;
  background: #fff !important;
  color: #0d9488 !important;
  font-weight: 800 !important;
  font-size: 12.5px !important;
  line-height: 1.3 !important;
  cursor: pointer !important;
  touch-action: manipulation !important;
}
#hmab-chat-container .hmab-more-btn:active { transform: none !important; }
@media (max-width: 767px) {
  #hmab-chat-overlay.active {
    height: 100svh !important;
    min-height: 100svh !important;
  }
  #hmab-chat-container {
    height: 100% !important;
    max-height: 100% !important;
  }
}
