/**
 * 子比商城扫一扫搜同款 - 前端样式
 *
 * 说明：
 * - 结果卡片由主题渲染时带 .card 类，插件不覆盖其外观，只负责布局；
 * - 兼容模式（无主题卡片）由 :not(.card) 兜底，保证任何站点可用。
 */

:root {
	--zss-primary: #f44b4b;
	--zss-primary-dark: #e23c3c;
	--zss-bg: #fff;
	--zss-bg-soft: #f6f7f9;
	--zss-text: #222;
	--zss-muted: #8a9099;
	--zss-border: rgba(0, 0, 0, .08);
	--zss-radius: 10px;
	--zss-shadow: 0 6px 24px rgba(0, 0, 0, .12);
	--zss-z: 99999;
}

/* 悬浮入口 */
.zss-float {
	position: fixed;
	bottom: 120px;
	right: 16px;
	z-index: 9998;
}

.zss-float .zss-entry {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	border: 0;
	cursor: pointer;
	box-shadow: 0 4px 14px rgba(244, 75, 75, .32);
	padding: 9px 16px;
	font-size: 14px;
	line-height: 1.4;
	white-space: nowrap;
	transition: transform .18s ease, box-shadow .18s ease;
}

.zss-float .zss-entry:hover {
	transform: translateY(-2px);
	box-shadow: 0 8px 20px rgba(244, 75, 75, .38);
}

.zss-icon {
	flex: none;
	vertical-align: -3px;
}

/* 内联入口条 */
.zss-entry-bar {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 14px;
	padding: 14px 16px;
	margin: 20px 0;
	border-radius: var(--zss-radius);
	background: var(--zss-bg-soft);
}

.zss-entry-bar-title {
	font-size: 15px;
	font-weight: 600;
	color: var(--zss-text);
}

.zss-entry-bar-desc {
	font-size: 13px;
	margin-top: 2px;
}

.zss-entry-btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	white-space: nowrap;
	border: 0;
	cursor: pointer;
}

/* 卡片入口 */
.zss-entry-box {
	display: flex;
	align-items: center;
	gap: 14px;
	padding: 16px;
	margin: 16px 0;
	border-radius: var(--zss-radius);
}

.zss-entry-box-icon {
	flex: none;
	width: 46px;
	height: 46px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 50%;
	background: rgba(244, 75, 75, .1);
	color: var(--zss-primary);
}

.zss-entry-box-body {
	flex: 1 1 auto;
	min-width: 0;
}

.zss-entry-box-title {
	font-size: 15px;
	font-weight: 600;
	color: var(--zss-text);
}

.zss-entry-box-desc {
	font-size: 13px;
	margin-top: 2px;
}

.zss-shortcode-btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	border: 0;
	cursor: pointer;
}

/* 弹窗 */
.zss-modal {
	position: fixed;
	inset: 0;
	z-index: var(--zss-z);
	display: flex;
	align-items: center;
	justify-content: center;
}

.zss-modal[hidden] {
	display: none;
}

.zss-modal-backdrop {
	position: absolute;
	inset: 0;
	background: rgba(0, 0, 0, .55);
	animation: zss-fade .2s ease;
}

.zss-modal-dialog {
	position: relative;
	width: min(520px, calc(100% - 32px));
	max-height: 88vh;
	display: flex;
	animation: zss-pop .24s cubic-bezier(.2, .9, .3, 1.1);
}

.zss-modal-content {
	position: relative;
	display: flex;
	flex-direction: column;
	width: 100%;
	max-height: 88vh;
	overflow: hidden;
	background: var(--zss-bg);
	border-radius: 14px;
	box-shadow: var(--zss-shadow);
	color: var(--zss-text);
}

.zss-modal-header {
	display: flex;
	align-items: flex-start;
	justify-content: space-between;
	gap: 12px;
	padding: 16px 18px 12px;
	border-bottom: 1px solid var(--zss-border);
}

.zss-modal-title {
	font-size: 16px;
	font-weight: 600;
}

.zss-modal-subtitle {
	font-size: 12.5px;
	margin-top: 3px;
}

.zss-modal-close {
	flex: none;
	width: 30px;
	height: 30px;
	display: flex;
	align-items: center;
	justify-content: center;
	border: 0;
	border-radius: 50%;
	background: rgba(0, 0, 0, .05);
	color: var(--zss-muted);
	cursor: pointer;
	transition: background .16s ease, color .16s ease;
}

