/**
 * WooCommerce Gift Card - Gift Card Listing Styles
 *
 * Styles for the [gift_cards] shortcode product listing.
 *
 * @package Dzine\WooCommerceGiftCard
 * @version 3.0.0
 */

/* ==========================================================================
   CSS Custom Properties
   ========================================================================== */

.wc-gift-card-listing {
	--gc-primary: #96588a;
	--gc-primary-hover: #7a4871;
	--gc-text: #333;
	--gc-text-muted: #666;
	--gc-border: #e5e5e5;
	--gc-bg: #fff;
	--gc-bg-alt: #f9f9f9;
	--gc-radius: 8px;
	--gc-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
	--gc-shadow-hover: 0 8px 24px rgba(0, 0, 0, 0.12);
	--gc-transition: 0.3s ease;
}

/* ==========================================================================
   Listing Container
   ========================================================================== */

.wc-gift-card-listing {
	display: block;
	clear: both;
	width: 100%;
	max-width: 100%;
	margin: 0 auto;
	padding: 0;
	box-sizing: border-box;
}

.wc-gift-card-listing *,
.wc-gift-card-listing *::before,
.wc-gift-card-listing *::after {
	box-sizing: border-box;
}

/* ==========================================================================
   Product Grid
   ========================================================================== */

.wc-gift-card-listing .products {
	display: grid !important;
	grid-template-columns: repeat(4, 1fr);
	gap: 24px;
	list-style: none !important;
	padding: 0 !important;
	margin: 0 !important;
	width: 100%;
	float: none !important;
}

/* Override common theme styles that might break the grid */
.wc-gift-card-listing .products::before,
.wc-gift-card-listing .products::after {
	content: none !important;
	display: none !important;
}

.wc-gift-card-listing .products.columns-1 {
	grid-template-columns: 1fr;
	max-width: 480px;
	margin: 0 auto !important;
}

.wc-gift-card-listing .products.columns-2 {
	grid-template-columns: repeat(2, 1fr);
}

.wc-gift-card-listing .products.columns-3 {
	grid-template-columns: repeat(3, 1fr);
}

.wc-gift-card-listing .products.columns-4 {
	grid-template-columns: repeat(4, 1fr);
}

.wc-gift-card-listing .products.columns-5 {
	grid-template-columns: repeat(5, 1fr);
}

.wc-gift-card-listing .products.columns-6 {
	grid-template-columns: repeat(6, 1fr);
}

/* ==========================================================================
   Product Card
   ========================================================================== */

.wc-gift-card-listing .products li.product {
	position: relative;
	display: flex !important;
	flex-direction: column;
	width: 100% !important;
	margin: 0 !important;
	padding: 0 !important;
	float: none !important;
	clear: none !important;
	background: var(--gc-bg);
	border: 1px solid var(--gc-border);
	border-radius: var(--gc-radius);
	overflow: hidden;
	transition: box-shadow var(--gc-transition), transform var(--gc-transition);
	list-style: none !important;
}

.wc-gift-card-listing .products li.product:hover {
	box-shadow: var(--gc-shadow-hover);
	transform: translateY(-4px);
}

/* Gift Card Badge */
.wc-gift-card-listing .products li.product::before {
	content: "";
	position: absolute;
	top: 12px;
	right: 12px;
	width: 32px;
	height: 32px;
	background: var(--gc-primary);
	border-radius: 50%;
	z-index: 10;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='white'%3E%3Cpath d='M20 7h-1.26A4.5 4.5 0 0 0 12 4.02a4.5 4.5 0 0 0-6.74 2.98H4a2 2 0 0 0-2 2v2h20V9a2 2 0 0 0-2-2zM9.5 6a2.5 2.5 0 0 1 2.5 2.5V9H9.5a2.5 2.5 0 0 1 0-5zm5 3H12v-.5a2.5 2.5 0 1 1 2.5 2.5zM2 13v7a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-7H2zm9 5H4v-2h7v2zm9 0h-7v-2h7v2z'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: center;
	background-size: 18px 18px;
	box-shadow: 0 2px 8px rgba(150, 88, 138, 0.4);
}

/* ==========================================================================
   Product Link
   ========================================================================== */

.wc-gift-card-listing-link {
	display: block;
	text-decoration: none;
	color: inherit;
}

.wc-gift-card-listing-link:hover,
.wc-gift-card-listing-link:focus {
	text-decoration: none;
	color: inherit;
}

/* ==========================================================================
   Product Thumbnail
   ========================================================================== */

.wc-gift-card-thumbnail {
	position: relative;
	overflow: hidden;
	background: var(--gc-bg-alt);
}

.wc-gift-card-thumbnail::after {
	content: "";
	display: block;
	padding-bottom: 75%;
}

.wc-gift-card-thumbnail img {
	position: absolute;
	top: 0;
	left: 0;
	width: 100%;
	height: 100%;
	object-fit: cover;
	transition: transform var(--gc-transition);
}

.wc-gift-card-listing .products li.product:hover .wc-gift-card-thumbnail img {
	transform: scale(1.05);
}

/* ==========================================================================
   Product Details
   ========================================================================== */

