/**
 * PaiCompare shared notification + validation styles.
 *
 * Enqueued on BOTH the public frontend and wp-admin so the toast component and
 * field-error treatment look identical everywhere. Positioning is BOTTOM-RIGHT
 * by product requirement.
 */

.pc-toast-host {
	position: fixed;
	bottom: 24px;
	right: 24px;
	left: auto;
	z-index: 100050;
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 12px;
	width: min(380px, calc(100vw - 32px));
	transform: none;
	pointer-events: none;
	margin: 0;
	padding: 0;
	list-style: none;
}

.pc-toast {
	pointer-events: auto;
	position: relative;
	box-sizing: border-box;
	display: flex;
	align-items: flex-start;
	gap: 12px;
	width: 100%;
	min-width: 0;
	padding: 14px 40px 15px 16px;
	overflow: hidden;
	border: 1px solid rgba(15, 23, 42, 0.08);
	border-left: 4px solid var(--pc-toast-accent, #2563eb);
	border-radius: 12px;
	background: #fff;
	box-shadow: 0 12px 30px rgba(15, 23, 42, 0.16), 0 2px 6px rgba(15, 23, 42, 0.08);
	color: #1e293b;
	font-family: inherit;
	font-size: 13px;
	line-height: 1.45;
	text-align: left;
	animation: pc-toast-in 0.24s cubic-bezier(0.21, 1, 0.32, 1);
}

.pc-toast.is-leaving {
	animation: pc-toast-out 0.2s ease forwards;
}

.pc-toast__icon {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 24px;
	height: 24px;
	margin-top: 1px;
	color: var(--pc-toast-accent, #2563eb);
}

.pc-toast__icon svg {
	display: block;
	width: 22px;
	height: 22px;
}

.pc-toast__content {
	flex: 1 1 auto;
	min-width: 0;
}

.pc-toast__title {
	margin: 0;
	padding: 0;
	color: var(--pc-toast-accent, #2563eb);
	font-size: 14px;
	font-weight: 700;
	line-height: 1.35;
}

.pc-toast__message {
	margin: 2px 0 0;
	padding: 0;
	color: #475569;
	font-size: 13px;
	line-height: 1.45;
	word-break: break-word;
}

.pc-toast__title + .pc-toast__message {
	margin-top: 3px;
}

.pc-toast__close {
	position: absolute;
	top: 8px;
	right: 8px;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 26px;
	height: 26px;
	padding: 0;
	border: 0;
	border-radius: 6px;
	background: transparent;
	color: #94a3b8;
	cursor: pointer;
	transition: background-color 0.15s ease, color 0.15s ease;
	box-shadow: none;
}

.pc-toast__close:hover,
.pc-toast__close:focus-visible {
	background: rgba(15, 23, 42, 0.06);
	color: #475569;
	outline: none;
}

.pc-toast__close svg {
	display: block;
}

.pc-toast__progress {
	position: absolute;
	left: 0;
	bottom: 0;
	height: 3px;
	width: 100%;
	transform-origin: left center;
	background: var(--pc-toast-accent, #2563eb);
	opacity: 0.85;
	border-bottom-left-radius: 12px;
	animation-name: pc-toast-progress;
	animation-timing-function: linear;
	animation-fill-mode: forwards;
}

/* Variant accents */
.pc-toast--success {
	--pc-toast-accent: #16a34a;
}

.pc-toast--error {
	--pc-toast-accent: #dc2626;
}

.pc-toast--warning {
	--pc-toast-accent: #d97706;
}

.pc-toast--info {
	--pc-toast-accent: #2563eb;
}

@keyframes pc-toast-in {
	from {
		opacity: 0;
		transform: translateY(12px) scale(0.98);
	}

	to {
		opacity: 1;
		transform: translateY(0) scale(1);
	}
}

@keyframes pc-toast-out {
	from {
		opacity: 1;
		transform: translateY(0);
	}

	to {
		opacity: 0;
		transform: translateY(12px);
	}
}

@keyframes pc-toast-progress {
	from {
		transform: scaleX(1);
	}

	to {
		transform: scaleX(0);
	}
}

@media screen and (max-width: 600px) {
	.pc-toast-host {
		left: 16px;
		right: 16px;
		bottom: 16px;
		width: auto;
		transform: none;
	}
}

@media (prefers-reduced-motion: reduce) {
	.pc-toast,
	.pc-toast.is-leaving {
		animation: none;
	}

	.pc-toast__progress {
		animation: none;
		display: none;
	}
}

/* --------------------------------------------------------------------------
 * Confirmation modal (styled replacement for window.confirm)
 * ----------------------------------------------------------------------- */

.pc-confirm-overlay {
	position: fixed;
	inset: 0;
	z-index: 100060;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 20px;
	background: rgba(15, 23, 42, 0.55);
	animation: pc-confirm-overlay-in 0.18s ease;
}

.pc-confirm-overlay.is-leaving {
	animation: pc-confirm-overlay-out 0.16s ease forwards;
}

.pc-confirm {
	box-sizing: border-box;
	display: flex;
	align-items: flex-start;
	gap: 16px;
	width: min(440px, 100%);
	max-height: calc(100vh - 40px);
	overflow: auto;
	padding: 24px;
	border-radius: 16px;
	background: #fff;
	box-shadow: 0 24px 60px rgba(15, 23, 42, 0.28), 0 4px 12px rgba(15, 23, 42, 0.12);
	color: #1e293b;
	font-family: inherit;
	text-align: left;
	animation: pc-confirm-in 0.2s cubic-bezier(0.21, 1, 0.32, 1);
}

.pc-confirm-overlay.is-leaving .pc-confirm {
	animation: pc-confirm-out 0.16s ease forwards;
}

.pc-confirm__icon {
	flex: 0 0 auto;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	border-radius: 50%;
	background: rgba(37, 99, 235, 0.12);
	color: #2563eb;
}

.pc-confirm--danger .pc-confirm__icon {
	background: rgba(220, 38, 38, 0.12);
	color: #dc2626;
}

.pc-confirm__content {
	flex: 1 1 auto;
	min-width: 0;
}

.pc-confirm__title {
	margin: 2px 0 0;
	padding: 0;
	color: #0f172a;
	font-size: 17px;
	font-weight: 700;
	line-height: 1.35;
}

.pc-confirm__message {
	margin: 8px 0 0;
	padding: 0;
	color: #475569;
	font-size: 14px;
	line-height: 1.5;
	white-space: pre-line;
	word-break: break-word;
}

.pc-confirm__actions {
	display: flex;
	justify-content: flex-end;
	gap: 10px;
	margin-top: 22px;
}

.pc-confirm__btn {
	box-sizing: border-box;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 92px;
	padding: 9px 18px;
	border: 1px solid transparent;
	border-radius: 9px;
	font-family: inherit;
	font-size: 14px;
	font-weight: 600;
	line-height: 1.2;
	cursor: pointer;
	transition: background-color 0.15s ease, border-color 0.15s ease, color 0.15s ease, box-shadow 0.15s ease;
}

.pc-confirm__btn:focus-visible {
	outline: none;
	box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.35);
}

.pc-confirm__btn--cancel {
	background: #fff;
	border-color: #cbd5e1;
	color: #334155;
}

.pc-confirm__btn--cancel:hover {
	background: #f1f5f9;
	border-color: #94a3b8;
}

.pc-confirm__btn--confirm {
	background: #2563eb;
	color: #fff;
}

.pc-confirm__btn--confirm:hover {
	background: #1d4ed8;
}

.pc-confirm__btn--danger {
	background: #dc2626;
	color: #fff;
}

.pc-confirm__btn--danger:hover {
	background: #b91c1c;
}

.pc-confirm__btn--danger:focus-visible {
	box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.35);
}

@keyframes pc-confirm-overlay-in {
	from {
		opacity: 0;
	}

	to {
		opacity: 1;
	}
}

@keyframes pc-confirm-overlay-out {
	from {
		opacity: 1;
	}

	to {
		opacity: 0;
	}
}

@keyframes pc-confirm-in {
	from {
		opacity: 0;
		transform: translateY(12px) scale(0.97);
	}

	to {
		opacity: 1;
		transform: translateY(0) scale(1);
	}
}

@keyframes pc-confirm-out {
	from {
		opacity: 1;
		transform: translateY(0) scale(1);
	}

	to {
		opacity: 0;
		transform: translateY(8px) scale(0.98);
	}
}

@media screen and (max-width: 600px) {
	.pc-confirm {
		width: 100%;
	}

	.pc-confirm__actions {
		flex-direction: column-reverse;
	}

	.pc-confirm__btn {
		width: 100%;
	}
}

@media (prefers-reduced-motion: reduce) {
	.pc-confirm-overlay,
	.pc-confirm-overlay.is-leaving,
	.pc-confirm,
	.pc-confirm-overlay.is-leaving .pc-confirm {
		animation: none;
	}
}

/* --------------------------------------------------------------------------
 * Field-level validation
 * ----------------------------------------------------------------------- */

.pc-field-error {
	/*
	 * Always render on its own full-width line directly beneath the field it
	 * targets — never beside it. The properties below neutralise flex/grid/inline
	 * parents that would otherwise lay the message out as a sibling column of the
	 * input (e.g. a `display:flex` select container), which pushed the error to
	 * the right of the control. `flex-basis`/`grid-column`/`width` force a wrap to
	 * a new full-width row; `display:block` defeats inline parents.
	 */
	display: block !important;
	flex-basis: 100% !important;
	width: 100% !important;
	grid-column: 1 / -1 !important;
	margin: 6px 0 0 !important;
	padding: 0 !important;
	color: #dc2626 !important;
	font-size: 11px !important;
	font-weight: 500 !important;
	line-height: 1.4 !important;
}

.is-invalid,
input.is-invalid,
select.is-invalid,
textarea.is-invalid {
	border-color: #dc2626 !important;
	box-shadow: 0 0 0 1px rgba(220, 38, 38, 0.35) !important;
}

.is-invalid:focus,
input.is-invalid:focus,
select.is-invalid:focus,
textarea.is-invalid:focus {
	border-color: #dc2626 !important;
	box-shadow: 0 0 0 2px rgba(220, 38, 38, 0.25) !important;
	outline: none;
}