.zss-modal-close:hover {
	background: rgba(0, 0, 0, .1);
	color: var(--zss-text);
}

.zss-modal-body {
	flex: 1 1 auto;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	padding: 16px 18px 20px;
}

/* 取景器 */
.zss-reader-wrap {
	position: relative;
	width: 100%;
	aspect-ratio: 1 / 1;
	max-height: 46vh;
	margin: 0 auto;
	overflow: hidden;
	border-radius: var(--zss-radius);
	background: #000;
}

.zss-reader,
.zss-reader video,
.zss-reader img {
	width: 100% !important;
	height: 100% !important;
	object-fit: cover;
	border-radius: var(--zss-radius);
}

.zss-reader-placeholder {
	position: absolute;
	inset: 0;
	display: none;
	align-items: center;
	justify-content: center;
	background: #000;
	color: #fff;
	font-size: 13px;
}

.zss-spinner {
	width: 26px;
	height: 26px;
	border: 2px solid rgba(255, 255, 255, .28);
	border-top-color: #fff;
	border-radius: 50%;
	animation: zss-spin .8s linear infinite;
}

/* 扫描线动画 */
.zss-scan-line {
	position: absolute;
	left: 12%;
	right: 12%;
	top: 20%;
	height: 2px;
	background: linear-gradient(90deg, transparent, var(--zss-primary), transparent);
	box-shadow: 0 0 12px rgba(244, 75, 75, .9);
	opacity: 0;
	pointer-events: none;
}

.zss-modal.zss-scanning .zss-scan-line {
	opacity: 1;
	animation: zss-scan 2.2s ease-in-out infinite;
}

/* 提示与错误 */
.zss-hint {
	margin-top: 12px;
	text-align: center;
	font-size: 13px;
	color: var(--zss-muted);
}

.zss-error {
	margin-top: 10px;
	padding: 9px 12px;
	border-radius: 8px;
	background: rgba(244, 75, 75, .1);
	color: var(--zss-primary-dark);
	font-size: 13px;
	line-height: 1.5;
	text-align: center;
}

.zss-error[hidden] {
	display: none;
}

/* 操作按钮 */
.zss-actions {
	display: flex;
	gap: 10px;
	justify-content: center;
	flex-wrap: wrap;
	margin-top: 14px;
}

.zss-actions-center {
	justify-content: center;
}

.zss-act-btn {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	border: 0;
	cursor: pointer;
	font-size: 13.5px;
	padding: 8px 14px;
}

/* 手动输入 */
.zss-manual {
	display: flex;
	gap: 8px;
	margin-top: 12px;
}

.zss-manual[hidden] {
	display: none;
}

.zss-manual-input {
	flex: 1 1 auto;
	min-width: 0;
	padding: 9px 12px;
	border: 1px solid var(--zss-border);
	border-radius: 8px;
	background: var(--zss-bg-soft);
	color: var(--zss-text);
	font-size: 14px;
}

.zss-manual-input:focus {
	outline: none;
	border-color: var(--zss-primary);
	background: var(--zss-bg);
}

.zss-manual button {
	border: 0;
	cursor: pointer;
	white-space: nowrap;
}

/* 相机不可用时的降级操作区 */
.zss-fallback {
	display: flex;
	gap: 10px;
	justify-content: center;
	flex-wrap: wrap;
	margin-top: 12px;
	padding: 12px;
	border-radius: 10px;
	background: var(--zss-bg-soft);
}

.zss-fallback[hidden] {
	display: none;
}

.zss-fb-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 5px;
	border: 0;
	cursor: pointer;
	font-size: 13.5px;
	padding: 9px 16px;
	min-width: 108px;
}

.zss-error:not([hidden]) + .zss-fallback:not([hidden]) {
	margin-top: 8px;
}

/* 相机启动失败：收起取景框，避免留下一块无意义的黑区 */
.zss-modal.zss-cam-error .zss-reader-wrap {
	display: none;
}

/* 结果区 */
.zss-stage[hidden] {
	display: none;
}

.zss-result-head {
	padding-bottom: 10px;
	border-bottom: 1px solid var(--zss-border);
}

.zss-result-code {
	font-size: 13px;
	color: var(--zss-muted);
	word-break: break-all;
}

