/**
 * Rhutech Product Options — Modern Storefront UI
 */

:root {
	--rh-po-primary: #4f46e5;
	--rh-po-primary-dark: #4338ca;
	--rh-po-primary-light: #eef2ff;
	--rh-po-success: #059669;
	--rh-po-danger: #dc2626;
	--rh-po-text: #1f2937;
	--rh-po-muted: #6b7280;
	--rh-po-border: #e5e7eb;
	--rh-po-bg: #ffffff;
	--rh-po-bg-soft: #f9fafb;
	--rh-po-radius: 12px;
	--rh-po-radius-sm: 8px;
	--rh-po-shadow: 0 4px 24px rgba(15, 23, 42, 0.08);
	--rh-po-transition: 0.2s ease;
}

/* Main panel */
.rhutech-product-options {
	margin: 1.5rem 0 1.25rem;
	font-family: inherit;
	color: var(--rh-po-text);
}

.rhutech-po-panel {
	background: var(--rh-po-bg);
	border: 1px solid var(--rh-po-border);
	border-radius: var(--rh-po-radius);
	box-shadow: var(--rh-po-shadow);
	overflow: hidden;
}

.rhutech-po-panel__header {
	display: flex;
	align-items: flex-start;
	gap: 14px;
	padding: 20px 22px;
	background: linear-gradient(135deg, var(--rh-po-primary) 0%, #7c3aed 100%);
	color: #fff;
}

.rhutech-po-panel__icon {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 44px;
	height: 44px;
	background: rgba(255, 255, 255, 0.15);
	border-radius: 10px;
	flex-shrink: 0;
}

.rhutech-po-panel__titles {
	flex: 1;
	min-width: 0;
}

.rhutech-po-panel__title {
	margin: 0 0 4px;
	padding: 0;
	font-size: 1.15rem;
	font-weight: 700;
	line-height: 1.3;
	color: #fff;
}

.rhutech-po-panel__subtitle {
	margin: 0;
	font-size: 0.875rem;
	opacity: 0.9;
	line-height: 1.45;
}

.rhutech-po-panel__badge {
	align-self: center;
	padding: 5px 12px;
	background: rgba(255, 255, 255, 0.18);
	border-radius: 20px;
	font-size: 0.75rem;
	font-weight: 600;
	white-space: nowrap;
}

.rhutech-po-panel__body {
	padding: 20px 22px 22px;
}

/* Option groups */
.rhutech-option-group + .rhutech-option-group {
	margin-top: 24px;
	padding-top: 24px;
	border-top: 1px solid var(--rh-po-border);
}

.rhutech-group-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 16px;
}

.rhutech-group-title {
	margin: 0;
	font-size: 1rem;
	font-weight: 700;
	color: var(--rh-po-text);
}

.rhutech-group-count {
	font-size: 0.75rem;
	font-weight: 600;
	color: var(--rh-po-muted);
	background: var(--rh-po-bg-soft);
	padding: 4px 10px;
	border-radius: 20px;
}

.rhutech-group-fields {
	display: flex;
	flex-direction: column;
	gap: 18px;
}

/* Fields */
.rhutech-field {
	padding: 16px;
	background: var(--rh-po-bg-soft);
	border: 1px solid var(--rh-po-border);
	border-radius: var(--rh-po-radius-sm);
	transition: border-color var(--rh-po-transition), box-shadow var(--rh-po-transition);
}

.rhutech-field:focus-within {
	border-color: var(--rh-po-primary);
	box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.rhutech-field-label {
	display: flex;
	align-items: center;
	gap: 8px;
	margin: 0;
	font-size: 0.9375rem;
	font-weight: 600;
	color: var(--rh-po-text);
}

.rhutech-required {
	display: inline-flex;
	align-items: center;
	padding: 2px 8px;
	background: #fef2f2;
	color: var(--rh-po-danger);
	border-radius: 20px;
	font-size: 0.6875rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.03em;
	text-decoration: none;
	border: none;
}

.rhutech-field-description {
	margin: 4px 0 0;
	font-size: 0.8125rem;
	color: var(--rh-po-muted);
	line-height: 1.4;
}

.rhutech-field-input {
	margin-top: 12px;
}

.rhutech-field.rhutech-hidden {
	display: none !important;
}

/* Choice cards (radio & checkbox) */
.rhutech-choice-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
	gap: 10px;
}

