/**
 * Amazon Product Box Styles
 *
 * BEM with afh- prefix. 4 layouts: horizontal, vertical, compact, mini.
 * CSS-only star rating, responsive, print-friendly.
 *
 * @package AffiliateHub
 * @subpackage Modules\AmazonProducts
 */

/* ==========================================================================
   Base / Reset
   ========================================================================== */

.afh-product-box {
	position: relative;
	display: flex;
	box-sizing: border-box;
	max-width: 100%;
	margin: 1.5em 0;
	padding: 1rem;
	border: 1px solid #e0e0e0;
	border-radius: 8px;
	background: #fff;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
	font-size: 14px;
	line-height: 1.5;
	color: #1a1a1a;
	transition: box-shadow 0.2s ease;
}

.afh-product-box:hover {
	box-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
}

.afh-product-box *,
.afh-product-box *::before,
.afh-product-box *::after {
	box-sizing: border-box;
}

/* ==========================================================================
   Layout: Horizontal (default — flex row)
   ========================================================================== */

.afh-product-box--horizontal {
	flex-direction: row;
	align-items: flex-start;
	gap: 1.25rem;
}

.afh-product-box--horizontal .afh-product-box__image-wrap {
	flex: 0 0 180px;
	max-width: 180px;
}

.afh-product-box--horizontal .afh-product-box__content {
	flex: 1 1 0%;
	min-width: 0;
}

/* ==========================================================================
   Layout: Vertical (flex column)
   ========================================================================== */

.afh-product-box--vertical {
	flex-direction: column;
	max-width: 360px;
}

.afh-product-box--vertical .afh-product-box__image-wrap {
	width: 100%;
	max-height: 260px;
}

.afh-product-box--vertical .afh-product-box__content {
	width: 100%;
}

/* ==========================================================================
   Layout: Compact (smaller horizontal)
   ========================================================================== */

.afh-product-box--compact {
	flex-direction: row;
	align-items: center;
	gap: 1rem;
	padding: 0.75rem;
}

.afh-product-box--compact .afh-product-box__image-wrap {
	flex: 0 0 100px;
	max-width: 100px;
}

.afh-product-box--compact .afh-product-box__content {
	flex: 1 1 0%;
	min-width: 0;
}

.afh-product-box--compact .afh-product-box__title {
	font-size: 0.9rem;
}

.afh-product-box--compact .afh-product-box__description {
	display: none;
}

.afh-product-box--compact .afh-product-box__cta {
	padding: 8px 16px;
	font-size: 0.85rem;
}

/* ==========================================================================
   Layout: Mini (inline-like)
   ========================================================================== */

.afh-product-box--mini {
	flex-direction: row;
	align-items: center;
	gap: 0.75rem;
	padding: 0.5rem 0.75rem;
	margin: 0.75em 0;
	border-radius: 6px;
}

.afh-product-box--mini .afh-product-box__image-wrap {
	flex: 0 0 60px;
	max-width: 60px;
}

.afh-product-box--mini .afh-product-box__content {
	flex: 1 1 0%;
	min-width: 0;
}

.afh-product-box--mini .afh-product-box__title {
	font-size: 0.85rem;
	margin-bottom: 0.25rem;
}

.afh-product-box--mini .afh-product-box__description,
.afh-product-box--mini .afh-product-box__brand,
.afh-product-box--mini .afh-product-box__disclaimer {
	display: none;
}

.afh-product-box--mini .afh-product-box__meta {
	gap: 0.5rem;
}

.afh-product-box--mini .afh-product-box__cta {
	padding: 6px 12px;
	font-size: 0.8rem;
	min-height: 36px;
}

/* ==========================================================================
   Image
   ========================================================================== */

.afh-product-box__image-wrap {
	position: relative;
	overflow: hidden;
}

.afh-product-box__image {
	display: block;
	width: 100%;
	height: auto;
	aspect-ratio: 1 / 1;
	object-fit: contain;
	border-radius: 4px;
	background: #fafafa;
}

.afh-product-box__image-placeholder {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	aspect-ratio: 1 / 1;
	background: #f5f5f5;
	border-radius: 4px;
	color: #999;
	font-size: 0.8rem;
	text-align: center;
}

