/* AI Smart Commerce — website chat widget. Everything is scoped under #asc-chat. */

#asc-chat {
	--asc-primary: #128c7e;
	--asc-on-primary: #fff;
	--asc-bg: #efeae2;
	--asc-surface: #fff;
	--asc-text: #111b21;
	--asc-muted: #667781;
	--asc-border: #e2e2e2;
	--asc-in: #fff;
	--asc-system: rgba(255, 255, 255, 0.85);
	--asc-chip-bg: #fff;
	--asc-shadow: 0 12px 40px rgba(0, 0, 0, 0.18);
	--asc-radius: 16px;
	position: fixed;
	bottom: 20px;
	z-index: 2147483000;
	font: 15px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Noto Sans", "Noto Sans Bengali", "Noto Naskh Arabic", "Helvetica Neue", Arial, sans-serif;
	color: var(--asc-text);
	text-align: start;
	letter-spacing: normal;
	text-transform: none;
}
#asc-chat *,
#asc-chat *::before,
#asc-chat *::after { box-sizing: border-box; }
#asc-chat.asc-chat--right { right: 20px; }
#asc-chat.asc-chat--left { left: 20px; }

#asc-chat[data-theme="dark"] {
	--asc-bg: #0b141a;
	--asc-surface: #1f2c34;
	--asc-text: #e9edef;
	--asc-muted: #8696a0;
	--asc-border: #2a3942;
	--asc-in: #202c33;
	--asc-system: rgba(32, 44, 51, 0.92);
	--asc-chip-bg: #202c33;
}
@media (prefers-color-scheme: dark) {
	#asc-chat[data-theme="auto"] {
		--asc-bg: #0b141a;
		--asc-surface: #1f2c34;
		--asc-text: #e9edef;
		--asc-muted: #8696a0;
		--asc-border: #2a3942;
		--asc-in: #202c33;
		--asc-system: rgba(32, 44, 51, 0.92);
		--asc-chip-bg: #202c33;
	}
}

#asc-chat button,
#asc-chat textarea,
#asc-chat input { font: inherit; color: inherit; margin: 0; }
#asc-chat a { color: inherit; }
#asc-chat img { max-width: 100%; }

/* Launcher */
.asc-chat__launcher {
	position: relative;
	display: flex;
	align-items: center;
	justify-content: center;
	width: 60px;
	height: 60px;
	border: 0;
	border-radius: 50%;
	background: var(--asc-primary);
	color: var(--asc-on-primary) !important;
	box-shadow: var(--asc-shadow);
	cursor: pointer;
	padding: 0;
	transition: transform 0.15s ease;
}
.asc-chat--left .asc-chat__launcher { margin-right: auto; }
.asc-chat--right .asc-chat__launcher { margin-left: auto; }
.asc-chat__launcher:hover { transform: scale(1.05); }
.asc-chat__launcher:focus-visible,
#asc-chat button:focus-visible,
#asc-chat a:focus-visible,
#asc-chat textarea:focus-visible { outline: 3px solid var(--asc-primary); outline-offset: 2px; }
.asc-chat__launcher-img { width: 100%; height: 100%; object-fit: cover; border-radius: 50%; }
.asc-chat__badge {
	position: absolute;
	top: -2px;
	right: -2px;
	min-width: 22px;
	height: 22px;
	padding: 0 6px;
	border-radius: 11px;
	background: #e11d48;
	color: #fff;
	font-size: 12px;
	font-weight: 700;
	line-height: 22px;
	text-align: center;
}

/* Panel */
.asc-chat__panel {
	position: absolute;
	bottom: 76px;
	width: 370px;
	height: min(600px, calc(100vh - 120px));
	display: flex;
	flex-direction: column;
	border-radius: var(--asc-radius);
	overflow: hidden;
	background: var(--asc-bg);
	box-shadow: var(--asc-shadow);
	animation: asc-chat-in 0.18s ease-out;
}
.asc-chat__panel[hidden] { display: none; }
.asc-chat--right .asc-chat__panel { right: 0; }
.asc-chat--left .asc-chat__panel { left: 0; }
@keyframes asc-chat-in {
	from { opacity: 0; transform: translateY(12px); }
	to { opacity: 1; transform: none; }
}

