/*
 * Form controls (Phase 3A — docs/COMPONENT-LIBRARY.md), per docs/DESIGN-SYSTEM.md §7:
 * text input, search input, select, checkbox, radio, toggle, textarea,
 * quantity selector, validation/error/success states. Focus-visible ring is
 * shared globally from base.css — never redefined here.
 */

.bholats-field {
	display: flex;
	flex-direction: column;
	gap: var(--space-2);
}

.bholats-label {
	font-size: var(--text-sm);
	font-weight: var(--font-weight-medium);
	color: var(--color-text-primary);
}

.bholats-label--required::after {
	content: " *";
	color: var(--color-error);
}

/* --- Base control styling shared by text/search/select/textarea --- */

.bholats-input,
.bholats-select,
.bholats-textarea {
	width: 100%;
	background: var(--color-surface);
	border: var(--border-width-sm) solid var(--color-border);
	border-radius: var(--radius-sm);
	padding: var(--space-3);
	font-family: var(--font-body);
	font-size: var(--text-sm);
	color: var(--color-text-primary);
	min-height: 44px;
	transition: border-color var(--duration-base) var(--ease-standard);
}

.bholats-input::placeholder,
.bholats-textarea::placeholder { color: var(--color-text-muted); }

.bholats-input:hover,
.bholats-select:hover,
.bholats-textarea:hover { border-color: var(--color-border-strong); }

.bholats-input:focus-visible,
.bholats-select:focus-visible,
.bholats-textarea:focus-visible { border-color: var(--color-brand-blue); }

.bholats-textarea { min-height: 120px; resize: vertical; }

.bholats-input:disabled,
.bholats-select:disabled,
.bholats-textarea:disabled {
	background: var(--color-surface-muted);
	color: var(--color-text-muted);
	cursor: not-allowed;
}

/* --- Select (custom chevron, native element for full a11y/keyboard support) --- */

.bholats-select {
	appearance: none;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 16 16' fill='none'%3E%3Cpath d='M4 6l4 4 4-4' stroke='%234B5D66' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: right var(--space-3) center;
	padding-right: var(--space-8);
}

/* --- Search input (visually dominant variant — docs/NAVIGATION-SYSTEM.md §1) --- */

.bholats-search {
	position: relative;
	display: flex;
	align-items: center;
	width: 100%;
}

.bholats-search__input {
	width: 100%;
	background: var(--color-surface);
	border: var(--border-width-sm) solid var(--color-border);
	border-radius: var(--radius-md);
	padding: var(--space-3) 76px var(--space-3) var(--space-10);
	font-size: var(--text-sm);
	min-height: 44px;
	transition: border-color var(--duration-base) var(--ease-standard), box-shadow var(--duration-base) var(--ease-standard);
}

.bholats-search__input:focus-visible {
	outline: none;
	border-color: var(--color-brand-blue);
	box-shadow: var(--shadow-focus);
}

/* Leading icon — decorative only, the real accessible label is the
   associated <label for="bholats-search-input"> (Phase 3B — docs/SEARCH-IMPLEMENTATION.md). */
.bholats-search__icon {
	position: absolute;
	left: var(--space-3);
	top: 50%;
	transform: translateY(-50%);
	display: flex;
	color: var(--color-text-secondary);
	pointer-events: none;
}
.bholats-search__icon svg { width: var(--icon-md); height: var(--icon-md); }

.bholats-search__clear {
	position: absolute;
	right: 40px;
	top: 50%;
	transform: translateY(-50%);
	width: 32px;
	height: 32px;
	display: none;
	align-items: center;
	justify-content: center;
	background: transparent;
	border: none;
	border-radius: var(--radius-sm);
	color: var(--color-text-secondary);
	cursor: pointer;
}
.bholats-search--has-value .bholats-search__clear { display: flex; }
.bholats-search__clear:hover { background: var(--color-surface-sunken); color: var(--color-text-primary); }
.bholats-search__clear svg { width: var(--icon-sm); height: var(--icon-sm); }

.bholats-search__submit {
	position: absolute;
	right: var(--space-1);
	top: 50%;
	transform: translateY(-50%);
	width: 36px;
	height: 36px;
	display: flex;
	align-items: center;
	justify-content: center;
	background: transparent;
	border: none;
	border-radius: var(--radius-sm);
	color: var(--color-text-secondary);
	cursor: pointer;
}

