/* Keep native WooCommerce notices readable when they remain in the page flow. */
body.woocommerce-page :is(.woocommerce-message, .woocommerce-info:not(.cart-empty)) {
	position: relative;
	display: grid;
	grid-template-columns: 30px 24px minmax(0, 1fr);
	align-items: start;
	column-gap: 10px;
	box-sizing: border-box;
	margin: 0 0 12px;
	padding: 14px 16px;
	border-radius: 24px 8px 24px 24px;
	direction: rtl;
	text-align: right;
	font-family: "Vazirmatn", sans-serif;
	font-size: 14px;
	line-height: 1.65;
}

body.woocommerce-page .woocommerce-error {
	position: relative;
	display: flex;
	flex-direction: column;
	gap: 10px;
	box-sizing: border-box;
	margin: 0 0 12px;
	padding: 14px 16px;
	border-radius: 24px 8px 24px 24px;
	direction: rtl;
	text-align: right;
	font-family: "Vazirmatn", sans-serif;
	font-size: 14px;
	line-height: 1.65;
	list-style: none;
}

body.woocommerce-page :is(.woocommerce-message, .woocommerce-info:not(.cart-empty)) > .ns-woocommerce-notice__content {
	grid-column: 3;
	grid-row: 1;
	min-width: 0;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	column-gap: 12px;
	row-gap: 8px;
	text-align: right;
	line-height: inherit;
	overflow-wrap: anywhere;
}

body.woocommerce-page .woocommerce-error > li {
	position: relative;
	display: grid;
	grid-template-columns: minmax(0, 1fr) 30px;
	align-items: start;
	column-gap: 12px;
	min-width: 0;
	padding-inline-start: 34px;
}

body.woocommerce-page .woocommerce-error > li > .ns-woocommerce-notice__content {
	grid-column: 1;
	grid-row: 1;
	min-width: 0;
	overflow-wrap: anywhere;
}

/* Preserve WooCommerce's inline notice icons and colors outside the toast layer. */
body.woocommerce-page :is(.woocommerce-message, .woocommerce-info:not(.cart-empty))::before {
	position: static;
	inset: auto;
	grid-column: 2;
	grid-row: 1;
	align-self: start;
	justify-self: center;
	margin: 2px 0 0;
	transform: none;
}

body.woocommerce-page .woocommerce-error::before {
	top: 17px;
	right: 16px;
	left: auto;
}

body.woocommerce-page :is(.woocommerce-message, .woocommerce-error, .woocommerce-info:not(.cart-empty)) .ns-woocommerce-notice__close {
	position: static;
	z-index: 1;
	display: inline-flex;
	grid-column: 1;
	grid-row: 1;
	width: 30px;
	min-width: 30px;
	height: 30px;
	align-items: center;
	justify-content: center;
	justify-self: center;
	margin: 0;
	padding: 0;
	border: 1px solid rgba(255, 255, 255, .3);
	border-radius: 9px;
	background: rgba(255, 255, 255, .08);
	color: #fff;
	font: inherit;
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
	transition: background-color 160ms ease, border-color 160ms ease;
}

body.woocommerce-page .woocommerce-error > li > .ns-woocommerce-notice__close {
	grid-column: 2;
	grid-row: 1;
}

body.woocommerce-page :is(.woocommerce-message, .woocommerce-error, .woocommerce-info:not(.cart-empty)) .ns-woocommerce-notice__close:hover {
	border-color: rgba(255, 255, 255, .55);
	background: rgba(255, 255, 255, .18);
}

body.woocommerce-page :is(.woocommerce-message, .woocommerce-error, .woocommerce-info:not(.cart-empty)) .ns-woocommerce-notice__close:focus-visible {
	outline: 2px solid #0efdc2;
	outline-offset: 3px;
}

/* Native action links retain their destinations and remain easy to identify. */
body.woocommerce-page :is(.woocommerce-message, .woocommerce-error, .woocommerce-info:not(.cart-empty)) .ns-woocommerce-notice__content a {
	float: none;
	flex: 0 0 auto;
	box-sizing: border-box;
	max-width: 100%;
	min-height: 40px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	margin: 0;
	padding: 7px 16px;
	border: 1px solid rgba(255, 255, 255, .92);
	border-radius: 8px;
	background: #fff;
	color: #191919 !important;
	font: inherit;
	line-height: 1.4;
	text-align: center;
	text-decoration: none;
	white-space: normal;
	transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}

