/**
 * Cart Btn – Floating cart FAB + side drawer
 * Colors match design: amber #FDB910 / badge #E53935
 */

:root {
	--cart-btn-yellow: #fdb910;
	--cart-btn-yellow-hover: #e5a60e;
	--cart-btn-badge: #e53935;
	--cart-btn-text: #1a1a1a;
	--cart-btn-muted: #757575;
	--cart-btn-border: #e8e8e8;
	--cart-btn-footer-bg: #f5f5f5;
	--cart-btn-drawer-w: 380px;
	--cart-btn-fab-size: 60px;
	--cart-btn-z: 99999;
}

/* ========== Floating Action Button ========== */
.cart-btn-fab {
	position: fixed !important;
	top: auto !important;
	left: auto !important;
	right: 20px !important;
	bottom: 96px !important;
	z-index: var(--cart-btn-z) !important;
	width: var(--cart-btn-fab-size);
	height: var(--cart-btn-fab-size);
	border: none;
	border-radius: 50%;
	background: var(--cart-btn-yellow);
	color: var(--cart-btn-text);
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	box-shadow: 0 4px 14px rgba(0, 0, 0, 0.18);
	transition: transform 0.2s ease, box-shadow 0.2s ease, background 0.15s ease;
	padding: 0;
	margin: 0 !important;
	line-height: 1;
	-webkit-tap-highlight-color: transparent;
}

.cart-btn-fab:hover,
.cart-btn-fab:focus-visible {
	background: var(--cart-btn-yellow-hover);
	transform: scale(1.06);
	box-shadow: 0 6px 18px rgba(0, 0, 0, 0.22);
	outline: none;
}

.cart-btn-fab:active {
	transform: scale(0.96);
}

.cart-btn-fab.is-open {
	opacity: 0;
	pointer-events: none;
	transform: scale(0.8);
}

.cart-btn-fab__icon {
	display: block;
	pointer-events: none;
}

.cart-btn-fab__badge {
	position: absolute;
	top: -2px;
	right: -2px;
	min-width: 22px;
	height: 22px;
	padding: 0 5px;
	border-radius: 50%;
	background: var(--cart-btn-badge);
	color: #fff;
	font-size: 12px;
	font-weight: 700;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	line-height: 22px;
	text-align: center;
	box-sizing: border-box;
	pointer-events: none;
}

.cart-btn-fab__badge.is-hidden {
	display: none;
}

/* ========== Overlay ========== */
.cart-btn-overlay {
	position: fixed !important;
	inset: 0 !important;
	width: 100% !important;
	height: 100% !important;
	z-index: calc(var(--cart-btn-z) + 1) !important;
	background: rgba(0, 0, 0, 0.45);
	opacity: 0;
	visibility: hidden;
	transition: opacity 0.28s ease, visibility 0.28s ease;
	margin: 0 !important;
}

.cart-btn-overlay.is-visible {
	opacity: 1;
	visibility: visible;
}

.cart-btn-overlay[hidden] {
	display: block !important; /* allow transition; visibility handles hide */
}

/* ========== Drawer ========== */
/* Native dialog drawer (top-layer) */
.cart-btn-drawer,
dialog.cart-btn-drawer {
	position: fixed !important;
	top: 0 !important;
	left: auto !important;
	right: 0 !important;
	bottom: 0 !important;
	height: 100% !important;
	height: 100dvh !important;
	max-height: 100% !important;
	max-height: 100dvh !important;
	z-index: calc(var(--cart-btn-z) + 2) !important;
	width: min(100vw, var(--cart-btn-drawer-w)) !important;
	max-width: 100% !important;
	background: #fff;
	display: flex;
	flex-direction: column;
	border: none;
	padding: 0;
	box-shadow: -4px 0 24px rgba(0, 0, 0, 0.12);
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
	color: var(--cart-btn-text);
	margin: 0 !important;
	overflow: hidden;
	transform: none;
}

dialog.cart-btn-drawer:not([open]) {
	display: none !important;
}

dialog.cart-btn-drawer[open],
.cart-btn-drawer.is-fallback-open {
	display: flex !important;
}

dialog.cart-btn-drawer::backdrop {
	background: rgba(0, 0, 0, 0.45);
}

.cart-btn-drawer.is-fallback-open {
	transform: none !important;
}

/* Header */
.cart-btn-drawer__header {
	flex: 0 0 auto;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 16px 18px;
	background: var(--cart-btn-yellow);
}

.cart-btn-drawer__title-wrap {
	display: flex;
	align-items: center;
	gap: 8px;
	min-width: 0;
}

.cart-btn-drawer__title-icon {
	flex-shrink: 0;
	color: var(--cart-btn-text);
}

.cart-btn-drawer__title {
	font-size: 17px;
	font-weight: 700;
	letter-spacing: -0.01em;
	white-space: nowrap;
}

.cart-btn-drawer__count {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 22px;
	height: 22px;
	padding: 0 6px;
	border-radius: 4px;
	background: #fff;
	color: var(--cart-btn-text);
	font-size: 13px;
	font-weight: 700;
	line-height: 1;
}

