/**
 * RAA Brochure Pro — Frontend Styles.
 *
 * CSS variables are set via wp_head dynamic output from admin settings.
 * Fallbacks declared here for when dynamic CSS hasn't loaded.
 *
 * @package raa-brochure-pro
 */

/* ─── Variable Fallbacks ────────────────────────────────── */
:root {
	--rbp-heart-color: #8c0014;
	--rbp-wishlist-bg: #ffffff;
	--rbp-compare-color: #202020;
	--rbp-compare-bg: #ffffff;
	--rbp-primary: #202020;
	--rbp-border: #d9d9d9;
	--rbp-radius: 2px;
	--rbp-btn-font-size: 13px;
	--rbp-shadow: 0 2px 12px rgba(0, 0, 0, 0.08);
	--rbp-transition: 0.2s ease;
	--rbp-btn-min-width: 140px;
}

/* ─── Wishlist Heart — Loop (overlaid on image) ─────────── */
.rbp-wishlist-toggle {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	background: none;
	border: none;
	cursor: pointer;
	padding: 0;
	line-height: 1;
}

.rbp-wishlist-toggle--loop:hover {
	transform: scale(1.1);
	transition: transform var(--rbp-transition);
}

.rbp-wishlist-toggle--loop {
	position: absolute;
	top: 10px;
	right: 10px;
	z-index: 3;
	width: 36px;
	height: 36px;
	background: var(--rbp-wishlist-bg);
	border-radius: 50%;
	box-shadow: 0 1px 4px rgba(0, 0, 0, 0.08);
}

.rbp-wishlist-toggle--loop .rbp-icon--heart {
	color: #999;
	transition: color var(--rbp-transition), fill var(--rbp-transition);
}

.rbp-wishlist-toggle--loop[aria-pressed="true"] .rbp-icon--heart {
	color: var(--rbp-heart-color);
	fill: var(--rbp-heart-color);
}

.woocommerce-image__wrapper {
	position: relative;
}

/* ─── Wishlist & Compare — Single Product (uniform) ─────── */
.rbp-single-actions {
	display: flex;
	gap: 10px;
	align-items: stretch;
	margin: 14px 0;
	flex-wrap: wrap;
}

.rbp-wishlist-toggle--single,
.rbp-compare-toggle--single {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	padding: 10px 18px;
	flex: 1;
	box-sizing: border-box;
	min-width: var(--rbp-btn-min-width);
	border: 1px solid var(--rbp-border);
	border-radius: var(--rbp-radius);
	background: var(--rbp-wishlist-bg);
	font-size: var(--rbp-btn-font-size);
	font-weight: 600;
	color: var(--rbp-primary);
	cursor: pointer;
	transition: all var(--rbp-transition);
	text-align: center;
	line-height: 1.3;
}

.rbp-compare-toggle--single {
	background: var(--rbp-compare-bg);
}

.rbp-wishlist-toggle--single .rbp-icon--heart,
.rbp-compare-toggle--single .rbp-icon--compare {
	transition: color var(--rbp-transition), fill var(--rbp-transition);
	flex-shrink: 0;
}

.rbp-wishlist-toggle--single:hover {
	border-color: var(--rbp-compare-color);
	color: var(--rbp-compare-color);
}

.rbp-wishlist-toggle--single[aria-pressed="true"] {
	border-color: var(--rbp-heart-color);
	background: var(--rbp-heart-color);
	color: #fff;
}

.rbp-wishlist-toggle--single[aria-pressed="true"] .rbp-icon--heart {
	color: #fff;
	fill: #fff;
}

.rbp-compare-toggle--single:hover {
	border-color: var(--rbp-compare-color);
	color: var(--rbp-compare-color);
}

.rbp-compare-toggle--single[aria-pressed="true"] {
	border-color: var(--rbp-compare-color);
	background: var(--rbp-compare-color);
	color: #fff;
}

.rbp-compare-toggle--single[aria-pressed="true"] .rbp-icon--compare {
	color: #fff;
}

/* ─── Compare Button — Loop ─────────────────────────────── */
.rbp-compare-toggle {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 4px;
	background: var(--rbp-compare-bg);
	border: 1px solid var(--rbp-border);
	border-radius: var(--rbp-radius);
	padding: 6px 10px;
	font-size: calc(var(--rbp-btn-font-size) - 1px);
	font-weight: 600;
	color: var(--rbp-primary);
	cursor: pointer;
	transition: all var(--rbp-transition);
	line-height: 1;
}

