/**
 * Custom Menu Cart — Frontend Styles
 *
 * BEM naming with `cmc-` prefix.
 */

/* ───── Menu Item ───── */
.cmc-menu-item {
	position: relative;
	list-style: none;
	overflow: visible !important;
	visibility: visible !important;
	opacity: 1 !important;
}

.cmc-menu-item--left {
	float: left;
}

.cmc-menu-item--right {
	float: right;
}

.cmc-menu-item__link {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	text-decoration: none;
	position: relative;
	cursor: pointer;
	color: inherit;
	line-height: 1;
}

.cmc-menu-item__link:hover,
.cmc-menu-item__link:focus {
	text-decoration: none;
}

/* ───── Icon ───── */
.cmc-icon {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	position: relative;
	width: 24px;
	height: 24px;
}

.cmc-icon svg {
	width: 100%;
	height: 100%;
	fill: none !important;
	stroke: currentColor;
	color: inherit;
}

.cmc-icon__custom-img {
	width: 24px;
	height: 24px;
	object-fit: contain;
}

/* ───── Badge ───── */
.cmc-badge {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	position: absolute;
	top: -8px;
	right: -10px;
	min-width: 18px;
	height: 18px;
	padding: 0 4px;
	font-size: 11px;
	font-weight: 700;
	line-height: 1;
	color: #fff;
	background-color: #e74c3c;
	border-radius: 9px;
	pointer-events: none;
	z-index: 1;
	transition: transform 0.3s ease;
}

.cmc-badge--empty {
	display: none;
}

/* Pulse animation on update */
.cmc-badge--pulse {
	animation: cmc-pulse 0.4s ease-in-out;
}

@keyframes cmc-pulse {
	0% { transform: scale(1); }
	50% { transform: scale(1.3); }
	100% { transform: scale(1); }
}

/* ───── Label, Count & Price ───── */
.cmc-label {
	font-size: inherit;
	white-space: nowrap;
}

.cmc-count,
.cmc-price {
	font-size: inherit;
	white-space: nowrap;
}

/* ───── Flyout Panel ───── */
.cmc-flyout {
	position: fixed;
	top: 0;
	right: -400px;
	width: 380px;
	max-width: 90vw;
	height: 100vh;
	height: 100dvh;
	background: #fff;
	box-shadow: -4px 0 20px rgba(0, 0, 0, 0.15);
	z-index: 99999;
	overflow: clip;
	transition: right 0.3s ease, opacity 0.3s ease;
	opacity: 0;
	pointer-events: none;
}

.cmc-flyout--open {
	right: 0;
	opacity: 1;
	pointer-events: auto;
}

/* Close button */
.cmc-flyout__close {
	position: absolute;
	top: 12px;
	right: 12px;
	background: none;
	border: none;
	font-size: 28px;
	line-height: 1;
	color: #888;
	cursor: pointer;
	padding: 4px 8px;
	z-index: 1;
	transition: color 0.2s;
}

.cmc-flyout__close:hover,
.cmc-flyout__close:focus {
	color: #333;
}

.cmc-flyout__close:focus-visible {
	outline: 2px solid #2271b1;
	outline-offset: 2px;
}

.cmc-flyout__inner {
	display: flex;
	flex-direction: column;
	height: 100%;
	padding: 24px 20px 20px;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
}

/* Empty state */
.cmc-flyout__empty {
	text-align: center;
	color: #888;
	padding: 40px 10px;
	font-size: 14px;
}

/* Item list */
.cmc-flyout__items {
	list-style: none;
	margin: 0;
	padding: 0;
	flex: 1 1 auto;
	overflow-y: auto;
}

.cmc-flyout__item {
	display: flex;
	align-items: flex-start;
	gap: 12px;
	padding: 12px 0;
	border-bottom: 1px solid #eee;
	position: relative;
}

.cmc-flyout__item:last-child {
	border-bottom: none;
}

/* Thumbnail */
.cmc-flyout__item-thumb {
	flex: 0 0 50px;
	width: 50px;
	height: 50px;
}

.cmc-flyout__item-thumb img {
	width: 50px;
	height: 50px;
	object-fit: cover;
	border-radius: 4px;
}

