/**
 * Product Add-ons Frontend Styles
 *
 * Styles for displaying product add-ons on the frontend,
 * including price display, conditional fields, and field styling.
 *
 * @package ProductAddons\WooCommerce
 * @since   1.0.0
 */

/* ==========================================================================
   Add-ons Wrapper
   ========================================================================== */

.pa-wc-addons-wrapper {
	margin: 20px 0;
	padding: 20px;
	background: #f9f9f9;
	border: 1px solid #e0e0e0;
	border-radius: 4px;
}

.pa-wc-addons-title {
	margin: 0 0 15px 0;
	font-size: 1.2em;
	font-weight: 600;
	color: #333;
}

/* ==========================================================================
   Field Styling
   ========================================================================== */

.pa-wc-addon-field {
	margin-bottom: 15px;
}

.pa-wc-addon-field label {
	display: block;
	margin-bottom: 5px;
	font-weight: 600;
	color: #333;
}

.pa-wc-addon-field .description {
	display: block;
	margin-top: 5px;
	font-size: 0.9em;
	color: #666;
	font-style: italic;
}

.pa-wc-addon-field .required {
	color: #d00;
	font-weight: bold;
	text-decoration: none;
}

/* Input, select, and textarea styling */
.pa-wc-addon-field input[type="text"],
.pa-wc-addon-field input[type="email"],
.pa-wc-addon-field input[type="number"],
.pa-wc-addon-field input[type="url"],
.pa-wc-addon-field input[type="tel"],
.pa-wc-addon-field textarea,
.pa-wc-addon-field select {
	width: 100%;
	padding: 8px 12px;
	border: 1px solid #ccc;
	border-radius: 3px;
	font-size: 1em;
	font-family: inherit;
	background-color: #fff;
	color: #333;
	box-sizing: border-box;
	margin: 0;
	display: block;
}

.pa-wc-addon-field input[type="text"]:focus,
.pa-wc-addon-field input[type="email"]:focus,
.pa-wc-addon-field input[type="number"]:focus,
.pa-wc-addon-field input[type="url"]:focus,
.pa-wc-addon-field input[type="tel"]:focus,
.pa-wc-addon-field textarea:focus,
.pa-wc-addon-field select:focus {
	border-color: #999;
	box-shadow: 0 0 3px rgba(0, 0, 0, 0.1);
	outline: none;
}

/* ==========================================================================
   Price Display
   ========================================================================== */

.pa-wc-price {
	color: #4caf50;
	font-weight: 600;
	margin-left: 5px;
	white-space: nowrap;
}

.pa-wc-price:before {
	content: "";
}

/* Negative prices (discounts) */
.pa-wc-price.negative {
	color: #ff5722;
}

/* Price in labels */
label .pa-wc-price {
	font-size: 0.95em;
}

/* ==========================================================================
   Swatches (Image/Color)
   ========================================================================== */

/* Swatch wrapper */
.pa-wc-swatch-wrapper {
	display: inline-block;
	text-align: center;
}

.pa-wc-swatch-wrapper label.pa-wc-swatch-item.pa-wc-swatch-image {
	margin-bottom: 0;
	line-height: 1;
}

/* Vertical layout - show labels */
.pa-wc-radio-layout-vertical.pa-wc-radio-style-color .pa-wc-swatch-wrapper {
	display: flex;
	align-items: center;
	column-gap: 10px;
	margin-bottom: 15px;
}

/* Horizontal layout - inline swatches */
.pa-wc-radio-layout-horizontal.pa-wc-radio-style-color .pa-wc-swatch-wrapper {
	display: grid;
	justify-items: center;
	align-items: start;
}

.pa-wc-swatch-grid {
	margin-top: 8px;
}

.pa-wc-swatches {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
	gap: 10px;
	margin-top: 10px;
}

.pa-wc-swatch-item {
	display: flex;
	flex-direction: column;
	align-items: center;
	cursor: pointer;
	transition: all 0.2s ease;
	position: relative;
	padding: 8px;
	border: 2px solid transparent;
	border-radius: 4px;
}

