/**
 * Cart Popup Module — added-to-cart popup and floating mini-cart widget.
 *
 * @package WPAIC
 */

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

.wpaic-cart-popup-overlay {
	position: fixed;
	inset: 0;
	z-index: 99998;
	background: rgba(0, 0, 0, 0.5);
	opacity: 0;
	transition: opacity 0.3s ease;
	pointer-events: none;
}

.wpaic-cart-popup-overlay.is-visible {
	opacity: 1;
	pointer-events: auto;
}


/* === Popup Modal === */

.wpaic-cart-popup {
	position: fixed;
	z-index: 99999;
	background: #fff;
	border-radius: 12px;
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.2);
	max-width: 520px;
	width: calc(100% - 32px);
	max-height: 90vh;
	overflow-y: auto;
	opacity: 0;
	pointer-events: none;
	transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Center position */
.wpaic-cart-popup--center {
	top: 50%;
	left: 50%;
	transform: translate(-50%, -50%) scale(0.9);
}

.wpaic-cart-popup--center.is-visible {
	transform: translate(-50%, -50%) scale(1);
}

/* Fade animation */
.wpaic-cart-popup--fade {
	transition: opacity 0.3s ease, transform 0.3s ease;
}

/* Slide animation */
.wpaic-cart-popup--slide {
	transition: opacity 0.3s ease, transform 0.35s cubic-bezier(0.22, 1, 0.36, 1);
}

.wpaic-cart-popup--slide.wpaic-cart-popup--center {
	transform: translate(-50%, -40%) scale(0.95);
}

.wpaic-cart-popup--slide.wpaic-cart-popup--center.is-visible {
	transform: translate(-50%, -50%) scale(1);
}

/* Zoom animation */
.wpaic-cart-popup--zoom {
	transition: opacity 0.3s ease, transform 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.wpaic-cart-popup--zoom.wpaic-cart-popup--center {
	transform: translate(-50%, -50%) scale(0.5);
}

.wpaic-cart-popup--zoom.wpaic-cart-popup--center.is-visible {
	transform: translate(-50%, -50%) scale(1);
}

.wpaic-cart-popup.is-visible {
	opacity: 1;
	pointer-events: auto;
}


/* === Popup Header === */

.wpaic-cart-popup__header {
	display: flex;
	align-items: center;
	gap: 10px;
	padding: 16px 20px;
	border-bottom: 1px solid #e5e7eb;
	background: #f0fdf4;
	border-radius: 12px 12px 0 0;
}

.wpaic-cart-popup__header-icon {
	flex-shrink: 0;
	width: 28px;
	height: 28px;
	display: flex;
	align-items: center;
	justify-content: center;
	background: #22c55e;
	color: #fff;
	border-radius: 50%;
}

.wpaic-cart-popup__header-icon svg {
	width: 16px;
	height: 16px;
}

.wpaic-cart-popup__header-title {
	flex: 1;
	font-size: 15px;
	font-weight: 600;
	color: #166534;
	margin: 0;
}

.wpaic-cart-popup__close {
	flex-shrink: 0;
	width: 32px;
	height: 32px;
	display: flex;
	align-items: center;
	justify-content: center;
	background: none;
	border: none;
	color: #6b7280;
	cursor: pointer;
	border-radius: 6px;
	font-size: 20px;
	line-height: 1;
	transition: background 0.2s, color 0.2s;
}

.wpaic-cart-popup__close:hover {
	background: #f3f4f6;
	color: #111827;
}


/* === Product Info === */

.wpaic-cart-popup__product {
	display: flex;
	gap: 16px;
	padding: 16px 20px;
	border-bottom: 1px solid #f3f4f6;
}

.wpaic-cart-popup__product-image {
	flex-shrink: 0;
	width: 80px;
	height: 80px;
	border-radius: 8px;
	overflow: hidden;
	background: #f9fafb;
}

.wpaic-cart-popup__product-image img {
	width: 100%;
	height: 100%;
	object-fit: cover;
}

.wpaic-cart-popup__product-info {
	flex: 1;
	min-width: 0;
}

.wpaic-cart-popup__product-name {
	font-size: 15px;
	font-weight: 600;
	color: #111827;
	margin: 0 0 4px;
	line-height: 1.3;
}

.wpaic-cart-popup__product-name a {
	color: inherit;
	text-decoration: none;
}

.wpaic-cart-popup__product-name a:hover {
	color: #2563eb;
}

.wpaic-cart-popup__product-variations {
	display: flex;
	flex-wrap: wrap;
	gap: 4px 12px;
	margin-bottom: 6px;
}

.wpaic-cart-popup__product-variation {
	font-size: 12px;
	color: #6b7280;
}

.wpaic-cart-popup__product-variation strong {
	color: #374151;
	font-weight: 500;
}

.wpaic-cart-popup__product-price {
	font-size: 16px;
	font-weight: 700;
	color: #111827;
}

.wpaic-cart-popup__product-qty {
	font-size: 13px;
	color: #6b7280;
	font-weight: 400;
}

.wpaic-cart-popup__product-subtotal {
	font-size: 13px;
	color: #374151;
	margin-top: 2px;
}


/* === Cart Summary === */

.wpaic-cart-popup__summary {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 12px 20px;
	background: #f9fafb;
	border-bottom: 1px solid #f3f4f6;
}

.wpaic-cart-popup__summary-label {
	font-size: 13px;
	color: #6b7280;
}

.wpaic-cart-popup__summary-value {
	font-size: 15px;
	font-weight: 700;
	color: #111827;
}


/* === Action Buttons === */

.wpaic-cart-popup__actions {
	display: flex;
	gap: 8px;
	padding: 16px 20px;
	border-bottom: 1px solid #f3f4f6;
}

.wpaic-cart-popup__btn {
	flex: 1;
	display: inline-flex;
	align-items: center;
	justify-content: center;
	padding: 10px 16px;
	font-size: 13px;
	font-weight: 600;
	border-radius: 8px;
	cursor: pointer;
	transition: all 0.2s;
	text-decoration: none;
	line-height: 1;
	white-space: nowrap;
	border: none;
}

.wpaic-cart-popup__btn--continue {
	background: #f3f4f6;
	color: #374151;
	border: 1px solid #d1d5db;
}

.wpaic-cart-popup__btn--continue:hover {
	background: #e5e7eb;
	color: #111827;
}

.wpaic-cart-popup__btn--cart {
	background: #2563eb;
	color: #fff;
}

.wpaic-cart-popup__btn--cart:hover {
	background: #1d4ed8;
	color: #fff;
}

.wpaic-cart-popup__btn--checkout {
	background: #16a34a;
	color: #fff;
}

.wpaic-cart-popup__btn--checkout:hover {
	background: #15803d;
	color: #fff;
}


/* === Recommendations / Upsell === */

.wpaic-cart-popup__upsell {
	padding: 16px 20px 20px;
}

.wpaic-cart-popup__upsell-title {
	font-size: 14px;
	font-weight: 600;
	color: #374151;
	margin: 0 0 12px;
}

.wpaic-cart-popup__upsell-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
	gap: 12px;
}