.cmc-flyout__item-thumb a {
	display: block;
}

/* Details */
.cmc-flyout__item-details {
	flex: 1 1 auto;
	min-width: 0;
}

.cmc-flyout__item-name {
	font-size: 14px;
	font-weight: 500;
	margin-bottom: 4px;
	line-height: 1.3;
}

.cmc-flyout__item-name a {
	color: inherit;
	text-decoration: none;
}

.cmc-flyout__item-name a:hover {
	text-decoration: underline;
}

.cmc-flyout__item-variation {
	font-size: 12px;
	color: #888;
	margin-bottom: 4px;
}

.cmc-flyout__item-meta {
	font-size: 13px;
	color: #555;
}

.cmc-flyout__item-price {
	font-weight: 600;
}

.cmc-flyout__item-qty {
	color: #888;
	margin-left: 4px;
}

/* Remove button */
.cmc-flyout__item-remove {
	flex: 0 0 auto;
	background: none;
	border: none;
	cursor: pointer;
	font-size: 20px;
	line-height: 1;
	color: #aaa;
	padding: 0 4px;
	transition: color 0.2s;
	align-self: center;
}

.cmc-flyout__item-remove:hover,
.cmc-flyout__item-remove:focus {
	color: #e74c3c;
}

.cmc-flyout__item-remove:focus-visible {
	outline: 2px solid #2271b1;
	outline-offset: 2px;
}

/* Loading spinner on item being removed */
.cmc-flyout__item--removing {
	opacity: 0.4;
	pointer-events: none;
}

/* Total row */
.cmc-flyout__total {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 16px 0;
	border-top: 2px solid #eee;
	font-size: 15px;
	font-weight: 600;
	flex: 0 0 auto;
}

.cmc-flyout__total-label {
	color: #555;
}

.cmc-flyout__total-amount {
	color: #333;
}

/* Buttons */
.cmc-flyout__buttons {
	display: flex;
	gap: 8px;
	flex: 0 0 auto;
	padding-top: 8px;
}

.cmc-flyout__btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: 1 1 0;
	padding: 10px 16px;
	font-size: 14px;
	font-weight: 600;
	text-decoration: none;
	text-align: center;
	border-radius: 6px;
	cursor: pointer;
	transition: background 0.2s, color 0.2s;
	border: none;
	line-height: 1.4;
}

.cmc-flyout__btn:focus-visible {
	outline: 2px solid #2271b1;
	outline-offset: 2px;
}

.cmc-flyout__btn--cart {
	background: #f0f0f0;
	color: #333;
}

.cmc-flyout__btn--cart:hover {
	background: #e0e0e0;
	color: #333;
	text-decoration: none;
}

.cmc-flyout__btn--checkout {
	background: #333;
	color: #fff;
}

.cmc-flyout__btn--checkout:hover {
	background: #555;
	color: #fff;
	text-decoration: none;
}

/* ───── WC Sidebar (mini-cart inside our panel) ───── */
.cmc-wc-sidebar .widget_shopping_cart_content {
	flex: 1 1 auto;
	overflow-y: auto;
}

.cmc-wc-sidebar .widget_shopping_cart_content ul.woocommerce-mini-cart {
	list-style: none;
	margin: 0;
	padding: 0;
}

.cmc-wc-sidebar .widget_shopping_cart_content .woocommerce-mini-cart-item {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 10px 0;
	border-bottom: 1px solid #eee;
}

.cmc-wc-sidebar .widget_shopping_cart_content .woocommerce-mini-cart-item:last-child {
	border-bottom: none;
}

.cmc-wc-sidebar .widget_shopping_cart_content .woocommerce-mini-cart-item img {
	width: 50px;
	height: 50px;
	object-fit: cover;
	border-radius: 4px;
}

.cmc-wc-sidebar .widget_shopping_cart_content .woocommerce-mini-cart-item a.remove {
	color: #aaa;
	font-size: 18px;
	text-decoration: none;
	order: 3;
	margin-left: auto;
}

.cmc-wc-sidebar .widget_shopping_cart_content .woocommerce-mini-cart-item a.remove:hover {
	color: #e74c3c;
}

