/**
 * دایرکت فروشگاه — استایل مشترک همه قالب‌ها
 */

/* دکمه کاربر — یکسان در همه قالب‌ها، بالای فوتر */
#store-user-portal {
	position: fixed;
	bottom: max(1rem, env(safe-area-inset-bottom));
	right: max(0.875rem, env(safe-area-inset-right));
	left: auto;
	z-index: 10040;
	pointer-events: none;
}

/* موبایل: سمت چپ تا روی نام دسته‌ها (راست‌چین RTL) نیفتد */
@media (max-width: 1023px) {
	#store-user-portal {
		right: auto;
		left: max(0.875rem, env(safe-area-inset-left));
	}
}

.store-direct-account {
	position: relative;
	pointer-events: auto;
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	padding: 0.5rem 0.875rem 0.5rem 0.625rem;
	border-radius: 9999px;
	background: rgba(255, 255, 255, 0.96);
	border: 1px solid rgba(15, 23, 42, 0.1);
	box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
	color: #0f172a;
	font-size: 0.8125rem;
	font-weight: 600;
	text-decoration: none;
	backdrop-filter: blur(12px);
	transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.store-direct-account:hover { transform: translateY(-1px); }
.store-direct-account.hidden { display: none; }
.store-direct-account-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 1.75rem;
	height: 1.75rem;
	border-radius: 9999px;
	background: var(--store-btn-bg, linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%));
	color: #fff;
}

.btn-product-direct,
.store-direct-trigger {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.375rem;
	width: 100%;
	margin-top: 0.5rem;
	min-height: 2.75rem;
	padding: 0.625rem 1rem;
	border: none;
	border-radius: 0.875rem;
	background: var(--store-direct-bg);
	color: #fff;
	font-size: 0.875rem;
	font-weight: 600;
	cursor: pointer;
	box-shadow: 0 4px 14px rgba(37, 99, 235, 0.25);
	transition: transform 0.2s ease, box-shadow 0.2s ease, filter 0.2s ease;
}
.btn-product-direct:hover,
.store-direct-trigger:hover {
	transform: translateY(-1px);
	box-shadow: 0 6px 18px rgba(37, 99, 235, 0.32);
}

/* دایرکت — آیکون روی تصویر (عرض کامل فقط برای دکمه زیر کارت در تم‌های دیگر) */
.btn-product-direct.store-direct-fab {
	width: 2.5rem;
	height: 2.5rem;
	min-height: 0;
	margin: 0;
	padding: 0;
	border-radius: 9999px;
}

#cs-store-portal .cs-direct {
	position: fixed;
	inset: 0;
	z-index: 1;
	display: flex;
	align-items: flex-end;
	justify-content: center;
	padding: 0;
	background: rgba(2, 6, 23, 0.55);
	backdrop-filter: blur(8px);
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.28s ease, visibility 0.28s ease;
}
#cs-store-portal .cs-direct.open {
	opacity: 1;
	visibility: visible;
}

.cs-direct-panel {
	width: 100%;
	max-width: 560px;
	max-height: min(92vh, 780px);
	background: #111827;
	border: 1px solid rgba(59, 130, 246, 0.22);
	border-radius: 1.25rem 1.25rem 0 0;
	box-shadow: 0 -20px 60px rgba(0, 0, 0, 0.45);
	display: flex;
	flex-direction: column;
	overflow: hidden;
	color: #e2e8f0;
	transform: translateY(100%);
	transition: transform 0.34s cubic-bezier(0.22, 1, 0.36, 1);
}
#cs-store-portal .cs-direct.open .cs-direct-panel {
	transform: translateY(0);
}

@media (min-width: 640px) {
	#cs-store-portal .cs-direct {
		align-items: center;
		padding: 1.25rem;
	}
	.cs-direct-panel {
		border-radius: 1.25rem;
		max-height: min(88vh, 820px);
		transform: translateY(20px) scale(0.96);
	}
	#cs-store-portal .cs-direct.open .cs-direct-panel {
		transform: translateY(0) scale(1);
	}
}