.wpaic-cart-popup__upsell-item {
	text-align: center;
	text-decoration: none;
	color: inherit;
	transition: transform 0.2s;
}

.wpaic-cart-popup__upsell-item:hover {
	transform: translateY(-2px);
}

.wpaic-cart-popup__upsell-img {
	width: 100%;
	aspect-ratio: 1;
	object-fit: cover;
	border-radius: 8px;
	background: #f9fafb;
	margin-bottom: 6px;
}

.wpaic-cart-popup__upsell-name {
	font-size: 12px;
	font-weight: 500;
	color: #374151;
	line-height: 1.3;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	margin-bottom: 4px;
}

.wpaic-cart-popup__upsell-price {
	font-size: 13px;
	font-weight: 700;
	color: #111827;
}

.wpaic-cart-popup__upsell-add {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	margin-top: 6px;
	padding: 4px 10px;
	font-size: 11px;
	font-weight: 600;
	background: #2563eb;
	color: #fff;
	border: none;
	border-radius: 4px;
	cursor: pointer;
	transition: background 0.2s;
}

.wpaic-cart-popup__upsell-add:hover {
	background: #1d4ed8;
}

.wpaic-cart-popup__upsell-add.is-loading {
	opacity: 0.6;
	pointer-events: none;
}


/* === Floating Mini Cart Widget === */

.wpaic-cart-widget {
	position: fixed;
	bottom: 160px;
	right: 20px;
	z-index: 99990;
	display: flex;
	flex-direction: column;
	align-items: flex-end;
	gap: 8px;
	transform: scale(0);
	opacity: 0;
	transition: transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), opacity 0.2s;
	pointer-events: none;
}

.wpaic-cart-widget.is-visible {
	transform: scale(1);
	opacity: 1;
	pointer-events: auto;
}