/* Header */
.asc-chat__header {
	display: flex;
	align-items: center;
	gap: 10px;
	padding-block: 12px;
	padding-inline: 14px 10px;
	background: var(--asc-primary);
	color: var(--asc-on-primary);
	flex: 0 0 auto;
}
.asc-chat__avatar {
	flex: 0 0 40px;
	width: 40px;
	height: 40px;
	border-radius: 50%;
	background: rgba(255, 255, 255, 0.25);
	display: flex;
	align-items: center;
	justify-content: center;
	font-weight: 700;
	overflow: hidden;
}
.asc-chat__avatar img { width: 100%; height: 100%; object-fit: cover; }
.asc-chat__heading { flex: 1 1 auto; min-width: 0; }
.asc-chat__title { font-weight: 600; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.asc-chat__status { font-size: 12px; opacity: 0.92; display: flex; align-items: center; gap: 6px; }
.asc-chat__dot { width: 8px; height: 8px; border-radius: 50%; background: #c7c7c7; }
.asc-chat__dot.is-online { background: #4ade80; box-shadow: 0 0 0 2px rgba(74, 222, 128, 0.35); }
.asc-chat__actions { display: flex; align-items: center; gap: 2px; flex: 0 0 auto; }
.asc-chat__icon-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	border: 0;
	border-radius: 50%;
	background: transparent;
	color: var(--asc-on-primary) !important;
	cursor: pointer;
	padding: 0;
	text-decoration: none;
}
.asc-chat__icon-btn:hover { background: rgba(255, 255, 255, 0.16); }

/* Messages */
.asc-chat__log {
	flex: 1 1 auto;
	overflow-y: auto;
	padding: 14px 12px 6px;
	display: flex;
	flex-direction: column;
	gap: 6px;
	overscroll-behavior: contain;
}
.asc-chat__msg { display: flex; }
.asc-chat__msg--customer { justify-content: flex-end; }
.asc-chat__msg--system { justify-content: center; }
.asc-chat__bubble {
	max-width: 85%;
	padding: 7px 10px 5px;
	border-radius: 10px;
	background: var(--asc-in);
	box-shadow: 0 1px 1px rgba(0, 0, 0, 0.08);
	overflow-wrap: anywhere;
}
.asc-chat__msg--customer .asc-chat__bubble { background: var(--asc-primary); color: var(--asc-on-primary); border-end-end-radius: 3px; }
.asc-chat__msg--assistant .asc-chat__bubble,
.asc-chat__msg--agent .asc-chat__bubble { border-end-start-radius: 3px; }
.asc-chat__msg--system .asc-chat__bubble { background: var(--asc-system); color: var(--asc-muted); font-size: 13px; text-align: center; box-shadow: none; max-width: 92%; }
.asc-chat__msg.is-pending .asc-chat__bubble { opacity: 0.7; }
.asc-chat__msg.is-failed { flex-direction: column; align-items: flex-end; }
.asc-chat__text { white-space: pre-wrap; }
.asc-chat__text a { text-decoration: underline; }
.asc-chat__who { font-size: 12px; font-weight: 600; color: var(--asc-primary); margin-bottom: 2px; }
.asc-chat__time { font-size: 11px; opacity: 0.65; text-align: end; margin-top: 2px; }
.asc-chat__error { font-size: 12px; color: #e11d48; margin-top: 4px; display: flex; gap: 8px; align-items: center; }
.asc-chat__retry { border: 0; background: none; color: #e11d48; text-decoration: underline; cursor: pointer; padding: 0; }
.asc-chat__link-btn {
	display: inline-block;
	margin-top: 6px;
	padding: 6px 10px;
	border-radius: 8px;
	background: var(--asc-primary);
	color: var(--asc-on-primary) !important;
	text-decoration: none;
	font-size: 14px;
}

/* Lists to choose from */
.asc-chat__list { display: flex; flex-direction: column; gap: 4px; margin-top: 8px; }
.asc-chat__list-row {
	display: block;
	width: 100%;
	padding: 6px 10px;
	border: 1px solid var(--asc-border);
	border-radius: 8px;
	background: transparent;
	color: inherit;
	text-align: start;
	font: inherit;
	cursor: pointer;
}
.asc-chat__list-row:hover, .asc-chat__list-row:focus-visible { border-color: var(--asc-primary); }
.asc-chat__list-title { display: block; font-size: 14px; font-weight: 600; }
.asc-chat__list-desc { display: block; font-size: 12px; opacity: 0.75; }

/* Product cards */
.asc-chat__cards { display: flex; gap: 8px; overflow-x: auto; margin-top: 8px; padding-bottom: 4px; scroll-snap-type: x mandatory; }
.asc-chat__card {
	flex: 0 0 200px;
	border: 1px solid var(--asc-border);
	border-radius: 10px;
	background: var(--asc-surface);
	overflow: hidden;
	scroll-snap-align: start;
	display: flex;
	flex-direction: column;
}
.asc-chat__card-img { width: 100%; height: 130px; object-fit: cover; display: block; }
.asc-chat__card-body { padding: 8px; display: flex; flex-direction: column; gap: 3px; flex: 1; }
.asc-chat__card-name { font-weight: 600; font-size: 14px; }
.asc-chat__card-price del { opacity: 0.6; }
.asc-chat__card-meta { font-size: 12px; color: var(--asc-muted); }
.asc-chat__card-stock { font-size: 12px; }
.asc-chat__card-stock.is-in { color: #16a34a; }
.asc-chat__card-stock.is-out { color: #e11d48; }
.asc-chat__card-actions { display: flex; gap: 6px; margin-top: auto; padding-top: 6px; }
.asc-chat__card-btn {
	flex: 1;
	text-align: center;
	padding: 6px 4px;
	border-radius: 8px;
	border: 1px solid var(--asc-border);
	text-decoration: none;
	font-size: 13px;
}
.asc-chat__card-btn.is-primary { background: var(--asc-primary); color: var(--asc-on-primary) !important; border-color: transparent; }

/* Order summary */
.asc-chat__order { margin-top: 8px; border-top: 1px dashed currentColor; padding-top: 6px; font-size: 14px; }
.asc-chat__order-row { display: flex; justify-content: space-between; gap: 12px; padding: 2px 0; }
.asc-chat__order-row.is-total { font-weight: 700; border-top: 1px solid var(--asc-border); margin-top: 4px; padding-top: 4px; }

/* Typing indicator */
.asc-chat__typing {
	align-self: flex-start;
	display: inline-flex;
	gap: 4px;
	padding: 10px 12px;
	border-radius: 10px;
	background: var(--asc-in);
}
.asc-chat__typing[hidden] { display: none; }
.asc-chat__typing span { width: 7px; height: 7px; border-radius: 50%; background: var(--asc-muted); animation: asc-chat-dot 1.2s infinite ease-in-out; }
.asc-chat__typing span:nth-child(2) { animation-delay: 0.15s; }
.asc-chat__typing span:nth-child(3) { animation-delay: 0.3s; }
@keyframes asc-chat-dot {
	0%, 80%, 100% { opacity: 0.3; transform: translateY(0); }
	40% { opacity: 1; transform: translateY(-3px); }
}

/* Quick replies */
.asc-chat__quick { display: flex; flex-wrap: wrap; gap: 6px; padding: 4px 12px 8px; flex: 0 0 auto; }
.asc-chat__quick:empty { display: none; }
.asc-chat__chip {
	border: 1px solid var(--asc-primary);
	background: var(--asc-chip-bg);
	color: var(--asc-text);
	border-radius: 16px;
	padding: 5px 12px;
	font-size: 13px;
	cursor: pointer;
}
.asc-chat__chip:hover { background: var(--asc-primary); color: var(--asc-on-primary); }

/* Composer */
.asc-chat__privacy { margin: 0; padding: 6px 14px; font-size: 11.5px; color: var(--asc-muted); background: var(--asc-surface); border-top: 1px solid var(--asc-border); }
.asc-chat__privacy[hidden] { display: none; }
.asc-chat__privacy a { text-decoration: underline; }
.asc-chat__form {
	display: flex;
	align-items: flex-end;
	gap: 8px;
	padding: 8px 10px calc(8px + env(safe-area-inset-bottom, 0px));
	background: var(--asc-surface);
	border-top: 1px solid var(--asc-border);
	margin: 0;
	flex: 0 0 auto;
}
.asc-chat__hp { position: absolute !important; left: -9999px !important; width: 1px; height: 1px; opacity: 0; }
.asc-chat__input {
	flex: 1;
	resize: none;
	min-height: 40px;
	max-height: 120px;
	padding: 9px 12px;
	border: 1px solid var(--asc-border);
	border-radius: 20px;
	background: var(--asc-bg);
	line-height: 1.35;
	box-shadow: none;
	overflow-y: hidden;
}
.asc-chat__send {
	flex: 0 0 42px;
	width: 42px;
	height: 42px;
	border: 0;
	border-radius: 50%;
	background: var(--asc-primary);
	color: var(--asc-on-primary) !important;
	display: flex;
	align-items: center;
	justify-content: center;
	cursor: pointer;
	padding: 0;
}
.asc-chat__send:disabled { opacity: 0.6; cursor: default; }
#asc-chat[dir="rtl"] .asc-chat__send svg { transform: scaleX(-1); }

/* Language menu */
.asc-chat__lang-menu {
	position: absolute;
	top: 60px;
	inset-inline-end: 10px;
	z-index: 5;
	min-width: 150px;
	padding: 4px;
	display: flex;
	flex-direction: column;
	border-radius: 10px;
	background: var(--asc-bg);
	box-shadow: var(--asc-shadow);
}
.asc-chat__lang-menu[hidden] { display: none; }
#asc-chat .asc-chat__lang-item {
	display: block;
	width: 100%;
	padding: 10px 12px;
	border: 0;
	border-radius: 8px;
	background: transparent;
	color: inherit;
	font: inherit;
	font-size: 14px;
	line-height: 1.3;
	text-align: start;
	cursor: pointer;
}
#asc-chat .asc-chat__lang-item:hover { background: rgba(127, 127, 127, 0.15); }
#asc-chat .asc-chat__lang-item[aria-checked="true"] { font-weight: 700; color: var(--asc-primary); }

/* Bengali and Arabic letters need more room above and below the line. */
#asc-chat[lang="bn"] .asc-chat__text,
#asc-chat[lang="ar"] .asc-chat__text,
.asc-chat__bubble[lang="bn"] .asc-chat__text,
.asc-chat__bubble[lang="ar"] .asc-chat__text { line-height: 1.6; }

/* Phones: full-screen sheet */
@media (max-width: 480px) {
	#asc-chat { bottom: 16px; }
	#asc-chat.asc-chat--right { right: 16px; }
	#asc-chat.asc-chat--left { left: 16px; }
	#asc-chat.is-open .asc-chat__panel {
		position: fixed;
		inset: 0;
		width: auto;
		height: 100%;
		height: 100dvh;
		border-radius: 0;
	}
	#asc-chat.is-open .asc-chat__launcher { display: none; }
	.asc-chat__input { font-size: 16px; } /* Prevents iOS zoom on focus. */
	.asc-chat--hide-mobile { display: none !important; }
}

@media (prefers-reduced-motion: reduce) {
	.asc-chat__panel,
	.asc-chat__typing span,
	.asc-chat__launcher { animation: none !important; transition: none !important; }
}

@media print {
	#asc-chat { display: none !important; }
}
