/* Ukaz shop assistant. Override --upa-shop-accent (and friends) in the theme to match the brand. */
.upa-shop {
	--upa-shop-accent: #1f2937;
	--upa-shop-accent-text: #fff;
	--upa-shop-bg: #fff;
	--upa-shop-text: #1f2937;
	--upa-shop-muted: #6b7280;
	--upa-shop-soft: #f3f4f6;
	--upa-shop-border: #e5e7eb;
	--upa-shop-radius: 14px;
	font-size: 14px;
	line-height: 1.5;
	color: var(--upa-shop-text);
	box-sizing: border-box;
}
.upa-shop *, .upa-shop *::before, .upa-shop *::after { box-sizing: inherit; }

/* Floating launcher + panel */
.upa-shop--floating {
	position: fixed;
	/* Start side (left in English, right in Arabic): Woodmart's floating cart sits on the end side. */
	inset-inline-start: 20px;
	bottom: 20px;
	z-index: 99990;
	display: flex;
	flex-direction: column;
	align-items: flex-start;
	gap: 12px;
}
.upa-shop__launcher {
	display: inline-flex;
	align-items: center;
	gap: 8px;
	padding: 12px 18px;
	border: 0;
	border-radius: 999px;
	background: var(--upa-shop-accent);
	color: var(--upa-shop-accent-text);
	font: inherit;
	font-weight: 600;
	cursor: pointer;
	box-shadow: 0 6px 20px rgba(0, 0, 0, .18);
}
.upa-shop__launcher:hover { filter: brightness(1.1); }
.upa-shop__launcher:focus-visible, .upa-shop button:focus-visible, .upa-shop textarea:focus-visible {
	outline: 2px solid var(--upa-shop-accent);
	outline-offset: 2px;
}
.upa-shop--floating .upa-shop__panel { display: none; }
.upa-shop--floating.is-open .upa-shop__panel { display: flex; }
.upa-shop--floating.is-open .upa-shop__launcher { display: none; }
.upa-shop--floating .upa-shop__panel {
	width: min(380px, calc(100vw - 24px));
	height: min(600px, calc(100vh - 40px));
	box-shadow: 0 12px 40px rgba(0, 0, 0, .2);
}

/* Inline (shortcode) */
.upa-shop--inline { margin: 1.5em 0; }
.upa-shop--inline .upa-shop__panel { display: flex; height: 560px; max-width: 720px; }

.upa-shop__panel {
	flex-direction: column;
	background: var(--upa-shop-bg);
	border: 1px solid var(--upa-shop-border);
	border-radius: var(--upa-shop-radius);
	overflow: hidden;
}
.upa-shop__head {
	display: flex;
	align-items: center;
	gap: 4px;
	padding: 12px 12px 12px 16px;
	background: var(--upa-shop-accent);
	color: var(--upa-shop-accent-text);
}
.upa-shop__title { flex: 1; font-weight: 600; font-size: 15px; }
.upa-shop__icon {
	display: inline-flex;
	padding: 6px;
	border: 0;
	border-radius: 8px;
	background: transparent;
	color: inherit;
	cursor: pointer;
}
.upa-shop__icon:hover { background: rgba(255, 255, 255, .15); }