.cart-btn-drawer__close {
	flex-shrink: 0;
	width: 36px;
	height: 36px;
	border: none;
	background: transparent;
	color: var(--cart-btn-text);
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 6px;
	padding: 0;
	-webkit-tap-highlight-color: transparent;
}

.cart-btn-drawer__close:hover,
.cart-btn-drawer__close:focus-visible {
	background: rgba(0, 0, 0, 0.08);
	outline: none;
}

/* Body / items */
.cart-btn-drawer__body {
	flex: 1 1 auto;
	overflow-y: auto;
	-webkit-overflow-scrolling: touch;
	overscroll-behavior: contain;
	background: #fff;
}

.cart-btn-loading {
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 48px 16px;
}

.cart-btn-spinner {
	width: 28px;
	height: 28px;
	border: 3px solid var(--cart-btn-border);
	border-top-color: var(--cart-btn-yellow);
	border-radius: 50%;
	animation: cart-btn-spin 0.7s linear infinite;
}

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

.cart-btn-empty {
	padding: 56px 24px;
	text-align: center;
	color: var(--cart-btn-muted);
	font-size: 15px;
}

.cart-btn-item {
	display: grid;
	grid-template-columns: 72px 1fr;
	gap: 14px;
	padding: 16px 18px;
	border-bottom: 1px solid var(--cart-btn-border);
}

.cart-btn-item__thumb {
	width: 72px;
	height: 72px;
	border-radius: 8px;
	object-fit: cover;
	background: #f0f0f0;
	display: block;
}

.cart-btn-item__info {
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 4px;
}

.cart-btn-item__label {
	font-size: 15px;
	font-weight: 700;
	color: var(--cart-btn-text);
	line-height: 1.3;
	word-break: break-word;
}

.cart-btn-item__label a {
	color: inherit;
	text-decoration: none;
}

.cart-btn-item__label a:hover {
	text-decoration: underline;
}

.cart-btn-item__subtitle {
	font-size: 13px;
	color: var(--cart-btn-muted);
	line-height: 1.35;
	word-break: break-word;
}

.cart-btn-item__price {
	margin-top: 2px;
	font-size: 15px;
	font-weight: 700;
	color: var(--cart-btn-text);
	line-height: 1.4;
}

.cart-btn-item__price .amount,
.cart-btn-item__price .woocommerce-Price-amount {
	font-weight: 700;
}

.cart-btn-item__unit {
	font-size: 12px;
	font-weight: 400;
	color: var(--cart-btn-muted);
	margin-left: 4px;
}

.cart-btn-item__controls {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-top: 10px;
}

/* Qty stepper */
.cart-btn-qty {
	display: inline-flex;
	align-items: stretch;
	flex: 0 0 auto;
	width: auto;
	height: 32px;
	border: 1px solid #d0d0d0;
	border-radius: 6px;
	overflow: visible;
	background: #fff;
	box-sizing: border-box;
}

.cart-btn-qty__btn {
	flex: 0 0 30px;
	width: 30px !important;
	min-width: 30px;
	height: 100% !important;
	min-height: 0;
	margin: 0 !important;
	border: none !important;
	border-radius: 0 !important;
	box-shadow: none !important;
	background: transparent !important;
	color: var(--cart-btn-text) !important;
	font-size: 16px !important;
	font-weight: 500;
	line-height: 1 !important;
	cursor: pointer;
	display: inline-flex !important;
	align-items: center;
	justify-content: center;
	padding: 0 !important;
	-webkit-tap-highlight-color: transparent;
	user-select: none;
}

.cart-btn-qty__btn:hover:not(:disabled),
.cart-btn-qty__btn:focus-visible {
	background: #f5f5f5 !important;
	outline: none;
}

.cart-btn-qty__btn:disabled {
	opacity: 0.35;
	cursor: not-allowed;
}

.cart-btn-drawer .cart-btn-qty__input,
.cart-btn-qty__input {
	flex: 0 0 44px;
	width: 44px !important;
	min-width: 44px !important;
	max-width: 44px !important;
	height: 100% !important;
	min-height: 0 !important;
	margin: 0 !important;
	padding: 0 !important;
	border: none !important;
	border-left: 1px solid #d0d0d0 !important;
	border-right: 1px solid #d0d0d0 !important;
	border-radius: 0 !important;
	box-shadow: none !important;
	background: #fff !important;
	color: var(--cart-btn-text) !important;
	font-size: 14px !important;
	font-weight: 600 !important;
	font-family: inherit !important;
	line-height: 30px !important;
	letter-spacing: normal !important;
	text-align: center !important;
	vertical-align: middle;
	box-sizing: border-box !important;
	-webkit-appearance: none !important;
	-moz-appearance: textfield !important;
	appearance: textfield !important;
}

.cart-btn-drawer .cart-btn-qty__input::-webkit-outer-spin-button,
.cart-btn-drawer .cart-btn-qty__input::-webkit-inner-spin-button,
.cart-btn-qty__input::-webkit-outer-spin-button,
.cart-btn-qty__input::-webkit-inner-spin-button {
	-webkit-appearance: none !important;
	appearance: none !important;
	display: none !important;
	margin: 0 !important;
	height: 0 !important;
	width: 0 !important;
}

