/**
 * Slide-out cart drawer.
 *
 * Triggered by the header cart icon. Drawer slides from the right,
 * stacking above the sticky header (z-index 1000) and mobile menu
 * (z-index 999). Uses the plugin's shared .wsp-sidebar__* classes
 * for cart item rendering (styled in plugin's checkout.css).
 *
 * @package Woo_Specialist_Theme
 */

/* =========================================================================
   Overlay
   ========================================================================= */

.wst-cart-drawer-overlay {
	position: fixed;
	inset: 0;
	background: rgba(0, 0, 0, 0.5);
	opacity: 0;
	visibility: hidden;
	transition: opacity 250ms ease, visibility 250ms ease;
	z-index: 1100;
}

.wst-cart-drawer-overlay.is-open {
	opacity: 1;
	visibility: visible;
}

/* =========================================================================
   Drawer shell
   ========================================================================= */

.wst-cart-drawer {
	position: fixed;
	top: 0;
	right: 0;
	bottom: 0;
	/*
	 * Width: 420px on desktop, but on narrow phones leave a visible sliver
	 * of the page behind the drawer so the customer doesn't feel locked
	 * inside the panel and tap-outside-to-close stays discoverable. The
	 * `min()` resolves to 420px when 92vw >= 420 (≥457px viewport) and to
	 * 92vw on narrower screens — at 360px → 331px drawer + 29px sliver.
	 */
	width: min(420px, 92vw);
	background: #ffffff;
	box-shadow: -8px 0 32px rgba(0, 0, 0, 0.15);
	transform: translateX(100%);
	transition: transform 300ms cubic-bezier(0.25, 0.1, 0.25, 1), visibility 300ms;
	z-index: 1101;
	display: flex;
	flex-direction: column;
	visibility: hidden;
}

/* Offset below the WP admin bar so the drawer title isn't cramped under it. */
.admin-bar .wst-cart-drawer,
.admin-bar .wst-cart-drawer-overlay {
	top: 32px;
}

@media (max-width: 782px) {
	.admin-bar .wst-cart-drawer,
	.admin-bar .wst-cart-drawer-overlay {
		top: 46px;
	}
}

.wst-cart-drawer.is-open {
	transform: translateX(0);
	visibility: visible;
}

/* =========================================================================
   Drawer header
   ========================================================================= */

.wst-cart-drawer__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 28px 24px 20px;
	border-bottom: 1px solid var(--wst-color-border, #d2d2d7);
	flex-shrink: 0;
}

