/**
 * OPI Frequently Bought Together - Front-end styles
 *
 * Accent color is injected via --opi-accent CSS custom property (set inline on .opi-fbt-wrap).
 * Default: #6abf2e
 *
 * @package OPI_FBT
 * @since   1.0.0
 */

/* ── Wrapper ─────────────────────────────────────────────────────────────── */
.opi-fbt-wrap {
	--opi-accent: #6abf2e;
	margin: 28px 0;
	padding: 20px 24px;
	background: #ffffff;
	border: 1px solid #e8e8e8;
	border-radius: 12px;
	box-shadow: 0 2px 12px rgba(0, 0, 0, .06);
	font-family: inherit;
	box-sizing: border-box;
}

/* ── Title ───────────────────────────────────────────────────────────────── */
.opi-fbt-title {
	display: flex;
	align-items: center;
	gap: 8px;
	font-size: 1em;
	font-weight: 700;
	color: #1a1a1a;
	margin: 0 0 18px;
	padding: 0;
	border: none;
	line-height: 1.4;
}

.opi-fbt-title::before {
	content: '';
	flex-shrink: 0;
	display: inline-block;
	width: 18px;
	height: 18px;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23555' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 2L3 6v14a2 2 0 002 2h14a2 2 0 002-2V6l-3-4z'/%3E%3Cline x1='3' y1='6' x2='21' y2='6'/%3E%3Cpath d='M16 10a4 4 0 01-8 0'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-size: contain;
}

/* ── Inner row ───────────────────────────────────────────────────────────── */
.opi-fbt-inner {
	display: flex;
	align-items: center;
	gap: 0;
}

/* ── Products list ───────────────────────────────────────────────────────── */
.opi-fbt-products {
	display: flex;
	align-items: center;
	flex: 1;
	flex-wrap: nowrap;
	gap: 0;
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
}

/* ── Single product card ─────────────────────────────────────────────────── */
.opi-fbt-product-item {
	background: #f7f7f7;
	border-radius: 10px;
	transition: opacity .2s ease, background .15s ease;
	flex-shrink: 0;
}

/* Dim unchecked items */
.opi-fbt-product-item.is-unchecked {
	opacity: .45;
}

.opi-fbt-product-item label {
	display: flex;
	align-items: center;
	gap: 10px;
	cursor: pointer;
	padding: 12px 14px;
	margin: 0;
	width: 100%;
	box-sizing: border-box;
}

/* Hidden native checkbox – we use the card click instead */
.opi-fbt-product-item input[type="checkbox"] {
	position: absolute;
	opacity: 0;
	pointer-events: none;
}

/* ── Thumbnail ───────────────────────────────────────────────────────────── */
.opi-fbt-thumb {
	flex-shrink: 0;
	display: block;
	line-height: 0;
}

.opi-fbt-thumb img {
	width: 52px;
	height: 52px;
	object-fit: contain;
	border-radius: 6px;
	display: block;
}

/* ── Product info ────────────────────────────────────────────────────────── */
.opi-fbt-product-info {
	display: flex;
	flex-direction: column;
	gap: 4px;
	min-width: 0;
}

.opi-fbt-product-name {
	display: block;
}

.opi-fbt-product-name a {
	font-size: .82em;
	font-weight: 600;
	color: #1a1a1a;
	text-decoration: none;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	display: block;
	max-width: 120px;
	line-height: 1.35;
}

.opi-fbt-product-name a:hover {
	text-decoration: underline;
}

.opi-fbt-product-price {
	font-size: .9em;
	font-weight: 700;
	color: var(--opi-accent);
	line-height: 1;
}

/* WooCommerce overrides price color for .amount */
.opi-fbt-product-price .woocommerce-Price-amount {
	color: var(--opi-accent);
}

/* ── Plus separator ──────────────────────────────────────────────────────── */
.opi-fbt-plus {
	font-size: 1.3em;
	color: #c0c0c0;
	font-weight: 300;
	padding: 0 10px;
	flex-shrink: 0;
	user-select: none;
	line-height: 1;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */
.opi-fbt-sidebar {
	flex-shrink: 0;
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 6px;
	padding-left: 24px;
	margin-left: 20px;
	border-left: 1px solid #ebebeb;
	min-width: 170px;
	text-align: center;
}

.opi-fbt-total-label {
	font-size: .75em;
	color: #888;
	font-weight: 500;
	text-transform: uppercase;
	letter-spacing: .05em;
}

.opi-fbt-total-price {
	font-size: 1.5em;
	font-weight: 700;
	color: #1a1a1a;
	line-height: 1;
	transition: opacity .2s;
}

.opi-fbt-total-price.is-partial {
	opacity: .55;
}

/* ── CTA button ──────────────────────────────────────────────────────────── */
.opi-fbt-btn-add-all {
	display: block;
	width: 100%;
	background: var(--opi-accent) !important;
	color: #ffffff !important;
	border: none !important;
	border-radius: 8px !important;
	padding: 11px 16px !important;
	font-size: .88em !important;
	font-weight: 600 !important;
	line-height: 1.3 !important;
	cursor: pointer;
	text-align: center;
	transition: filter .2s ease, transform .1s ease;
	box-shadow: none !important;
}

.opi-fbt-btn-add-all:hover:not(:disabled) {
	filter: brightness(.9);
	transform: translateY(-1px);
}

.opi-fbt-btn-add-all:active:not(:disabled) {
	transform: translateY(0);
}

.opi-fbt-btn-add-all:disabled {
	opacity: .65;
	cursor: not-allowed;
	transform: none !important;
}

/* ── Spinner ─────────────────────────────────────────────────────────────── */
.opi-fbt-spinner {
	width: 18px;
	height: 18px;
	border: 2px solid rgba(0, 0, 0, .15);
	border-top-color: var(--opi-accent);
	border-radius: 50%;
	animation: opi-fbt-spin .65s linear infinite;
	display: inline-block;
}

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

/* ── Status message ──────────────────────────────────────────────────────── */
.opi-fbt-message {
	font-size: .8em;
	font-weight: 500;
	line-height: 1.4;
	text-align: center;
	min-height: 1.4em;
}

.opi-fbt-message a {
	color: var(--opi-accent);
}

.opi-fbt-message.is-success { color: #27ae60; }
.opi-fbt-message.is-error   { color: #e74c3c; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media screen and (max-width: 640px) {
	.opi-fbt-wrap {
		padding: 16px;
	}

	.opi-fbt-inner {
		flex-direction: column;
		align-items: stretch;
		gap: 16px;
	}

	.opi-fbt-products {
		flex-wrap: wrap;
		gap: 8px;
	}

	.opi-fbt-plus {
		padding: 0 6px;
	}

	.opi-fbt-sidebar {
		border-left: none;
		border-top: 1px solid #ebebeb;
		padding-left: 0;
		padding-top: 16px;
		margin-left: 0;
		width: 100%;
	}

	.opi-fbt-btn-add-all {
		padding: 12px 16px !important;
	}
}