/* Full-width on listing/loop pages to match Add to Cart */
.rbp-compare-toggle:not(.rbp-compare-toggle--single) {
	width: 100%;
	padding: 8px 10px;
	box-sizing: border-box;
	margin-top: 6px;
}

.rbp-compare-toggle:hover {
	border-color: var(--rbp-compare-color);
	background: var(--rbp-compare-color);
	color: #fff;
}

.rbp-compare-toggle[aria-pressed="true"] {
	border-color: var(--rbp-compare-color);
	background: var(--rbp-compare-color);
	color: #fff;
}

.rbp-compare-toggle[aria-pressed="true"] .rbp-icon--compare {
	color: #fff;
}

/* Show on hover only on desktop */
@media (min-width: 769px) {
	.woocommerce-card__header .rbp-compare-toggle {
		opacity: 0;
		margin-bottom: 6px;
		transition: opacity var(--rbp-transition), border-color var(--rbp-transition), color var(--rbp-transition), background var(--rbp-transition);
	}

	.product:hover .woocommerce-card__header .rbp-compare-toggle,
	.rbp-compare-toggle[aria-pressed="true"] {
		opacity: 1;
	}
}

/* ─── Sticky Compare Bar ────────────────────────────────── */
.rbp-compare-bar {
	position: fixed;
	bottom: 0;
	left: 0;
	right: 0;
	z-index: 9990;
	background: #fff;
	border-top: 1px solid var(--rbp-border);
	box-shadow: 0 -1px 8px rgba(0, 0, 0, 0.06);
	transform: translateY(100%);
	transition: transform 0.3s ease;
}

.rbp-compare-bar.rbp-compare-bar--visible {
	transform: translateY(0);
}

.rbp-compare-bar__inner {
	display: flex;
	align-items: center;
	justify-content: space-between;
	max-width: 1200px;
	margin: 0 auto;
	padding: 12px 20px;
	gap: 16px;
}

.rbp-compare-bar__items {
	display: flex;
	gap: 12px;
	align-items: center;
	flex: 1;
	min-width: 0;
}

.rbp-compare-bar__item {
	display: flex;
	align-items: center;
	gap: 8px;
	background: #f5f5f5;
	border-radius: var(--rbp-radius);
	padding: 6px 10px;
	min-width: 0;
}

.rbp-compare-bar__item-img {
	width: 40px;
	height: 40px;
	object-fit: cover;
	border-radius: var(--rbp-radius);
	flex-shrink: 0;
}

.rbp-compare-bar__item-title {
	font-size: 13px;
	font-weight: 500;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	max-width: 120px;
	color: var(--rbp-primary);
}

.rbp-compare-bar__item-remove {
	background: none;
	border: none;
	cursor: pointer;
	color: #999;
	font-size: 16px;
	padding: 0 4px;
	line-height: 1;
	flex-shrink: 0;
	transition: color var(--rbp-transition);
}

.rbp-compare-bar__item-remove:hover {
	color: var(--rbp-heart-color);
}

.rbp-compare-bar__actions {
	display: flex;
	align-items: center;
	gap: 10px;
	flex-shrink: 0;
}

.rbp-compare-bar__count {
	font-size: 13px;
	color: #999;
}

.rbp-compare-bar__btn {
	display: inline-block;
	padding: 10px 24px;
	background: var(--rbp-primary);
	color: #fff;
	text-decoration: none;
	border-radius: var(--rbp-radius);
	font-size: 13px;
	font-weight: 700;
	letter-spacing: 0.02em;
	transition: opacity var(--rbp-transition);
}

.rbp-compare-bar__btn:hover {
	opacity: 0.85;
	color: #fff;
}

.rbp-compare-bar__clear {
	background: none;
	border: none;
	cursor: pointer;
	color: #999;
	font-size: 13px;
	text-decoration: underline;
	transition: color var(--rbp-transition);
}

.rbp-compare-bar__clear:hover {
	color: var(--rbp-heart-color);
}

/* ─── Brochure Dialog ───────────────────────────────────── */
.rbp-dialog {
	border: none;
	border-radius: 3px;
	padding: 0;
	max-width: 440px;
	width: 90vw;
	box-shadow: 0 4px 24px rgba(0, 0, 0, 0.12);
}

.rbp-dialog::backdrop {
	background: rgba(0, 0, 0, 0.45);
	backdrop-filter: blur(4px);
}

.rbp-dialog__content {
	padding: 28px;
}

