/**
 * WooCommerce Popup Manager - Frontend Popup Styles
 *
 * Beautiful, modern popup styles with minimal conflict risk.
 *
 * @package WooCommerce_Popup_Manager
 * @since 1.0.0
 */

/* ---------------------------------------------------------------------------
   Overlay
   --------------------------------------------------------------------------- */
.wpm-overlay {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	z-index: 99999;
	background-color: rgba(0, 0, 0, 0.6);
	opacity: 0;
	transition: opacity 0.3s ease;
	display: flex;
	align-items: center;
	justify-content: center;
	pointer-events: auto;
}

.wpm-overlay[aria-hidden="true"] {
	pointer-events: none;
}

/* ---------------------------------------------------------------------------
   Popup Wrapper
   --------------------------------------------------------------------------- */
.wpm-popup-wrapper {
	position: fixed;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	z-index: 100000;
	display: flex;
	align-items: center;
	justify-content: center;
	pointer-events: none;
}

.wpm-popup-wrapper > * {
	pointer-events: auto;
}

/* ---------------------------------------------------------------------------
   Popup Box
   --------------------------------------------------------------------------- */
.wpm-popup {
	position: relative;
	background-color: #ffffff;
	border-radius: 12px;
	box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3), 0 0 0 1px rgba(0, 0, 0, 0.05);
	max-width: 90vw;
	width: 540px;
	max-height: 85vh;
	overflow-y: auto;
	padding: 40px 36px 36px;
	z-index: 100001;
	margin: 20px;
}

/* Scrollbar styling for popup content */
.wpm-popup::-webkit-scrollbar {
	width: 6px;
}

.wpm-popup::-webkit-scrollbar-track {
	background: transparent;
}

.wpm-popup::-webkit-scrollbar-thumb {
	background: rgba(0, 0, 0, 0.15);
	border-radius: 3px;
}

.wpm-popup::-webkit-scrollbar-thumb:hover {
	background: rgba(0, 0, 0, 0.25);
}

/* ---------------------------------------------------------------------------
   Close Button
   --------------------------------------------------------------------------- */
.wpm-close-button {
	position: absolute;
	width: 30px;
	height: 30px;
	cursor: pointer;
	border-radius: 50%;
	display: flex;
	align-items: center;
	justify-content: center;
	font-size: 20px;
	line-height: 1;
	border: none;
	background: transparent;
	color: #666666;
	padding: 0;
	transition: background-color 0.2s ease, color 0.2s ease, transform 0.2s ease;
	z-index: 10;
	outline: none;
}

.wpm-close-button:hover {
	background-color: rgba(0, 0, 0, 0.06);
	color: #333333;
	transform: rotate(90deg);
}

.wpm-close-button:focus-visible {
	outline: 2px solid #2271b1;
	outline-offset: 2px;
}

/* Close button positions */
.wpm-close-top-right {
	top: 12px;
	right: 12px;
}

.wpm-close-top-left {
	top: 12px;
	left: 12px;
}

.wpm-close-bottom-right {
	bottom: 12px;
	right: 12px;
}

.wpm-close-bottom-left {
	bottom: 12px;
	left: 12px;
}

/* Close button types */
.wpm-close-icon {
	/* X icon - default styling */
}

.wpm-close-text {
	width: auto;
	height: auto;
	padding: 6px 14px;
	border-radius: 4px;
	font-size: 14px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.5px;
}

.wpm-close-text:hover {
	transform: none;
}

.wpm-close-circle {
	background-color: rgba(0, 0, 0, 0.08);
	border: 1px solid rgba(0, 0, 0, 0.12);
}

.wpm-close-circle:hover {
	background-color: rgba(0, 0, 0, 0.15);
	transform: scale(1.1);
}

.wpm-close-x {
	font-size: 22px;
	font-weight: 300;
	line-height: 1;
	display: block;
}

/* ---------------------------------------------------------------------------
   Popup Content
   --------------------------------------------------------------------------- */
.wpm-popup-content {
	font-size: 16px;
	line-height: 1.6;
	color: #333333;
}

.wpm-popup-content p {
	margin: 0 0 1em;
}

.wpm-popup-content p:last-child {
	margin-bottom: 0;
}

.wpm-popup-content img {
	max-width: 100%;
	height: auto;
	border-radius: 6px;
}

/* ---------------------------------------------------------------------------
   Coupon Section
   --------------------------------------------------------------------------- */
.wpm-coupon-section {
	margin-top: 24px;
	text-align: center;
}