.rhutech-choice-card {
	position: relative;
	cursor: pointer;
	margin: 0;
}

.rhutech-choice-card input {
	position: absolute;
	opacity: 0;
	width: 0;
	height: 0;
	pointer-events: none;
}

.rhutech-choice-card__inner {
	display: flex;
	align-items: flex-start;
	gap: 10px;
	padding: 12px 14px;
	background: #fff;
	border: 2px solid var(--rh-po-border);
	border-radius: var(--rh-po-radius-sm);
	transition: all var(--rh-po-transition);
	min-height: 100%;
}

.rhutech-choice-card:hover .rhutech-choice-card__inner {
	border-color: #c7d2fe;
}

.rhutech-choice-card input:checked + .rhutech-choice-card__inner,
.rhutech-choice-card.is-selected .rhutech-choice-card__inner {
	border-color: var(--rh-po-primary);
	background: var(--rh-po-primary-light);
	box-shadow: 0 0 0 1px var(--rh-po-primary);
}

.rhutech-choice-card__radio,
.rhutech-choice-card__check {
	flex-shrink: 0;
	width: 18px;
	height: 18px;
	margin-top: 2px;
	border: 2px solid #d1d5db;
	background: #fff;
	transition: all var(--rh-po-transition);
}

.rhutech-choice-card__radio {
	border-radius: 50%;
}

.rhutech-choice-card__check {
	border-radius: 4px;
}

.rhutech-choice-card input:checked + .rhutech-choice-card__inner .rhutech-choice-card__radio,
.rhutech-choice-card.is-selected .rhutech-choice-card__radio {
	border-color: var(--rh-po-primary);
	border-width: 5px;
}

.rhutech-choice-card input:checked + .rhutech-choice-card__inner .rhutech-choice-card__check,
.rhutech-choice-card.is-selected .rhutech-choice-card__check {
	background: var(--rh-po-primary);
	border-color: var(--rh-po-primary);
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M3 8.5L6.5 12L13 4' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: center;
	background-size: 12px;
}

.rhutech-choice-card__content {
	display: flex;
	flex-direction: column;
	gap: 4px;
	min-width: 0;
}

.rhutech-choice-card__label {
	font-size: 0.875rem;
	font-weight: 600;
	color: var(--rh-po-text);
	line-height: 1.35;
}

.rhutech-choice-card__price .rhutech-price-badge,
.rhutech-image-option__price .rhutech-price-badge,
.rhutech-pill-option__label .rhutech-price-badge {
	display: inline-block;
}

/* Price badges */
.rhutech-price-badge {
	display: inline-flex;
	align-items: center;
	padding: 2px 8px;
	background: #ecfdf5;
	color: var(--rh-po-success);
	border-radius: 20px;
	font-size: 0.75rem;
	font-weight: 700;
	line-height: 1.4;
}

.rhutech-price-badge--minus {
	background: #fef2f2;
	color: var(--rh-po-danger);
}

.rhutech-price-badge .woocommerce-Price-amount {
	font-size: inherit;
	color: inherit;
}

/* Pill buttons */
.rhutech-pill-group {
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}

.rhutech-pill-option {
	cursor: pointer;
	margin: 0;
}

.rhutech-pill-option input {
	position: absolute;
	opacity: 0;
	width: 0;
	height: 0;
}

.rhutech-pill-option__label {
	display: inline-flex;
	align-items: center;
	gap: 6px;
	padding: 10px 16px;
	background: #fff;
	border: 2px solid var(--rh-po-border);
	border-radius: 999px;
	font-size: 0.875rem;
	font-weight: 600;
	color: var(--rh-po-text);
	transition: all var(--rh-po-transition);
}

.rhutech-pill-option:hover .rhutech-pill-option__label {
	border-color: #c7d2fe;
}

.rhutech-pill-option input:checked + .rhutech-pill-option__label,
.rhutech-pill-option.is-selected .rhutech-pill-option__label {
	background: var(--rh-po-primary);
	border-color: var(--rh-po-primary);
	color: #fff;
}

.rhutech-pill-option input:checked + .rhutech-pill-option__label .rhutech-price-badge,
.rhutech-pill-option.is-selected .rhutech-pill-option__label .rhutech-price-badge {
	background: rgba(255, 255, 255, 0.2);
	color: #fff;
}

