/**
 * Sellback storefront: capture popup, on-site recovery banner and the communication preferences page.
 * Colors follow the theme through custom properties; override --sellback-accent and friends in the
 * theme to restyle (the preferences page takes the Email module's brand color).
 *
 * @since 1.0.0
 * @package MeuMouse\Sellback
 */
:root {
	--sellback-accent: #111827;
	--sellback-accent-text: #ffffff;
	--sellback-surface: #ffffff;
	--sellback-text: #111827;
	--sellback-muted: #4b5563;
	--sellback-border: #e5e7eb;
	--sellback-radius: 12px;
}

.sellback-popup {
	position: fixed;
	inset: 0;
	z-index: 999999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 16px;
	background: rgba(17, 24, 39, 0.55);
}

.sellback-popup[hidden],
.sellback-onsite[hidden] {
	display: none;
}

.sellback-popup__dialog {
	position: relative;
	width: 100%;
	max-width: 420px;
	padding: 28px 24px 24px;
	border-radius: var(--sellback-radius);
	background: var(--sellback-surface);
	color: var(--sellback-text);
	box-shadow: 0 20px 50px rgba(0, 0, 0, 0.25);
	font-size: 15px;
	line-height: 1.5;
}

.sellback-popup__title {
	margin: 0 32px 8px 0;
	font-size: 20px;
	font-weight: 700;
	line-height: 1.3;
}

.sellback-popup__text {
	margin: 0 0 16px;
	color: var(--sellback-muted);
}

.sellback-popup__form {
	display: grid;
	gap: 10px;
	margin: 0;
}

.sellback-popup__input {
	box-sizing: border-box;
	width: 100%;
	min-height: 44px;
	padding: 10px 12px;
	border: 1px solid var(--sellback-border);
	border-radius: 8px;
	background: #fff;
	color: var(--sellback-text);
	font: inherit;
}

.sellback-popup__notice {
	margin: 0;
	color: var(--sellback-muted);
	font-size: 12px;
	line-height: 1.4;
}

.sellback-popup__consent {
	display: flex;
	gap: 8px;
	align-items: flex-start;
	color: var(--sellback-muted);
	font-size: 13px;
}

.sellback-popup__button,
.sellback-onsite__button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-height: 44px;
	padding: 10px 18px;
	border: 0;
	border-radius: 8px;
	background: var(--sellback-accent);
	color: var(--sellback-accent-text);
	font: inherit;
	font-weight: 600;
	text-decoration: none;
	cursor: pointer;
}

.sellback-popup__button[disabled] {
	opacity: 0.6;
	cursor: wait;
}

.sellback-popup__close,
.sellback-onsite__close {
	border: 0;
	background: transparent;
	color: var(--sellback-muted);
	font-size: 24px;
	line-height: 1;
	cursor: pointer;
}

.sellback-popup__close {
	position: absolute;
	top: 12px;
	right: 12px;
	padding: 4px 8px;
}

.sellback-popup__error {
	margin: 0;
	color: #b91c1c;
	font-size: 13px;
}

.sellback-popup__coupon {
	display: flex;
	gap: 8px;
	align-items: center;
	justify-content: space-between;
	margin: 12px 0 0;
	padding: 12px;
	border: 1px dashed var(--sellback-border);
	border-radius: 8px;
	font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
	font-size: 18px;
	font-weight: 700;
	letter-spacing: 0.04em;
}

.sellback-popup__copy {
	padding: 6px 10px;
	border: 1px solid var(--sellback-border);
	border-radius: 6px;
	background: #fff;
	color: var(--sellback-text);
	font-family: inherit;
	font-size: 13px;
	font-weight: 600;
	letter-spacing: 0;
	cursor: pointer;
}

.sellback-onsite {
	position: fixed;
	right: 16px;
	bottom: 16px;
	left: 16px;
	z-index: 99999;
	display: flex;
	flex-wrap: wrap;
	gap: 12px;
	align-items: center;
	justify-content: space-between;
	max-width: 720px;
	margin: 0 auto;
	padding: 14px 16px;
	border: 1px solid var(--sellback-border);
	border-radius: var(--sellback-radius);
	background: var(--sellback-surface);
	color: var(--sellback-text);
	box-shadow: 0 12px 32px rgba(0, 0, 0, 0.15);
	font-size: 14px;
	line-height: 1.45;
}

.sellback-onsite__title {
	margin: 0;
	font-weight: 700;
}

.sellback-onsite__text {
	margin: 2px 0 0;
	color: var(--sellback-muted);
}

.sellback-onsite__actions {
	display: flex;
	gap: 8px;
	align-items: center;
}

@media (prefers-reduced-motion: no-preference) {
	.sellback-popup__dialog,
	.sellback-onsite {
		animation: sellback-in 0.2s ease-out;
	}
}