.zss-result-status {
	margin-top: 4px;
	font-size: 14.5px;
	font-weight: 600;
	display: flex;
	align-items: center;
	gap: 8px;
	flex-wrap: wrap;
}

.zss-result-ok {
	color: #2ba471;
}

.zss-result-fail {
	color: var(--zss-text);
	font-weight: 500;
}

.zss-match-tag {
	display: inline-block;
	padding: 1px 8px;
	border-radius: 20px;
	background: rgba(43, 164, 113, .12);
	color: #2ba471;
	font-size: 12px;
	font-weight: 500;
}

/* 结果网格：主题卡片自带样式时只做布局 */
.zss-result-list {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 10px;
	margin: 12px 0;
}

.zss-result-list > * {
	min-width: 0;
}

/* 兼容模式卡片（无主题 .card 样式时） */
.zss-result-list > .zss-result-item:not(.card) {
	display: flex;
	flex-direction: column;
	overflow: hidden;
	border: 1px solid var(--zss-border);
	border-radius: 8px;
	background: var(--zss-bg);
	text-decoration: none;
	color: inherit;
}

.zss-result-list > .zss-result-item:not(.card) .item-thumbnail {
	position: relative;
	width: 100%;
	padding-top: 100%;
	overflow: hidden;
	background: var(--zss-bg-soft);
}

.zss-result-list > .zss-result-item:not(.card) .item-thumbnail img {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.zss-result-list > .zss-result-item:not(.card) .item-body {
	padding: 8px;
}

.zss-result-list > .zss-result-item:not(.card) .item-heading {
	margin: 0 0 4px;
	font-size: 13.5px;
	line-height: 1.4;
	font-weight: 500;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.zss-result-list > .zss-result-item:not(.card) .item-heading a {
	color: inherit;
	text-decoration: none;
}

.zss-result-list > .zss-result-item:not(.card) .item-excerpt {
	font-size: 12px;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.zss-result-list > .zss-result-item:not(.card) .item-price {
	margin-top: 6px;
}

.zss-result-foot {
	text-align: center;
	margin-top: 4px;
}

.zss-view-all {
	display: inline-block;
	border: 0;
	cursor: pointer;
	text-decoration: none;
}

/* 滚动锁定 */
html.zss-lock,
body.zss-lock {
	overflow: hidden;
}

/* 动画 */
@keyframes zss-fade {
	from { opacity: 0; }
	to { opacity: 1; }
}

@keyframes zss-pop {
	from { opacity: 0; transform: translateY(14px) scale(.98); }
	to { opacity: 1; transform: translateY(0) scale(1); }
}

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

@keyframes zss-scan {
	0% { top: 20%; opacity: .2; }
	10% { opacity: 1; }
	50% { top: 78%; }
	90% { opacity: 1; }
	100% { top: 20%; opacity: .2; }
}

/* 移动端：底部抽屉 */
@media (max-width: 640px) {
	.zss-modal {
		align-items: flex-end;
	}

	.zss-modal-dialog {
		width: 100%;
		max-width: 100%;
		max-height: 90vh;
	}

	.zss-modal-content {
		border-radius: 16px 16px 0 0;
		max-height: 90vh;
		animation: zss-slide .26s cubic-bezier(.2, .9, .3, 1);
	}

	.zss-result-list {
		grid-template-columns: repeat(2, minmax(0, 1fr));
	}

	.zss-float {
		bottom: 84px;
	}

	.zss-float .zss-entry-text {
		display: none;
	}

	.zss-float .zss-entry {
		width: 50px;
		height: 50px;
		padding: 0;
		justify-content: center;
		border-radius: 50%;
	}

	.zss-entry-bar {
		flex-direction: column;
		align-items: stretch;
		text-align: center;
	}

	.zss-entry-btn {
		justify-content: center;
	}
}

@keyframes zss-slide {
	from { transform: translateY(100%); }
	to { transform: translateY(0); }
}

/* 深色模式 */
@media (prefers-color-scheme: dark) {
	:root {
		--zss-bg: #1c1f23;
		--zss-bg-soft: #26292e;
		--zss-text: #e6e8ea;
		--zss-muted: #8b9299;
		--zss-border: rgba(255, 255, 255, .1);
		--zss-shadow: 0 6px 28px rgba(0, 0, 0, .5);
	}
}
