/**
 * Kohper Bulk Order — storefront styles.
 *
 * Deliberately low-specificity and theme-friendly: neutral surfaces, a single
 * accent variable, and a horizontally scrollable table on small screens.
 */

.kohper-bo {
	--kh-bo-accent: #3f6b9c;
	--kh-bo-accent-ink: #fff;
	--kh-bo-border: #e2e5ea;
	--kh-bo-muted: #6b7280;
	--kh-bo-surface: #fff;
	--kh-bo-surface-alt: #f4f6f8;
	--kh-bo-out: #b42318;

	color: #1f2933;
	font-size: 15px;
	line-height: 1.4;
}

.kohper-bo *,
.kohper-bo *::before,
.kohper-bo *::after {
	box-sizing: border-box;
}

/* Header */
.kohper-bo__title {
	margin: 0 0 0.25em;
	font-size: 1.6em;
	font-weight: 800;
	letter-spacing: -0.01em;
}

.kohper-bo__intro {
	margin: 0 0 1.25em;
	max-width: 60ch;
	color: var(--kh-bo-muted);
}

/* Toolbar */
.kohper-bo__toolbar {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	justify-content: space-between;
	gap: 0.75em;
	padding-bottom: 0.75em;
	border-bottom: 2px solid var(--kh-bo-border);
	margin-bottom: 0.5em;
}

.kohper-bo__filled {
	font-weight: 700;
	font-size: 1.1em;
}

.kohper-bo__toolbar-actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5em;
}

/* Buttons */
.kohper-bo-btn {
	appearance: none;
	border: 1px solid var(--kh-bo-border);
	background: var(--kh-bo-surface);
	color: inherit;
	padding: 0.5em 0.9em;
	font: inherit;
	font-weight: 600;
	line-height: 1.2;
	border-radius: 6px;
	cursor: pointer;
	text-transform: uppercase;
	letter-spacing: 0.03em;
	font-size: 0.8em;
}

.kohper-bo-btn:hover:not(:disabled) {
	border-color: var(--kh-bo-accent);
	color: var(--kh-bo-accent);
}

.kohper-bo-btn:disabled {
	opacity: 0.5;
	cursor: not-allowed;
}

.kohper-bo-btn--primary {
	background: var(--kh-bo-accent);
	border-color: var(--kh-bo-accent);
	color: var(--kh-bo-accent-ink);
	font-size: 0.95em;
	padding: 0.75em 1.4em;
}

.kohper-bo-btn--primary:hover:not(:disabled) {
	color: var(--kh-bo-accent-ink);
	filter: brightness(0.94);
}

/* Table */
.kohper-bo__table-wrap {
	overflow-x: auto;
}

.kohper-bo__table {
	width: 100%;
	border-collapse: collapse;
	/* 95px a column: 760px for the full eight, less as a site drops columns. */
	min-width: calc(var(--kohper-bo-cols, 8) * 95px);
}

.kohper-bo__table thead th {
	text-align: left;
	font-size: 0.72em;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--kh-bo-muted);
	font-weight: 700;
	padding: 0.75em 0.6em;
	border-bottom: 1px solid var(--kh-bo-border);
	white-space: nowrap;
}

.kohper-bo__table td {
	padding: 0.75em 0.6em;
	border-bottom: 1px solid var(--kh-bo-border);
	vertical-align: top;
}

.kohper-bo-col-num {
	width: 2.5em;
	color: var(--kh-bo-muted);
	font-variant-numeric: tabular-nums;
}

.kohper-bo-col-unit,
.kohper-bo-col-total {
	text-align: right;
	white-space: nowrap;
	font-variant-numeric: tabular-nums;
}

.kohper-bo-col-remove {
	width: 2em;
	text-align: center;
}

.kohper-bo-row--blocked {
	background: #fbecea33;
}

.kohper-bo-muted {
	color: var(--kh-bo-muted);
}

/* Search */
.kohper-bo-search {
	position: relative;
}

.kohper-bo-search__input,
.kohper-bo-qty,
.kohper-bo-variations__select {
	width: 100%;
	padding: 0.5em 0.6em;
	border: 1px solid var(--kh-bo-border);
	border-radius: 6px;
	font: inherit;
	background: var(--kh-bo-surface);
}

.kohper-bo-search__input:focus,
.kohper-bo-qty:focus,
.kohper-bo-variations__select:focus {
	outline: 2px solid var(--kh-bo-accent);
	outline-offset: -1px;
}

/* Positioned as `position: fixed` inline (anchored to the input in JS) so it
   escapes the grid's horizontally-scrollable, vertically-clipping wrapper. */
.kohper-bo-search__results {
	z-index: 1000;
	margin: 2px 0 0;
	padding: 0.25em;
	list-style: none;
	background: var(--kh-bo-surface);
	border: 1px solid var(--kh-bo-border);
	border-radius: 8px;
	box-shadow: 0 8px 24px rgba(15, 23, 42, 0.12);
	max-height: 320px;
	overflow-y: auto;
}

.kohper-bo-search__hint {
	padding: 0.6em;
	color: var(--kh-bo-muted);
	font-size: 0.9em;
}

