/*
 * Bulk Custom Text: name list table and import wizard.
 *
 * Follows the Summary block it sits under: a primary-coloured line title,
 * hairline rules instead of boxes, and the theme's own field and button
 * metrics. Every colour comes from the branch variables in main.css so a
 * custom-themed shop restyles this for free.
 */

.bct {
	margin: 24px 0 0;
}

/* Header: same weight and colour as the Summary line title above it. */
.bct-head {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 12px;
	margin-bottom: 6px;
}

.bct-title {
	color: var(--primary-color);
	font-size: 14px;
	font-weight: 500;
}

.bct-upload-open {
	border: 0;
	background: none;
	padding: 0;
	color: #555;
	font-size: 11px;
	font-weight: 500;
	cursor: pointer;
	border-bottom: 1px solid rgba(170, 170, 170, 0.5);
	transition: color 160ms cubic-bezier(0.22, 1, 0.36, 1),
		border-color 160ms cubic-bezier(0.22, 1, 0.36, 1);
}

.bct-upload-open:hover {
	color: #222;
	border-bottom-color: var(--primary-color);
}

/* Table */

.bct-scroll { overflow-x: auto; }

.bct-table {
	width: 100%;
	min-width: 380px;
	border-collapse: collapse;
	/*
	 * Fixed layout is load-bearing. In auto layout a child at width:100% does
	 * not widen its column, so every column shrinks to its header text and the
	 * selects become unusable.
	 */
	table-layout: fixed;
	border-top: rgba(170, 170, 170, 0.2) 1px solid;
}

.bct-col-attr { width: 104px; }
.bct-col-qty { width: 66px; }
.bct-col-remove { width: 26px; }

.bct-table th {
	text-align: left;
	padding: 8px 8px 6px 0;
	font-size: 11px;
	font-weight: 500;
	color: #aaa;
	white-space: nowrap;
}

.bct-table th:last-child { padding-right: 0; }
/* Needs the same specificity as `.bct-table th` above, which sets left. */
.bct-table th.bct-th-qty { text-align: center; padding-right: 0; }

.bct-fieldprice {
	display: block;
	margin-top: 1px;
	color: var(--price-color);
	font-size: 10px;
	font-weight: 500;
	white-space: nowrap;
}

.bct-req {
	color: var(--price-color);
	text-decoration: none;
	margin-left: 2px;
}

.bct-table tbody tr {
	border-top: rgba(170, 170, 170, 0.2) 1px solid;
}

/*
 * The delete control stays hidden until the row is under the cursor. A column
 * of red crosses reads as a column of warnings; revealed on hover it reads as
 * an affordance.
 */
.bct-table tbody tr .bct-remove {
	opacity: 0;
	transition: opacity 140ms cubic-bezier(0.22, 1, 0.36, 1),
		color 140ms cubic-bezier(0.22, 1, 0.36, 1);
}

.bct-table tbody tr:hover .bct-remove,
.bct-table tbody tr:focus-within .bct-remove {
	opacity: 1;
}

.bct-table td {
	padding: 7px 8px 7px 0;
	vertical-align: middle;
}

.bct-table tbody tr { transition: background-color 140ms cubic-bezier(0.22, 1, 0.36, 1); }
.bct-table tbody tr:hover { background-color: rgba(247, 210, 76, 0.05); }

.bct-table td:last-child { padding-right: 0; }

.bct-table input,
.bct-table select {
	width: 100%;
	min-width: 0;
	height: 35px;
	padding: 0 10px;
	border: #ddd 1px solid;
	border-radius: 5px;
	background: #fff;
	font-size: 13px;
	font-weight: 300;
	color: #222;
	box-sizing: border-box;
	transition: border-color 160ms cubic-bezier(0.22, 1, 0.36, 1);
}

.bct-table input:focus,
.bct-table select:focus {
	outline: 0;
	border-color: var(--primary-color);
}

.bct-table select {
	padding: 0 22px 0 10px;
	appearance: none;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='8' height='5' viewBox='0 0 8 5'%3E%3Cpath d='M0 0l4 5 4-5z' fill='%23aaa'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right 9px center;
}

