/**
 * CoolMart - Cart Drawer Styles
 */

/* ===== Overlay ===== */
.cm-drawer-overlay {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(0, 0, 0, 0.5);
	z-index: 9998;
	opacity: 0;
	visibility: hidden;
	transition: all 0.3s ease;
}

.cm-drawer-overlay.active {
	opacity: 1;
	visibility: visible;
}

/* ===== Drawer ===== */
.cm-cart-drawer {
	position: fixed;
	top: 0;
	right: 0;
	width: 420px;
	max-width: 90vw;
	height: 100vh;
	background: var(--cm-white);
	z-index: 9999;
	transform: translateX(100%);
	transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
	display: flex;
	flex-direction: column;
	box-shadow: var(--cm-shadow-xl);
}

.cm-cart-drawer.active {
	transform: translateX(0);
}

/* ===== Drawer Header ===== */
.cm-drawer-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 20px 24px;
	border-bottom: 1px solid var(--cm-border);
	flex-shrink: 0;
}

.cm-drawer-header h3 {
	display: flex;
	align-items: center;
	gap: 10px;
	margin: 0;
	font-size: 1.125rem;
	font-weight: 700;
}

.cm-drawer-count {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 22px;
	height: 22px;
	padding: 0 6px;
	background: var(--cm-primary);
	color: var(--cm-white);
	font-size: 0.75rem;
	font-weight: 700;
	border-radius: 11px;
}

.cm-drawer-close {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 36px;
	height: 36px;
	border: none;
	background: var(--cm-surface);
	border-radius: 50%;
	cursor: pointer;
	color: var(--cm-contrast);
	transition: var(--cm-transition);
}

.cm-drawer-close:hover {
	background: var(--cm-border);
}

/* ===== Drawer Body ===== */
.cm-drawer-body {
	flex: 1;
	overflow-y: auto;
	display: flex;
	flex-direction: column;
}

/* ===== Empty State ===== */
.cm-drawer-empty {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	padding: 60px 24px;
	text-align: center;
	flex: 1;
}

.cm-drawer-empty svg {
	margin-bottom: 16px;
}

.cm-drawer-empty p {
	color: var(--cm-muted);
	font-size: 1rem;
	margin: 0 0 24px;
}

/* ===== Cart Items ===== */
.cm-drawer-items {
	flex: 1;
	overflow-y: auto;
	padding: 16px 24px;
}

.cm-drawer-item {
	display: flex;
	gap: 12px;
	padding: 16px 0;
	border-bottom: 1px solid var(--cm-border);
}

.cm-drawer-item:last-child {
	border-bottom: none;
}

.cm-drawer-item-image {
	width: 72px;
	height: 72px;
	flex-shrink: 0;
	border-radius: var(--cm-radius);
	overflow: hidden;
	background: var(--cm-surface);
}

.cm-drawer-item-image img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.cm-drawer-item-details {
	flex: 1;
	min-width: 0;
}

.cm-drawer-item-name {
	margin: 0 0 4px;
	font-size: 0.875rem;
	font-weight: 600;
	line-height: 1.3;
}

.cm-drawer-item-name a {
	color: var(--cm-contrast);
}

.cm-drawer-item-name a:hover {
	color: var(--cm-primary);
}

.cm-drawer-item-price {
	font-size: 0.875rem;
	color: var(--cm-muted);
	margin-bottom: 8px;
}

.cm-drawer-item-price .amount {
	font-weight: 600;
	color: var(--cm-contrast);
}

/* Quantity Controls */
.cm-drawer-item-qty {
	display: inline-flex;
	align-items: center;
	border: 1px solid var(--cm-border);
	border-radius: var(--cm-radius);
	overflow: hidden;
}

.cm-qty-btn {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 28px;
	border: none;
	background: var(--cm-surface);
	cursor: pointer;
	font-size: 1rem;
	font-weight: 600;
	color: var(--cm-contrast);
	transition: var(--cm-transition);
}

.cm-qty-btn:hover {
	background: var(--cm-primary);
	color: var(--cm-white);
}

.cm-qty-value {
	width: 32px;
	text-align: center;
	font-size: 0.8125rem;
	font-weight: 600;
}

/* Item Actions */
.cm-drawer-item-actions {
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	justify-content: space-between;
}

.cm-drawer-item-remove {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 28px;
	height: 28px;
	border: none;
	background: transparent;
	cursor: pointer;
	color: var(--cm-muted);
	border-radius: 50%;
	transition: var(--cm-transition);
}

.cm-drawer-item-remove:hover {
	background: #FEE2E2;
	color: var(--cm-sale);
}

.cm-drawer-item-total {
	font-size: 0.9375rem;
	font-weight: 700;
	color: var(--cm-contrast);
}

.cm-drawer-item-total .amount {
	font-weight: 700;
}

/* ===== Drawer Footer ===== */
.cm-drawer-footer {
	padding: 20px 24px;
	border-top: 1px solid var(--cm-border);
	background: var(--cm-surface);
	flex-shrink: 0;
}

.cm-drawer-subtotal {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 8px;
}

.cm-drawer-subtotal span:first-child {
	font-size: 1rem;
	font-weight: 600;
}

.cm-drawer-subtotal-value {
	font-size: 1.25rem;
	font-weight: 700;
	color: var(--cm-primary);
}

.cm-drawer-subtotal-value .amount {
	font-weight: 700;
}

.cm-drawer-shipping-note {
	font-size: 0.8125rem;
	color: var(--cm-muted);
	margin: 0 0 16px;
}

.cm-drawer-actions {
	display: flex;
	gap: 12px;
}

.cm-drawer-actions .cm-btn {
	flex: 1;
	padding: 12px 16px;
	font-size: 0.875rem;
}

/* ===== Loading State ===== */
.cm-drawer-loading {
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 40px;
}

.cm-drawer-loading::after {
	content: '';
	width: 32px;
	height: 32px;
	border: 3px solid var(--cm-border);
	border-top-color: var(--cm-primary);
	border-radius: 50%;
	animation: cm-spin 0.8s linear infinite;
}

@keyframes cm-spin {
	to { transform: rotate(360deg); }
}

/* ===== Toast Notification ===== */
.cm-toast {
	position: fixed;
	bottom: 24px;
	left: 50%;
	transform: translateX(-50%) translateY(100px);
	background: var(--cm-contrast);
	color: var(--cm-white);
	padding: 12px 24px;
	border-radius: var(--cm-radius);
	font-size: 0.875rem;
	font-weight: 500;
	z-index: 10000;
	opacity: 0;
	transition: all 0.3s ease;
	display: flex;
	align-items: center;
	gap: 8px;
}

.cm-toast.active {
	transform: translateX(-50%) translateY(0);
	opacity: 1;
}

.cm-toast-success {
	background: var(--cm-success);
}

/* ===== Responsive ===== */
@media (max-width: 480px) {
	.cm-cart-drawer {
		width: 100vw;
		max-width: 100vw;
	}

	.cm-drawer-actions {
		flex-direction: column;
	}
}
