/**
 * Stock Notifier for WooCommerce — Frontend styles
 * متوافق مع WoodMart ويدعم RTL تلقائياً.
 */

:root {
	--wsn-accent: #0d6efd;
	--wsn-accent-text: #ffffff;
	--wsn-radius: 6px;
	--wsn-border: rgba(0, 0, 0, .12);
	--wsn-bg: rgba(0, 0, 0, .02);
}

/* ---------- الحاوية ---------- */

.wsn-form-wrap {
	margin: 18px 0;
	padding: 18px;
	border: 1px solid var(--wsn-border);
	border-radius: calc(var(--wsn-radius) + 4px);
	background: var(--wsn-bg);
	max-width: 520px;
	box-sizing: border-box;
}

.wsn-form-wrap.wsn-compact {
	margin: 8px 0 0;
	padding: 0;
	border: 0;
	background: transparent;
	max-width: none;
}

.wsn-form-wrap.wsn-context-modal {
	margin: 0;
	padding: 0;
	border: 0;
	background: transparent;
	max-width: none;
}

.wsn-heading {
	font-weight: 700;
	font-size: 1.05em;
	line-height: 1.4;
	margin-bottom: 4px;
	color: inherit;
}

.wsn-sub {
	font-size: .9em;
	opacity: .75;
	margin-bottom: 14px;
	line-height: 1.5;
}

/* ---------- الحقول ---------- */

.wsn-field {
	margin-bottom: 10px;
}

.wsn-field-inline {
	display: flex;
	gap: 8px;
	align-items: stretch;
	flex-wrap: wrap;
	margin-bottom: 0;
}

.wsn-phone-group {
	position: relative;
	display: flex;
	align-items: stretch;
	flex: 1 1 190px;
	min-width: 0;
	background: #fff;
	border: 1px solid var(--wsn-border);
	border-radius: var(--wsn-radius);
	overflow: hidden;
}

.wsn-phone-group .wsn-cc {
	display: flex;
	align-items: center;
	padding: 0 10px;
	font-size: .9em;
	font-weight: 600;
	opacity: .7;
	background: rgba(0, 0, 0, .04);
	white-space: nowrap;
	direction: ltr;
}

.wsn-form-wrap .wsn-input {
	width: 100%;
	min-width: 0;
	height: 44px;
	padding: 0 12px;
	border: 1px solid var(--wsn-border);
	border-radius: var(--wsn-radius);
	background: #fff;
	font-size: 15px;
	line-height: 1.4;
	box-shadow: none;
	box-sizing: border-box;
	color: inherit;
}

.wsn-form-wrap .wsn-input-phone {
	border: 0;
	border-radius: 0;
	direction: ltr;
	text-align: start;
}

.wsn-form-wrap .wsn-input:focus {
	outline: none;
	border-color: var(--wsn-accent);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--wsn-accent) 20%, transparent);
}

.wsn-phone-group:focus-within {
	border-color: var(--wsn-accent);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--wsn-accent) 20%, transparent);
}

/* ---------- الزر ---------- */

.wsn-form-wrap .wsn-submit,
.wsn-modal-trigger {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	height: 44px;
	padding: 0 20px;
	border: 0;
	border-radius: var(--wsn-radius);
	background: var(--wsn-accent);
	color: var(--wsn-accent-text);
	font-weight: 600;
	font-size: 14px;
	line-height: 1;
	cursor: pointer;
	transition: filter .18s ease, opacity .18s ease;
	white-space: nowrap;
	text-decoration: none;
}

.wsn-form-wrap .wsn-submit:hover,
.wsn-modal-trigger:hover {
	background: var(--wsn-accent);
	color: var(--wsn-accent-text);
	filter: brightness(.92);
}

.wsn-form-wrap .wsn-submit[disabled] {
	opacity: .65;
	cursor: not-allowed;
}

.wsn-modal-trigger {
	width: 100%;
	height: 40px;
	font-size: 13px;
}

/* السبينر */

.wsn-spinner {
	display: none;
	width: 15px;
	height: 15px;
	border: 2px solid currentColor;
	border-top-color: transparent;
	border-radius: 50%;
	animation: wsn-spin .7s linear infinite;
}

.wsn-loading .wsn-spinner {
	display: inline-block;
}

@keyframes wsn-spin {
	to { transform: rotate(360deg); }
}

@media (prefers-reduced-motion: reduce) {
	.wsn-spinner { animation-duration: 2s; }
}

/* ---------- الموافقة ومصيدة السبام ---------- */