.rbp-dialog__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 20px;
}

.rbp-dialog__header h3 {
	margin: 0;
	font-size: 18px;
	font-weight: 700;
	color: var(--rbp-primary);
}

.rbp-dialog__close {
	background: none;
	border: none;
	font-size: 24px;
	cursor: pointer;
	color: #999;
	padding: 0;
	line-height: 1;
	transition: color var(--rbp-transition);
}

.rbp-dialog__close:hover {
	color: var(--rbp-primary);
}

.rbp-form-field {
	margin-bottom: 16px;
}

.rbp-form-field label {
	display: block;
	margin-bottom: 4px;
	font-size: 13px;
	font-weight: 600;
	color: var(--rbp-primary);
	letter-spacing: 0.01em;
}

.rbp-form-field input {
	width: 100%;
	padding: 10px 12px;
	border: 1px solid var(--rbp-border);
	border-radius: var(--rbp-radius);
	font-size: 14px;
	transition: border-color var(--rbp-transition);
}

.rbp-form-field input:focus {
	outline: none;
	border-color: var(--rbp-primary);
}

.rbp-btn {
	display: inline-block;
	padding: 12px 24px;
	border: none;
	border-radius: var(--rbp-radius);
	font-size: 14px;
	font-weight: 700;
	cursor: pointer;
	letter-spacing: 0.02em;
	transition: opacity var(--rbp-transition);
}

.rbp-btn--primary {
	background: var(--rbp-primary);
	color: #fff;
	width: 100%;
}

.rbp-btn--primary:hover {
	opacity: 0.85;
}

.rbp-btn--primary:disabled {
	opacity: 0.4;
	cursor: not-allowed;
}

.rbp-brochure-form__status {
	margin-top: 12px;
	font-size: 14px;
	text-align: center;
}

.rbp-brochure-form__status--success {
	color: #1a7a3a;
}

.rbp-brochure-form__status--error {
	color: var(--rbp-heart-color);
}

/* ─── Wishlist Page ─────────────────────────────────────── */
.rbp-wishlist-page__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 24px;
	flex-wrap: wrap;
	gap: 12px;
}

.rbp-wishlist-page__actions {
	display: flex;
	gap: 8px;
}

.rbp-wishlist-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
	gap: 20px;
}

.rbp-wishlist-item {
	border: 1px solid var(--rbp-border);
	border-radius: var(--rbp-radius);
	padding: 16px;
	position: relative;
	transition: border-color var(--rbp-transition);
}

.rbp-wishlist-item:hover {
	border-color: #bbb;
}

.rbp-wishlist-item__img {
	width: 100%;
	aspect-ratio: 1;
	object-fit: cover;
	border-radius: var(--rbp-radius);
	margin-bottom: 12px;
}

.rbp-wishlist-item__title {
	font-size: 14px;
	font-weight: 700;
	margin-bottom: 6px;
	line-height: 1.4;
}

.rbp-wishlist-item__title a {
	color: var(--rbp-primary);
	text-decoration: none;
}

.rbp-wishlist-item__title a:hover {
	color: var(--rbp-heart-color);
}

.rbp-wishlist-item__price {
	font-size: 14px;
	font-weight: 600;
	margin-bottom: 8px;
	color: var(--rbp-primary);
}

.rbp-wishlist-item__price del {
	color: #999;
	font-weight: 400;
	margin-right: 4px;
}

.rbp-compare-table del {
	color: #999;
	font-weight: 400;
	margin-right: 4px;
}

.rbp-wishlist-item__stock {
	font-size: 12px;
	margin-bottom: 10px;
	font-weight: 500;
}

.rbp-wishlist-item__stock--instock {
	color: #1a7a3a;
}

.rbp-wishlist-item__stock--outofstock {
	color: var(--rbp-heart-color);
}

.rbp-wishlist-item__stock--onbackorder {
	color: #b8860b;
}

.rbp-wishlist-item__remove {
	position: absolute;
	top: 8px;
	right: 8px;
	background: rgba(255, 255, 255, 0.92);
	border: none;
	width: 28px;
	height: 28px;
	border-radius: 50%;
	cursor: pointer;
	display: flex;
	align-items: center;
	justify-content: center;
	color: #999;
	font-size: 16px;
	transition: color var(--rbp-transition);
}

.rbp-wishlist-item__remove:hover {
	color: var(--rbp-heart-color);
}

