.ctd-wrap {
	margin: 20px 0;
	max-width: 520px;
}

/* Safety net: if something renders the default add-to-cart form outside the
   normal WooCommerce hook/template (e.g. certain page-builder widgets),
   hide it via CSS so it never shows twice. Excludes our own widget, since
   it's also a form.cart (intentionally, so it inherits the theme's real
   button styling) — :not(.ctd-wrap) is what keeps this from hiding itself. */
body.ctd-active form.cart:not(.ctd-wrap) {
	display: none !important;
}

.ctd-field { margin-bottom: 14px; }
.ctd-label {
	display: block;
	font-weight: 600;
	margin-bottom: 6px;
	font-size: 13px;
}
.ctd-required { color: #d63638; }
.ctd-note { font-size: 11px; color: #888; margin-top: 4px; }

/* --- Logo upload --- */
.ctd-upload-box {
	position: relative;
	border: 2px dashed #ccc;
	border-radius: 6px;
	padding: 10px 14px;
	text-align: left;
	cursor: pointer;
	background: #fafafa;
	transition: border-color .15s ease;
	display: flex;
	align-items: center;
	gap: 10px;
	min-height: 44px;
}
.ctd-upload-box:hover { border-color: #999; }
.ctd-upload-box.ctd-dragover { border-color: #f0932b; background: #fff6ec; }
.ctd-logo-input {
	position: absolute;
	inset: 0;
	width: 100%;
	height: 100%;
	opacity: 0;
	cursor: pointer;
}
.ctd-upload-placeholder { display: flex; align-items: center; gap: 8px; }
.ctd-upload-placeholder .dashicons { color: #999; flex-shrink: 0; }
.ctd-upload-placeholder p { margin: 0; font-size: 12px; color: #666; line-height: 1.3; }
.ctd-upload-preview { position: relative; display: inline-block; }
.ctd-upload-preview img {
	max-width: 40px;
	max-height: 40px;
	border-radius: 4px;
	border: 1px solid #ddd;
	display: block;
}
.ctd-remove-logo-file {
	position: absolute;
	top: -8px;
	right: -8px;
	width: 18px;
	height: 18px;
	border-radius: 50%;
	background: #d63638;
	color: #fff;
	border: none;
	cursor: pointer;
	line-height: 1;
	font-size: 11px;
	z-index: 2;
}

/* --- Logo placement + multiple upload slots --- */
.ctd-logo-placement-options {
	display: flex;
	flex-wrap: wrap;
	gap: 14px;
	margin-bottom: 10px;
}
.ctd-radio {
	display: flex;
	align-items: center;
	gap: 5px;
	font-size: 13px;
	cursor: pointer;
	font-weight: 400;
}
.ctd-radio input { cursor: pointer; }

.ctd-logo-slots { display: flex; flex-direction: column; gap: 10px; }
.ctd-logo-slot { }
.ctd-logo-slot-header {
	display: flex;
	align-items: center;
	justify-content: space-between;
	margin-bottom: 5px;
}
.ctd-logo-slot-title { font-size: 12px; font-weight: 600; color: #444; }
.ctd-logo-slot-label-input {
	font-size: 12px;
	padding: 4px 7px;
	border: 1px solid #ccc;
	border-radius: 4px;
	flex: 1;
	margin-right: 8px;
}
.ctd-remove-logo-slot {
	background: none;
	border: none;
	color: #d63638;
	font-size: 16px;
	cursor: pointer;
	line-height: 1;
	padding: 0 2px;
}
.ctd-add-logo-slot {
	margin-top: 8px;
	background: none;
	border: 1px dashed #bbb;
	border-radius: 4px;
	padding: 6px 12px;
	font-size: 12px;
	color: #555;
	cursor: pointer;
}
.ctd-add-logo-slot:hover { border-color: #888; color: #222; }

/* --- Text field --- */
.ctd-custom-text {
	width: 100%;
	box-sizing: border-box;
	padding: 10px;
	border: 1px solid #ccc;
	border-radius: 4px;
	font-family: inherit;
	resize: vertical;
}

/* --- Presets --- */
.ctd-presets { display: flex; flex-wrap: wrap; gap: 8px; }
.ctd-preset-btn {
	padding: 8px 14px;
	border: 1px solid #ccc;
	background: #fff;
	border-radius: 4px;
	cursor: pointer;
	font-size: 13px;
}
.ctd-preset-btn:hover { border-color: #f0932b; }
.ctd-preset-btn.active {
	background: #1a1a2e;
	border-color: #1a1a2e;
	color: #fff;
}

/* --- Sizes --- */
.ctd-sizes-header {
	display: flex;
	justify-content: space-between;
	align-items: center;
	flex-wrap: wrap;
	gap: 6px;
}
.ctd-selected-count { font-size: 12px; background: #f2f2f2; padding: 3px 9px; border-radius: 20px; }
.ctd-total-qty { color: #1a7f37; }
.ctd-size-rows {
	margin-top: 8px;
	display: flex;
	flex-wrap: wrap;
	gap: 8px;
}
.ctd-size-row {
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 6px;
	padding: 10px 8px;
	border: 1px solid #e2e2e2;
	border-radius: 6px;
	background: #fafafa;
	min-width: 88px;
}
.ctd-size-label { font-weight: 600; font-size: 13px; }
.ctd-stepper { display: flex; align-items: center; border: 1px solid #ccc; border-radius: 4px; overflow: hidden; background: #fff; }
.ctd-stepper button {
	width: 28px;
	height: 32px;
	background: #f5f5f5;
	border: none;
	cursor: pointer;
	font-size: 16px;
	line-height: 1;
}
.ctd-stepper button:hover { background: #e6e6e6; }
.ctd-size-qty {
	width: 42px;
	height: 32px;
	border: none;
	border-left: 1px solid #ccc;
	border-right: 1px solid #ccc;
	text-align: center;
	font-size: 15px;
	font-weight: 600;
	color: #222;
	-moz-appearance: textfield;
}
.ctd-size-qty::-webkit-outer-spin-button,
.ctd-size-qty::-webkit-inner-spin-button { -webkit-appearance: none; margin: 0; }

/* --- Colors: visible swatches, synced with the native gallery --- */
.ctd-color-swatches { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 4px; }
.ctd-color-swatch {
	width: 44px;
	height: 44px;
	border-radius: 6px;
	border: 2px solid #fff;
	box-shadow: 0 0 0 1px #ccc;
	cursor: pointer;
	padding: 0;
	overflow: hidden;
}
.ctd-color-swatch img {
	width: 100%;
	height: 100%;
	object-fit: cover;
	display: block;
}
.ctd-color-swatch.active { box-shadow: 0 0 0 2px #1a1a2e; }
.ctd-colors-field .ctd-note { margin-top: 6px; }
.ctd-selected-color-name { color: #1a7f37; font-weight: 600; }

/* --- Messages / button --- */
.ctd-messages {
	padding: 10px 14px;
	border-radius: 4px;
	font-size: 13px;
	margin-bottom: 12px;
}
.ctd-messages.ctd-error { background: #fdeaea; color: #d63638; border: 1px solid #f3c1c1; }
.ctd-messages.ctd-success { background: #eafaf0; color: #1a7f37; border: 1px solid #b7ebc9; }
.ctd-add-to-cart-btn {
	display: block;
	width: 100%;
	text-align: center;
	background: #000 !important;
	color: #fff !important;
	border: none !important;
	border-radius: 0 !important;
	padding: 15px 20px !important;
	font-size: 13px !important;
	font-weight: 600 !important;
	text-transform: uppercase !important;
	letter-spacing: 0.8px !important;
	cursor: pointer;
	transition: opacity .15s ease;
	box-shadow: none !important;
}
.ctd-add-to-cart-btn:hover:not([disabled]) { opacity: .85; }
.ctd-add-to-cart-btn[disabled] {
	background: #b3b3b3 !important;
	opacity: 1 !important;
	cursor: not-allowed;
}

/* Draws the eye to the size grid when Add to Cart is blocked because no
   quantity has been entered yet. */
.ctd-sizes-field.ctd-flag .ctd-size-row {
	animation: ctd-flag-pulse 1.6s ease;
}
@keyframes ctd-flag-pulse {
	0%   { border-color: #d63638; box-shadow: 0 0 0 2px rgba(214,54,56,.25); }
	70%  { border-color: #d63638; box-shadow: 0 0 0 2px rgba(214,54,56,.25); }
	100% { border-color: #e2e2e2; box-shadow: none; }
}

/* --- Admin: color card grid --- */
.ctd-section-label { display: block; font-weight: 600; margin: 0 0 6px 175px; }
.ctd-indented { margin-left: 175px !important; }

.ctd-empty-note {
	background: #fcf9e8;
	border: 1px solid #f0e2a3;
	border-radius: 4px;
	padding: 10px 14px !important;
	color: #6b5900;
	max-width: 600px;
}

.ctd-colors-grid {
	display: flex;
	flex-wrap: wrap;
	gap: 14px;
	max-width: 760px;
	margin-top: 12px;
}

.ctd-color-card {
	width: 130px;
	background: #fff;
	border: 1px solid #dcdcde;
	border-radius: 8px;
	padding: 8px;
	box-shadow: 0 1px 2px rgba(0,0,0,.04);
}

.ctd-color-image-preview {
	width: 100%;
	height: 110px;
	object-fit: cover;
	display: block;
	border-radius: 5px;
	background: #f0f0f1;
}

.ctd-color-name-input {
	width: 100%;
	box-sizing: border-box;
	font-size: 12px;
	padding: 6px 7px;
	margin-top: 8px;
	border: 1px solid #ccc;
	border-radius: 4px;
}
.ctd-color-name-input::placeholder { color: #a7aaad; }