/* Main round button */
.wpaic-cart-widget__btn {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 56px;
	height: 56px;
	background: #16a34a;
	color: #fff;
	border: none;
	border-radius: 50%;
	cursor: pointer;
	box-shadow: 0 4px 16px rgba(22, 163, 74, 0.4);
	transition: background 0.2s, transform 0.2s, box-shadow 0.2s;
	text-decoration: none;
	position: relative;
}

.wpaic-cart-widget__btn:hover {
	background: #15803d;
	transform: scale(1.08);
	box-shadow: 0 6px 24px rgba(22, 163, 74, 0.5);
	color: #fff;
}

.wpaic-cart-widget__btn svg {
	width: 24px;
	height: 24px;
}

/* Badge counter */
.wpaic-cart-widget__badge {
	position: absolute;
	top: -4px;
	right: -4px;
	min-width: 22px;
	height: 22px;
	padding: 0 6px;
	background: #ef4444;
	color: #fff;
	border-radius: 11px;
	font-size: 12px;
	font-weight: 700;
	line-height: 22px;
	text-align: center;
	border: 2px solid #fff;
	box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15);
}

/* Tooltip label */
.wpaic-cart-widget__label {
	background: #1e293b;
	color: #fff;
	padding: 6px 12px;
	border-radius: 6px;
	font-size: 13px;
	font-weight: 500;
	white-space: nowrap;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
	opacity: 0;
	transform: translateX(8px);
	transition: opacity 0.2s, transform 0.2s;
	pointer-events: none;
	position: absolute;
	right: 64px;
	top: 50%;
	margin-top: -15px;
}

.wpaic-cart-widget:hover .wpaic-cart-widget__label {
	opacity: 1;
	transform: translateX(0);
}

/* Total price under label */
.wpaic-cart-widget__total {
	display: none;
}

.wpaic-cart-widget--show-total .wpaic-cart-widget__total {
	display: block;
	font-size: 11px;
	color: #fff;
	text-align: center;
	background: #1e293b;
	padding: 2px 8px;
	border-radius: 4px;
	margin-top: -4px;
	white-space: nowrap;
}

/* Bounce animation on add */
@keyframes wpaic-cart-bounce {
	0%, 100% { transform: scale(1); }
	30% { transform: scale(1.25); }
	60% { transform: scale(0.95); }
}

.wpaic-cart-widget__btn.is-bouncing {
	animation: wpaic-cart-bounce 0.4s ease;
}


/* === Scrollbar for popup === */

.wpaic-cart-popup::-webkit-scrollbar {
	width: 6px;
}

.wpaic-cart-popup::-webkit-scrollbar-track {
	background: transparent;
}

.wpaic-cart-popup::-webkit-scrollbar-thumb {
	background: #d1d5db;
	border-radius: 3px;
}


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

@media (max-width: 768px) {
	.wpaic-cart-popup {
		max-width: 100%;
		width: 100%;
		max-height: 80vh;
		border-radius: 12px 12px 0 0;
	}

	.wpaic-cart-popup--center {
		top: auto;
		bottom: 0;
		left: 0;
		transform: translateY(100%);
	}

	.wpaic-cart-popup--center.is-visible {
		transform: translateY(0);
	}

	.wpaic-cart-popup--slide.wpaic-cart-popup--center {
		transform: translateY(100%);
	}

	.wpaic-cart-popup--slide.wpaic-cart-popup--center.is-visible {
		transform: translateY(0);
	}

	.wpaic-cart-popup--zoom.wpaic-cart-popup--center {
		transform: translateY(100%) scale(0.9);
	}

	.wpaic-cart-popup--zoom.wpaic-cart-popup--center.is-visible {
		transform: translateY(0) scale(1);
	}

	.wpaic-cart-popup__header {
		padding: 14px 16px;
	}

	.wpaic-cart-popup__product {
		padding: 14px 16px;
	}

	.wpaic-cart-popup__actions {
		flex-direction: column;
		padding: 14px 16px;
	}

	.wpaic-cart-popup__upsell-grid {
		grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
		gap: 10px;
	}

	.wpaic-cart-widget {
		bottom: 140px;
		right: 12px;
	}

	.wpaic-cart-widget__btn {
		width: 48px;
		height: 48px;
	}

	.wpaic-cart-widget__btn svg {
		width: 20px;
		height: 20px;
	}

	.wpaic-cart-widget__label {
		display: none;
	}
}

@media (max-width: 480px) {
	.wpaic-cart-popup__product-image {
		width: 64px;
		height: 64px;
	}

	.wpaic-cart-popup__upsell-grid {
		grid-template-columns: repeat(3, 1fr);
	}
}