/* CSS-only box icon for image placeholder */
.afh-product-box__placeholder-icon {
	display: inline-block;
	width: 40px;
	height: 36px;
	border: 2px solid #ccc;
	border-radius: 3px;
	position: relative;
	background: transparent;
}

.afh-product-box__placeholder-icon::before {
	content: "";
	position: absolute;
	bottom: 4px;
	left: 4px;
	width: 0;
	height: 0;
	border-left: 8px solid transparent;
	border-right: 8px solid transparent;
	border-bottom: 10px solid #ccc;
}

.afh-product-box__placeholder-icon::after {
	content: "";
	position: absolute;
	top: 6px;
	right: 6px;
	width: 6px;
	height: 6px;
	border-radius: 50%;
	background: #ccc;
}

/* ==========================================================================
   Content
   ========================================================================== */

.afh-product-box__content {
	display: flex;
	flex-direction: column;
	gap: 0.5rem;
}

.afh-product-box__brand {
	font-size: 0.75rem;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.03em;
	color: #666;
}

.afh-product-box__title {
	margin: 0;
	font-size: 1rem;
	font-weight: 600;
	line-height: 1.3;
	color: #0f1111;
	overflow-wrap: break-word;
	word-break: break-word;
}

.afh-product-box__title a {
	color: inherit;
	text-decoration: none;
}

.afh-product-box__title a:hover {
	color: #c7511f;
	text-decoration: underline;
}

.afh-product-box__description {
	margin: 0;
	font-size: 0.85rem;
	color: #555;
	line-height: 1.4;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
}

/* ==========================================================================
   Meta: Rating, Prime, Badges
   ========================================================================== */

.afh-product-box__meta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.75rem;
}

/* CSS-only star rating */
.afh-product-box__rating {
	display: inline-flex;
	align-items: center;
	gap: 0.35rem;
}

.afh-product-box__stars {
	position: relative;
	display: inline-block;
	width: 5.4em;
	height: 1.1em;
	font-size: 0.85rem;
	line-height: 1;
	letter-spacing: 0.15em;
	overflow: hidden;
}

.afh-product-box__stars::before {
	content: "\2605\2605\2605\2605\2605";
	color: #ddd;
}

.afh-product-box__stars::after {
	content: "\2605\2605\2605\2605\2605";
	position: absolute;
	top: 0;
	left: 0;
	overflow: hidden;
	white-space: nowrap;
	color: #ffa41c;
	width: calc(var(--rating, 0) / 5 * 100%);
}

.afh-product-box__rating-count {
	font-size: 0.8rem;
	color: #007185;
}

/* Prime badge */
.afh-product-box__prime {
	display: inline-flex;
	align-items: center;
	gap: 0.2rem;
	font-size: 0.75rem;
	font-weight: 700;
	color: #00A8E1;
}

.afh-product-box__prime-icon {
	display: inline-block;
	width: 0.7em;
	height: 0.7em;
	border-radius: 50%;
	background: #00A8E1;
	position: relative;
}

.afh-product-box__prime-icon::after {
	content: "";
	position: absolute;
	top: 50%;
	left: 50%;
	transform: translate(-50%, -55%) rotate(-45deg);
	width: 0.35em;
	height: 0.2em;
	border-left: 1.5px solid #fff;
	border-bottom: 1.5px solid #fff;
}

/* Discount badge */
.afh-product-box__discount-badge {
	display: inline-block;
	padding: 0.15em 0.5em;
	border-radius: 3px;
	background: #cc0c39;
	color: #fff;
	font-size: 0.75rem;
	font-weight: 700;
	line-height: 1.3;
}

/* ==========================================================================
   Pricing
   ========================================================================== */

.afh-product-box__pricing {
	display: flex;
	flex-wrap: wrap;
	align-items: baseline;
	gap: 0.5rem;
}

.afh-product-box__price {
	font-size: 1.25rem;
	font-weight: 700;
	color: #0f1111;
}

.afh-product-box__price--stale {
	color: #6b6b6b;
}

.afh-product-box__original-price {
	font-size: 0.9rem;
	color: #888;
	text-decoration: line-through;
}

.afh-product-box__price-notice {
	display: block;
	width: 100%;
	font-size: 0.75rem;
	color: #888;
	font-style: italic;
}

/* ==========================================================================
   Stub / Placeholder Styles
   ========================================================================== */