.upa-shop__log {
	flex: 1;
	overflow-y: auto;
	padding: 16px;
	display: flex;
	flex-direction: column;
	gap: 10px;
	overscroll-behavior: contain;
}
.upa-shop__msg {
	max-width: 88%;
	padding: 10px 14px;
	border-radius: 14px;
	word-wrap: break-word;
}
.upa-shop__msg p { margin: 0 0 .5em; }
.upa-shop__msg p:last-child { margin-bottom: 0; }
.upa-shop__msg ul, .upa-shop__msg ol { margin: .25em 0 .5em; padding-inline-start: 1.25em; }
.upa-shop__msg li { margin: 0 0 .2em; }
.upa-shop__msg a { color: inherit; text-decoration: underline; font-weight: 600; }
.upa-shop__msg--assistant { align-self: flex-start; background: var(--upa-shop-soft); border-end-start-radius: 4px; }
.upa-shop__msg--user {
	align-self: flex-end;
	background: var(--upa-shop-accent);
	color: var(--upa-shop-accent-text);
	border-end-end-radius: 4px;
	white-space: pre-wrap;
}
.upa-shop__msg--error { background: #fef2f2; color: #991b1b; }
.upa-shop__msg--wait { color: var(--upa-shop-muted); }

.upa-shop__dots { display: inline-flex; gap: 3px; vertical-align: middle; }
.upa-shop__dots i {
	width: 6px; height: 6px; border-radius: 50%;
	background: currentColor;
	animation: upa-shop-blink 1.2s infinite ease-in-out;
}
.upa-shop__dots i:nth-child(2) { animation-delay: .2s; }
.upa-shop__dots i:nth-child(3) { animation-delay: .4s; }
@keyframes upa-shop-blink { 0%, 80%, 100% { opacity: .25; } 40% { opacity: 1; } }
@media (prefers-reduced-motion: reduce) { .upa-shop__dots i { animation: none; opacity: .6; } }

.upa-shop__cards { display: grid; gap: 8px; margin-top: 10px; }
.upa-shop__card {
	display: flex;
	gap: 10px;
	align-items: center;
	padding: 8px;
	background: var(--upa-shop-bg);
	border: 1px solid var(--upa-shop-border);
	border-radius: 10px;
	text-decoration: none !important;
	color: var(--upa-shop-text) !important;
	font-weight: 400 !important;
}
.upa-shop__card:hover { border-color: var(--upa-shop-accent); }
.upa-shop__card img, .upa-shop__noimg {
	width: 48px; height: 48px; flex: none;
	object-fit: cover; border-radius: 6px; background: var(--upa-shop-soft);
}
.upa-shop__card-body { display: flex; flex-direction: column; min-width: 0; }
.upa-shop__card-name { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upa-shop__card-price { color: var(--upa-shop-muted); font-size: 13px; }

.upa-shop__form {
	display: flex;
	gap: 8px;
	align-items: flex-end;
	padding: 10px 12px;
	border-top: 1px solid var(--upa-shop-border);
	margin: 0;
}
/* Themes often give textareas a large min-height, so these win over theme form styles. */
.upa-shop .upa-shop__form textarea {
	flex: 1;
	resize: none;
	height: 40px;
	min-height: 40px !important;
	max-height: 120px !important;
	width: auto;
	overflow-y: hidden;
	line-height: 20px;
	margin: 0;
	padding: 9px 12px;
	border: 1px solid var(--upa-shop-border);
	border-radius: 10px;
	font: inherit;
	color: inherit;
	background: var(--upa-shop-bg);
	box-shadow: none;
}
.upa-shop__send {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px; height: 40px; flex: none;
	padding: 0;
	border: 0;
	border-radius: 10px;
	background: var(--upa-shop-accent);
	color: var(--upa-shop-accent-text);
	cursor: pointer;
}
[dir="rtl"] .upa-shop__send svg { transform: scaleX(-1); }
.upa-shop__send:disabled { opacity: .5; cursor: default; }
.upa-shop__note { margin: 0; padding: 0 12px 8px; font-size: 11px; color: var(--upa-shop-muted); text-align: center; }

@media (max-width: 480px) {
	.upa-shop--floating { inset-inline-start: 12px; bottom: 12px; }
	.upa-shop--floating.is-open { inset: 0; }
	.upa-shop--floating.is-open .upa-shop__panel { width: 100vw; height: 100%; border-radius: 0; border: 0; }
}

/* Theme button styles (e.g. Woodmart) override plain class selectors; keep the chat's own colours. */
.upa-shop .upa-shop__launcher,
.upa-shop .upa-shop__send {
	background: var(--upa-shop-accent) !important;
	color: var(--upa-shop-accent-text) !important;
	border: 0 !important;
	box-shadow: none;
	text-transform: none;
	letter-spacing: normal;
	min-height: 0;
	line-height: 1.2;
}
.upa-shop .upa-shop__launcher {
	padding: 12px 18px !important;
	border-radius: 999px !important;
	box-shadow: 0 6px 20px rgba(0, 0, 0, .18);
}
.upa-shop .upa-shop__send {
	padding: 0 !important;
	border-radius: 10px !important;
}
.upa-shop .upa-shop__icon {
	background: transparent !important;
	color: inherit !important;
	border: 0 !important;
	padding: 6px !important;
	min-height: 0;
	box-shadow: none;
}
.upa-shop .upa-shop__icon:hover { background: rgba(255, 255, 255, .15) !important; }