.cmc-wc-sidebar .widget_shopping_cart_content .woocommerce-mini-cart__total {
	display: flex;
	justify-content: space-between;
	padding: 14px 0;
	border-top: 2px solid #eee;
	font-size: 15px;
	font-weight: 600;
}

.cmc-wc-sidebar .widget_shopping_cart_content .woocommerce-mini-cart__buttons {
	display: none; /* We use our own buttons below */
}

.cmc-wc-sidebar .widget_shopping_cart_content p.woocommerce-mini-cart__empty-message {
	text-align: center;
	color: #888;
	padding: 40px 10px;
	font-size: 14px;
}

/* Flyout overlay */
.cmc-flyout-overlay {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	background: rgba(0, 0, 0, 0.3);
	z-index: 99998;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.3s ease;
}

.cmc-flyout-overlay--visible {
	opacity: 1;
	pointer-events: auto;
}

/* ───── Hover Preview (dropdown under icon) ───── */
.cmc-hover-preview {
	position: fixed;
	width: 320px;
	max-height: 80vh;
	background: #fff;
	border-radius: 8px;
	box-shadow: 0 8px 24px rgba(0, 0, 0, 0.15);
	z-index: 99999;
	opacity: 0;
	visibility: hidden;
	transform: translateY(8px);
	transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s ease;
	pointer-events: none;
	overflow: hidden;
}

.cmc-hover-preview--visible {
	opacity: 1;
	visibility: visible;
	transform: translateY(0);
	pointer-events: auto;
}

.cmc-hover-preview__inner {
	padding: 16px;
	overflow-y: auto;
	max-height: calc(80vh - 2px);
}

.cmc-hover-preview__empty {
	text-align: center;
	color: #888;
	padding: 20px 10px;
	font-size: 13px;
}

/* Hover preview items */
.cmc-hover-preview__items {
	list-style: none;
	margin: 0;
	padding: 0;
}

.cmc-hover-preview__item {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 8px 0;
	border-bottom: 1px solid #f0f0f0;
	font-size: 13px;
}

.cmc-hover-preview__item:last-child {
	border-bottom: none;
}

.cmc-hover-preview__item-thumb {
	flex: 0 0 40px;
	width: 40px;
	height: 40px;
}

.cmc-hover-preview__item-thumb img {
	width: 40px;
	height: 40px;
	object-fit: cover;
	border-radius: 3px;
}

.cmc-hover-preview__item-details {
	flex: 1 1 auto;
	min-width: 0;
}

.cmc-hover-preview__item-name {
	font-weight: 500;
	line-height: 1.3;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.cmc-hover-preview__item-name a {
	color: inherit;
	text-decoration: none;
}

.cmc-hover-preview__item-meta {
	color: #888;
	font-size: 12px;
}

.cmc-hover-preview__item-remove {
	flex: 0 0 auto;
	background: none;
	border: none;
	cursor: pointer;
	font-size: 16px;
	color: #bbb;
	padding: 0 2px;
	line-height: 1;
	transition: color 0.2s;
}

.cmc-hover-preview__item-remove:hover,
.cmc-hover-preview__item-remove:focus {
	color: #e74c3c;
}

.cmc-hover-preview__item-remove:focus-visible {
	outline: 2px solid #2271b1;
	outline-offset: 2px;
}

.cmc-hover-preview__item--removing {
	opacity: 0.4;
	pointer-events: none;
}

/* Hover preview total */
.cmc-hover-preview__total {
	display: flex;
	justify-content: space-between;
	padding: 10px 0 6px;
	border-top: 1px solid #eee;
	font-size: 14px;
	font-weight: 600;
}

/* Hover preview buttons */
.cmc-hover-preview__buttons {
	display: flex;
	gap: 6px;
	padding-top: 8px;
}

.cmc-hover-preview__btn {
	flex: 1 1 0;
	padding: 8px 12px;
	font-size: 12px;
	font-weight: 600;
	text-align: center;
	text-decoration: none;
	border-radius: 5px;
	line-height: 1.4;
	cursor: pointer;
	transition: background 0.2s;
}

.cmc-hover-preview__btn:focus-visible {
	outline: 2px solid #2271b1;
	outline-offset: 2px;
}

.cmc-hover-preview__btn--cart {
	background: #f0f0f0;
	color: #333;
}

.cmc-hover-preview__btn--cart:hover {
	background: #e0e0e0;
	color: #333;
	text-decoration: none;
}

.cmc-hover-preview__btn--checkout {
	background: #333;
	color: #fff;
}

.cmc-hover-preview__btn--checkout:hover {
	background: #555;
	color: #fff;
	text-decoration: none;
}

@media (max-width: 768px) {
	.cmc-hover-preview {
		width: 280px;
	}
}

/* ───── Floating Cart ───── */
.cmc-floating-cart {
	position: fixed;
	z-index: 99997;
	transition: transform 0.2s ease, opacity 0.2s ease;
}

.cmc-floating-cart--bottom-right {
	bottom: 24px;
	right: 24px;
}

.cmc-floating-cart--bottom-left {
	bottom: 24px;
	left: 24px;
}

.cmc-floating-cart--top-right {
	top: 24px;
	right: 24px;
}

.cmc-floating-cart--top-left {
	top: 24px;
	left: 24px;
}

.cmc-floating-cart__btn {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 56px;
	height: 56px;
	background: #333;
	color: #fff;
	text-decoration: none;
	position: relative;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.25);
	transition: background 0.2s, box-shadow 0.2s, transform 0.2s;
}