/* An entry a site pinned through kohper.bulkOrder.searchOptions. */
.kohper-bo-search__result--custom {
	font-style: italic;
}

.kohper-bo-search__result {
	display: flex;
	align-items: center;
	gap: 0.6em;
	width: 100%;
	padding: 0.5em;
	border: 0;
	background: transparent;
	/* Explicit color: some themes (e.g. Astra) style <button> text white, which
	   would make the product name invisible on the light dropdown. */
	color: #1f2933;
	border-radius: 6px;
	cursor: pointer;
	text-align: left;
	font: inherit;
}

.kohper-bo-search__result:hover {
	background: var(--kh-bo-surface-alt);
}

.kohper-bo-search__thumb {
	width: 34px;
	height: 34px;
	object-fit: cover;
	border-radius: 4px;
	flex: 0 0 auto;
}

.kohper-bo-search__meta {
	display: flex;
	flex-direction: column;
	min-width: 0;
}

.kohper-bo-search__name {
	font-weight: 600;
}

.kohper-bo-search__sku {
	font-size: 0.8em;
	color: var(--kh-bo-muted);
}

/* Selected product cell */
.kohper-bo-product__title {
	font-weight: 600;
	display: flex;
	align-items: baseline;
	gap: 0.4em;
}

.kohper-bo-product__clear {
	border: 0;
	background: transparent;
	color: var(--kh-bo-muted);
	cursor: pointer;
	font-size: 1.1em;
	line-height: 1;
	padding: 0 0.2em;
}

.kohper-bo-product__clear:hover {
	color: var(--kh-bo-out);
}

.kohper-bo-product__sku {
	font-size: 0.82em;
	color: var(--kh-bo-muted);
	margin-top: 0.15em;
}

.kohper-bo-product__error {
	font-size: 0.82em;
	color: var(--kh-bo-out);
	margin-top: 0.3em;
}

/* Variation pickers */
.kohper-bo-variations {
	display: flex;
	flex-direction: column;
	gap: 0.5em;
}

.kohper-bo-variations__label {
	display: block;
	font-size: 0.68em;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--kh-bo-muted);
	font-weight: 700;
	margin-bottom: 0.3em;
}

.kohper-bo-variations__swatches {
	display: flex;
	flex-wrap: wrap;
	gap: 0.3em;
}

.kohper-bo-swatch {
	border: 1px solid var(--kh-bo-border);
	background: var(--kh-bo-surface);
	color: #1f2933; /* Don't inherit theme <button> text colour (e.g. white). */
	border-radius: 5px;
	padding: 0.3em 0.6em;
	font: inherit;
	font-size: 0.85em;
	cursor: pointer;
	line-height: 1.2;
}

.kohper-bo-swatch:hover {
	border-color: var(--kh-bo-accent);
}

.kohper-bo-swatch.is-active {
	background: var(--kh-bo-accent);
	border-color: var(--kh-bo-accent);
	color: var(--kh-bo-accent-ink);
}

/* Qty + stock */
.kohper-bo-qty {
	max-width: 5.5em;
	text-align: center;
	font-variant-numeric: tabular-nums;
}

.kohper-bo-stock--out {
	color: var(--kh-bo-out);
	font-weight: 600;
}

.kohper-bo-remove {
	border: 0;
	background: transparent;
	color: var(--kh-bo-muted);
	cursor: pointer;
	font-size: 1.2em;
	line-height: 1;
}

.kohper-bo-remove:hover {
	color: var(--kh-bo-out);
}

/* Footer */
.kohper-bo__foot {
	display: flex;
	flex-wrap: wrap;
	align-items: flex-end;
	justify-content: space-between;
	gap: 1em;
	padding-top: 1em;
	border-top: 2px solid var(--kh-bo-border);
	margin-top: 0.5em;
}

.kohper-bo__totals {
	display: flex;
	align-items: center;
	gap: 1.5em;
	flex-wrap: wrap;
}

.kohper-bo__stat {
	display: flex;
	flex-direction: column;
}

.kohper-bo__stat-label {
	font-size: 0.68em;
	text-transform: uppercase;
	letter-spacing: 0.06em;
	color: var(--kh-bo-muted);
	font-weight: 700;
}

.kohper-bo__stat-value {
	font-size: 1.5em;
	font-weight: 800;
	font-variant-numeric: tabular-nums;
}

.kohper-bo__checkout {
	display: flex;
	align-items: center;
	gap: 1.25em;
	flex-wrap: wrap;
}

.kohper-bo__subtotal {
	display: flex;
	flex-direction: column;
	text-align: right;
}

.kohper-bo__subtotal-value {
	font-size: 1.6em;
	font-weight: 800;
	font-variant-numeric: tabular-nums;
}

/* Tier bar */
.kohper-bo-tier {
	display: flex;
	flex-direction: column;
	gap: 0.3em;
	min-width: 220px;
}

.kohper-bo-tier__label {
	font-size: 0.8em;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: 0.04em;
	color: var(--kh-bo-accent);
}

.kohper-bo-tier__track {
	display: block;
	height: 6px;
	border-radius: 999px;
	background: var(--kh-bo-border);
	overflow: hidden;
}