body.woocommerce-page :is(.woocommerce-message, .woocommerce-error, .woocommerce-info:not(.cart-empty)) .ns-woocommerce-notice__content a:hover,
body.woocommerce-page :is(.woocommerce-message, .woocommerce-error, .woocommerce-info:not(.cart-empty)) .ns-woocommerce-notice__content a:focus-visible {
	border-color: #3e0e57;
	background: #3e0e57;
	color: #fff !important;
}

body.woocommerce-page :is(.woocommerce-message, .woocommerce-error, .woocommerce-info:not(.cart-empty)) .ns-woocommerce-notice__content a:focus-visible {
	outline: 2px solid #0efdc2;
	outline-offset: 3px;
}

body.woocommerce-page :is(.woocommerce-message, .woocommerce-info:not(.cart-empty)).is-dismissing,
body.woocommerce-page .woocommerce-error > li.is-dismissing {
	opacity: 0;
	transition: opacity 160ms ease;
}

/* Body-root overlay: absolute positioning leaves the document flow untouched. */
body:is(.woocommerce-page, .single-product, .woocommerce) .ns-woocommerce-toast-layer {
	--ns-toast-safe-top: env(safe-area-inset-top, 0px);
	position: absolute;
	z-index: 99990;
	left: calc(env(safe-area-inset-left, 0px) + 12px);
	display: flex;
	width: min(360px, calc(100vw - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px) - 24px));
	max-width: calc(100vw - env(safe-area-inset-left, 0px) - env(safe-area-inset-right, 0px) - 24px);
	flex-direction: column;
	gap: 10px;
	box-sizing: border-box;
	padding: 2px;
	direction: ltr;
	overflow-x: hidden;
	overflow-y: auto;
	overscroll-behavior: contain;
	scrollbar-width: thin;
	pointer-events: none;
}

body:is(.woocommerce-page, .single-product, .woocommerce) .ns-woocommerce-toast {
	--ns-toast-surface: #f2f4ff;
	--ns-toast-ink: #24142e;
	--ns-toast-accent: #4b30ff;
	position: relative;
	display: grid;
	grid-template-columns: 44px minmax(0, 1fr) 32px;
	grid-template-rows: auto;
	align-items: start;
	column-gap: 10px;
	width: 100%;
	min-width: 0;
	box-sizing: border-box;
	padding: 12px 13px;
	border: 1px solid rgba(36, 20, 46, .14);
	border-left: 3px solid var(--ns-toast-accent);
	border-radius: 24px 8px 24px 24px;
	background: var(--ns-toast-surface);
	box-shadow: 0 12px 28px rgba(22, 12, 35, .16), 0 2px 7px rgba(22, 12, 35, .06);
	color: var(--ns-toast-ink);
	direction: ltr;
	font-family: "Vazirmatn", sans-serif;
	font-size: 14px;
	line-height: 1.6;
	opacity: 1;
	text-align: right;
	transition: opacity 700ms ease;
	pointer-events: auto;
}

body:is(.woocommerce-page, .single-product, .woocommerce) .ns-woocommerce-toast--success {
	--ns-toast-surface: #eaf8ef;
	--ns-toast-ink: #14532d;
	--ns-toast-accent: #15803d;
}

body:is(.woocommerce-page, .single-product, .woocommerce) .ns-woocommerce-toast--error {
	--ns-toast-surface: #fff1f2;
	--ns-toast-ink: #881337;
	--ns-toast-accent: #b42318;
}

body:is(.woocommerce-page, .single-product, .woocommerce) .ns-woocommerce-toast--info {
	--ns-toast-surface: #f2f4ff;
	--ns-toast-ink: #24142e;
	--ns-toast-accent: #4b30ff;
}

body:is(.woocommerce-page, .single-product, .woocommerce) .ns-woocommerce-toast > .ns-woocommerce-toast__icon {
	grid-column: 3;
	grid-row: 1;
	display: inline-flex;
	width: 32px;
	height: 32px;
	align-items: center;
	justify-content: center;
	box-sizing: border-box;
	border-radius: 10px 5px 10px 10px;
	background: rgba(255, 255, 255, .78);
	color: var(--ns-toast-accent);
	font-size: 17px;
	font-weight: 800;
	line-height: 1;
}