/* Stub title: italic grey for products awaiting API data */
.afh-product-box__title--stub,
.afh-product-box__title--stub a {
	font-style: italic;
	color: #888;
}

.afh-product-box__title--stub a:hover {
	color: #007185;
}

/* "Check Amazon" clickable link when price is unavailable */
.afh-product-box__price-na {
	font-size: 0.9rem;
	font-weight: 600;
	color: #007185;
	text-decoration: none;
	cursor: pointer;
}

.afh-product-box__price-na:hover {
	color: #c7511f;
	text-decoration: underline;
}

/* "No data" for stub ratings */
.afh-product-box__rating-na {
	font-size: 0.8rem;
	font-style: italic;
	color: #999;
}

/* ==========================================================================
   CTA Button
   ========================================================================== */

.afh-product-box__cta {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 100%;
	min-height: 48px;
	padding: 12px 24px;
	border: none;
	border-radius: 8px;
	background: #FF9900;
	color: #0f1111;
	font-size: 1rem;
	font-weight: 700;
	text-align: center;
	text-decoration: none;
	cursor: pointer;
	transition: background-color 0.15s ease, transform 0.1s ease;
	line-height: 1.3;
}

.afh-product-box__cta:hover {
	filter: brightness(0.9);
	color: #0f1111;
	text-decoration: none;
}

.afh-product-box__cta:active {
	transform: scale(0.98);
}

.afh-product-box__cta:focus-visible {
	outline: 2px solid #FF9900;
	outline-offset: 2px;
}

/* ==========================================================================
   Disclaimer
   ========================================================================== */

.afh-product-box__disclaimer {
	margin-top: 0.5rem;
	padding-top: 0.5rem;
	border-top: 1px solid #f0f0f0;
	font-size: 0.7rem;
	color: #999;
	line-height: 1.4;
}

/* ==========================================================================
   Auto-Disclaimer (Amazon TOS compliance, rendered by DisclaimerManager)
   ========================================================================== */

.afh-amazon-disclaimer {
	margin: 1em 0 0.5em;
	font-size: 0.75rem;
	line-height: 1.4;
	color: #767676;
}

/* ==========================================================================
   Fallback Box (no product data)
   ========================================================================== */

.afh-product-box--fallback {
	flex-direction: column;
	align-items: center;
	text-align: center;
	max-width: 360px;
	padding: 1.5rem;
}

.afh-product-box--fallback .afh-product-box__cta {
	margin-top: 0.5rem;
}

.afh-product-box__fallback-text {
	font-size: 0.9rem;
	color: #555;
	margin: 0 0 0.75rem;
}

/* ==========================================================================
   Price Tiers
   ========================================================================== */

.afh-product-box__tier-indicator {
	display: inline-block;
	width: 6px;
	height: 6px;
	border-radius: 50%;
	margin-right: 0.25rem;
	vertical-align: middle;
}

.afh-product-box__tier-indicator--fresh {
	background: #067d06;
}

.afh-product-box__tier-indicator--stale {
	background: #b17704;
}

/* ==========================================================================
   Responsive: Below 480px horizontal stacks to vertical
   ========================================================================== */

@media (max-width: 480px) {
	.afh-product-box--horizontal {
		flex-direction: column;
	}

	.afh-product-box--horizontal .afh-product-box__image-wrap {
		flex: none;
		max-width: 100%;
	}

	.afh-product-box--compact {
		flex-direction: column;
		align-items: flex-start;
	}

	.afh-product-box--compact .afh-product-box__image-wrap {
		flex: none;
		max-width: 100%;
	}
}

/* ==========================================================================
   Inline Link with Tooltip
   ========================================================================== */

.afh-inline-link {
	position: relative;
	display: inline;
}

.afh-inline-link__anchor {
	color: #007185;
	text-decoration: underline dotted;
	text-underline-offset: 2px;
	cursor: pointer;
}

.afh-inline-link__anchor:hover {
	color: #ff9900;
	text-decoration-style: solid;
}

.afh-inline-link__anchor:focus-visible {
	outline: 2px solid #ff9900;
	outline-offset: 2px;
	border-radius: 2px;
}