.pa-wc-swatch-item:hover {
	border-color: #ddd;
	background: #f9f9f9;
}

.pa-wc-swatch-item.selected {
	border-color: #2c3e50;
	background: #f0f0f0;
}

.pa-wc-swatch-item:hover .pa-wc-swatch-color {
	transform: scale(1.1);
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Selected state - add checkmark or ring */
.pa-wc-swatch-item input[type="radio"]:checked + .pa-wc-swatch-color {
	border-color: #2c3e50;
	border-width: 3px;
	box-shadow: 0 0 0 2px #fff, 0 0 0 4px #2c3e50;
}

.pa-wc-swatch-item input[type="radio"]:checked + .pa-wc-swatch-image {
	border: 3px solid #2c3e50;
	box-shadow: 0 0 0 2px #fff, 0 0 0 4px #2c3e50;
}

.pa-wc-swatch-image {
	display: inline-block;
	cursor: pointer;
	transition: all 0.2s ease;
	border: 2px solid transparent;
	border-radius: 4px;
	padding: 2px;
	line-height: 0;
	margin-bottom: -4px;
}

.pa-wc-swatch-image:hover {
	border-color: #ccc;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
}

.pa-wc-swatch-image img {
	max-width: 60px;
	max-height: 60px;
	display: block;
	margin: 0 auto;
	pointer-events: none; /* Ensure clicks pass through to label */
}

.pa-wc-swatch-color {
	display: inline-block;
	width: 40px;
	height: 40px;
	border-radius: 50%;
	transition: all 0.2s ease;
	cursor: pointer;
}

.pa-wc-swatch-label {
	display: block;
	margin-top: 0;
	font-size: 0.85em;
	text-align: center;
	color: #555;
	font-weight: 500;
}

.pa-wc-swatch-price {
	display: block;
	margin-top: 4px;
	font-size: 0.8em;
	color: #4caf50;
	font-weight: 500;
	text-align: center;
}

/* ==========================================================================
   Help Tooltips
   ========================================================================== */

.pa-wc-help-tip {
	color: #999;
	cursor: help;
	font-size: 1em;
	margin-left: 4px;
	vertical-align: middle;
}

.pa-wc-help-tip:hover {
	color: #555;
}

/* ==========================================================================
   Conditional Logic (Hidden Fields)
   ========================================================================== */

.pa-wc-conditional-field {
	transition: opacity 0.3s ease, max-height 0.3s ease, margin 0.3s ease;
	overflow: hidden;
}

.pa-wc-conditional-field.hidden {
	display: none;
}

/* ==========================================================================
   Character Counter
   ========================================================================== */

.pa-wc-character-counter {
	display: block;
	margin-top: 5px;
	font-size: 0.85em;
	color: #666;
}

.pa-wc-character-counter.over-limit {
	color: #d00;
	font-weight: 600;
}

/* ==========================================================================
   Error Messages
   ========================================================================== */

.pa-wc-field-error {
	display: block;
	margin-top: 5px;
	padding: 8px 12px;
	background: #ffebee;
	border-left: 3px solid #d00;
	color: #c62828;
	font-size: 0.9em;
	border-radius: 2px;
}

.pa-wc-addon-field.has-error input,
.pa-wc-addon-field.has-error select,
.pa-wc-addon-field.has-error textarea {
	border-color: #d00;
}

/* ==========================================================================
   Radio Fields
   ========================================================================== */

/* Radio Group Container */
.pa-wc-radio-group {
	margin: 10px 0;
}

/* Vertical Layout (default) */
.pa-wc-radio-layout-vertical .pa-wc-radio-group {
	display: flex;
	flex-direction: column;
	gap: 10px;
}

/* Horizontal Layout */
.pa-wc-radio-layout-horizontal .pa-wc-radio-group {
	display: flex;
	flex-direction: row;
	flex-wrap: wrap;
	gap: 5px;
}

/* Radio Option Wrapper */
.pa-wc-radio-option {
	display: block;
}

.pa-wc-radio-option label {
	display: inline-flex;
	align-items: center;
	cursor: pointer;
	font-weight: normal;
	margin: 0;
}

.pa-wc-radio-option input[type="radio"] {
	margin: 0 8px 0 0;
	width: auto;
	cursor: pointer;
}

.pa-wc-radio-label {
	margin-right: 5px;
}

/* Clear Selection Button */
.pa-wc-clear-selection-wrapper {
	margin-top: 10px;
	margin-bottom: 10px;
}

.pa-wc-clear-selection {
	padding: 6px 12px;
	font-size: 0.9em;
	background: #f5f5f5;
	border: 1px solid #ddd;
	border-radius: 3px;
	color: #666;
	cursor: pointer;
	transition: all 0.2s ease;
	display: inline-block;
}

.pa-wc-clear-selection:hover {
	background: #e8e8e8;
	border-color: #bbb;
	color: #333;
}

.pa-wc-clear-selection:active {
	background: #ddd;
}

/* Button Style Radio Options */
.pa-wc-radio-style-button .pa-wc-radio-group {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
}

.pa-wc-radio-button-wrapper {
	position: relative;
}

.pa-wc-radio-button-input {
	position: absolute;
	opacity: 0;
	width: 0;
	height: 0;
}

.pa-wc-radio-button {
	display: inline-block;
	padding: 10px 20px;
	background: #fff;
	border: 2px solid #ddd !important;
	border-radius: 4px;
	cursor: pointer;
	transition: all 0.2s ease;
	font-weight: 500;
	text-align: center;
	min-width: 80px;
	margin: 0;
}

.pa-wc-radio-button:hover {
	border-color: #999;
	background: #f9f9f9;
}

.pa-wc-radio-button-input:checked + .pa-wc-radio-button {
	background: #2c3e50;
	border-color: #2c3e50;
	color: #fff;
}

.pa-wc-radio-button-input:checked + .pa-wc-radio-button .pa-wc-price {
	color: #fff;
}

.pa-wc-radio-button-input:focus + .pa-wc-radio-button {
	outline: 2px solid #4a90e2;
	outline-offset: 2px;
}

.pa-wc-button-text {
	display: inline-block;
}

/* Select button group */
.pa-wc-select-button-group {
	display: flex;
	flex-wrap: wrap;
	gap: 10px;
}

.pa-wc-select-button-wrapper {
	position: relative;
}

.pa-wc-select-button-input {
	position: absolute;
	opacity: 0;
	width: 0;
	height: 0;
}

.pa-wc-select-button {
	display: inline-block;
	padding: 10px 20px;
	background: #fff;
	border: 2px solid #ddd !important;
	border-radius: 4px;
	cursor: pointer;
	transition: all 0.2s ease;
	font-weight: 500;
	text-align: center;
	min-width: 80px;
	margin: 0;
}

.pa-wc-select-button:hover {
	border-color: #999;
	background: #f9f9f9;
}

.pa-wc-select-button-input:checked + .pa-wc-select-button {
	background: #2c3e50;
	border-color: #2c3e50;
	color: #fff;
}

.pa-wc-select-button-input:checked + .pa-wc-select-button .pa-wc-price {
	color: #fff;
}

.pa-wc-select-button-input:focus + .pa-wc-select-button {
	outline: 2px solid #4a90e2;
	outline-offset: 2px;
}

/* ==========================================================================
   Responsive Design
   ========================================================================== */

@media (max-width: 768px) {
	.pa-wc-addons-wrapper {
		padding: 15px;
	}

	.pa-wc-swatches {
		grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
		gap: 8px;
	}

	.pa-wc-swatch-image img {
		max-width: 50px;
		max-height: 50px;
	}

	.pa-wc-swatch-color {
		width: 35px;
		height: 35px;
	}
}

@media (max-width: 480px) {
	.pa-wc-swatches {
		grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
	}
}