/* Image swatches */
.rhutech-swatch-grid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
	gap: 12px;
}

.rhutech-image-option {
	cursor: pointer;
	margin: 0;
}

.rhutech-image-option input {
	position: absolute;
	opacity: 0;
	width: 0;
	height: 0;
}

.rhutech-image-option__card {
	position: relative;
	display: flex;
	flex-direction: column;
	background: #fff;
	border: 2px solid var(--rh-po-border);
	border-radius: var(--rh-po-radius-sm);
	overflow: hidden;
	transition: all var(--rh-po-transition);
}

.rhutech-image-option:hover .rhutech-image-option__card {
	border-color: #c7d2fe;
	transform: translateY(-1px);
}

.rhutech-image-option input:checked + .rhutech-image-option__card,
.rhutech-image-option.is-selected .rhutech-image-option__card {
	border-color: var(--rh-po-primary);
	box-shadow: 0 0 0 1px var(--rh-po-primary), 0 8px 20px rgba(79, 70, 229, 0.15);
}

.rhutech-image-option__media {
	display: block;
	aspect-ratio: 1;
	overflow: hidden;
	background: var(--rh-po-bg-soft);
}

.rhutech-image-option__media img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}

.rhutech-image-option__placeholder {
	display: flex;
	align-items: center;
	justify-content: center;
	aspect-ratio: 1;
	color: var(--rh-po-muted);
	background: var(--rh-po-bg-soft);
}

.rhutech-image-option__footer {
	padding: 10px;
	text-align: center;
}

.rhutech-image-option__label {
	display: block;
	font-size: 0.8125rem;
	font-weight: 600;
	color: var(--rh-po-text);
	line-height: 1.3;
}

.rhutech-image-option__price {
	display: block;
	margin-top: 4px;
}

.rhutech-image-option__selected {
	position: absolute;
	top: 8px;
	right: 8px;
	width: 24px;
	height: 24px;
	display: flex;
	align-items: center;
	justify-content: center;
	background: var(--rh-po-primary);
	color: #fff;
	border-radius: 50%;
	opacity: 0;
	transform: scale(0.8);
	transition: all var(--rh-po-transition);
}

.rhutech-image-option input:checked + .rhutech-image-option__card .rhutech-image-option__selected,
.rhutech-image-option.is-selected .rhutech-image-option__selected {
	opacity: 1;
	transform: scale(1);
}

/* Text inputs */
.rhutech-input-wrap,
.rhutech-select-wrap {
	position: relative;
}

.rhutech-input,
.rhutech-field .rhutech-select,
.rhutech-field .rhutech-multiselect {
	width: 100%;
	padding: 12px 14px;
	border: 1px solid var(--rh-po-border);
	border-radius: var(--rh-po-radius-sm);
	font-size: 0.9375rem;
	color: var(--rh-po-text);
	background: #fff;
	transition: border-color var(--rh-po-transition), box-shadow var(--rh-po-transition);
	appearance: none;
}