body:is(.woocommerce-page, .single-product, .woocommerce) .ns-woocommerce-toast > :is(.woocommerce-message, .woocommerce-error, .woocommerce-info) {
	grid-column: 2;
	grid-row: 1;
	position: static;
	display: block;
	min-width: 0;
	margin: 0;
	padding: 0;
	border: 0;
	border-radius: 0;
	background: transparent;
	box-shadow: none;
	color: var(--ns-toast-ink);
	direction: rtl;
	font-family: inherit;
	font-size: inherit;
	line-height: inherit;
	list-style: none;
	text-align: right;
	text-transform: none;
	text-shadow: none;
	overflow-wrap: anywhere;
}

body:is(.woocommerce-page, .single-product, .woocommerce) .ns-woocommerce-toast > :is(.woocommerce-message, .woocommerce-error, .woocommerce-info)::before {
	display: none;
}

body:is(.woocommerce-page, .single-product, .woocommerce) .ns-woocommerce-toast .woocommerce-error > li {
	display: block;
	min-width: 0;
	margin: 0;
	padding: 0;
	border: 0;
	list-style: none;
	overflow-wrap: anywhere;
}

body:is(.woocommerce-page, .single-product, .woocommerce) .ns-woocommerce-toast .woocommerce-error > li + li {
	margin-block-start: 6px;
}

body:is(.woocommerce-page, .single-product, .woocommerce) .ns-woocommerce-toast :is(.woocommerce-message, .woocommerce-error, .woocommerce-info) a {
	float: none;
	max-width: 100%;
	min-height: 38px;
	box-sizing: border-box;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	margin: 7px 6px 0 0;
	padding: 6px 12px;
	border: 1px solid var(--ns-toast-accent);
	border-radius: 8px;
	background: #fff;
	color: var(--ns-toast-ink) !important;
	font: inherit;
	line-height: 1.4;
	text-align: center;
	text-decoration: none;
	white-space: normal;
	transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}

body:is(.woocommerce-page, .single-product, .woocommerce) .ns-woocommerce-toast :is(.woocommerce-message, .woocommerce-error, .woocommerce-info) a:hover,
body:is(.woocommerce-page, .single-product, .woocommerce) .ns-woocommerce-toast :is(.woocommerce-message, .woocommerce-error, .woocommerce-info) a:focus-visible {
	border-color: #3e0e57;
	background: #3e0e57;
	color: #fff !important;
}

body:is(.woocommerce-page, .single-product, .woocommerce) .ns-woocommerce-toast :is(.woocommerce-message, .woocommerce-error, .woocommerce-info) a:focus-visible {
	outline: 2px solid #3e0e57;
	outline-offset: 3px;
}

body:is(.woocommerce-page, .single-product, .woocommerce) .ns-woocommerce-toast > .ns-woocommerce-notice__close--toast {
	position: static;
	display: inline-flex;
	grid-column: 1;
	grid-row: 1;
	width: 44px;
	min-width: 44px;
	height: 44px;
	align-self: start;
	justify-self: start;
	align-items: center;
	justify-content: center;
	margin: 0;
	padding: 0;
	border: 1px solid var(--ns-toast-accent);
	border-radius: 12px 6px 12px 12px;
	background: rgba(255, 255, 255, .82);
	color: var(--ns-toast-accent);
	appearance: none;
	font-family: inherit;
	font-size: 25px;
	font-weight: 400;
	line-height: 1;
	cursor: pointer;
	transition: background-color 160ms ease, border-color 160ms ease, color 160ms ease;
}

body:is(.woocommerce-page, .single-product, .woocommerce) .ns-woocommerce-toast > .ns-woocommerce-notice__close--toast:hover {
	border-color: var(--ns-toast-accent);
	background: var(--ns-toast-accent);
	color: #fff;
}

body:is(.woocommerce-page, .single-product, .woocommerce) .ns-woocommerce-toast > .ns-woocommerce-notice__close--toast:focus-visible {
	outline: 2px solid #3e0e57;
	outline-offset: 2px;
}

body:is(.woocommerce-page, .single-product, .woocommerce) .ns-woocommerce-toast.is-dismissing {
	opacity: 0;
	pointer-events: none;
}

/* Cart and Checkout templates keep their native notice row bounded to page content. */
body.woocommerce-cart .page-content > .woocommerce > .woocommerce-notices-wrapper,
body.woocommerce-checkout .page-content > .woocommerce > .woocommerce-notices-wrapper {
	box-sizing: border-box;
	width: min(1192px, calc(100% - 32px));
	max-width: 100%;
	margin-inline: auto;
}

/* Keep the existing Single Product notice frame available for inline exceptions. */
body.single-product .ns-woocommerce-notice-frame {
	position: relative;
	z-index: 4;
	box-sizing: border-box;
	width: min(1192px, calc(100% - 32px));
	min-height: 0;
	margin: 0 auto;
	direction: rtl;
}

