/* =====================================================
   Baijia Cart Drawer Widget
   ===================================================== */

/* ── 触发按钮包裹 ── */
.bjcd-wrapper {
	display: inline-flex;
	position: relative;
}

/* ── 触发按钮 ── */
.bjcd-trigger {
	position: relative;
	display: inline-flex;
	align-items: center;
	gap: 6px;
	cursor: pointer;
	border: none;
	background: transparent;
	line-height: 1;
	transition: background-color 0.25s ease, color 0.25s ease, border-color 0.25s ease;
	-webkit-appearance: none;
	appearance: none;
}

.bjcd-trigger svg {
	display: block;
	flex-shrink: 0;
}

.bjcd-btn-text {
	white-space: nowrap;
}

/* ── 数量徽章 ── */
.bjcd-count {
	position: absolute;
	top: 0;
	right: 0;
	transform: translate(40%, -40%);
	min-width: var(--bjcd-badge-size, 18px);
	height: var(--bjcd-badge-size, 18px);
	padding: 0 4px;
	border-radius: 999px;
	background: var(--bjcd-badge-bg, #e53935);
	color: var(--bjcd-badge-color, #ffffff);
	font-size: calc(var(--bjcd-badge-size, 18px) * 0.6);
	font-weight: 700;
	line-height: var(--bjcd-badge-size, 18px);
	text-align: center;
	pointer-events: none;
	transition: opacity 0.2s ease, transform 0.2s ease;
}

.bjcd-count-zero {
	opacity: 0;
	transform: translate(40%, -40%) scale(0);
}

/* =====================================================
   遮罩层
   ===================================================== */
.bjcd-overlay {
	position: fixed;
	inset: 0;
	z-index: 99998;
	background: var(--bjcd-overlay, rgba(0, 0, 0, 0.5));
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.3s ease, visibility 0s linear 0.3s;
}

.bjcd-overlay.is-open {
	opacity: 1;
	visibility: visible;
	transition: opacity 0.3s ease, visibility 0s linear 0s;
}

/* =====================================================
   抽屉主体
   ===================================================== */
.bjcd-drawer {
	position: fixed;
	top: 0;
	right: 0;
	height: 100%;
	width: var(--bjcd-width, 400px);
	max-width: 100vw;
	z-index: 99999;
	background: var(--bjcd-bg, #ffffff);
	display: flex;
	flex-direction: column;
	box-shadow: -4px 0 24px rgba(0, 0, 0, 0.12);
	transform: translateX(100%);
	transition: transform 0.35s cubic-bezier(0.25, 0.46, 0.45, 0.94);
	will-change: transform;
}

.bjcd-drawer.is-open {
	transform: translateX(0);
}

/* ── 头部 ── */
.bjcd-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 20px 24px;
	border-bottom: 1px solid var(--bjcd-divider, #eeeeee);
	flex-shrink: 0;
}

.bjcd-header-title {
	font-size: 18px;
	font-weight: 600;
	color: var(--bjcd-title-color, #111111);
	display: flex;
	align-items: baseline;
	gap: 6px;
}

.bjcd-header-count {
	font-size: 14px;
	font-weight: 400;
	color: #888888;
}

.bjcd-close {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	border: none;
	background: transparent;
	cursor: pointer;
	color: #555555;
	border-radius: 50%;
	transition: background-color 0.2s ease, color 0.2s ease;
	-webkit-appearance: none;
	appearance: none;
	flex-shrink: 0;
}

.bjcd-close:hover {
	background: #f5f5f5;
	color: #111111;
}

.bjcd-close svg {
	width: 20px;
	height: 20px;
	display: block;
}

/* ── 内容区（可滚动） ── */
.bjcd-body {
	flex: 1;
	overflow-y: auto;
	padding: 8px 24px;
	overscroll-behavior: contain;
	-webkit-overflow-scrolling: touch;
}

.bjcd-body.is-loading {
	opacity: 0.45;
	pointer-events: none;
}

/* ── 商品项 ── */
.bjcd-item {
	display: grid;
	grid-template-columns: 80px 1fr 28px;
	gap: 14px;
	padding: 16px 0;
	border-bottom: 1px solid var(--bjcd-divider, #eeeeee);
	align-items: start;
}

.bjcd-item:last-child {
	border-bottom: none;
}

.bjcd-item-thumb {
	display: block;
	width: 80px;
	height: 80px;
	border-radius: 6px;
	overflow: hidden;
	flex-shrink: 0;
	background: #f5f5f5;
}

.bjcd-item-thumb img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.bjcd-item-info {
	display: flex;
	flex-direction: column;
	gap: 5px;
	min-width: 0;
}

.bjcd-item-name {
	font-size: 14px;
	font-weight: 500;
	color: #111111;
	text-decoration: none;
	line-height: 1.4;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

.bjcd-item-name:hover {
	text-decoration: underline;
}

.bjcd-item-meta {
	font-size: 12px;
	color: #888888;
	line-height: 1.4;
}

.bjcd-item-price-row {
	display: flex;
	align-items: center;
	gap: 4px;
	font-size: 13px;
	color: #555555;
}

.bjcd-item-price {
	font-size: 13px;
	color: #555555;
}

.bjcd-item-sep {
	color: #aaaaaa;
	font-size: 12px;
}

.bjcd-item-qty {
	font-size: 13px;
	color: #555555;
}

.bjcd-item-subtotal {
	font-size: 14px;
	font-weight: 600;
	color: #111111;
}

.bjcd-item-remove {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 28px;
	border: none;
	background: transparent;
	cursor: pointer;
	color: #bbbbbb;
	border-radius: 50%;
	transition: background-color 0.2s ease, color 0.2s ease;
	-webkit-appearance: none;
	appearance: none;
	padding: 0;
	flex-shrink: 0;
}

.bjcd-item-remove:hover {
	background: #fee2e2;
	color: #e53935;
}

.bjcd-item-remove svg {
	width: 16px;
	height: 16px;
	display: block;
}

/* ── 空购物车 ── */
.bjcd-empty {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: 60px 24px;
	text-align: center;
	color: #aaaaaa;
}

.bjcd-empty svg {
	width: 72px;
	height: 72px;
	margin-bottom: 16px;
	opacity: 0.35;
}

.bjcd-empty p {
	font-size: 15px;
	color: #888888;
	margin: 0 0 20px;
}

.bjcd-go-shop {
	display: inline-block;
	padding: 10px 24px;
	border: 1px solid #111111;
	color: #111111;
	text-decoration: none;
	font-size: 14px;
	border-radius: 4px;
	transition: background-color 0.2s ease, color 0.2s ease;
}

.bjcd-go-shop:hover {
	background: #111111;
	color: #ffffff;
}

/* ── 底部区域 ── */
.bjcd-footer {
	flex-shrink: 0;
	padding: 20px 24px;
	border-top: 1px solid var(--bjcd-divider, #eeeeee);
	background: var(--bjcd-bg, #ffffff);
}

.bjcd-footer-hidden {
	display: none;
}

.bjcd-subtotal-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 16px;
}

.bjcd-subtotal-label {
	font-size: 14px;
	color: #555555;
}

.bjcd-subtotal-price {
	font-size: 18px;
	font-weight: 700;
	color: #111111;
}

.bjcd-footer-actions {
	display: flex;
	flex-direction: column;
	gap: 10px;
}

.bjcd-btn {
	display: block;
	width: 100%;
	padding: 13px 20px;
	text-align: center;
	text-decoration: none;
	font-size: 14px;
	font-weight: 500;
	border-radius: 4px;
	transition: opacity 0.2s ease, background-color 0.2s ease;
	box-sizing: border-box;
}

.bjcd-btn-cart {
	border: 1px solid #111111;
	color: #111111;
	background: transparent;
}

.bjcd-btn-cart:hover {
	background: #f5f5f5;
}

.bjcd-btn-checkout {
	background: var(--bjcd-ck-bg, #111111);
	color: var(--bjcd-ck-color, #ffffff);
	border: 1px solid transparent;
}

.bjcd-btn-checkout:hover {
	opacity: 0.85;
}

/* ── 响应式 ── */
@media (max-width: 480px) {
	.bjcd-drawer {
		width: 100vw;
	}

	.bjcd-header {
		padding: 16px 20px;
	}

	.bjcd-body {
		padding: 8px 20px;
	}

	.bjcd-footer {
		padding: 16px 20px;
	}
}