/* Coupon Button */
.wpm-coupon-button {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 14px 32px;
	background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
	color: #ffffff;
	border: none;
	border-radius: 8px;
	font-size: 16px;
	font-weight: 600;
	cursor: pointer;
	transition: transform 0.2s ease, box-shadow 0.2s ease, opacity 0.2s ease;
	box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

/* Ensure inner text inherits and is readable on top of the gradient */
.wpm-coupon-button .wpm-coupon-button-text {
    color: inherit;
    font-weight: 700;
    letter-spacing: 0.3px;
    display: inline-block;
}

/* Higher-specificity rule to override WordPress core `.button` defaults if needed */
.wpm-coupon-button.button {
	background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
	color: #ffffff;
	border: none;
}

/* Force opaque, high-contrast button on patterned/light popup backgrounds */
.wpm-popup .wpm-coupon-button,
.wpm-popup .wpm-coupon-button.button {
	background: linear-gradient(135deg, #667eea 0%, #764ba2 100%) !important;
	color: #ffffff !important;
	border: none !important;
	opacity: 1 !important;
	box-shadow: 0 6px 20px rgba(0, 0, 0, 0.18) !important;
	padding: 12px 28px !important;
}

.wpm-popup .wpm-coupon-button .wpm-coupon-button-text {
	color: #ffffff !important;
	text-shadow: 0 1px 0 rgba(0,0,0,0.35) !important;
}

.wpm-coupon-button:hover {
	transform: translateY(-2px);
	box-shadow: 0 6px 20px rgba(102, 126, 234, 0.5);
}

.wpm-coupon-button:active {
	transform: translateY(0);
}

.wpm-coupon-button:disabled {
	opacity: 0.7;
	cursor: not-allowed;
	transform: none;
}

.wpm-coupon-button:focus-visible {
	outline: 2px solid #2271b1;
	outline-offset: 2px;
}

/* Loading Spinner */
.wpm-spinner {
	display: inline-flex;
	align-items: center;
	justify-content: center;
}

.wpm-spinner-icon {
	display: inline-block;
	width: 18px;
	height: 18px;
	border: 2px solid rgba(255, 255, 255, 0.3);
	border-top-color: #ffffff;
	border-radius: 50%;
	animation: wpm-spin 0.6s linear infinite;
}

@keyframes wpm-spin {
	to {
		transform: rotate(360deg);
	}
}

/* Coupon Result */
.wpm-coupon-result {
	margin-top: 16px;
}

/* Coupon Success */
.wpm-coupon-success {
	padding: 20px;
	background: #f0fdf4;
	border: 1px solid #bbf7d0;
	border-radius: 10px;
}

.wpm-coupon-checkmark {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 48px;
	height: 48px;
	background: #22c55e;
	color: #ffffff;
	border-radius: 50%;
	font-size: 24px;
	font-weight: bold;
	margin-bottom: 12px;
}

.wpm-coupon-message {
	font-size: 15px;
	color: #166534;
	margin-bottom: 16px;
	line-height: 1.5;
}

.wpm-coupon-message strong {
	font-weight: 700;
}

/* Coupon Code Box */
.wpm-coupon-code-box {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 12px;
	margin-bottom: 12px;
	flex-wrap: wrap;
}

.wpm-coupon-code {
	display: inline-block;
	padding: 10px 20px;
	background: #ffffff;
	border: 2px dashed #22c55e;
	border-radius: 6px;
	font-family: 'Courier New', Courier, monospace;
	font-size: 20px;
	font-weight: 700;
	color: #15803d;
	letter-spacing: 1px;
	word-break: break-all;
}

.wpm-coupon-discount {
	display: inline-block;
	padding: 8px 16px;
	background: linear-gradient(135deg, #f59e0b, #d97706);
	color: #ffffff;
	border-radius: 6px;
	font-size: 14px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.5px;
}

/* Copy Button */
.wpm-copy-button {
	display: inline-block;
	padding: 8px 20px;
	background: #ffffff;
	color: #22c55e;
	border: 2px solid #22c55e;
	border-radius: 6px;
	font-size: 14px;
	font-weight: 600;
	cursor: pointer;
	transition: background-color 0.2s ease, color 0.2s ease;
}

.wpm-copy-button:hover {
	background: #22c55e;
	color: #ffffff;
}

.wpm-copy-button:focus-visible {
	outline: 2px solid #2271b1;
	outline-offset: 2px;
}

/* Coupon Expiry */
.wpm-coupon-expiry {
	font-size: 13px;
	color: #6b7280;
	margin-top: 8px;
}

/* Coupon Error */
.wpm-coupon-error {
	padding: 16px;
	background: #fef2f2;
	border: 1px solid #fecaca;
	border-radius: 10px;
}

.wpm-coupon-error-message {
	color: #991b1b;
	font-size: 14px;
	margin: 0;
}

/* ---------------------------------------------------------------------------
   Animations - Entrance
   --------------------------------------------------------------------------- */

/* Fade In */
.wpm-fade-in {
	opacity: 0;
	animation: wpmAnimFadeIn 0.3s ease forwards;
}

@keyframes wpmAnimFadeIn {
	to {
		opacity: 1;
	}
}

/* Slide In */
.wpm-slide-in {
	opacity: 0;
	transform: translateY(-50px);
	animation: wpmAnimSlideIn 0.4s ease forwards;
}

@keyframes wpmAnimSlideIn {
	to {
		opacity: 1;
		transform: translateY(0);
	}
}

/* Bounce In */
.wpm-bounce-in {
	opacity: 0;
	transform: scale(0.3);
	animation: wpmAnimBounceIn 0.5s ease forwards;
}

@keyframes wpmAnimBounceIn {
	50% {
		opacity: 1;
		transform: scale(1.05);
	}
	75% {
		transform: scale(0.95);
	}
	100% {
		opacity: 1;
		transform: scale(1);
	}
}

/* Zoom In */
.wpm-zoom-in {
	opacity: 0;
	transform: scale(0.5);
	animation: wpmAnimZoomIn 0.3s ease forwards;
}

@keyframes wpmAnimZoomIn {
	to {
		opacity: 1;
		transform: scale(1);
	}
}

/* ---------------------------------------------------------------------------
   Animations - Exit
   --------------------------------------------------------------------------- */

/* Fade Out */
.wpm-fade-out {
	animation: wpmAnimFadeOut 0.3s ease forwards;
}

@keyframes wpmAnimFadeOut {
	to {
		opacity: 0;
	}
}

/* Slide Out */
.wpm-slide-out {
	animation: wpmAnimSlideOut 0.4s ease forwards;
}

@keyframes wpmAnimSlideOut {
	to {
		opacity: 0;
		transform: translateY(30px);
	}
}

/* Bounce Out */
.wpm-bounce-out {
	animation: wpmAnimBounceOut 0.4s ease forwards;
}

@keyframes wpmAnimBounceOut {
	20% {
		transform: scale(1.1);
	}
	100% {
		opacity: 0;
		transform: scale(0.5);
	}
}

/* Zoom Out */
.wpm-zoom-out {
	animation: wpmAnimZoomOut 0.3s ease forwards;
}

@keyframes wpmAnimZoomOut {
	to {
		opacity: 0;
		transform: scale(0.5);
	}
}

/* ---------------------------------------------------------------------------
   Shortcode Trigger Link
   --------------------------------------------------------------------------- */
.wpm-shortcode-trigger {
	color: #2271b1;
	text-decoration: underline;
	cursor: pointer;
}

.wpm-shortcode-trigger:hover {
	color: #135e96;
}

/* ---------------------------------------------------------------------------
   Mobile Responsive
   --------------------------------------------------------------------------- */
@media screen and (max-width: 768px) {
	.wpm-popup {
		max-width: 95vw;
		width: 100%;
		max-height: 80vh;
		padding: 30px 20px 24px;
		margin: 10px;
		border-radius: 10px;
	}

	.wpm-popup-content {
		font-size: 15px;
	}

	.wpm-coupon-button {
		padding: 12px 24px;
		font-size: 15px;
		width: 100%;
	}

	.wpm-coupon-code {
		font-size: 16px;
		padding: 8px 14px;
	}

	.wpm-coupon-code-box {
		flex-direction: column;
		gap: 8px;
	}

	.wpm-copy-button {
		width: 100%;
	}
}

@media screen and (max-width: 480px) {
	.wpm-popup {
		padding: 24px 16px 20px;
		border-radius: 8px;
		max-height: 75vh;
	}

	.wpm-popup-content {
		font-size: 14px;
	}

	.wpm-close-button {
		width: 26px;
		height: 26px;
		font-size: 18px;
		top: 8px;
		right: 8px;
	}
}

/* ---------------------------------------------------------------------------
   Print Styles
   --------------------------------------------------------------------------- */
@media print {
	.wpm-popup-wrapper,
	.wpm-overlay {
		display: none !important;
	}
}

/* ---------------------------------------------------------------------------
   Accessibility: Reduced Motion
   --------------------------------------------------------------------------- */
@media (prefers-reduced-motion: reduce) {
	.wpm-popup-wrapper,
	.wpm-overlay,
	.wpm-popup,
	.wpm-close-button,
	.wpm-coupon-button,
	.wpm-copy-button {
		transition: none !important;
		animation: none !important;
	}

	.wpm-fade-in,
	.wpm-slide-in,
	.wpm-bounce-in,
	.wpm-zoom-in,
	.wpm-fade-out,
	.wpm-slide-out,
	.wpm-bounce-out,
	.wpm-zoom-out {
		animation: none !important;
		opacity: 1 !important;
		transform: none !important;
	}
}