.wsn-consent {
	display: flex;
	align-items: flex-start;
	gap: 8px;
	margin-top: 12px;
	font-size: .85em;
	line-height: 1.5;
	opacity: .85;
	cursor: pointer;
}

.wsn-consent input {
	margin-top: 3px;
	flex: 0 0 auto;
}

.wsn-hp {
	position: absolute !important;
	left: -9999px !important;
	width: 1px;
	height: 1px;
	overflow: hidden;
}

/* ---------- الرسائل ---------- */

.wsn-message {
	display: none;
	margin-top: 12px;
	padding: 10px 12px;
	border-radius: var(--wsn-radius);
	font-size: .9em;
	line-height: 1.5;
}

.wsn-message.is-visible {
	display: block;
}

.wsn-message.is-success {
	background: #e8f7ee;
	color: #14612f;
	border: 1px solid #b7e3c6;
}

.wsn-message.is-error {
	background: #fdecec;
	color: #8a1c1c;
	border: 1px solid #f3c2c2;
}

/* ---------- شارة غير متوفر ---------- */

ul.products li.product,
.wd-products .wd-product,
.products .product {
	position: relative;
}

.wsn-oos-badge {
	position: absolute;
	top: 10px;
	inset-inline-start: 10px;
	z-index: 5;
	padding: 4px 10px;
	border-radius: 999px;
	background: rgba(33, 37, 41, .88);
	color: #fff;
	font-size: 11px;
	font-weight: 600;
	line-height: 1.6;
	letter-spacing: .2px;
	pointer-events: none;
}

.wsn-product-oos .product-image-link img,
.wsn-product-oos .woocommerce-loop-product__link img,
.wsn-product-oos .attachment-woocommerce_thumbnail {
	opacity: .62;
	filter: grayscale(35%);
	transition: opacity .2s ease, filter .2s ease;
}

.wsn-product-oos:hover .product-image-link img,
.wsn-product-oos:hover .woocommerce-loop-product__link img {
	opacity: .8;
	filter: grayscale(0);
}

/* ---------- المودال ---------- */

.wsn-modal {
	position: fixed;
	inset: 0;
	z-index: 999999;
	display: none;
	align-items: center;
	justify-content: center;
	padding: 20px;
}

.wsn-modal.is-open {
	display: flex;
}

.wsn-modal-overlay {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, .55);
	backdrop-filter: blur(2px);
}

.wsn-modal-dialog {
	position: relative;
	z-index: 1;
	width: 100%;
	max-width: 440px;
	max-height: 90vh;
	overflow-y: auto;
	padding: 26px 24px 24px;
	border-radius: 14px;
	background: #fff;
	color: #212529;
	box-shadow: 0 20px 60px rgba(0, 0, 0, .28);
	animation: wsn-pop .22s ease;
}

@keyframes wsn-pop {
	from { transform: translateY(14px); opacity: 0; }
	to   { transform: translateY(0); opacity: 1; }
}

.wsn-modal-close {
	position: absolute;
	top: 8px;
	inset-inline-end: 12px;
	width: 34px;
	height: 34px;
	padding: 0;
	border: 0;
	background: transparent;
	color: #666;
	font-size: 26px;
	line-height: 1;
	cursor: pointer;
	border-radius: 50%;
}

.wsn-modal-close:hover {
	background: rgba(0, 0, 0, .06);
	color: #000;
}

.wsn-modal-title {
	font-size: 1.15em;
	font-weight: 700;
	margin-bottom: 4px;
	padding-inline-end: 28px;
}

.wsn-modal-product {
	font-size: .9em;
	opacity: .7;
	margin-bottom: 16px;
	line-height: 1.5;
}

.wsn-modal-body {
	min-height: 60px;
}

.wsn-modal-loading {
	display: flex;
	justify-content: center;
	padding: 26px 0;
}

.wsn-modal-loading .wsn-spinner {
	display: inline-block;
	width: 26px;
	height: 26px;
	border-width: 3px;
	color: var(--wsn-accent);
}

/* ---------- الاستجابة ---------- */

@media (max-width: 480px) {
	.wsn-field-inline {
		flex-direction: column;
	}

	.wsn-form-wrap .wsn-submit {
		width: 100%;
	}
}

/* ---------- توافق WoodMart ---------- */

.wd-product .wsn-form-wrap.wsn-compact {
	padding-inline: 0;
}

.wd-product .wsn-oos-badge {
	top: 12px;
}

.woodmart-hover-base .wsn-modal-trigger,
.wd-hover-base .wsn-modal-trigger {
	margin-top: 6px;
}