@media (max-width: 639px) {
	#cs-store-portal .cs-direct.open .cs-direct-panel--chat,
	#cs-store-portal .cs-direct.open .cs-direct-panel--auth {
		max-width: none;
		max-height: none;
		height: 100%;
		border-radius: 0;
		border: none;
	}
}

.cs-direct-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	padding: 0.875rem 1rem;
	border-bottom: 1px solid rgba(59, 130, 246, 0.15);
	background: rgba(17, 24, 39, 0.98);
}
.cs-direct-header-title {
	display: flex;
	align-items: center;
	gap: 0.625rem;
	min-width: 0;
}
.cs-direct-header-title h3 {
	margin: 0;
	font-size: 0.9375rem;
	font-weight: 700;
	color: #f8fafc;
}
.cs-direct-header-sub {
	margin: 0.125rem 0 0;
	font-size: 0.6875rem;
	color: #64748b;
}
.cs-direct-status-dot {
	width: 0.5rem;
	height: 0.5rem;
	border-radius: 9999px;
	background: #64748b;
	flex-shrink: 0;
}
.cs-direct-status-dot--online {
	background: #22c55e;
	box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.25);
}
.cs-direct-close {
	width: 2.25rem;
	height: 2.25rem;
	min-width: 2.25rem;
	min-height: 2.25rem;
	max-width: 2.25rem;
	max-height: 2.25rem;
	padding: 0;
	border: none;
	border-radius: 50%;
	aspect-ratio: 1 / 1;
	box-sizing: border-box;
	-webkit-appearance: none;
	appearance: none;
	overflow: hidden;
	background: rgba(51, 65, 85, 0.6);
	color: #94a3b8;
	font-size: 1.25rem;
	line-height: 1;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}
.cs-direct-close:hover { background: rgba(51, 65, 85, 0.9); color: #e2e8f0; }

.cs-direct-header-actions {
	display: flex;
	align-items: center;
	gap: 0.375rem;
	flex-shrink: 0;
}

.cs-direct-delete-btn {
	width: 2.25rem;
	height: 2.25rem;
	min-width: 2.25rem;
	min-height: 2.25rem;
	max-width: 2.25rem;
	max-height: 2.25rem;
	padding: 0;
	border: none;
	border-radius: 50%;
	aspect-ratio: 1 / 1;
	box-sizing: border-box;
	-webkit-appearance: none;
	appearance: none;
	overflow: hidden;
	background: rgba(239, 68, 68, 0.15);
	color: #f87171;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
}

.cs-direct-delete-btn:hover {
	background: rgba(239, 68, 68, 0.25);
	color: #fca5a5;
}

.cs-direct-body { padding: 1rem; overflow-y: auto; }
.cs-direct-intro-text {
	font-size: 0.8125rem;
	color: #94a3b8;
	margin: 0 0 1rem;
	line-height: 1.6;
}
.cs-direct-label {
	display: block;
	font-size: 0.8125rem;
	font-weight: 500;
	color: #cbd5e1;
	margin-bottom: 0.375rem;
}
.cs-direct-input {
	width: 100%;
	border: 1px solid rgba(59, 130, 246, 0.25);
	border-radius: 0.75rem;
	background: rgba(15, 23, 42, 0.8);
	color: #f1f5f9;
	padding: 0.75rem 0.875rem;
	font-size: 0.875rem;
	outline: none;
}
.cs-direct-input:focus {
	border-color: rgba(59, 130, 246, 0.55);
	box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.15);
}
.cs-direct-input--otp {
	text-align: center;
	letter-spacing: 0.35em;
}
.cs-direct-hint {
	font-size: 0.8125rem;
	color: #94a3b8;
	margin: 0 0 0.75rem;
}
.cs-direct-error {
	font-size: 0.8125rem;
	color: #f87171;
	margin-top: 0.75rem;
}
.cs-direct-error.hidden { display: none; }
.cs-direct-step.hidden { display: none; }