.cmc-floating-cart__btn:hover {
	background: #555;
	box-shadow: 0 6px 16px rgba(0, 0, 0, 0.3);
	transform: scale(1.05);
	color: #fff;
	text-decoration: none;
}

.cmc-floating-cart__btn:focus-visible {
	outline: 2px solid #2271b1;
	outline-offset: 3px;
}

.cmc-floating-cart--circle .cmc-floating-cart__btn {
	border-radius: 50%;
}

.cmc-floating-cart--square .cmc-floating-cart__btn {
	border-radius: 12px;
}

.cmc-floating-cart__btn .cmc-icon {
	width: 24px;
	height: 24px;
}

.cmc-floating-cart__btn .cmc-icon svg {
	color: #fff;
	fill: none !important;
	stroke: currentColor;
}

/* Floating badge */
.cmc-floating-cart__badge {
	position: absolute;
	top: -4px;
	right: -4px;
	min-width: 20px;
	height: 20px;
	padding: 0 5px;
	font-size: 11px;
	font-weight: 700;
	line-height: 20px;
	text-align: center;
	color: #fff;
	background: #e74c3c;
	border-radius: 10px;
	pointer-events: none;
}

/* ───── Device Visibility ───── */
.cmc-floating-cart--mobile {
	display: none;
}

.cmc-floating-cart--desktop {
	display: block;
}

@media (max-width: 768px) {
	.cmc-floating-cart--mobile {
		display: block;
	}

	.cmc-floating-cart--desktop {
		display: none;
	}
}

/* ───── Responsive ───── */
@media (max-width: 768px) {
	.cmc-flyout {
		width: 100vw;
		max-width: 100vw;
		right: -100vw;
	}

	.cmc-flyout--open {
		right: 0;
	}

	.cmc-flyout__inner {
		padding: 20px 16px 16px;
	}

	.cmc-flyout__buttons {
		flex-direction: column;
	}
}

/* ───── Shortcode wrapper ───── */
.cmc-shortcode {
	display: inline-flex;
	align-items: center;
}

.cmc-shortcode .cmc-menu-item__link {
	display: inline-flex;
}

/* ───── Body Scroll Lock ───── */
.cmc-body--flyout-open {
	overflow: hidden;
}

/* ───── Reduced Motion ───── */
@media (prefers-reduced-motion: reduce) {
	.cmc-flyout,
	.cmc-flyout-overlay,
	.cmc-hover-preview,
	.cmc-floating-cart,
	.cmc-floating-cart__btn,
	.cmc-badge {
		transition: none;
	}

	.cmc-badge--pulse {
		animation: none;
	}
}

/* ───── Screen Reader ───── */
.screen-reader-text {
	border: 0;
	clip: rect(1px, 1px, 1px, 1px);
	clip-path: inset(50%);
	height: 1px;
	margin: -1px;
	overflow: hidden;
	padding: 0;
	position: absolute;
	width: 1px;
	word-wrap: normal !important;
}