.bholats-search__submit:hover { background: var(--color-surface-sunken); color: var(--color-brand-blue); }
.bholats-search__submit svg { width: var(--icon-md); height: var(--icon-md); }

/* --- Checkbox & radio (native inputs, styled via accent-color for full a11y —
   no fake div-based controls) --- */

.bholats-checkbox,
.bholats-radio {
	display: inline-flex;
	align-items: center;
	gap: var(--space-2);
	font-size: var(--text-sm);
	color: var(--color-text-primary);
	cursor: pointer;
	min-height: 44px;
}

.bholats-checkbox input,
.bholats-radio input {
	width: 18px;
	height: 18px;
	accent-color: var(--color-brand-blue);
	cursor: pointer;
	flex-shrink: 0;
}

/* --- Toggle switch (checkbox styled as a switch — keyboard/AT behaviour of a
   real checkbox is preserved; role="switch" + aria-checked set in markup) --- */

.bholats-toggle {
	display: inline-flex;
	align-items: center;
	gap: var(--space-3);
	cursor: pointer;
	min-height: 44px;
}

.bholats-toggle input {
	appearance: none;
	width: 40px;
	height: 24px;
	border-radius: var(--radius-full);
	background: var(--color-border-strong);
	position: relative;
	cursor: pointer;
	transition: background-color var(--duration-base) var(--ease-standard);
	flex-shrink: 0;
}

.bholats-toggle input::before {
	content: "";
	position: absolute;
	top: 2px;
	left: 2px;
	width: 20px;
	height: 20px;
	border-radius: var(--radius-full);
	background: var(--color-surface);
	box-shadow: var(--shadow-sm);
	transition: transform var(--duration-base) var(--ease-standard);
}

.bholats-toggle input:checked { background: var(--color-brand-blue); }
.bholats-toggle input:checked::before { transform: translateX(16px); }
.bholats-toggle input:focus-visible { box-shadow: var(--shadow-focus); outline: none; }

.bholats-toggle__label { font-size: var(--text-sm); color: var(--color-text-primary); }

/* --- Quantity selector (stepper) ---
   Buttons are real <button type="button">, input is inputmode="numeric" with
   min/max/step attributes set server-side from real stock data — never a
   hardcoded max (docs/DESIGN-SYSTEM.md, docs/PAGE-REQUIREMENTS.md). */

.bholats-qty {
	display: inline-flex;
	align-items: stretch;
	border: var(--border-width-sm) solid var(--color-border);
	border-radius: var(--radius-sm);
	overflow: hidden;
	width: fit-content;
}

.bholats-qty__btn {
	width: 40px;
	min-height: 44px;
	display: flex;
	align-items: center;
	justify-content: center;
	background: var(--color-surface);
	border: none;
	color: var(--color-text-primary);
	font-size: var(--text-base);
	cursor: pointer;
	transition: background-color var(--duration-base) var(--ease-standard);
}

.bholats-qty__btn:hover { background: var(--color-surface-sunken); }
.bholats-qty__btn:disabled { color: var(--color-text-muted); cursor: not-allowed; background: var(--color-surface-muted); }

.bholats-qty__input {
	width: 48px;
	min-height: 44px;
	border: none;
	border-left: var(--border-width-sm) solid var(--color-border);
	border-right: var(--border-width-sm) solid var(--color-border);
	text-align: center;
	font-family: var(--font-body);
	font-size: var(--text-sm);
	font-variant-numeric: tabular-nums;
	color: var(--color-text-primary);
	-moz-appearance: textfield;
}

.bholats-qty__input::-webkit-outer-spin-button,
.bholats-qty__input::-webkit-inner-spin-button {
	-webkit-appearance: none;
	margin: 0;
}

/* --- Validation states --- */

.bholats-input[aria-invalid="true"],
.bholats-select[aria-invalid="true"],
.bholats-textarea[aria-invalid="true"] {
	border-color: var(--color-error);
}

.bholats-input--success,
.bholats-select--success {
	border-color: var(--color-success);
}

.bholats-field__message {
	font-size: var(--text-helper);
	display: flex;
	align-items: center;
	gap: var(--space-1);
}

.bholats-field__message--error { color: var(--color-error); }
.bholats-field__message--success { color: var(--color-success); }