.wc-gift-card-listing .products li.product .wc-gift-card-listing-link + * {
	padding: 0 16px;
}

.wc-gift-card-listing .products li.product > .wc-gift-card-listing-link {
	display: flex;
	flex-direction: column;
}

.wc-gift-card-listing .products li.product .wc-gift-card-title,
.wc-gift-card-listing .products li.product .wc-gift-card-price,
.wc-gift-card-listing .products li.product .wc-gift-card-excerpt {
	padding: 0 16px;
}

/* ==========================================================================
   Product Title
   ========================================================================== */

.wc-gift-card-title {
	font-size: 1rem;
	font-weight: 600;
	line-height: 1.4;
	margin: 16px 0 8px;
	color: var(--gc-text);
}

.wc-gift-card-listing .products li.product:hover .wc-gift-card-title {
	color: var(--gc-primary);
}

/* ==========================================================================
   Product Price
   ========================================================================== */

.wc-gift-card-price {
	margin-bottom: 12px;
}

.wc-gift-card-price .price {
	display: flex;
	align-items: center;
	gap: 8px;
	flex-wrap: wrap;
}

.wc-gift-card-price .woocommerce-Price-amount {
	font-size: 1.25rem;
	font-weight: 700;
	color: var(--gc-primary);
}

.wc-gift-card-price del {
	opacity: 0.5;
}

.wc-gift-card-price del .woocommerce-Price-amount {
	font-size: 1rem;
	font-weight: 400;
	color: var(--gc-text-muted);
}

.wc-gift-card-price ins {
	text-decoration: none;
}

/* ==========================================================================
   Product Excerpt
   ========================================================================== */

.wc-gift-card-excerpt {
	font-size: 0.875rem;
	line-height: 1.5;
	color: var(--gc-text-muted);
	margin-bottom: 16px;
}

.wc-gift-card-excerpt p {
	margin: 0;
}

/* ==========================================================================
   Add to Cart Button
   ========================================================================== */

.wc-gift-card-listing .products li.product .button,
.wc-gift-card-listing .products li.product .add_to_cart_button {
	display: block;
	width: calc(100% - 32px);
	margin: 0 16px 16px;
	padding: 12px 20px;
	background: var(--gc-primary);
	color: #fff;
	border: none;
	border-radius: 6px;
	font-size: 0.875rem;
	font-weight: 600;
	text-align: center;
	text-decoration: none;
	cursor: pointer;
	transition: background var(--gc-transition), transform 0.15s ease;
}

.wc-gift-card-listing .products li.product .button:hover,
.wc-gift-card-listing .products li.product .add_to_cart_button:hover {
	background: var(--gc-primary-hover);
	color: #fff;
	transform: translateY(-1px);
}

.wc-gift-card-listing .products li.product .button.loading::after {
	display: inline-block;
	width: 14px;
	height: 14px;
	margin-left: 8px;
	border: 2px solid rgba(255, 255, 255, 0.3);
	border-top-color: #fff;
	border-radius: 50%;
	animation: gc-spin 0.8s linear infinite;
	content: "";
	vertical-align: middle;
}

.wc-gift-card-listing .products li.product .added_to_cart {
	display: block;
	text-align: center;
	padding: 8px 16px;
	color: var(--gc-primary);
	font-size: 0.875rem;
	font-weight: 500;
	text-decoration: none;
}

.wc-gift-card-listing .products li.product .added_to_cart:hover {
	text-decoration: underline;
}

/* ==========================================================================
   Pagination
   ========================================================================== */

.wc-gift-card-pagination {
	margin-top: 40px;
	text-align: center;
}

.wc-gift-card-pagination ul,
.wc-gift-card-pagination .page-numbers {
	display: inline-flex;
	gap: 6px;
	list-style: none;
	padding: 0;
	margin: 0;
	flex-wrap: wrap;
	justify-content: center;
}

.wc-gift-card-pagination li {
	margin: 0;
}

.wc-gift-card-pagination a,
.wc-gift-card-pagination span {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	min-width: 40px;
	height: 40px;
	padding: 0 12px;
	border: 1px solid var(--gc-border);
	border-radius: 6px;
	text-decoration: none;
	color: var(--gc-text);
	font-weight: 500;
	transition: all 0.2s ease;
}

.wc-gift-card-pagination a:hover {
	background: var(--gc-bg-alt);
	border-color: var(--gc-primary);
	color: var(--gc-primary);
}

.wc-gift-card-pagination .current,
.wc-gift-card-pagination span.current {
	background: var(--gc-primary);
	color: #fff;
	border-color: var(--gc-primary);
}

.wc-gift-card-pagination .prev,
.wc-gift-card-pagination .next {
	font-size: 1.25rem;
}

/* ==========================================================================
   No Products Message
   ========================================================================== */

.wc-gift-card-no-products {
	text-align: center;
	padding: 60px 30px;
	background: var(--gc-bg-alt);
	border-radius: var(--gc-radius);
	color: var(--gc-text-muted);
	font-size: 1rem;
}

