/* Cart drawer — Phase 6B */

.vn-cart-drawer-root {
	--vn-cart-drawer-width: min(430px, 100%);
	--vn-cart-drawer-header-height: 70px;
}

.vn-cart-drawer__overlay {
	position: fixed;
	inset: 0;
	border: 0;
	padding: 0;
	margin: 0;
	background: rgba(0, 0, 0, 0.42);
	z-index: 100001;
	cursor: pointer;
	visibility: hidden;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.25s ease, visibility 0.25s ease;
}

.vn-cart-drawer-root:has(.vn-cart-drawer.is-open) .vn-cart-drawer__overlay:not([hidden]) {
	visibility: visible;
	opacity: 1;
	pointer-events: auto;
}

.vn-cart-drawer {
	position: fixed;
	top: 0;
	right: 0;
	width: var(--vn-cart-drawer-width);
	height: 100dvh;
	max-height: 100vh;
	background: #fff;
	box-shadow: -8px 0 32px rgba(0, 0, 0, 0.12);
	transform: translateX(100%);
	transition: transform 0.25s ease;
	z-index: 100002;
	display: flex;
	flex-direction: column;
}

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

.vn-cart-drawer__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	min-height: var(--vn-cart-drawer-header-height);
	padding: 16px 20px;
	border-bottom: 1px solid #e8ece8;
	flex-shrink: 0;
}

.vn-cart-drawer__title {
	margin: 0;
	font-size: 1.25rem;
	font-weight: 700;
	color: #1a361a;
}

.vn-cart-drawer__close {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 40px;
	height: 40px;
	border: 0;
	border-radius: 8px;
	background: transparent;
	color: #4b5563;
	font-size: 28px;
	line-height: 1;
	cursor: pointer;
	transition: background 0.15s ease, color 0.15s ease;
}

.vn-cart-drawer__close:hover,
.vn-cart-drawer__close:focus {
	background: #f3f4f6;
	color: #1a361a;
	outline: none;
}

.vn-cart-drawer__content {
	display: flex;
	flex-direction: column;
	flex: 1;
	min-height: 0;
	overflow: hidden;
}

.vn-cart-drawer__items {
	flex: 1;
	overflow-y: auto;
	padding: 12px 16px;
}

.vn-cart-drawer__footer {
	padding: 16px 20px 20px;
	border-top: 1px solid #e8ece8;
	background: #fff;
	flex-shrink: 0;
}

.vn-cart-drawer__subtotal {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 14px;
	font-size: 15px;
}

.vn-cart-drawer__subtotal-label {
	color: #4b5563;
}

.vn-cart-drawer__subtotal-value {
	font-weight: 700;
	color: #1a361a;
}

.vn-cart-drawer__actions {
	display: grid;
	grid-template-columns: 1fr 1fr;
	gap: 10px;
}

.vn-cart-drawer__btn {
	min-height: var(--vn-button-height-md);
	padding: 0 16px;
	font-size: 14px;
	text-align: center;
}

.vn-cart-drawer__empty {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 16px;
	min-height: 240px;
	padding: 32px 24px;
	text-align: center;
}

.vn-cart-drawer__empty-text {
	margin: 0;
	color: #6b7280;
	font-size: 15px;
}

.vn-cart-drawer__loading,
.vn-cart-drawer__error {
	padding: 32px 20px;
	text-align: center;
	color: #6b7280;
	font-size: 14px;
}

.vn-cart-drawer__error {
	color: #b45309;
}

/* Cart item */
.vn-cart-item {
	display: grid;
	grid-template-columns: 80px 1fr auto;
	gap: 12px;
	align-items: start;
	padding: 12px 0;
	border-bottom: 1px solid #f0f2f0;
}

.vn-cart-item:last-child {
	border-bottom: 0;
}

.vn-cart-item.is-removing {
	opacity: 0.45;
	pointer-events: none;
}

.vn-cart-item__thumb {
	width: 80px;
	height: 80px;
	border-radius: 8px;
	overflow: hidden;
	background: #f5f5f5;
	flex-shrink: 0;
}

.vn-cart-item__thumb a {
	display: block;
	width: 100%;
	height: 100%;
}

.vn-cart-item__thumb-img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.vn-cart-item__thumb-placeholder {
	display: block;
	width: 100%;
	height: 100%;
	background: linear-gradient(135deg, #eee, #f8f8f8);
}

.vn-cart-item__body {
	min-width: 0;
}

.vn-cart-item__title {
	margin: 0 0 6px;
	font-size: 14px;
	font-weight: 600;
	line-height: 1.35;
}

.vn-cart-item__title a {
	color: #1a361a;
	text-decoration: none;
}

.vn-cart-item__title a:hover {
	color: #2d6a2d;
}

.vn-cart-item__meta {
	margin: 0 0 6px;
	font-size: 12px;
	color: #6b7280;
	line-height: 1.4;
}

.vn-cart-item__meta dl {
	margin: 0;
}

.vn-cart-item__price {
	margin: 0;
	font-size: 13px;
	color: #374151;
}

.vn-cart-item__qty {
	font-weight: 600;
}

.vn-cart-item__times {
	margin: 0 4px;
	color: #9ca3af;
}

.vn-cart-item__remove {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 32px;
	height: 32px;
	border: 0;
	border-radius: 6px;
	background: transparent;
	color: #9ca3af;
	font-size: 22px;
	line-height: 1;
	cursor: pointer;
	transition: background 0.15s ease, color 0.15s ease;
}

.vn-cart-item__remove:hover,
.vn-cart-item__remove:focus {
	background: #fef2f2;
	color: #b91c1c;
	outline: none;
}

.vn-cart-item__remove:disabled {
	opacity: 0.5;
	cursor: wait;
}

body.vn-cart-drawer-open {
	overflow: hidden;
}

@media (max-width: 480px) {
	.vn-cart-drawer {
		width: 100%;
	}

	.vn-cart-drawer__actions {
		grid-template-columns: 1fr;
	}
}