.rbp-wishlist-item__notify {
	display: flex;
	flex-direction: column;
	gap: 6px;
	margin-top: 10px;
	padding-top: 10px;
	border-top: 1px solid var(--rbp-border);
}

.rbp-notify-btn {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	background: none;
	border: 1px solid var(--rbp-border);
	border-radius: var(--rbp-radius);
	padding: 6px 10px;
	font-size: 12px;
	font-weight: 500;
	color: var(--rbp-primary);
	cursor: pointer;
	transition: all var(--rbp-transition);
}

.rbp-notify-btn:hover {
	border-color: var(--rbp-primary);
}

.rbp-notify-btn--active {
	border-color: #1a7a3a;
	color: #1a7a3a;
	background: rgba(26, 122, 58, 0.04);
}

.rbp-notify-login-prompt {
	font-size: 12px;
	color: #999;
	margin-top: 6px;
}

.rbp-notify-login-prompt a {
	color: var(--rbp-heart-color);
	font-weight: 600;
}

/* ─── Compare Page ──────────────────────────────────────── */
.rbp-compare-table-wrap {
	overflow-x: auto;
	margin: 20px 0;
}

.rbp-compare-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 14px;
}

.rbp-compare-table th,
.rbp-compare-table td {
	padding: 14px 20px;
	border: none;
	border-bottom: 1px solid var(--rbp-border);
	vertical-align: top;
	text-align: left;
}

.rbp-compare-table th {
	background: none;
	font-weight: 600;
	white-space: normal;
	width: 100px;
	min-width: 80px;
	color: #999;
	font-size: 12px;
	text-transform: uppercase;
	letter-spacing: 0.04em;
}

.rbp-compare-table td {
	min-width: 200px;
	color: var(--rbp-primary);
}

.rbp-compare-table__img {
	width: 100%;
	max-width: 200px;
	aspect-ratio: 1;
	object-fit: cover;
	border-radius: var(--rbp-radius);
}

.rbp-compare-table__remove {
	display: inline-flex;
	align-items: center;
	gap: 4px;
	background: none;
	border: none;
	padding: 4px 0;
	font-size: 12px;
	font-weight: 600;
	color: #999;
	cursor: pointer;
	margin-top: 8px;
	transition: color var(--rbp-transition);
	text-decoration: underline;
}

.rbp-compare-table__remove:hover {
	color: var(--rbp-heart-color);
}

.rbp-compare-empty,
.rbp-wishlist-empty {
	text-align: center;
	padding: 60px 20px;
	color: #999;
	font-size: 15px;
}

.rbp-compare-empty__hint {
	font-size: 14px;
	color: #999;
	max-width: 400px;
	margin: 8px auto 16px;
	line-height: 1.5;
}

.rbp-compare-empty a,
.rbp-wishlist-empty a {
	color: var(--rbp-heart-color);
	font-weight: 600;
}

/* ─── Checkbox for Brochure Selection ───────────────────── */
.rbp-wishlist-item__select {
	position: absolute;
	top: 8px;
	left: 8px;
}

.rbp-wishlist-item__select input[type="checkbox"] {
	width: 18px;
	height: 18px;
	cursor: pointer;
	accent-color: var(--rbp-primary);
}

/* ─── Toast ────────────────────────────────────────────── */
.rbp-toast a {
	color: var(--rbp-heart-color);
	text-decoration: underline;
	font-weight: 700;
}

.rbp-toast a:hover {
	opacity: 0.75;
}

/* ─── Focus States (Accessibility) ──────────────────────── */
.rbp-wishlist-toggle:focus-visible,
.rbp-compare-toggle:focus-visible,
.rbp-notify-btn:focus-visible,
.rbp-compare-bar__btn:focus-visible,
.rbp-btn:focus-visible {
	outline: 2px solid var(--rbp-primary);
	outline-offset: 2px;
}

.rbp-compare-bar__item-remove:focus-visible,
.rbp-compare-bar__clear:focus-visible,
.rbp-compare-table__remove:focus-visible,
.rbp-wishlist-item__remove:focus-visible,
.rbp-dialog__close:focus-visible {
	outline: 2px solid var(--rbp-primary);
	outline-offset: 2px;
}

/* ─── Loading State ─────────────────────────────────────── */
.rbp-loading {
	pointer-events: none;
	opacity: 0.6;
}

