/**
 * DiveWP Upsell Frontend Styles
 *
 * New card design: rounded corners, image top, price row, save badge bottom.
 * Color: #fba4a4 for save badge, theme default fonts.
 *
 * @package DiveWP_Upsell_For_WC
 */

/* Section container */
.divewp-upsells-section {
	margin: 20px 0;
	padding: 0 10px;
}

/* Section title */
.divewp-upsells-title {
	display: block;
	font-size: 0.9em;
	font-weight: 700;
	margin: 0 0 5px 0;
	padding: 0;
	color: #1a1a1a;
	letter-spacing: -0.2px;
}

/* Products container - 3 column grid */
.divewp-upsells-container {
	display: grid;
	grid-template-columns: repeat(3, 1fr);
	gap: 12px;
}

/* Individual product card - new design per screenshot */
.divewp-upsell-product-card {
	position: relative;
	display: flex;
	flex-direction: column;
	background: #fff;
	border: 1px solid #eee;
	border-radius: 16px;
	text-decoration: none;
	color: inherit;
	overflow: hidden;
	cursor: pointer;
	transition: all 0.2s ease;
	user-select: none;
}

.divewp-upsell-product-card:hover {
	text-decoration: none;
	color: inherit;
	border-color: #fba4a4;
	box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
}

/* Selected state */
.divewp-upsell-product-card.divewp-upsell-selected {
	background: #fff;
	border-color: #fba4a4;
	border-width: 2px;
	box-shadow: 0 6px 16px rgba(251, 164, 164, 0.2);
}

/* Image wrapper - at the top */
.divewp-upsell-product-image-wrapper {
	position: relative;
	width: 100%;
	aspect-ratio: 1 / 1;
	background: #fff;
	overflow: hidden;
	display: flex;
	align-items: center;
	justify-content: center;
}

/* Product image */
.divewp-upsell-product-image {
	width: 100%;
	height: 100%;
	object-fit: contain;
	padding: 0px;
	box-sizing: border-box;
}

/* Product title - max 2 rows with ellipsis */
.divewp-upsell-product-title-wrapper {
	display: -webkit-box;
	-webkit-line-clamp: 2;
	line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	text-overflow: ellipsis;
	font-size: 1rem!important;
	line-height: 1.3;
	font-weight: 500;
	margin: 8px 8px 0 8px;
	color: #333;
	text-align: center;
	min-height: 2.6em; /* Ensure 2 rows height consistency */
}

/* Price row - strikethrough left, discounted right */
.divewp-upsell-product-price-row {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 6px;
	padding: 0 8px 6px 8px;
	background: #fff;
	font-size: 1rem;
}

/* Strikethrough (original) price */
.divewp-upsell-price-strikethrough {
	text-decoration: line-through;
	color: #999;
	font-size: 0.8em;
	font-weight: 400;
}

/* Discounted price */
.divewp-upsell-price-discounted {
	color: #1a1a1a;
	font-size: 1.1em;
	font-weight: 700;
}

/* Regular price (when no discount) */
.divewp-upsell-price-regular {
	color: #1a1a1a;
	font-size: 1.1em;
	font-weight: 600;
}

/* Save badge at bottom */
.divewp-upsell-save-badge {
	display: block;
	padding: 6px 4px;
	background: #fba4a4;
	color: #fff;
	font-size: 1rem;
	font-weight: 800;
	text-align: center;
	text-transform: none;
	margin-top: auto; /* Push to bottom */
}

/* Total price display */
.divewp-upsells-total {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin-top: 18px;
	padding: 16px;
	background: #f9f9f9;
	border-radius: 12px;
}

.divewp-upsells-total-regular {
	text-decoration: line-through;
	color: #999;
	font-size: 1.1em;
	font-weight: 400;
	margin-right: 8px;
}

.divewp-upsells-total-amount {
	display: block;
	font-size: 22px;
	font-weight: 800;
	color: #1a1a1a;
}

.divewp-upsells-total-save {
	font-size: 20px;
	font-weight: 700;
	color: #3bb174;
}

/* Responsive - Horizontal scroll on mobile */
@media (max-width: 480px) {
	.divewp-upsells-container {
		display: flex;
		flex-wrap: nowrap;
		overflow-x: auto;
		gap: 8px;
		padding-bottom: 8px;
		margin: 0;
		scroll-snap-type: x mandatory;
		-webkit-overflow-scrolling: touch;
	}

	.divewp-upsells-container::-webkit-scrollbar {
		display: none;
	}

	.divewp-upsell-product-card {
		flex: 0 0 155px; /* More square-ish width */
		scroll-snap-align: start;
		border-radius: 14px;
	}


	.divewp-upsell-product-price-row {
		flex-direction: row;
		justify-content: center;
		align-items: center;
		gap: 4px;
		padding: 0 6px 4px 6px;
	}

	.divewp-upsell-price-strikethrough {
		font-size: 0.75em;
	}

	.divewp-upsell-price-discounted,
	.divewp-upsell-price-regular {
		font-size: 1em;
	}

	.divewp-upsell-save-badge {
		padding: 2px;
	}

	.divewp-upsells-total {
		padding: 12px;
		margin-top: 12px;
	}

	.divewp-upsells-total-amount {
		font-size: 22px;
	}

	.divewp-upsells-total-save {
		font-size: 22px;
	}
}

/* WooCommerce compatibility */
.woocommerce .divewp-upsells-section {
	width: 100%;
}