/* Placeholder option should not read as a chosen value. */
.bct-table select.is-empty { color: #aaa; }
/*
 * The native spinner sits in the right edge of a number input and collides
 * with a right-aligned value in a column this narrow. Hidden, and the figure
 * centred so a lone "1" is not pinned to one side.
 */
.bct-table .bct-qty {
	padding: 0 4px;
	text-align: center;
	-moz-appearance: textfield;
	appearance: textfield;
}

.bct-table .bct-qty::-webkit-outer-spin-button,
.bct-table .bct-qty::-webkit-inner-spin-button {
	-webkit-appearance: none;
	margin: 0;
}

.bct-remove {
	display: block;
	width: 22px;
	height: 22px;
	margin-left: auto;
	border: 0;
	padding: 0;
	background: none;
	color: #ccc;
	font-size: 15px;
	line-height: 22px;
	cursor: pointer;
	transition: color 160ms cubic-bezier(0.22, 1, 0.36, 1);
}

.bct-remove:hover { color: #c33; }

.bct-foot {
	display: flex;
	align-items: baseline;
	justify-content: space-between;
	gap: 12px;
	margin-top: 10px;
}

.bct-count {
	font-size: 11px;
	color: #aaa;
	font-variant-numeric: tabular-nums;
}

.bct-count strong {
	color: #222;
	font-weight: 600;
}

.bct-count .bct-count-extra { color: var(--price-color); }
.bct-count .bct-count-todo { color: #bbb; }

.bct-count-sep {
	display: inline-block;
	width: 3px;
	height: 3px;
	margin: 0 7px 2px;
	border-radius: 50%;
	background: #d5d5d5;
	vertical-align: middle;
}

.bct-hint {
	margin: 12px 0 0;
	padding: 0;
	font-size: 11px;
	color: #aaa;
}

.bct-hint button {
	border: 0;
	background: none;
	padding: 0;
	font: inherit;
	color: #555;
	cursor: pointer;
	text-decoration: underline;
}

.bct-hint button:hover { color: #222; }

.bct-add-row {
	margin-top: 0;
	border: 0;
	background: none;
	padding: 0;
	color: #aaa;
	font-size: 11px;
	font-weight: 500;
	cursor: pointer;
	transition: color 160ms cubic-bezier(0.22, 1, 0.36, 1);
}

.bct-add-row::before {
	content: "+";
	color: var(--primary-color);
	margin-right: 6px;
	font-size: 13px;
}

.bct-add-row:hover { color: #555; }

.bct-row-error input,
.bct-row-error select { border-color: #c33; }

/*
 * Over the character limit. Marked on the field itself and the moment it
 * happens: an imported value that is quietly too long, flagged only when Add
 * to cart is pressed, is found far too late.
 */
.bct-table input.bct-too-long {
	border-color: #c33;
	background: rgba(204, 51, 51, 0.04);
}

.bct-table input.bct-too-long:focus { border-color: #c33; }

.bct-limit {
	display: inline-block;
	margin-left: 5px;
	color: #c33;
	font-variant-numeric: tabular-nums;
}

.bct-notice {
	margin: 10px 0 0;
	padding: 0;
	color: #c33;
	font-size: 11px;
	min-height: 1em;
}

/* Import wizard */

.bct-modal {
	position: fixed;
	inset: 0;
	z-index: 9999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 32px;
	background: rgba(34, 34, 34, 0.55);
	animation: bct-fade 180ms cubic-bezier(0.22, 1, 0.36, 1);
}

.bct-modal.hide { display: none; }

.bct-modal-card {
	position: relative;
	width: min(660px, 100%);
	max-height: min(86vh, 760px);
	overflow: auto;
	background: #fff;
	border-radius: 6px;
	padding: 40px 44px 36px;
	animation: bct-rise 240ms cubic-bezier(0.22, 1, 0.36, 1);
}

@keyframes bct-fade {
	from { opacity: 0; }
	to { opacity: 1; }
}

@keyframes bct-rise {
	from { opacity: 0; transform: translateY(10px) scale(0.995); }
	to { opacity: 1; transform: none; }
}

.bct-modal-card h3 {
	margin: 0;
	color: #222;
	font-size: 20px;
	font-weight: 600;
	letter-spacing: -0.01em;
}

.bct-close {
	position: absolute;
	top: 18px;
	right: 20px;
	border: 0;
	background: none;
	padding: 0;
	color: #ccc;
	font-size: 20px;
	line-height: 1;
	cursor: pointer;
	transition: color 160ms cubic-bezier(0.22, 1, 0.36, 1);
}

.bct-close:hover { color: #555; }

/*
 * Progress: numbered markers on a hairline track. Four grey words told the user
 * nothing about where they were or how far was left.
 */
.bct-steps {
	display: flex;
	list-style: none;
	margin: 30px 0 34px;
	padding: 0;
	counter-reset: bct-step;
}

.bct-steps li {
	position: relative;
	flex: 1;
	display: flex;
	flex-direction: column;
	align-items: center;
	gap: 9px;
	font-size: 11px;
	font-weight: 500;
	color: #bbb;
	counter-increment: bct-step;
	transition: color 200ms cubic-bezier(0.22, 1, 0.36, 1);
}

/* The track sits behind the markers and stops at the row's edges. */
.bct-steps li::before {
	content: "";
	position: absolute;
	top: 11px;
	left: -50%;
	width: 100%;
	height: 1px;
	background: rgba(170, 170, 170, 0.3);
}

.bct-steps li:first-child::before { display: none; }

.bct-steps li i {
	position: relative;
	z-index: 1;
	display: grid;
	place-items: center;
	width: 24px;
	height: 24px;
	border-radius: 50%;
	background: #fff;
	box-shadow: inset 0 0 0 1px rgba(170, 170, 170, 0.45);
	font-size: 10px;
	font-weight: 600;
	font-style: normal;
	color: #bbb;
	transition: box-shadow 200ms cubic-bezier(0.22, 1, 0.36, 1),
		background-color 200ms cubic-bezier(0.22, 1, 0.36, 1),
		color 200ms cubic-bezier(0.22, 1, 0.36, 1);
}

.bct-steps li i::after { content: counter(bct-step); }

.bct-steps li.active { color: #222; }

.bct-steps li.active i {
	background: var(--primary-color);
	box-shadow: inset 0 0 0 1px var(--primary-color);
	color: var(--secondary-color);
}

.bct-steps li.done { color: #888; }

.bct-steps li.done i {
	background: rgba(247, 210, 76, 0.22);
	box-shadow: inset 0 0 0 1px rgba(247, 210, 76, 0.5);
	color: #8a6d1c;
}

/* A tick reads faster than a number for work already done. */
.bct-steps li.done i::after { content: "\2713"; font-size: 11px; }

.bct-step-body { font-size: 13px; color: #555; }

/* Long tables must scroll inside the card, never widen it. */
.bct-map-scroll { overflow-x: auto; }
.bct-step-body p { padding: 0 0 12px; }
.bct-step-body a { color: #222; text-decoration: underline; }

/* Drop zone. The browser's own file input is the ugliest control on the page
   and gives no hint that dragging works. */
.bct-drop {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: 7px;
	min-height: 172px;
	padding: 36px 24px;
	border: 1px solid #e2e2e2;
	border-radius: 5px;
	background: #fafafa;
	text-align: center;
	cursor: pointer;
	transition: border-color 180ms cubic-bezier(0.22, 1, 0.36, 1),
		background-color 180ms cubic-bezier(0.22, 1, 0.36, 1);
}

.bct-drop input[type="file"] {
	position: absolute;
	width: 1px;
	height: 1px;
	opacity: 0;
	pointer-events: none;
}

.bct-drop:hover { border-color: #d0d0d0; background: #f7f7f7; }

.bct-drop.is-over {
	border-color: var(--primary-color);
	background: rgba(247, 210, 76, 0.09);
}

.bct-drop.has-file {
	border-color: rgba(247, 210, 76, 0.7);
	background: rgba(247, 210, 76, 0.07);
}

.bct-drop-icon {
	color: var(--primary-color);
	width: 30px;
	height: 30px;
	margin-bottom: 6px;
	transition: transform 220ms cubic-bezier(0.22, 1, 0.36, 1);
}

.bct-drop.is-over .bct-drop-icon { transform: translateY(-3px); }
.bct-drop.has-file .bct-drop-icon { color: #8a6d1c; }

.bct-drop-main { font-size: 14px; color: #222; }
.bct-drop-main u { text-decoration-color: rgba(170, 170, 170, 0.7); }
.bct-drop-size { color: #aaa; font-size: 11px; }
.bct-drop-sub { font-size: 12px; color: #aaa; }

/* Checkbox, matching the field metrics used in the table. */
.bct-check {
	display: flex;
	align-items: center;
	gap: 10px;
	margin: 26px 0 0;
	font-size: 12px;
	color: #555;
	cursor: pointer;
}

.bct-check input {
	appearance: none;
	width: 16px;
	height: 16px;
	margin: 0;
	border: #ddd 1px solid;
	border-radius: 4px;
	background: #fff;
	cursor: pointer;
	transition: border-color 160ms cubic-bezier(0.22, 1, 0.36, 1),
		background-color 160ms cubic-bezier(0.22, 1, 0.36, 1);
}

.bct-check input:checked {
	border-color: var(--primary-color);
	background: var(--primary-color)
		url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='8' viewBox='0 0 10 8'%3E%3Cpath d='M1 4l2.5 2.5L9 1' stroke='%23222' stroke-width='1.8' fill='none' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E")
		center no-repeat;
}

.bct-check input:focus-visible { outline: 2px solid var(--primary-color); outline-offset: 2px; }

.bct-aside {
	margin: 16px 0 0;
	padding: 0;
	font-size: 12px;
	color: #aaa;
	line-height: 1.5;
}

.bct-aside a { color: #555; }

.bct-lead {
	margin: 0 0 20px;
	padding: 0;
	font-size: 13px;
	color: #555;
	line-height: 1.55;
}

.bct-lead strong { color: #222; font-weight: 600; }
.bct-warn { color: var(--price-color); }

.bct-map-col { display: block; color: #222; }

.bct-map-sample {
	display: block;
	margin-top: 1px;
	font-size: 11px;
	color: #aaa;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
}

.bct-preview {
	width: 100%;
	margin: 0 0 4px;
	border-collapse: collapse;
	border-top: rgba(170, 170, 170, 0.2) 1px solid;
	font-size: 11px;
}

.bct-preview th {
	padding: 7px 10px 6px 0;
	text-align: left;
	font-weight: 500;
	color: #aaa;
	white-space: nowrap;
}

.bct-preview tbody tr { border-top: rgba(170, 170, 170, 0.2) 1px solid; }

.bct-preview td {
	padding: 7px 10px 7px 0;
	color: #222;
	white-space: nowrap;
	overflow: hidden;
	text-overflow: ellipsis;
	max-width: 130px;
}

.bct-preview th:last-child,
.bct-preview td:last-child { padding-right: 0; }

/* Needs to outrank `.bct-preview th`, which sets left alignment above. */
.bct-preview th.bct-preview-qty,
.bct-preview td.bct-preview-qty { text-align: right; }

.bct-map {
	width: 100%;
	margin: 4px 0 18px;
	border-collapse: collapse;
	border-top: rgba(170, 170, 170, 0.2) 1px solid;
}

.bct-map tr { border-bottom: rgba(170, 170, 170, 0.2) 1px solid; }

.bct-map td {
	padding: 7px 10px 7px 0;
	vertical-align: middle;
	font-size: 12px;
	color: #222;
	word-break: break-word;
}

.bct-map td:first-child { width: 52%; }
.bct-map td:last-child { padding-right: 0; }

.bct-map select {
	width: 100%;
	height: 32px;
	padding: 0 8px;
	border: #ddd 1px solid;
	border-radius: 5px;
	background: #fff;
	font-size: 12px;
	color: #222;
	box-sizing: border-box;
}

.bct-map select:focus { outline: 0; border-color: var(--primary-color); }

/*
 * Back sits left, the forward action right, matching the direction the step
 * tracker runs. margin-right:auto on Back keeps the primary pinned right even
 * on step one, where there is nothing to go back to.
 */
.bct-actions {
	display: flex;
	align-items: center;
	justify-content: flex-end;
	gap: 12px;
	margin-top: 32px;
	padding-top: 24px;
	border-top: rgba(170, 170, 170, 0.2) 1px solid;
}

.bct-back { margin-right: auto; }

/* Button metrics from .btn in buttons.css, so these sit with the rest. */
.bct-primary {
	height: 46px;
	padding: 0 22px;
	border: 0;
	border-radius: 5px;
	background: var(--primary-color);
	color: var(--secondary-color);
	font-size: 12px;
	font-weight: 600;
	cursor: pointer;
	transition: filter 160ms cubic-bezier(0.22, 1, 0.36, 1);
}

.bct-primary:hover { filter: brightness(0.94); }

/* Faded yellow reads as broken rather than inactive; a neutral is honest. */
.bct-primary[disabled] {
	background: #ededed;
	color: #b0b0b0;
	cursor: not-allowed;
	filter: none;
}

.bct-back {
	height: 46px;
	padding: 0 18px;
	border: 0;
	border-radius: 5px;
	background: none;
	color: #888;
	font-size: 12px;
	cursor: pointer;
	transition: color 160ms cubic-bezier(0.22, 1, 0.36, 1);
}

.bct-back:hover { color: #222; }

.bct-error {
	margin: 14px 0 0;
	padding: 0;
	color: #c33;
	font-size: 11px;
	min-height: 1em;
}

/* ---------------------------------------------------------------- mobile */

@media screen and (max-width: 700px) {
	/*
	 * A centred card wastes the short edge of a phone. Anchoring to the bottom
	 * gives the content the full width, puts the actions under the thumb, and
	 * leaves the page visible above so the dialog stays in context.
	 */
	.bct-modal {
		align-items: flex-end;
		padding: 0;
	}

	.bct-modal-card {
		width: 100%;
		max-height: 92vh;
		border-radius: 10px 10px 0 0;
		padding: 26px 20px calc(24px + env(safe-area-inset-bottom));
		animation: bct-sheet 260ms cubic-bezier(0.22, 1, 0.36, 1);
	}

	@keyframes bct-sheet {
		from { transform: translateY(100%); }
		to { transform: none; }
	}

	.bct-modal-card h3 { font-size: 17px; }

	.bct-close { top: 22px; right: 16px; }

	.bct-steps { margin: 24px 0 26px; }
	.bct-steps li { font-size: 10px; gap: 7px; }
	.bct-steps li i { width: 21px; height: 21px; }
	.bct-steps li::before { top: 10px; }

	.bct-drop { min-height: 148px; padding: 28px 18px; }
	.bct-drop-main { font-size: 13px; }

	.bct-map td:first-child { width: 46%; }

	/* Thumb-sized targets, primary action taking the width it deserves. */
	.bct-actions {
		margin-top: 26px;
		padding-top: 20px;
	}

	/* Forward action takes the width; Back stays a quiet escape on the left. */
	.bct-primary { flex: 1; height: 48px; }
	.bct-back { height: 48px; padding: 0 14px 0 0; flex: 0 0 auto; }

	/* The name list itself: the browser must not shrink the fields away. */
	.bct-table { min-width: 460px; }
}

@media screen and (max-width: 380px) {
	/* Four labels stop fitting; the numbers still carry the progress. */
	.bct-steps li { font-size: 0; gap: 0; }
	.bct-steps li i { font-size: 10px; }
}

/* Pointer-coarse devices get taller rows regardless of width. */
@media (pointer: coarse) {
	.bct-table input,
	.bct-table select { height: 40px; }
	.bct-remove { opacity: 1; }
}

@media (prefers-reduced-motion: reduce) {
	.bct-modal,
	.bct-modal-card { animation: none; }
	.bct-drop.is-over .bct-drop-icon { transform: none; }
}