.rhutech-input:focus,
.rhutech-field .rhutech-select:focus,
.rhutech-field .rhutech-multiselect:focus {
	outline: none;
	border-color: var(--rh-po-primary);
	box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.rhutech-textarea {
	min-height: 96px;
	resize: vertical;
}

/* Color picker */
.rhutech-color-wrap {
	display: flex;
	align-items: center;
	gap: 12px;
}

.rhutech-color-input {
	width: 56px;
	height: 44px;
	padding: 4px;
	border: 2px solid var(--rh-po-border);
	border-radius: var(--rh-po-radius-sm);
	cursor: pointer;
	background: #fff;
}

.rhutech-color-preview {
	width: 44px;
	height: 44px;
	border-radius: var(--rh-po-radius-sm);
	border: 1px solid var(--rh-po-border);
	background: var(--rh-po-primary);
}

/* Price breakdown */
.rhutech-price-breakdown {
	margin-top: 22px;
	padding: 18px;
	background: linear-gradient(180deg, var(--rh-po-bg-soft) 0%, #fff 100%);
	border: 1px solid var(--rh-po-border);
	border-radius: var(--rh-po-radius-sm);
	position: relative;
}

.rhutech-price-breakdown__header {
	display: flex;
	align-items: center;
	gap: 8px;
	margin-bottom: 14px;
	font-size: 0.875rem;
	font-weight: 700;
	color: var(--rh-po-text);
}

.rhutech-price-breakdown__header svg {
	color: var(--rh-po-primary);
}

.rhutech-price-breakdown__rows {
	margin-bottom: 8px;
}

.rhutech-price-row {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 7px 0;
	font-size: 0.875rem;
}

.rhutech-price-row__label {
	color: var(--rh-po-muted);
	font-weight: 500;
}

.rhutech-price-row__amount {
	font-weight: 600;
	color: var(--rh-po-text);
	transition: color var(--rh-po-transition);
}

.rhutech-price-row--total {
	margin-top: 8px;
	padding-top: 14px;
	border-top: 2px dashed var(--rh-po-border);
}

.rhutech-price-row--total .rhutech-price-row__label {
	font-size: 1rem;
	font-weight: 700;
	color: var(--rh-po-text);
}

.rhutech-price-row--total .rhutech-price-row__amount {
	font-size: 1.25rem;
	font-weight: 800;
	color: var(--rh-po-primary);
}

.rhutech-price-row__amount.is-updated {
	animation: rh-po-price-pulse 0.5s ease;
}

@keyframes rh-po-price-pulse {
	0% { transform: scale(1); }
	50% { transform: scale(1.04); color: var(--rh-po-success); }
	100% { transform: scale(1); }
}

.rhutech-price-breakdown.is-loading .rhutech-price-breakdown__rows,
.rhutech-price-breakdown.is-loading .rhutech-price-row--total {
	opacity: 0.5;
}

.rhutech-price-loading {
	display: flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	position: absolute;
	inset: 0;
	background: rgba(255, 255, 255, 0.7);
	border-radius: var(--rh-po-radius-sm);
	font-size: 0.8125rem;
	font-weight: 600;
	color: var(--rh-po-muted);
}

.rhutech-price-loading[hidden] {
	display: none !important;
}

.rhutech-spinner {
	width: 16px;
	height: 16px;
	border: 2px solid var(--rh-po-border);
	border-top-color: var(--rh-po-primary);
	border-radius: 50%;
	animation: rh-po-spin 0.7s linear infinite;
}

@keyframes rh-po-spin {
	to { transform: rotate(360deg); }
}

/* Select2 overrides */
.rhutech-product-options .select2-container--default .select2-selection--single,
.rhutech-product-options .select2-container--default .select2-selection--multiple {
	border: 1px solid var(--rh-po-border);
	border-radius: var(--rh-po-radius-sm);
	min-height: 44px;
	padding: 4px 6px;
}

.rhutech-product-options .select2-container--default .select2-selection--single .select2-selection__rendered {
	line-height: 34px;
	padding-left: 8px;
	color: var(--rh-po-text);
}

.rhutech-product-options .select2-container--default .select2-selection--single .select2-selection__arrow {
	height: 42px;
}

.rhutech-product-options .select2-container--default.select2-container--focus .select2-selection--single,
.rhutech-product-options .select2-container--default.select2-container--focus .select2-selection--multiple {
	border-color: var(--rh-po-primary);
	box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.12);
}

.rhutech-product-options .select2-container--default .select2-selection--multiple .select2-selection__choice {
	background: var(--rh-po-primary-light);
	border-color: #c7d2fe;
	color: var(--rh-po-primary-dark);
	border-radius: 20px;
	padding: 2px 8px;
}

/* Responsive */
@media (max-width: 640px) {
	.rhutech-po-panel__header {
		flex-wrap: wrap;
		padding: 16px;
	}

	.rhutech-po-panel__body {
		padding: 16px;
	}

	.rhutech-choice-grid {
		grid-template-columns: 1fr;
	}

	.rhutech-swatch-grid {
		grid-template-columns: repeat(2, 1fr);
	}

	.rhutech-field {
		padding: 14px;
	}

	.rhutech-price-row--total .rhutech-price-row__amount {
		font-size: 1.1rem;
	}
}

/* Theme compatibility */
.woocommerce div.product form.cart .rhutech-product-options {
	clear: both;
}

.woocommerce div.product form.cart .rhutech-product-options + .quantity {
	margin-top: 1rem;
}
