/**
 * PIC Product Configurator 2.0 - Public Styles
 *
 * Styles for product page configurator display.
 *
 * @package PIC_Prodfig
 * @since 2.0.0
 */

/* ================================================================
 * CONFIGURATOR WRAPPER
 * ================================================================ */

label[for^="prodfig_quantity"] {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.prodfig-sr-price-announce {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}

.prodfig-configurator {
	margin: 20px 0;
}

.prodfig-form {
	max-width: 600px;
}

/* ================================================================
 * MAIN WC PRICE (hero — shows live configured price)
 * ================================================================ */

.woocommerce.prodfig-product div.product div.summary > p.price,
.prodfig-product .summary p.price,
.prodfig-product .product-info p.price,
.prodfig-product .product-main p.price,
.prodfig-product .entry-summary p.price {
	margin-bottom: 2px;
}

/* ================================================================
 * PRICE CONTEXT (positioned directly under p.price via JS)
 * Shows range/from context depending on display mode.
 * ================================================================ */

.prodfig-price-wrapper {
	margin-bottom: 20px;
	padding: 0;
	background: none;
	border-radius: 0;
}

.prodfig-price-context {
	font-size: 13px;
	color: #888;
	margin: 0;
}

/* "Starting from" label inside p.price for 'from' display mode */
.prodfig-from-label {
	font-size: 0.6em;
	font-weight: normal;
	color: #888;
}

/* Noscript notice */
.prodfig-noscript-notice {
	font-size: 13px;
	color: #888;
	font-style: italic;
	margin: 0 0 15px 0;
}

/* ================================================================
 * OPTION GROUPS
 * ================================================================ */

.prodfig-option-groups {
	margin-bottom: 20px;
}

.prodfig-option-group {
	margin-bottom: 20px;
	padding-bottom: 20px;
	border-bottom: 1px solid #eee;
}

.prodfig-option-group:last-child {
	border-bottom: none;
	margin-bottom: 0;
	padding-bottom: 0;
}

.prodfig-group-title {
	margin: 0 0 10px 0;
	font-size: 16px;
	font-weight: 600;
}

.prodfig-required-indicator {
	color: #e00;
	margin-left: 3px;
}

.prodfig-group-description {
	margin: 0 0 10px 0;
	font-size: 13px;
	color: #666;
}

/* ================================================================
 * OPTIONS (Dropdown Select)
 * ================================================================ */

.prodfig-options {
	margin-top: 8px;
}

.prodfig-select {
	width: 100%;
	max-width: 400px;
	padding: 10px 12px;
	font-size: 15px;
	border: 1px solid #ddd;
	border-radius: 4px;
	background-color: #fff;
	cursor: pointer;
	appearance: none;
	background-image: url("data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23666%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E");
	background-repeat: no-repeat;
	background-position: right 12px center;
	background-size: 10px;
	padding-right: 36px;
}

.prodfig-select:hover {
	border-color: #999;
}

.prodfig-select:focus {
	outline: none;
	border-color: #2271b1;
	box-shadow: 0 0 0 1px #2271b1;
}

/* Validation error state */
.prodfig-option-group.prodfig-error .prodfig-select {
	border-color: #e00;
}

.prodfig-option-group.prodfig-error .prodfig-group-title {
	color: #e00;
}

/* ================================================================
 * OPTIONS (Radio Buttons - for themes that prefer them)
 * ================================================================ */

.prodfig-options-radio {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.prodfig-option {
	display: flex;
	align-items: center;
	padding: 12px 15px;
	background: #fff;
	border: 2px solid #e0e0e0;
	border-radius: 4px;
	cursor: pointer;
	transition: border-color 0.2s, background-color 0.2s;
}

.prodfig-option:hover {
	border-color: #999;
}

.prodfig-option input[type="radio"] {
	margin: 0;
	margin-right: 12px;
	width: 18px;
	height: 18px;
	cursor: pointer;
}

.prodfig-option input[type="radio"]:checked + .prodfig-option-content {
	font-weight: 500;
}

.prodfig-option:has(input[type="radio"]:checked) {
	border-color: #2271b1;
	background: #f0f7fc;
}

.prodfig-option-content {
	display: flex;
	align-items: center;
	justify-content: space-between;
	flex: 1;
}

.prodfig-option-label {
	flex: 1;
}

.prodfig-option-price {
	margin-left: 15px;
	font-size: 14px;
	color: #666;
	white-space: nowrap;
}

.prodfig-option.prodfig-default .prodfig-option-label::after {
	content: " (Default)";
	font-size: 12px;
	color: #999;
	font-weight: normal;
}

/* Validation error state for radio buttons */
.prodfig-option-group.prodfig-error .prodfig-options-radio {
	border: 2px solid #e00;
	border-radius: 4px;
	padding: 5px;
}

/* ================================================================
 * SKU DISPLAY
 * ================================================================ */

.prodfig-sku-display {
	margin: 15px 0;
	font-size: 13px;
	color: #666;
}

.prodfig-sku-label {
	margin-right: 5px;
}

.prodfig-sku-value {
	font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
	background: #f5f5f5;
	padding: 3px 8px;
	border-radius: 3px;
}

/* ================================================================
 * QUANTITY FIELD
 * ================================================================ */

.prodfig-quantity {
	margin: 20px 0;
	display: flex;
	align-items: center;
	gap: 10px;
}

.prodfig-quantity label {
	font-weight: 500;
}

.prodfig-quantity .qty {
	width: 80px;
	padding: 8px 12px;
	border: 1px solid #ddd;
	border-radius: 4px;
	text-align: center;
}

/* ================================================================
 * CART / CHECKOUT ITEM DATA
 * ================================================================ */

/* Fix WC's wpautop() <p> inside <dd> breaking horizontal alignment */
.woocommerce-cart-form .variation dd p,
.woocommerce-checkout-review-order .variation dd p,
.woocommerce-mini-cart .variation dd p {
	margin: 0;
	line-height: inherit;
}

/* ================================================================
 * ADD TO CART BUTTON
 * ================================================================ */

.prodfig-add-to-cart-wrapper {
	margin-top: 20px;
}

.prodfig-add-to-cart {
	min-width: 200px;
	padding: 12px 24px;
	font-size: 16px;
}

/* ================================================================
 * CONFIRMATION MODAL
 * ================================================================ */

body.prodfig-modal-open {
	overflow: hidden;
}

.prodfig-modal {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 99999;
	display: flex;
	align-items: center;
	justify-content: center;
}

.prodfig-modal-overlay {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(0, 0, 0, 0.5);
}

.prodfig-modal-content {
	position: relative;
	background: #fff;
	border-radius: 8px;
	max-width: 500px;
	width: 90%;
	max-height: 80vh;
	overflow-y: auto;
	box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
	padding: 25px;
}

.prodfig-modal-close {
	position: absolute;
	top: 15px;
	right: 15px;
	background: none;
	border: none;
	font-size: 24px;
	cursor: pointer;
	color: #999;
	line-height: 1;
	padding: 0;
	width: 30px;
	height: 30px;
}

.prodfig-modal-close:hover {
	color: #333;
}

.prodfig-modal-close:focus,
.prodfig-modal-close:focus-visible {
	outline: 2px solid #2271b1;
	outline-offset: 2px;
	border-radius: 3px;
}

.prodfig-modal-title {
	margin: 0 0 20px 0;
	font-size: 20px;
	padding-right: 30px;
}

/* Modal Summary List */
.prodfig-modal-summary .prodfig-summary-list {
	margin: 0;
	padding: 0;
	list-style: none;
}

.prodfig-summary-item {
	display: flex;
	justify-content: space-between;
	padding: 10px 0;
	border-bottom: 1px solid #f0f0f0;
}

.prodfig-summary-item:last-child {
	border-bottom: none;
}

.prodfig-summary-label {
	color: #666;
	font-weight: 600;
	font-size: 1.2rem;
}

.prodfig-summary-value {
	font-size: 0.85rem;
	font-weight: 500;
	text-align: right;
}

.prodfig-summary-price {
	color: #666;
	font-weight: normal;
	font-size: 13px;
}

/* Modal Totals */
.prodfig-modal-total,
.prodfig-modal-sku {
	margin-top: 15px;
	padding-top: 15px;
	border-top: 2px solid #eee;
	display: flex;
	justify-content: space-between;
	align-items: center;
}

.prodfig-modal-total {
	font-size: 18px;
	font-weight: 600;
}

.prodfig-modal-sku {
	font-size: 14px;
	border-top: none;
	margin-top: 8px;
	padding-top: 0;
}

.prodfig-modal-sku-value {
	font-family: ui-monospace, SFMono-Regular, "SF Mono", Menlo, Consolas, monospace;
	background: #f5f5f5;
	padding: 3px 8px;
	border-radius: 3px;
}

/* Modal Actions */
.prodfig-modal-actions {
	margin-top: 25px;
	display: flex;
	gap: 10px;
	justify-content: flex-end;
}

.prodfig-modal-cancel,
.prodfig-modal-confirm {
	padding: 10px 20px;
	border-radius: 0px;
	cursor: pointer;
	font-size: 14px;
	transition: background 0.2s;
}

.prodfig-modal-cancel {
	background: #f0f0f0;
	border: 1px solid #ddd;
	color: #333;
}

.prodfig-modal-cancel:hover {
	background: #e0e0e0;
}

.prodfig-modal-confirm {
	background: #2271b1;
	border: none;
	color: #fff;
}

.prodfig-modal-confirm:hover {
	background: #135e96;
}

.prodfig-modal-cancel:focus,
.prodfig-modal-cancel:focus-visible,
.prodfig-modal-confirm:focus,
.prodfig-modal-confirm:focus-visible {
	outline: 2px solid #2271b1;
	outline-offset: 2px;
}

/* ================================================================
 * CONFIGURATOR MODAL (display_mode = 'modal')
 * ================================================================ */

.prodfig-customize-wrapper {
	margin: 20px 0;
}

.prodfig-customize-btn {
	width: 100%;
	padding: 12px 24px;
	font-size: 16px;
}

/* Modal mode: hide option groups until modal opens (noscript fallback keeps them accessible) */
.prodfig-configurator[data-display-mode="modal"] .prodfig-option-groups {
	display: none;
}

.prodfig-config-modal {
	position: fixed;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	z-index: 99999;
	display: flex;
	align-items: center;
	justify-content: center;
}

.prodfig-config-modal__overlay {
	position: absolute;
	top: 0;
	left: 0;
	right: 0;
	bottom: 0;
	background: rgba(0, 0, 0, 0.5);
}

.prodfig-config-modal__container {
	position: relative;
	max-width: 500px;
	width: 90%;
	max-height: 80vh;
	background: #fff;
	border-radius: 8px;
	box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
	display: flex;
	flex-direction: column;
	overflow: hidden;
}

.prodfig-config-modal__header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 16px 20px;
	border-bottom: 1px solid #eee;
	flex-shrink: 0;
}

.prodfig-config-modal__title {
	margin: 0;
	font-size: 18px;
	font-weight: 600;
	padding-right: 30px;
}

.prodfig-config-modal__close {
	position: absolute;
	top: 12px;
	right: 12px;
	background: none;
	border: none;
	font-size: 24px;
	cursor: pointer;
	color: #999;
	line-height: 1;
	padding: 0;
	width: 30px;
	height: 30px;
}

.prodfig-config-modal__close:hover {
	color: #333;
}

.prodfig-config-modal__close:focus,
.prodfig-config-modal__close:focus-visible {
	outline: 2px solid #2271b1;
	outline-offset: 2px;
	border-radius: 3px;
}

.prodfig-config-modal__body {
	flex: 1;
	overflow-y: auto;
	padding: 20px;
}

/* Show option groups when they're inside the modal body (specificity must beat the hiding rule) */
.prodfig-configurator[data-display-mode="modal"] .prodfig-config-modal__body .prodfig-option-groups {
	display: block;
}

.prodfig-config-modal__body .prodfig-option-group {
	margin-bottom: 16px;
}

.prodfig-config-modal__body .prodfig-select {
	width: 100%;
}

.prodfig-config-modal__footer {
	display: flex;
	align-items: center;
	justify-content: space-between;
	padding: 16px 20px;
	border-top: 1px solid #eee;
	flex-shrink: 0;
	background: #f9f9f9;
}

.prodfig-config-modal__price {
	font-size: 16px;
}

.prodfig-config-modal__price-label {
	font-weight: 600;
	margin-right: 8px;
}

.prodfig-config-modal__price-value {
	font-weight: 700;
	font-size: 18px;
}

.prodfig-config-modal__price-value del {
	color: #999;
	font-weight: 400;
	font-size: 14px;
	margin-right: 4px;
}

.prodfig-config-modal__price-value ins {
	text-decoration: none;
	color: #e00;
}

.prodfig-config-modal__footer .prodfig-add-to-cart {
	flex-shrink: 0;
	margin-left: 16px;
}

.prodfig-config-modal__footer .prodfig-add-to-cart:focus,
.prodfig-config-modal__footer .prodfig-add-to-cart:focus-visible {
	outline: 2px solid #2271b1;
	outline-offset: 2px;
}

/* Mobile: full-screen modal below 768px */
@media (max-width: 768px) {
	.prodfig-config-modal__container {
		width: 100%;
		height: 100%;
		max-width: none;
		max-height: none;
		border-radius: 0;
	}

	.prodfig-config-modal__footer {
		flex-direction: column;
		gap: 12px;
	}

	.prodfig-config-modal__footer .prodfig-add-to-cart {
		width: 100%;
		margin-left: 0;
	}
}

/* ================================================================
 * VALIDATION
 * ================================================================ */

.prodfig-field-error {
	color: #e00;
	font-size: 13px;
	margin-top: 8px;
}

.prodfig-validation-message {
	color: #e00;
	font-size: 13px;
	margin-top: 8px;
}

/* ================================================================
 * LOADING STATE
 * ================================================================ */

.prodfig-loading {
	opacity: 0.6;
	pointer-events: none;
}

/* ================================================================
 * PRICE DISPLAY ON SHOP LISTINGS
 * ================================================================ */

.prodfig-price-range-display {
	display: block;
}

.prodfig-price-from-display::before {
	content: "From ";
	font-weight: normal;
	font-size: 0.9em;
}

/* ================================================================
 * RESPONSIVE
 * ================================================================ */

@media (max-width: 600px) {
	.prodfig-option-content {
		flex-direction: column;
		align-items: flex-start;
		gap: 5px;
	}

	.prodfig-option-price {
		margin-left: 0;
	}

	/* Full width add to cart button on mobile */
	.prodfig-add-to-cart {
		width: 100% !important;
		min-width: unset;
	}

	/* Modal adjustments for mobile */
	.prodfig-modal {
		align-items: flex-start;
		padding: 20px 10px;
		padding-bottom: 80px; /* Space for chatbot in bottom right */
	}

	.prodfig-modal-content {
		width: 90%;
		max-height: calc(100vh - 220px); /* Shorter to account for chatbot */
		padding: 20px;
		margin-top: 50px;
	}

	.prodfig-summary-label {
		font-size: 14px;
	}
	.prodfig-summary-value {
		font-size: 10px;
	}

	.prodfig-modal-actions {
		flex-direction: column;
	}

	.prodfig-modal-cancel,
	.prodfig-modal-confirm {
		width: 100%;
		text-align: center;
	}
}