/* ─── Responsive — Tablet & below ───────────────────────── */
@media (max-width: 768px) {
	/* Larger touch target for wishlist heart on product cards */
	.rbp-wishlist-toggle--loop {
		width: 40px;
		height: 40px;
	}

	/* Compare button easier to tap */
	.rbp-compare-toggle {
		padding: 8px 12px;
		font-size: var(--rbp-btn-font-size);
		margin-bottom: 6px;
	}

	/* Compare bar stacks and scrolls */
	.rbp-compare-bar__inner {
		flex-direction: column;
		padding: 10px 16px;
		gap: 10px;
	}

	.rbp-compare-bar__items {
		width: 100%;
		overflow-x: auto;
		-webkit-overflow-scrolling: touch;
		flex-shrink: 0;
	}

	.rbp-compare-bar__item {
		flex-shrink: 0;
		min-width: 0;
	}

	.rbp-compare-bar__item-img {
		width: 32px;
		height: 32px;
	}

	.rbp-compare-bar__item-title {
		max-width: 80px;
		font-size: 12px;
	}

	.rbp-compare-bar__actions {
		width: 100%;
		justify-content: center;
	}

	/* Wishlist grid 2 columns on tablet */
	.rbp-wishlist-grid {
		grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
		gap: 12px;
	}

	/* Single product action buttons full-width */
	.rbp-single-actions {
		flex-direction: column;
		align-items: stretch;
	}

	.rbp-wishlist-toggle--single,
	.rbp-compare-toggle--single {
		min-width: 0;
		width: 100%;
	}

	/* Wishlist page header stacks */
	.rbp-wishlist-page__header {
		flex-direction: column;
		align-items: flex-start;
	}

	.rbp-wishlist-page__actions {
		width: 100%;
	}

	.rbp-wishlist-page__actions .rbp-btn {
		flex: 1;
	}

	/* Notify buttons full-width for easier tapping */
	.rbp-notify-btn {
		width: 100%;
		justify-content: center;
		padding: 10px 12px;
	}

	/* Brochure dialog mobile-friendly */
	.rbp-dialog {
		width: calc(100vw - 32px);
		max-width: none;
		margin: auto;
		border-radius: 10px;
	}

	.rbp-dialog__content {
		padding: 20px;
	}

	.rbp-dialog__header {
		margin-bottom: 14px;
	}

	.rbp-dialog__header h3 {
		font-size: 16px;
	}

	.rbp-dialog__close {
		font-size: 28px;
		padding: 4px 8px;
	}

	.rbp-form-field {
		margin-bottom: 14px;
	}

	.rbp-form-field input {
		padding: 12px;
		font-size: 16px; /* prevents iOS auto-zoom */
	}

	.rbp-form-field input[type="checkbox"] {
		width: 20px;
		height: 20px;
	}

	.rbp-btn--primary {
		padding: 14px 24px;
		font-size: 15px;
	}

	.rbp-brochure-form__status {
		font-size: 13px;
	}

	/* Compare table scroll hint */
	.rbp-compare-table-wrap {
		-webkit-overflow-scrolling: touch;
	}

	.rbp-compare-table th,
	.rbp-compare-table td {
		padding: 10px 12px;
	}

	.rbp-compare-table td {
		min-width: 160px;
	}
}

/* ─── Responsive — Small phones ─────────────────────────── */
@media (max-width: 480px) {
	/* Single column wishlist grid */
	.rbp-wishlist-grid {
		grid-template-columns: 1fr;
		gap: 10px;
	}

	/* Wishlist items horizontal layout on small screens */
	.rbp-wishlist-item {
		display: flex;
		gap: 12px;
		padding: 12px;
	}

	.rbp-wishlist-item__img {
		width: 80px;
		height: 80px;
		aspect-ratio: 1;
		margin-bottom: 0;
		flex-shrink: 0;
	}

	.rbp-wishlist-item__select {
		top: 4px;
		left: 4px;
	}

	.rbp-wishlist-item__remove {
		top: 4px;
		right: 4px;
	}

	/* Compare bar more compact */
	.rbp-compare-bar__btn {
		padding: 8px 14px;
		font-size: 13px;
	}

	/* Brochure dialog centered on small phones */
	.rbp-dialog {
		width: calc(100vw - 32px);
		max-width: none;
		margin: auto;
		border-radius: 10px;
	}

	.rbp-dialog__content {
		padding: 20px 16px 24px;
	}

	.rbp-dialog__header {
		margin-bottom: 12px;
	}

	.rbp-dialog__header h3 {
		font-size: 15px;
	}

	.rbp-btn--primary {
		padding: 16px 24px;
		font-size: 16px;
		border-radius: 8px;
	}
}