.cart-btn-qty__input:focus {
	outline: none !important;
	background: #fffbeb !important;
	box-shadow: none !important;
}

.cart-btn-qty__val {
	min-width: 28px;
	text-align: center;
	font-size: 14px;
	font-weight: 600;
	color: var(--cart-btn-text);
	line-height: 1;
}

.cart-btn-item__remove {
	flex: 0 0 32px;
	width: 32px;
	height: 32px;
	border: 1px solid #e0e0e0;
	background: #fff;
	color: var(--cart-btn-muted);
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	border-radius: 6px;
	padding: 0;
	box-sizing: border-box;
	-webkit-tap-highlight-color: transparent;
}

.cart-btn-item__remove:hover,
.cart-btn-item__remove:focus-visible {
	color: var(--cart-btn-badge);
	background: rgba(229, 57, 53, 0.08);
	outline: none;
}

/* Footer */
.cart-btn-drawer__footer {
	flex: 0 0 auto;
	padding: 16px 18px calc(16px + env(safe-area-inset-bottom, 0px));
	background: var(--cart-btn-footer-bg);
	border-top: 1px solid var(--cart-btn-border);
}

.cart-btn-drawer__footer[hidden] {
	display: none !important;
}

.cart-btn-drawer__subtotal {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 14px;
	font-size: 15px;
	color: var(--cart-btn-text);
}

.cart-btn-drawer__subtotal strong {
	font-size: 20px;
	font-weight: 700;
}

.cart-btn-drawer__checkout,
.cart-btn-drawer__view-cart {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	min-height: 50px;
	padding: 12px 16px;
	border-radius: 8px;
	text-decoration: none;
	text-align: center;
	box-sizing: border-box;
	cursor: pointer;
	transition: background 0.15s ease, border-color 0.15s ease;
	-webkit-tap-highlight-color: transparent;
}

.cart-btn-drawer__checkout {
	border: none;
	background: var(--cart-btn-yellow);
	color: var(--cart-btn-text);
	font-size: 14px;
	font-weight: 800;
	letter-spacing: 0.04em;
	text-transform: uppercase;
}

.cart-btn-drawer__checkout:hover,
.cart-btn-drawer__checkout:focus-visible {
	background: var(--cart-btn-yellow-hover);
	color: var(--cart-btn-text);
	outline: none;
}

.cart-btn-drawer__view-cart {
	margin-top: 10px;
	border: 1px solid #e0e0e0;
	background: #fff;
	color: var(--cart-btn-text);
	font-size: 15px;
	font-weight: 600;
}

.cart-btn-drawer__view-cart:hover,
.cart-btn-drawer__view-cart:focus-visible {
	background: #fafafa;
	border-color: #cfcfcf;
	color: var(--cart-btn-text);
	outline: none;
}

.cart-btn-drawer__empty-cart {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	min-height: 44px;
	margin-top: 10px;
	padding: 10px 16px;
	border: none;
	border-radius: 8px;
	background: transparent;
	color: var(--cart-btn-muted);
	font-size: 14px;
	font-weight: 600;
	font-family: inherit;
	text-decoration: underline;
	text-underline-offset: 2px;
	cursor: pointer;
	box-sizing: border-box;
	-webkit-tap-highlight-color: transparent;
	transition: color 0.15s ease, background 0.15s ease;
}

.cart-btn-drawer__empty-cart:hover,
.cart-btn-drawer__empty-cart:focus-visible {
	color: var(--cart-btn-badge);
	background: rgba(229, 57, 53, 0.06);
	outline: none;
}

/* Scroll lock — do NOT use position:fixed on body (breaks under theme transforms) */
html.cart-btn-no-scroll,
body.cart-btn-no-scroll {
	overflow: hidden !important;
	overscroll-behavior: none;
	touch-action: none;
}

/* ========== Responsive ========== */
@media (max-width: 480px) {
	:root {
		--cart-btn-drawer-w: 100vw;
		--cart-btn-fab-size: 56px;
	}

	.cart-btn-fab {
		right: 16px !important;
		bottom: calc(88px + env(safe-area-inset-bottom, 0px)) !important;
	}

	.cart-btn-item {
		grid-template-columns: 64px 1fr;
		gap: 12px;
		padding: 14px 14px;
	}

	.cart-btn-item__thumb {
		width: 64px;
		height: 64px;
	}

	.cart-btn-drawer__header {
		padding: 14px 14px;
	}

	.cart-btn-drawer__footer {
		padding: 14px 14px calc(14px + env(safe-area-inset-bottom, 0px));
	}
}

@media (min-width: 768px) {
	.cart-btn-fab {
		right: 28px !important;
		bottom: 110px !important;
	}
}

/* Prefer reduced motion */
@media (prefers-reduced-motion: reduce) {
	.cart-btn-fab,
	.cart-btn-overlay,
	.cart-btn-drawer,
	.cart-btn-drawer__checkout {
		transition: none;
	}

	.cart-btn-spinner {
		animation: none;
	}
}