/* Tooltip container */
.afh-inline-link__tooltip {
	display: none;
	position: absolute;
	bottom: calc(100% + 8px);
	left: 50%;
	transform: translateX(-50%);
	width: 280px;
	background: #fff;
	border: 1px solid #e0e0e0;
	border-radius: 8px;
	box-shadow: 0 4px 16px rgba(0, 0, 0, 0.12);
	padding: 12px;
	z-index: 1000;
	font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
	font-size: 14px;
	line-height: 1.5;
	color: #1a1a1a;
}

/* Tooltip arrow */
.afh-inline-link__tooltip::after {
	content: "";
	position: absolute;
	top: 100%;
	left: 50%;
	transform: translateX(-50%);
	border: 6px solid transparent;
	border-top-color: #fff;
}

.afh-inline-link__tooltip::before {
	content: "";
	position: absolute;
	top: 100%;
	left: 50%;
	transform: translateX(-50%);
	border: 7px solid transparent;
	border-top-color: #e0e0e0;
}

/* Show on hover and focus-within */
.afh-inline-link:hover .afh-inline-link__tooltip,
.afh-inline-link:focus-within .afh-inline-link__tooltip {
	display: flex;
	gap: 10px;
	align-items: flex-start;
}

/* Tooltip image */
.afh-inline-link__tooltip-image {
	flex: 0 0 80px;
	width: 80px;
	height: 80px;
	object-fit: contain;
	border-radius: 4px;
	background: #fafafa;
}

/* Tooltip body */
.afh-inline-link__tooltip-body {
	flex: 1 1 0%;
	min-width: 0;
	display: flex;
	flex-direction: column;
	gap: 0.25rem;
}

.afh-inline-link__tooltip-title {
	margin: 0;
	font-size: 0.85rem;
	font-weight: 600;
	line-height: 1.3;
	color: #0f1111;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
	overflow: hidden;
	overflow-wrap: break-word;
	word-break: break-word;
}

.afh-inline-link__tooltip-price {
	font-size: 1rem;
	font-weight: 700;
	color: #0f1111;
}

.afh-inline-link__tooltip-price--stale {
	color: #6b6b6b;
}

.afh-inline-link__tooltip-price--na {
	font-size: 0.813rem;
	font-weight: 600;
	color: #007185;
}

.afh-inline-link__tooltip-original-price {
	font-size: 0.75rem;
	color: #888;
	text-decoration: line-through;
}

/* Tooltip star rating (reuses --rating technique) */
.afh-inline-link__tooltip-rating {
	display: inline-flex;
	align-items: center;
	gap: 0.25rem;
}

.afh-inline-link__tooltip-stars {
	position: relative;
	display: inline-block;
	width: 5.4em;
	height: 1.1em;
	font-size: 0.7rem;
	line-height: 1;
	letter-spacing: 0.15em;
	overflow: hidden;
}

.afh-inline-link__tooltip-stars::before {
	content: "\2605\2605\2605\2605\2605";
	color: #ddd;
}

.afh-inline-link__tooltip-stars::after {
	content: "\2605\2605\2605\2605\2605";
	position: absolute;
	top: 0;
	left: 0;
	overflow: hidden;
	white-space: nowrap;
	color: #ffa41c;
	width: calc(var(--rating, 0) / 5 * 100%);
}

.afh-inline-link__tooltip-rating-count {
	font-size: 0.65rem;
	color: #007185;
}

/* Tooltip: hide on mobile (touch devices don't have hover) */
@media (max-width: 768px) {
	.afh-inline-link__tooltip {
		display: none !important;
	}
}

/* Inline link box-sizing reset */
.afh-inline-link *,
.afh-inline-link *::before,
.afh-inline-link *::after {
	box-sizing: border-box;
}

/* ==========================================================================
   Print Styles
   ========================================================================== */

@media print {
	.afh-product-box {
		border: 1px solid #ccc;
		box-shadow: none;
		page-break-inside: avoid;
	}

	.afh-product-box__cta {
		display: none;
	}

	.afh-product-box__title a::after {
		content: " (" attr(href) ")";
		font-size: 0.75rem;
		font-weight: 400;
		color: #666;
		word-break: break-all;
	}

	.afh-product-box__prime,
	.afh-product-box__discount-badge {
		border: 1px solid currentColor;
		background: none;
		color: #333;
	}

	.afh-product-box__disclaimer {
		display: none;
	}

	.afh-inline-link__tooltip {
		display: none !important;
	}

	.afh-inline-link__anchor {
		color: #333;
		text-decoration: underline;
	}
}
