/* --- Header Hiding (Prevents duplicate headings) --- */
/* Hides the rogue/duplicate header that WordPress/WooCommerce is adding
inside the comments template (#comments) by targeting the common H2/H3
unless it has our explicit class. */
#comments > h2:not(.woo-rrt-custom-header),
#comments > h3:not(.woo-rrt-custom-header),
#reviews #comments > h2, /* Ensure all headers inside #comments are hidden */
#reviews #comments > h3 {
	display: none !important;
}

/* Hide external review titles when no reviews exist (theme header like #reviewstitle). */
.woo-rrt-no-reviews #reviewstitle {
	display: none !important;
}

/* Limit review list height and enable scrolling when there are many reviews. */
#reviews.woo-rrt-scroll-reviews ol.commentlist,
#reviews.woo-rrt-scroll-reviews .commentlist,
.woo-rrt-scroll-reviews ol.commentlist,
.woo-rrt-scroll-reviews .commentlist {
	max-height: var(--woo-rrt-review-max-height, 480px);
	overflow-y: auto;
	padding-right: 10px;
}

/* --- Review submission notice styling --- */
.woo-rrt-dismissible-notice {
	position: relative;
	padding-right: 48px;
	transition: opacity 0.2s ease, transform 0.2s ease;
}

.woo-rrt-notice-close {
	position: absolute;
	top: 50%;
	right: 16px;
	transform: translateY(-50%);
	border: 0;
	background: transparent;
	color: inherit;
	font-size: 20px;
	line-height: 1;
	cursor: pointer;
	padding: 0;
}

.woo-rrt-notice-dismissed {
	opacity: 0;
	transform: translateY(-6px);
}

/* --- CRITICAL: Force External Separation (woocommerce_after_main_content) --- */
#reviews.woocommerce-reviews {
	/* Aggressive separation from elements above (like Related Products/Product Wrapper) */
	margin-top: 150px !important;
	/* Add generous top padding to ensure there is space inside the wrapper too */
	padding-top: 50px !important;
	clear: both !important; /* Ensure it starts on a new line */
}

/* --- Spacing Reset (Needed to ensure minimal gap *below* our header) --- */
/* CRITICAL FIX: Aggressively target all elements between our header and the review list
to remove rogue margin/padding. This keeps the internal gap small. */
#reviews .woo-rrt-custom-header + *,
#reviews #comments,
#reviews #comments > div,
#reviews ol.commentlist,
#reviews .commentlist,
#reviews ol.commentlist li:first-child {
	margin-top: 0 !important;
	padding-top: 0 !important;
}

/* --- Custom Header Spacing --- */
#reviews .woo-rrt-custom-header {
	margin-top: 0 !important; /* Top margin handled by #reviews container now */
	margin-bottom: 20px !important;
}

/* --- AVERAGE RATING SUMMARY STYLES (New) --- */
.woo-rrt-average-rating-summary {
	display: block; /* CRITICAL FIX: Forces element onto its own line, separating it from the price HTML */
	align-items: center;
	/* Set a margin-top to separate the rating from the price that precedes it */
	margin-top: 10px;
	margin-bottom: 5px; /* Reduced bottom margin */
	/* CRITICAL: Fix for Avada/Theme CSS conflict */
	float: none !important;
	clear: both;
	width: 100%;
	box-sizing: border-box;
	flex-wrap: wrap;
}

.woo-rrt-average-rating-summary .star-rating {
	margin: 0 5px 0 0 !important; /* Reduced spacing between stars and count */
}

.woo-rrt-rating-value {
	font-weight: 600;
	color: #2c3e50; /* Darker color for emphasis */
	margin-right: 5px;
}

.woo-rrt-review-count {
	font-size: 0.9em;
	color: #777;
}

/* CSS for Verified Badge */
.woo-rrt-verified-badge {
	display: inline-block;
	background-color: #e6f7d0;
	color: #528c00;
	font-weight: 700;
	padding: 3px 8px;
	border-radius: 3px;
	line-height: 1;
	text-transform: uppercase;
	vertical-align: middle;
	font-size: 0.65rem;
}

/* --- REVIEW CONTAINER FIXES --- */
.comment-body {
	border: 1px solid #ddd;
	padding: 12px 15px;
	margin-bottom: 16px;
	position: relative; /* CRITICAL: Allows absolute positioning of stars and date */
	border-radius: 4px;
}

/* Remove the default Woo comment-meta layout */
.comment-body .comment-meta {
	margin-bottom: 8px;
	display: flex;
	align-items: flex-start;
	flex-wrap: wrap;
	gap: 10px;
}

/* Keep reviewer name, badge, and date aligned on the left. */
.comment-body .woo-rrt-reviewer-meta {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px;
}

/* Style the reviewer name to be bold */
.comment-body .reviewer-name {
	font-weight: bold;
	display: inline;
	/* Add a small margin to the right to clear the badge/stars in case of wrap, though stars are absolute */
	margin-right: 10px;
}

/* Ensure the badge is also in line with the name/stars */
.comment-body .woo-rrt-verified-badge {
	margin-left: 4px;
}

/* --- STAR RATING INLINE ALIGNMENT --- */
/* Target our new explicit wrapper for the stars */
.comment-body .woo-rrt-review-rating-stars {
	margin: 0; /* Clear any default margin */
	/* CRITICAL FIX: Ensure the stars themselves are not hidden by a general theme CSS rule */
	visibility: visible !important;
	opacity: 1 !important;
	display: inline-flex !important;
	align-items: center;
	position: absolute;
	top: 12px;
	right: 15px;
}

/* The actual WooCommerce star-rating element */
.comment-body .woo-rrt-review-rating-stars .star-rating {
	margin: 0 !important; /* Clear any residual margin */

	/* CRITICAL: Ensure the actual star element is visible */
	display: block !important;
}

/* --- DATE INLINE ALIGNMENT --- */
.comment-body .review-date-meta {
	font-size: 0.85em;
	color: #888;
	line-height: 1;
	margin: 2px 0 0;
	flex-basis: 100%;
}

/* Increase bottom margin of review content to clear the date */
.comment-body .comment-content {
	margin-top: 8px;
	margin-bottom: 0;
}

/* --- VARIANT INFO DISPLAY --- */
.comment-content .woo-rrt-variation-details {
	font-size: 0.85em;
	color: #777777;
	margin-top: 0;
	margin-bottom: 4px;
	padding: 8px 10px;
	background-color: #f0f8ff;
	border-left: 3px solid #0a6cb9;
	border-radius: 0 4px 4px 0;
	display: inline-block; /* Crucial for controlling width */
}

.comment-content .woo-rrt-variation-details strong {
	color: #2c3e50;
	font-weight: 600;
}