.kohper-bo-tier__fill {
	display: block;
	height: 100%;
	background: var(--kh-bo-accent);
	transition: width 0.2s ease;
}

.kohper-bo-tier__next {
	font-size: 0.78em;
	color: var(--kh-bo-muted);
}

/* Toast */
.kohper-bo__toast {
	margin-top: 1em;
	padding: 0.8em 1em;
	border-radius: 8px;
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 1em;
}

.kohper-bo__toast--success {
	background: #e7f6ec;
	color: #14532d;
}

.kohper-bo__toast--error {
	background: #fdecea;
	color: var(--kh-bo-out);
}

.kohper-bo__toast-link {
	font-weight: 700;
	color: inherit;
}

/* Access notice */
.kohper-bulk-order-notice {
	padding: 1em 1.25em;
	border: 1px solid var(--kh-bo-border, #e2e5ea);
	border-radius: 8px;
	background: #f4f6f8;
	color: #374151;
}

/* Editor placeholder */
.kohper-bo-editor-placeholder {
	padding: 1.5em;
	border: 1px dashed #c3c9d3;
	border-radius: 8px;
	background: #f8fafc;
	text-align: center;
	color: #4b5563;
}

/* Import dialog — paste a list, or pick a CSV. Uses the same tokens as the
   grid so a theme restyles both by redefining --kh-bo-*. */
.kohper-bo-dialog {
	position: fixed;
	inset: 0;
	z-index: 9999;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 1.5em;
	background: rgba(17, 24, 39, 0.5);
}
.kohper-bo-dialog__panel {
	width: 100%;
	max-width: 640px;
	max-height: 90vh;
	overflow-y: auto;
	padding: 1.5em;
	border-radius: 10px;
	background: var(--kh-bo-surface, #fff);
	box-shadow: 0 12px 40px rgba(17, 24, 39, 0.25);
}
.kohper-bo-dialog__title {
	margin: 0 0 0.35em;
	font-size: 1.15em;
}
.kohper-bo-dialog__hint {
	margin: 0 0 1em;
	color: var(--kh-bo-muted, #6b7280);
	font-size: 0.9em;
	line-height: 1.5;
}
.kohper-bo-dialog__text {
	width: 100%;
	padding: 0.65em;
	border: 1px solid var(--kh-bo-border, #e2e5ea);
	border-radius: 6px;
	font-family: ui-monospace, SFMono-Regular, Menlo, monospace;
	font-size: 0.9em;
	resize: vertical;
}
.kohper-bo-dialog__file {
	margin: 0.75em 0 0;
}
.kohper-bo-dialog__error,
.kohper-bo-dialog__warn {
	margin: 0.75em 0 0;
	font-size: 0.9em;
	color: #b42318;
}
.kohper-bo-dialog__result {
	margin-top: 1em;
	padding-top: 1em;
	border-top: 1px solid var(--kh-bo-border, #e2e5ea);
}
.kohper-bo-dialog__summary {
	margin: 0;
	font-weight: 600;
}
.kohper-bo-dialog__problems {
	margin: 0.6em 0 0;
	padding-left: 1.2em;
	max-height: 30vh;
	overflow-y: auto;
	font-size: 0.88em;
	color: var(--kh-bo-muted, #6b7280);
	line-height: 1.6;
}
.kohper-bo-dialog__problems code {
	font-size: 0.95em;
}
.kohper-bo-dialog__actions {
	display: flex;
	flex-wrap: wrap;
	gap: 0.6em;
	justify-content: flex-end;
	margin-top: 1.25em;
}

/* A text action inside the dialog — a button, because it acts rather than
   navigates, but it should read as a link. */
.kohper-bo-dialog__link {
	padding: 0;
	border: 0;
	background: none;
	color: var(--kh-bo-accent, #b8622a);
	font: inherit;
	font-size: 0.9em;
	text-decoration: underline;
	cursor: pointer;
}
.kohper-bo-dialog__link:hover,
.kohper-bo-dialog__link:focus-visible {
	color: var(--kh-bo-accent-ink, #8a4a20);
}
.kohper-bo-dialog__file {
	display: flex;
	flex-wrap: wrap;
	gap: 0.9em;
	align-items: center;
}
.kohper-bo-dialog__result .kohper-bo-dialog__link {
	margin-top: 0.6em;
}

/* Quantities the import changed to fit the product's ordering rules. */
.kohper-bo-dialog__adjusted {
	margin: 0.6em 0 0;
	padding-left: 1.2em;
	max-height: 20vh;
	overflow-y: auto;
	font-size: 0.88em;
	color: var(--kh-bo-muted, #6b7280);
	line-height: 1.6;
}

/* Read-only attribute list on a simple product's row, in the column the
   variation pickers occupy on variable products. */
.kohper-bo-specs {
	margin: 0;
	padding: 0;
	list-style: none;
	display: flex;
	flex-direction: column;
	gap: 2px;
}
.kohper-bo-specs__item {
	margin: 0;
	font-size: 0.85em;
	line-height: 1.35;
	color: #50575e;
}