@keyframes sellback-in {
	from {
		opacity: 0;
		transform: translateY(8px);
	}
}

/* Communication preferences page (a document of its own, opened by unsubscribe links). */
.sellback-preferences-page {
	margin: 0;
	min-height: 100vh;
	background: #f4f5f7;
	color: var(--sellback-text);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	font-size: 15px;
	line-height: 1.5;
}

.sellback-preferences {
	box-sizing: border-box;
	max-width: 520px;
	margin: 0 auto;
	padding: 40px 16px 48px;
}

.sellback-preferences *,
.sellback-preferences *::before,
.sellback-preferences *::after {
	box-sizing: border-box;
}

.sellback-preferences__brand {
	margin-bottom: 24px;
	text-align: center;
}

.sellback-preferences__logo {
	max-width: 200px;
	max-height: 56px;
}

.sellback-preferences__store {
	font-size: 18px;
	font-weight: 700;
}

.sellback-preferences__card {
	display: block;
	padding: 28px 24px;
	border: 1px solid var(--sellback-border);
	border-radius: var(--sellback-radius);
	background: var(--sellback-surface);
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.04);
}

.sellback-preferences__title {
	margin: 0 0 8px;
	font-size: 22px;
	line-height: 1.3;
}

.sellback-preferences__text {
	margin: 0 0 16px;
	color: var(--sellback-muted);
}

.sellback-preferences__notice {
	margin: 0 0 16px;
	padding: 8px 12px;
	border-radius: 8px;
	background: #fff7e6;
	color: #7a4b00;
	font-size: 13px;
}

.sellback-preferences__channels {
	margin: 20px 0 0;
	padding: 0;
	border-top: 1px solid var(--sellback-border);
	list-style: none;
}

.sellback-preferences__channel {
	display: flex;
	gap: 16px;
	align-items: center;
	justify-content: space-between;
	padding: 14px 0;
	border-bottom: 1px solid var(--sellback-border);
}

.sellback-preferences__channel-name {
	display: block;
	font-weight: 600;
}

.sellback-preferences__channel-hint {
	display: block;
	color: var(--sellback-muted);
	font-size: 13px;
	overflow-wrap: anywhere;
}

.sellback-preferences__channel-note {
	display: block;
	margin-top: 2px;
	color: #b42318;
	font-size: 13px;
}

.sellback-preferences__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 8px 16px;
	align-items: center;
	margin-top: 24px;
}

.sellback-preferences__form {
	margin: 0;
}

.sellback-preferences__status {
	margin: 16px 0 0;
	font-size: 14px;
}

.sellback-preferences__status--success {
	color: #067647;
}

.sellback-preferences__status--error {
	color: #b42318;
}

.sellback-preferences__footer {
	margin-top: 20px;
	font-size: 14px;
	text-align: center;
}

.sellback-preferences__back {
	color: var(--sellback-muted);
}

.sellback-button,
.sellback-preferences__button {
	padding: 11px 18px;
	border: 0;
	border-radius: 8px;
	background: var(--sellback-accent);
	color: var(--sellback-accent-text);
	font: inherit;
	font-weight: 600;
	cursor: pointer;
}

.sellback-button--secondary {
	padding: 11px 4px;
	background: transparent;
	color: var(--sellback-text);
	text-decoration: underline;
}

.sellback-button:disabled {
	opacity: 0.6;
	cursor: not-allowed;
}

.sellback-button:focus-visible,
.sellback-switch:focus-visible {
	outline: 2px solid var(--sellback-accent);
	outline-offset: 2px;
}

.sellback-switch {
	display: inline-flex;
	flex: none;
	gap: 8px;
	align-items: center;
	padding: 0;
	border: 0;
	background: transparent;
	color: var(--sellback-muted);
	font: inherit;
	font-size: 13px;
	cursor: pointer;
}

.sellback-switch__track {
	position: relative;
	width: 44px;
	height: 26px;
	border-radius: 999px;
	background: #d1d5db;
	transition: background 0.15s;
}

.sellback-switch__track::after {
	position: absolute;
	top: 3px;
	left: 3px;
	width: 20px;
	height: 20px;
	border-radius: 50%;
	background: #ffffff;
	box-shadow: 0 1px 2px rgba(0, 0, 0, 0.2);
	content: "";
	transition: transform 0.15s;
}

.sellback-switch[aria-checked="true"] .sellback-switch__track {
	background: var(--sellback-accent);
}

.sellback-switch[aria-checked="true"] .sellback-switch__track::after {
	transform: translateX(18px);
}

.sellback-switch:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

@media (prefers-reduced-motion: reduce) {
	.sellback-switch__track,
	.sellback-switch__track::after {
		transition: none;
	}
}