body.single-product .ns-woocommerce-notice-frame > .woocommerce-notices-wrapper {
	position: absolute;
	z-index: 4;
	inset-block-start: 0;
	inset-inline: 0;
	width: 100%;
	margin: 0;
	pointer-events: none;
}

body.single-product .ns-woocommerce-notice-frame > .woocommerce-notices-wrapper > :is(.woocommerce-message, .woocommerce-error, .woocommerce-info:not(.cart-empty)) {
	margin-block-end: 10px;
	box-shadow: 0 14px 34px rgba(22, 12, 35, .18);
	pointer-events: auto;
}

@media (min-width: 641px) {
	body.single-product .ns-woocommerce-notice-frame > .woocommerce-notices-wrapper {
		inset-inline: auto;
		left: 0;
		right: auto;
		width: min(560px, calc(50% - 8px));
	}
}

@media (max-width: 640px) {
	body.woocommerce-page :is(.woocommerce-message, .woocommerce-info:not(.cart-empty)),
	body.woocommerce-page .woocommerce-error {
		padding: 12px;
		font-size: 13px;
		line-height: 1.55;
	}

	body.woocommerce-page :is(.woocommerce-message, .woocommerce-info:not(.cart-empty)) {
		grid-template-columns: 28px 22px minmax(0, 1fr);
		column-gap: 8px;
	}

	body.woocommerce-page .woocommerce-error > li {
		grid-template-columns: minmax(0, 1fr) 28px;
		column-gap: 8px;
		padding-inline-start: 30px;
	}

	body.woocommerce-page :is(.woocommerce-message, .woocommerce-error, .woocommerce-info:not(.cart-empty)) .ns-woocommerce-notice__close {
		width: 28px;
		min-width: 28px;
		height: 28px;
		font-size: 20px;
	}

	body.woocommerce-page .woocommerce-error::before {
		top: 15px;
		right: 12px;
	}

	body.woocommerce-page :is(.woocommerce-message, .woocommerce-error, .woocommerce-info:not(.cart-empty)) .ns-woocommerce-notice__content a {
		min-height: 38px;
		padding: 6px 12px;
		font-size: 13px;
	}

	body:is(.woocommerce-page, .single-product, .woocommerce) .ns-woocommerce-toast {
		grid-template-columns: 44px minmax(0, 1fr) 30px;
		column-gap: 8px;
		padding: 10px 11px;
		font-size: 13px;
	}

	body:is(.woocommerce-page, .single-product, .woocommerce) .ns-woocommerce-toast > :is(.woocommerce-message, .woocommerce-error, .woocommerce-info) {
		grid-template-columns: none;
		column-gap: normal;
		padding: 0;
		font-size: inherit;
		line-height: inherit;
	}

	body:is(.woocommerce-page, .single-product, .woocommerce) .ns-woocommerce-toast > .ns-woocommerce-toast__icon {
		width: 30px;
		height: 30px;
	}

	body:is(.woocommerce-page, .single-product, .woocommerce) .ns-woocommerce-toast > .ns-woocommerce-notice__close--toast {
		width: 44px;
		min-width: 44px;
		height: 44px;
	}

	body:is(.woocommerce-page, .single-product, .woocommerce) .ns-woocommerce-toast :is(.woocommerce-message, .woocommerce-error, .woocommerce-info) a {
		min-height: 38px;
		padding: 6px 10px;
	}
}

@media (prefers-reduced-motion: reduce) {
	body.woocommerce-page :is(.woocommerce-message, .woocommerce-info:not(.cart-empty)).is-dismissing,
	body.woocommerce-page .woocommerce-error > li.is-dismissing,
	body.woocommerce-page :is(.woocommerce-message, .woocommerce-error, .woocommerce-info:not(.cart-empty)) .ns-woocommerce-notice__close,
	body.woocommerce-page :is(.woocommerce-message, .woocommerce-error, .woocommerce-info:not(.cart-empty)) .ns-woocommerce-notice__content a,
	body:is(.woocommerce-page, .single-product, .woocommerce) .ns-woocommerce-toast,
	body:is(.woocommerce-page, .single-product, .woocommerce) .ns-woocommerce-toast > .ns-woocommerce-notice__close--toast,
	body:is(.woocommerce-page, .single-product, .woocommerce) .ns-woocommerce-toast :is(.woocommerce-message, .woocommerce-error, .woocommerce-info) a {
		transition: none;
	}
}
