/* Pattern Bundle - Frontend Styles */

.pb-bundle {
	margin: 24px 0;
	font-family: inherit;
}

.pb-bundle__ui {
	display: flex;
	flex-direction: column;
	gap: 20px;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Size Selector (Dropdown Style)
─────────────────────────────────────────────────────────────────────────────*/

.pb-size {
	display: flex;
	flex-direction: column;
	gap: 8px;
}

.pb-size__header {
	display: flex;
	justify-content: space-between;
	align-items: center;
}

.pb-size__label {
	font-size: 12px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.5px;
	color: #1a1a1a;
}

.pb-size__options {
	position: relative;
}

.pb-sizeSelect {
	width: 100%;
	max-width: 320px;
	padding: 14px 40px 14px 16px;
	font-size: 14px;
	font-weight: 500;
	border: 1px solid #d4d4d4;
	border-radius: 4px;
	background: #fff;
	cursor: pointer;
	appearance: none;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23333' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 16px center;
}

.pb-sizeSelect:focus {
	outline: none;
	border-color: #1a1a1a;
}

/* Legacy button style (hidden by default, shown via JS if needed) */
.pb-size__buttons {
	display: none;
	flex-wrap: wrap;
	gap: 8px;
}

.pb-sizeOption {
	min-width: 48px;
	padding: 12px 16px;
	font-size: 14px;
	font-weight: 500;
	border: 1px solid #d4d4d4;
	border-radius: 4px;
	background: #fff;
	cursor: pointer;
	transition: all 0.15s ease;
}

.pb-sizeOption:hover:not(.is-selected):not(.is-unavailable) {
	border-color: #1a1a1a;
}

.pb-sizeOption.is-selected {
	background: #1a1a1a;
	border-color: #1a1a1a;
	color: #fff;
}

.pb-sizeOption.is-unavailable {
	opacity: 0.4;
	cursor: not-allowed;
	text-decoration: line-through;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Yarn Components
─────────────────────────────────────────────────────────────────────────────*/

.pb-components {
	display: flex;
	flex-direction: column;
	gap: 16px;
}

.pb-components__header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding-bottom: 12px;
	border-bottom: 1px solid #e5e5e5;
}

.pb-components__title {
	font-size: 12px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 0.5px;
	color: #1a1a1a;
}

.pb-components__list {
	display: flex;
	flex-direction: column;
	gap: 16px;
}

/* Yarn Row */
.pb-yarnRow {
	display: flex;
	flex-direction: column;
	gap: 12px;
	padding-bottom: 16px;
	border-bottom: 1px solid #e5e5e5;
}

.pb-yarnRow:last-child {
	border-bottom: none;
	padding-bottom: 0;
}

.pb-yarnMain {
	display: flex;
	align-items: center;
	gap: 12px;
}

.pb-yarnSwatch {
	width: 48px;
	height: 48px;
	border-radius: 50%;
	border: none;
	background-color: #f0f0f0;
	background-size: cover;
	background-position: center;
	background-repeat: no-repeat;
	cursor: pointer;
	flex-shrink: 0;
	padding: 0;
}

.pb-yarnSwatch:focus {
	outline: 2px solid #1a1a1a;
	outline-offset: 2px;
}

.pb-yarnInfo {
	flex: 1;
	min-width: 0;
}

.pb-yarnName {
	font-size: 14px;
	font-weight: 500;
	color: #1a1a1a;
	line-height: 1.3;
}

.pb-yarnStock {
	font-size: 12px;
	color: #666;
	margin-top: 2px;
}

.pb-yarnStock.in-stock {
	color: #22863a;
}

.pb-yarnStock.out-of-stock {
	color: #cb2431;
}

.pb-yarnQtyPrice {
	display: flex;
	align-items: center;
	gap: 16px;
	flex-shrink: 0;
}

/* Quantity Selector */
.pb-qtySelector {
	display: flex;
	align-items: center;
	gap: 0;
	border: 1px solid #d4d4d4;
	border-radius: 4px;
	overflow: hidden;
}

.pb-qtyBtn {
	width: 36px;
	height: 36px;
	display: flex;
	align-items: center;
	justify-content: center;
	background: #fff;
	border: none;
	cursor: pointer;
	font-size: 18px;
	color: #1a1a1a;
	transition: background 0.15s ease;
}

.pb-qtyBtn:hover {
	background: #f5f5f5;
}

.pb-qtyBtn:disabled {
	opacity: 0.3;
	cursor: not-allowed;
}

.pb-qtyValue {
	width: 40px;
	text-align: center;
	font-size: 14px;
	font-weight: 500;
	border: none;
	border-left: 1px solid #d4d4d4;
	border-right: 1px solid #d4d4d4;
	padding: 8px 0;
	background: #fff;
}

.pb-yarnPrice {
	font-size: 14px;
	font-weight: 600;
	color: #1a1a1a;
	white-space: nowrap;
}

/* Color Picker Toggle */
.pb-colorToggle {
	display: flex;
	align-items: center;
	gap: 8px;
	padding: 8px 0;
	background: none;
	border: none;
	cursor: pointer;
	font-size: 13px;
	color: #1a1a1a;
	text-decoration: underline;
}

.pb-colorToggle__icon {
	width: 16px;
	height: 16px;
	transition: transform 0.2s ease;
}

.pb-colorToggle.is-open .pb-colorToggle__icon {
	transform: rotate(180deg);
}

/* Color Picker / Swatches */
.pb-yarnPicker {
	display: none;
	padding-top: 12px;
}

.pb-yarnPicker.is-open {
	display: block;
}

.pb-swatches {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(56px, 1fr));
	gap: 12px;
}