.cs-direct-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 0.5rem;
	width: 100%;
	min-height: 2.75rem;
	margin-top: 0.875rem;
	border: none;
	border-radius: 0.75rem;
	font-size: 0.875rem;
	font-weight: 600;
	cursor: pointer;
	transition: opacity 0.2s ease;
}
.cs-direct-btn-primary {
	background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
	color: #fff;
}
.cs-direct-btn-ghost {
	background: transparent;
	color: #2563eb;
	border: 1px solid rgba(37, 99, 235, 0.35);
}
.cs-direct-btn-ghost:hover:not(:disabled) {
	background: rgba(37, 99, 235, 0.08);
}
.cs-direct-btn:disabled { opacity: 0.65; cursor: not-allowed; }
.cs-direct-btn-spinner {
	width: 1rem;
	height: 1rem;
	border: 2px solid rgba(255, 255, 255, 0.35);
	border-top-color: #fff;
	border-radius: 50%;
	animation: cs-direct-spin 0.7s linear infinite;
}
@keyframes cs-direct-spin { to { transform: rotate(360deg); } }

.cs-direct-welcome {
	padding: 1rem 1.25rem 0.5rem;
	text-align: center;
}
.cs-direct-welcome p {
	margin: 0;
	font-size: 0.8125rem;
	color: #94a3b8;
	line-height: 1.65;
}
.cs-direct-welcome.hidden { display: none; }