.wc-gift-card-no-products::before {
	display: block;
	width: 64px;
	height: 64px;
	margin: 0 auto 16px;
	background: var(--gc-border);
	border-radius: 50%;
	content: "";
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='%23999'%3E%3Cpath d='M20 7h-1.26A4.5 4.5 0 0 0 12 4.02a4.5 4.5 0 0 0-6.74 2.98H4a2 2 0 0 0-2 2v2h20V9a2 2 0 0 0-2-2zM2 13v7a2 2 0 0 0 2 2h16a2 2 0 0 0 2-2v-7H2z'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: center;
	background-size: 32px 32px;
}

/* ==========================================================================
   Animations
   ========================================================================== */

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

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

@media (max-width: 1199px) {
	.wc-gift-card-listing .products.columns-5,
	.wc-gift-card-listing .products.columns-6 {
		grid-template-columns: repeat(4, 1fr);
	}
}

@media (max-width: 991px) {
	.wc-gift-card-listing .products,
	.wc-gift-card-listing .products.columns-4,
	.wc-gift-card-listing .products.columns-5,
	.wc-gift-card-listing .products.columns-6 {
		grid-template-columns: repeat(3, 1fr);
	}
}

@media (max-width: 767px) {
	.wc-gift-card-listing .products,
	.wc-gift-card-listing .products.columns-3,
	.wc-gift-card-listing .products.columns-4,
	.wc-gift-card-listing .products.columns-5,
	.wc-gift-card-listing .products.columns-6 {
		grid-template-columns: repeat(2, 1fr);
		gap: 16px;
	}

	.wc-gift-card-listing .products li.product::before {
		width: 28px;
		height: 28px;
		background-size: 14px 14px;
		top: 8px;
		right: 8px;
	}

	.wc-gift-card-title {
		font-size: 0.9rem;
	}

	.wc-gift-card-price .woocommerce-Price-amount {
		font-size: 1.1rem;
	}
}

@media (max-width: 480px) {
	.wc-gift-card-listing .products,
	.wc-gift-card-listing .products.columns-2,
	.wc-gift-card-listing .products.columns-3,
	.wc-gift-card-listing .products.columns-4,
	.wc-gift-card-listing .products.columns-5,
	.wc-gift-card-listing .products.columns-6 {
		grid-template-columns: 1fr;
	}

	.wc-gift-card-listing .products li.product {
		display: flex;
		flex-direction: row;
	}

	.wc-gift-card-thumbnail {
		flex: 0 0 120px;
		width: 120px;
	}

	.wc-gift-card-thumbnail::after {
		padding-bottom: 100%;
	}

	.wc-gift-card-listing .products li.product > .wc-gift-card-listing-link {
		flex-direction: row;
		width: 100%;
	}

	.wc-gift-card-listing .products li.product .wc-gift-card-listing-link .wc-gift-card-thumbnail + * {
		flex: 1;
		display: flex;
		flex-direction: column;
		justify-content: center;
	}

	.wc-gift-card-title {
		margin-top: 0;
	}

	.wc-gift-card-listing .products li.product .button,
	.wc-gift-card-listing .products li.product .add_to_cart_button {
		margin-top: auto;
	}
}

/* ==========================================================================
   RTL Support
   ========================================================================== */

[dir="rtl"] .wc-gift-card-listing .products li.product::before {
	right: auto;
	left: 12px;
}

/* ==========================================================================
   Theme Compatibility Overrides
   ========================================================================== */

/* Reset common Storefront/WooCommerce theme styles */
.wc-gift-card-listing ul.products {
	margin-left: 0 !important;
	margin-right: 0 !important;
}

.wc-gift-card-listing ul.products::before,
.wc-gift-card-listing ul.products::after {
	display: none !important;
	content: none !important;
}

/* Fix for themes using flex on .products */
.wc-gift-card-listing .products.columns-1,
.wc-gift-card-listing .products.columns-2,
.wc-gift-card-listing .products.columns-3,
.wc-gift-card-listing .products.columns-4,
.wc-gift-card-listing .products.columns-5,
.wc-gift-card-listing .products.columns-6 {
	display: grid !important;
	flex-wrap: unset !important;
}

/* Override width calculations from themes */
.wc-gift-card-listing .products li.product,
.wc-gift-card-listing ul.products li.product {
	width: 100% !important;
	max-width: none !important;
	margin-left: 0 !important;
	margin-right: 0 !important;
}

/* Fix for Elementor and page builders */
.elementor-widget-container .wc-gift-card-listing,
.wp-block-group .wc-gift-card-listing,
.entry-content .wc-gift-card-listing {
	width: 100%;
	max-width: 100%;
}

/* Ensure images scale properly */
.wc-gift-card-listing .products li.product img {
	max-width: 100%;
	height: auto;
}

/* Fix for themes that hide product content */
.wc-gift-card-listing .products li.product .wc-gift-card-title,
.wc-gift-card-listing .products li.product .wc-gift-card-price,
.wc-gift-card-listing .products li.product .wc-gift-card-excerpt,
.wc-gift-card-listing .products li.product .wc-gift-card-thumbnail {
	display: block !important;
	visibility: visible !important;
	opacity: 1 !important;
}