.pb-swatchItem {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 6px;
	cursor: pointer;
}

.pb-swatch {
	width: 48px;
	height: 48px;
	border-radius: 50%;
	border: 2px solid transparent;
	background-color: #f0f0f0;
	background-size: cover;
	background-position: center;
	background-repeat: no-repeat;
	padding: 0;
	cursor: pointer;
	transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

.pb-swatch:hover {
	border-color: #999;
}

.pb-swatch.is-selected {
	border-color: #1a1a1a;
	box-shadow: 0 0 0 2px #fff, 0 0 0 4px #1a1a1a;
}

.pb-swatch:focus {
	outline: none;
	border-color: #1a1a1a;
}

.pb-swatch:disabled {
	opacity: 0.3;
	cursor: not-allowed;
}

.pb-swatchLabel {
	font-size: 11px;
	color: #666;
	text-align: center;
	line-height: 1.2;
}

.pb-swatchBadge {
	position: absolute;
	top: -4px;
	right: -4px;
	background: #cb2431;
	color: #fff;
	font-size: 9px;
	padding: 2px 5px;
	border-radius: 10px;
	font-weight: 600;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Totals
─────────────────────────────────────────────────────────────────────────────*/

.pb-totals {
	display: flex;
	justify-content: space-between;
	align-items: center;
	padding: 20px 0;
	border-top: 1px solid #e5e5e5;
}

.pb-totals__label {
	font-size: 16px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 1px;
	color: #1a1a1a;
}

.pb-totals__value {
	font-size: 20px;
	font-weight: 700;
	color: #1a1a1a;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Add to Cart
─────────────────────────────────────────────────────────────────────────────*/

.pb-addToCart {
	margin-top: 0;
}

.pb-errors {
	margin-bottom: 12px;
}

.pb-errors:empty {
	display: none;
}

.pb-error {
	background: #fef0f0;
	border: 1px solid #f5c2c2;
	border-radius: 4px;
	padding: 12px 16px;
	margin-bottom: 8px;
	color: #cb2431;
	font-size: 13px;
	line-height: 1.4;
}

.pb-error:last-child {
	margin-bottom: 0;
}

.pb-addBtn {
	display: block;
	width: 100%;
	padding: 16px 24px;
	font-size: 14px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: 1px;
	line-height: 1.2;
	text-align: center;
	border: none;
	border-radius: 0;
	cursor: pointer;
	background: #1a1a1a;
	color: #fff;
	transition: background 0.15s ease, opacity 0.15s ease;
}

.pb-addBtn:hover:not(:disabled) {
	background: #333;
}

.pb-addBtn:focus {
	outline: 2px solid #1a1a1a;
	outline-offset: 2px;
}

.pb-addBtn:disabled {
	opacity: 0.4;
	cursor: not-allowed;
}

/* ─────────────────────────────────────────────────────────────────────────────
   Responsive
─────────────────────────────────────────────────────────────────────────────*/

@media (max-width: 480px) {
	.pb-yarnMain {
		flex-wrap: wrap;
	}

	.pb-yarnQtyPrice {
		width: 100%;
		justify-content: space-between;
		margin-top: 8px;
	}

	.pb-swatches {
		grid-template-columns: repeat(auto-fill, minmax(48px, 1fr));
		gap: 8px;
	}

	.pb-swatch {
		width: 40px;
		height: 40px;
	}
}

@media (prefers-reduced-motion: reduce) {
	.pb-bundle * {
		scroll-behavior: auto !important;
		transition: none !important;
		animation: none !important;
	}
}