.cs-direct-messages {
	flex: 1;
	min-height: 200px;
	overflow-y: auto;
	padding: 0.75rem 1rem;
	display: flex;
	flex-direction: column;
	gap: 0.625rem;
	background: linear-gradient(180deg, #0f172a 0%, #111827 100%);
}
.cs-direct-messages-empty {
	text-align: center;
	color: #64748b;
	font-size: 0.8125rem;
	padding: 2rem 1rem;
}

.cs-direct-bubble {
	max-width: 88%;
	padding: 0.625rem 0.875rem;
	border-radius: 1.125rem;
	font-size: 0.875rem;
	line-height: 1.55;
	word-break: break-word;
	display: flex;
	flex-direction: column;
	align-items: flex-start;
}
.cs-direct-bubble.is-mine {
	margin-inline-start: auto;
	background: rgba(37, 99, 235, 0.22);
	border: 1px solid rgba(59, 130, 246, 0.35);
	color: #eff6ff;
	border-bottom-left-radius: 0.35rem;
	align-items: flex-end;
}
.cs-direct-bubble.is-theirs {
	margin-inline-end: auto;
	background: rgba(30, 41, 59, 0.85);
	border: 1px solid rgba(71, 85, 105, 0.5);
	color: #e2e8f0;
	border-bottom-right-radius: 0.35rem;
}
.cs-direct-bubble-product {
	display: block;
	margin-top: 0.375rem;
	padding-top: 0.375rem;
	border-top: 1px solid rgba(255, 255, 255, 0.12);
	font-size: 0.75rem;
	opacity: 0.9;
}
.cs-direct-bubble-image {
	display: block;
	margin-top: 0.375rem;
	max-width: 220px;
	border-radius: 0.75rem;
	overflow: hidden;
	border: 1px solid rgba(255, 255, 255, 0.1);
}
.cs-direct-bubble-image img {
	display: block;
	width: 100%;
	height: auto;
}
.cs-direct-bubble-time {
	display: inline;
	font-size: 0.625rem;
	opacity: 0.65;
}

.direct-bubble-body {
	display: block;
	width: 100%;
}

.direct-bubble-meta {
	display: flex;
	align-items: center;
	gap: 0.25rem;
	margin-top: 0.25rem;
	width: 100%;
	flex-shrink: 0;
}

.direct-bubble-seen {
	display: inline-flex;
	align-items: center;
	flex-shrink: 0;
	line-height: 1;
	opacity: 0.9;
}

.direct-bubble-seen__icon {
	display: block;
	width: 0.75rem;
	height: 0.75rem;
	flex-shrink: 0;
}

.cs-direct-bubble.is-mine .direct-bubble-meta {
	justify-content: flex-end;
}

.cs-direct-bubble.is-theirs .direct-bubble-meta {
	justify-content: flex-start;
}

.cs-direct-quick {
	padding: 0 1rem 0.5rem;
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}
.cs-direct-quick.hidden { display: none; }
.cs-direct-quick-btn {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 0.75rem;
	width: 100%;
	padding: 0.75rem 0.875rem;
	border-radius: 9999px;
	border: 1px solid rgba(59, 130, 246, 0.35);
	background: transparent;
	color: #cbd5e1;
	font-size: 0.8125rem;
	text-align: right;
	cursor: pointer;
	transition: background 0.2s ease, border-color 0.2s ease;
}
.cs-direct-quick-btn:hover {
	background: rgba(37, 99, 235, 0.08);
	border-color: rgba(59, 130, 246, 0.55);
}

.cs-direct-compose {
	border-top: 1px solid rgba(59, 130, 246, 0.15);
	background: rgba(17, 24, 39, 0.98);
	padding: 0.75rem 0.875rem calc(0.75rem + env(safe-area-inset-bottom));
}
.cs-direct-compose-inner {
	display: flex;
	align-items: center;
	gap: 0.5rem;
}
.cs-direct-input-wrap {
	flex: 1;
	min-width: 0;
	min-height: 2.5rem;
	border: 1px solid rgba(59, 130, 246, 0.25);
	border-radius: 0.75rem;
	background: rgba(15, 23, 42, 0.9);
	padding: 0 0.75rem;
	display: flex;
	align-items: center;
	box-sizing: border-box;
}
.cs-direct-textarea {
	width: 100%;
	border: none;
	background: transparent;
	color: #f1f5f9;
	font-size: 0.875rem;
	line-height: 1.35;
	resize: none;
	height: 2.5rem;
	min-height: 2.5rem;
	max-height: 6rem;
	outline: none;
	overflow-y: auto;
	padding: 0.5rem 0;
	box-sizing: border-box;
}
.cs-direct-textarea::placeholder { color: #64748b; }
.cs-direct-icon-btn,
.cs-direct-send-btn {
	width: 2.5rem;
	height: 2.5rem;
	min-width: 2.5rem;
	min-height: 2.5rem;
	max-width: 2.5rem;
	max-height: 2.5rem;
	padding: 0;
	border: none;
	border-radius: 50%;
	aspect-ratio: 1 / 1;
	box-sizing: border-box;
	-webkit-appearance: none;
	appearance: none;
	overflow: hidden;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex-shrink: 0;
	cursor: pointer;
	color: #93c5fd;
	background: rgba(30, 41, 59, 0.8);
	transition: background 0.2s ease, color 0.2s ease;
}
.cs-direct-send-btn {
	background: linear-gradient(135deg, #2563eb 0%, #1d4ed8 100%);
	color: #fff;
}

/* موبایل/تاچ: هدف لمسی ۴۴px بدون از بین رفتن شکل دایره */
@media (pointer: coarse) {
	.cs-direct-close,
	.cs-direct-delete-btn,
	.cs-direct-icon-btn,
	.cs-direct-send-btn {
		width: 2.75rem;
		height: 2.75rem;
		min-width: 2.75rem;
		min-height: 2.75rem;
		max-width: 2.75rem;
		max-height: 2.75rem;
		padding: 0;
		border-radius: 50%;
	}
}
.cs-direct-icon-btn:hover { background: rgba(51, 65, 85, 0.95); color: #bfdbfe; }
.cs-direct-send-btn:hover { opacity: 0.92; }
.cs-direct-send-btn:disabled { opacity: 0.5; cursor: not-allowed; }

.cs-direct-image-preview {
	margin-top: 0.5rem;
	display: flex;
	align-items: center;
	gap: 0.5rem;
}
.cs-direct-image-preview.hidden { display: none; }
.cs-direct-image-preview img {
	width: 3.5rem;
	height: 3.5rem;
	object-fit: cover;
	border-radius: 0.5rem;
	border: 1px solid rgba(59, 130, 246, 0.3);
}
.cs-direct-image-preview button {
	border: none;
	background: transparent;
	color: #f87171;
	font-size: 0.75rem;
	cursor: pointer;
}