.wst-cart-drawer__title {
	font-size: 18px;
	font-weight: 600;
	color: var(--wst-color-text, #1d1d1f);
	margin: 0;
	line-height: 1.2;
}

.wst-cart-drawer__close {
	/* 44×44 = Apple HIG minimum tap target. The visual <svg> stays 16×16
	   inside this padded box so the icon doesn't feel oversized. */
	width: 44px;
	height: 44px;
	border: none;
	background: transparent;
	color: var(--wst-color-text-muted, #6e6e73);
	cursor: pointer;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: background-color 150ms ease, color 150ms ease;
	flex-shrink: 0;
	margin-right: -8px;
}

.wst-cart-drawer__close:hover {
	background: var(--wst-color-bg-alt, #f5f5f7);
	color: var(--wst-color-text, #1d1d1f);
}

.wst-cart-drawer__close:focus-visible {
	outline: 2px solid var(--wst-color-accent, #0071e3);
	outline-offset: 2px;
}

/* =========================================================================
   Drawer body (scrollable)
   ========================================================================= */

.wst-cart-drawer__body {
	flex: 1 1 auto;
	overflow-y: auto;
	padding: 16px 24px;
	-webkit-overflow-scrolling: touch;
}

/* Loading state during AJAX refresh */
.wst-cart-drawer__body.is-loading {
	opacity: 0.5;
	pointer-events: none;
	transition: opacity 150ms ease;
}

/* Inline error banner (AJAX failures) */
.wst-cart-drawer__error {
	margin: 0 0 12px;
	padding: 10px 14px;
	background: rgba(220, 38, 38, 0.08);
	border: 1px solid rgba(220, 38, 38, 0.3);
	border-radius: 6px;
	color: #dc2626;
	font-size: 13px;
	line-height: 1.4;
	text-align: center;
}

/* =========================================================================
   Cart items — local overrides for light-theme drawer context
   ========================================================================= */

.wsp-drawer__items {
	display: flex;
	flex-direction: column;
	gap: 12px;
}

/* Override the plugin's dark-sidebar styling since the drawer is light. */
.wst-cart-drawer .wsp-sidebar__item {
	display: grid;
	grid-template-columns: 64px 1fr auto;
	gap: 12px;
	padding: 12px;
	background: var(--wst-color-bg-alt, #f5f5f7);
	border-radius: 8px;
	align-items: start;
	margin: 0;
}

.wst-cart-drawer .wsp-sidebar__item-thumb {
	width: 64px;
	height: 64px;
	border-radius: 6px;
	overflow: hidden;
	position: relative;
	background: #ffffff;
	flex-shrink: 0;
}

.wst-cart-drawer .wsp-sidebar__item-thumb img,
.wst-cart-drawer .wsp-sidebar__item-img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

/* Placeholder for products without a thumbnail (or WC's default placeholder). */
.wst-cart-drawer .wsp-sidebar__item-img--placeholder {
	display: flex;
	align-items: center;
	justify-content: center;
	background: var(--wst-color-bg-alt, #f5f5f7);
}

.wst-cart-drawer .wsp-sidebar__item-img--placeholder::before {
	content: '';
	width: 24px;
	height: 24px;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236e6e73' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M21 16V8a2 2 0 0 0-1-1.73l-7-4a2 2 0 0 0-2 0l-7 4A2 2 0 0 0 3 8v8a2 2 0 0 0 1 1.73l7 4a2 2 0 0 0 2 0l7-4A2 2 0 0 0 21 16z'/%3E%3Cpolyline points='3.27 6.96 12 12.01 20.73 6.96'/%3E%3Cline x1='12' y1='22.08' x2='12' y2='12'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: center;
	background-size: contain;
	opacity: 0.5;
}

.wst-cart-drawer .wsp-sidebar__item-badge {
	position: absolute;
	top: -6px;
	right: -6px;
	min-width: 20px;
	height: 20px;
	padding: 0 6px;
	border-radius: 10px;
	background: var(--wst-color-accent, #0071e3);
	color: #ffffff;
	font-size: 11px;
	font-weight: 600;
	display: flex;
	align-items: center;
	justify-content: center;
	line-height: 1;
}

.wst-cart-drawer .wsp-sidebar__item-info {
	display: flex;
	flex-direction: column;
	gap: 6px;
	min-width: 0;
}

.wst-cart-drawer .wsp-sidebar__item-name {
	font-size: 14px;
	font-weight: 600;
	color: var(--wst-color-text, #1d1d1f);
	text-decoration: none;
	line-height: 1.3;
}

.wst-cart-drawer a.wsp-sidebar__item-name:hover {
	color: var(--wst-color-accent, #0071e3);
}

.wst-cart-drawer .wsp-sidebar__item-variations {
	font-size: 12px;
	color: var(--wst-color-text-muted, #6e6e73);
}

.wst-cart-drawer .wsp-sidebar__item-variations p {
	margin: 0;
}

.wst-cart-drawer .wsp-sidebar__item-controls {
	display: flex;
	align-items: center;
	gap: 6px;
	margin-top: 2px;
}

.wst-cart-drawer .wsp-sidebar__qty-btn {
	width: 24px;
	height: 24px;
	border: 1px solid var(--wst-color-border, #d2d2d7);
	background: #ffffff;
	color: var(--wst-color-text, #1d1d1f);
	font-size: 14px;
	line-height: 1;
	cursor: pointer;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 0;
	transition: border-color 150ms ease, background-color 150ms ease;
}

.wst-cart-drawer .wsp-sidebar__qty-btn:hover {
	border-color: var(--wst-color-text, #1d1d1f);
	background: var(--wst-color-bg-alt, #f5f5f7);
}

.wst-cart-drawer .wsp-sidebar__qty-btn:disabled {
	opacity: 0.4;
	cursor: not-allowed;
}

.wst-cart-drawer .wsp-sidebar__qty-val {
	font-size: 13px;
	color: var(--wst-color-text, #1d1d1f);
	min-width: 20px;
	text-align: center;
	font-weight: 500;
}

.wst-cart-drawer .wsp-sidebar__remove-btn {
	margin-left: auto;
	width: 24px;
	height: 24px;
	border: none;
	background: transparent;
	color: var(--wst-color-text-muted, #6e6e73);
	font-size: 20px;
	line-height: 1;
	cursor: pointer;
	padding: 0;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	transition: color 150ms ease, background-color 150ms ease;
}

.wst-cart-drawer .wsp-sidebar__remove-btn:hover {
	color: #dc2626;
	background: rgba(220, 38, 38, 0.08);
}

.wst-cart-drawer .wsp-sidebar__item-price {
	font-size: 14px;
	font-weight: 600;
	color: var(--wst-color-text, #1d1d1f);
	white-space: nowrap;
	align-self: start;
}

.wst-cart-drawer .wsp-sidebar__item-price .woocommerce-Price-amount {
	color: inherit;
}

/* =========================================================================
   Empty state
   ========================================================================= */

.wsp-drawer__empty {
	padding: 48px 16px;
	text-align: center;
}

.wsp-drawer__empty-text {
	font-size: 15px;
	color: var(--wst-color-text-muted, #6e6e73);
	margin: 0 0 16px;
}

.wsp-drawer__empty-link {
	display: inline-block;
	color: var(--wst-color-accent, #0071e3);
	font-size: 14px;
	font-weight: 500;
	text-decoration: none;
}

.wsp-drawer__empty-link:hover {
	text-decoration: underline;
}

/* =========================================================================
   Totals (scoped to drawer)
   ========================================================================= */

.wsp-drawer__totals {
	margin-top: 20px;
	padding-top: 16px;
	border-top: 1px solid var(--wst-color-border, #d2d2d7);
}

.wst-cart-drawer .wsp-sidebar__row {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 6px 0;
	font-size: 14px;
	color: var(--wst-color-text, #1d1d1f);
}

.wst-cart-drawer .wsp-sidebar__row-label {
	color: var(--wst-color-text-muted, #6e6e73);
}

.wst-cart-drawer .wsp-sidebar__row-value {
	color: var(--wst-color-text, #1d1d1f);
	font-weight: 500;
}

.wst-cart-drawer .wsp-sidebar__divider {
	height: 1px;
	background: var(--wst-color-border, #d2d2d7);
	margin: 6px 0;
}

.wst-cart-drawer .wsp-sidebar__row--total {
	font-size: 16px;
	font-weight: 600;
}

.wst-cart-drawer .wsp-sidebar__row--total .wsp-sidebar__row-label,
.wst-cart-drawer .wsp-sidebar__row--total .wsp-sidebar__row-value {
	color: var(--wst-color-text, #1d1d1f);
	font-weight: 600;
}

/* =========================================================================
   Drawer footer (CTA)
   ========================================================================= */

.wst-cart-drawer__footer {
	padding: 16px 24px 20px;
	border-top: 1px solid var(--wst-color-border, #d2d2d7);
	flex-shrink: 0;
	background: #ffffff;
}

.wst-cart-drawer__checkout {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	padding: 14px 20px;
	background: var(--wst-color-text, #1d1d1f);
	color: #ffffff;
	border: none;
	border-radius: 8px;
	font-size: 15px;
	font-weight: 600;
	text-decoration: none;
	cursor: pointer;
	transition: background-color 150ms ease;
}

.wst-cart-drawer__checkout:hover {
	background: #000000;
	color: #ffffff;
}

.wst-cart-drawer__checkout:focus-visible {
	outline: 2px solid var(--wst-color-accent, #0071e3);
	outline-offset: 2px;
}

.wst-cart-drawer__footer[hidden] {
	display: none;
}

/* =========================================================================
   Body scroll lock (applied by JS)
   ========================================================================= */

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

/* =========================================================================
   Responsive
   ========================================================================= */

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

	.wst-cart-drawer__header {
		padding: 24px 20px 16px;
	}

	.wst-cart-drawer__body {
		padding: 12px 20px;
	}

	.wst-cart-drawer__footer {
		padding: 12px 20px 16px;
	}
}

/* =========================================================================
   Reduced motion
   ========================================================================= */

@media (prefers-reduced-motion: reduce) {
	.wst-cart-drawer,
	.wst-cart-drawer-overlay {
		transition: visibility 0s;
	}
}
