/**
 * Akel Tools Design System — Extended form controls
 */

/* Switch */
.at-switch {
	display: inline-flex;
	align-items: center;
	gap: var(--space-3);
	cursor: pointer;
	user-select: none;
}

.at-switch input {
	position: absolute;
	opacity: 0;
	pointer-events: none;
}

.at-switch__track {
	position: relative;
	width: 40px;
	height: 22px;
	background: var(--surface-sunken);
	border: 1px solid var(--border-strong);
	border-radius: 11px !important;
	transition: background var(--duration-fast) var(--ease-out), border-color var(--duration-fast) var(--ease-out);
	flex-shrink: 0;
}

.at-switch__thumb {
	position: absolute;
	top: 2px;
	left: 2px;
	width: 16px;
	height: 16px;
	background: #fff;
	border-radius: 50% !important;
	box-shadow: var(--shadow-sm);
	transition: transform var(--duration-fast) var(--ease-out);
}

.at-switch input:checked ~ .at-switch__track {
	background: var(--brand-success);
	border-color: var(--brand-success);
}

.at-switch input:checked ~ .at-switch__track .at-switch__thumb {
	transform: translateX(18px);
}

.at-switch input:focus-visible ~ .at-switch__track {
	box-shadow: var(--focus-ring);
}

.at-switch--sm .at-switch__track {
	width: 32px;
	height: 18px;
}

.at-switch--sm .at-switch__thumb {
	width: 12px;
	height: 12px;
}

.at-switch--sm input:checked ~ .at-switch__track .at-switch__thumb {
	transform: translateX(14px);
}

.at-switch__label {
	font-size: var(--text-md);
	font-weight: var(--weight-medium);
	color: var(--text-primary);
}

/* Search */
.at-search {
	position: relative;
	display: flex;
	align-items: center;
}

.at-search__icon {
	position: absolute;
	left: var(--space-3);
	width: var(--icon-md);
	height: var(--icon-md);
	background-color: var(--text-tertiary);
	-webkit-mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none'%3E%3Ccircle cx='11' cy='11' r='6' stroke='white' stroke-width='2'/%3E%3Cpath d='M16 16l5 5' stroke='white' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
	mask: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none'%3E%3Ccircle cx='11' cy='11' r='6' stroke='white' stroke-width='2'/%3E%3Cpath d='M16 16l5 5' stroke='white' stroke-width='2' stroke-linecap='round'/%3E%3C/svg%3E") center / contain no-repeat;
	pointer-events: none;
}

.at-search__input {
	width: 100%;
	height: 36px;
	padding: 0 var(--space-8) 0 calc(var(--space-3) + var(--icon-md) + var(--space-2));
	font-size: var(--text-md);
	font-weight: var(--weight-medium);
	color: var(--text-primary);
	background: var(--surface-elevated);
	border: 1px solid var(--border-default);
	border-radius: 0;
}

.at-search__input:focus {
	outline: none;
	border-color: var(--brand-accent);
	box-shadow: var(--focus-ring);
}

.at-search__clear {
	position: absolute;
	right: var(--space-2);
	display: none;
	align-items: center;
	justify-content: center;
	width: 24px;
	height: 24px;
	padding: 0;
	color: var(--text-tertiary);
	background: transparent;
	border: none;
	border-radius: 0;
	cursor: pointer;
}

.at-search__clear.is-visible {
	display: inline-flex;
}

.at-search__kbd {
	position: absolute;
	right: var(--space-3);
	font-family: var(--font-mono);
	font-size: 14px;
	color: var(--text-tertiary);
	padding: 2px 5px;
	background: var(--surface-subtle);
	border: 1px solid var(--border-default);
	border-radius: 0;
}

/* Combobox */
.at-combobox {
	position: relative;
}

.at-combobox__menu {
	position: absolute;
	top: calc(100% + 4px);
	left: 0;
	right: 0;
	z-index: var(--z-popover);
	max-height: 240px;
	overflow: auto;
	background: var(--surface-elevated);
	border: 1px solid var(--border-default);
	border-radius: 0;
	box-shadow: var(--shadow-lg);
	display: none;
}

.at-combobox.is-open .at-combobox__menu {
	display: block;
}

.at-combobox__option {
	display: block;
	width: 100%;
	padding: var(--space-2) var(--space-3);
	font-size: var(--text-md);
	font-weight: var(--weight-medium);
	color: var(--text-primary);
	text-align: left;
	background: transparent;
	border: none;
	cursor: pointer;
}

.at-combobox__option:hover,
.at-combobox__option[aria-selected="true"] {
	background: var(--brand-accent-soft);
	color: var(--brand-accent);
}

/* Multi-select chips in input */
.at-multi {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: var(--space-2);
	min-height: 36px;
	padding: var(--space-1) var(--space-2);
	background: var(--surface-elevated);
	border: 1px solid var(--border-default);
	border-radius: 0;
}

.at-multi:focus-within {
	border-color: var(--brand-accent);
	box-shadow: var(--focus-ring);
}

.at-multi__input {
	flex: 1;
	min-width: 80px;
	border: none;
	background: transparent;
	font-size: var(--text-md);
	font-weight: var(--weight-medium);
	outline: none;
}

/* Tag input */
.at-tag-input {
	display: flex;
	flex-wrap: wrap;
	gap: var(--space-2);
	min-height: 36px;
	padding: var(--space-1) var(--space-2);
	background: var(--surface-elevated);
	border: 1px solid var(--border-default);
	border-radius: 0;
}

.at-tag-input__tag {
	display: inline-flex;
	align-items: center;
	gap: var(--space-1);
	height: 24px;
	padding: 0 var(--space-2);
	font-size: var(--text-xs);
	font-weight: var(--weight-semibold);
	background: var(--surface-subtle);
	border: 1px solid var(--border-default);
	border-radius: 0;
}

.at-tag-input__remove {
	padding: 0;
	background: none;
	border: none;
	color: var(--text-tertiary);
	cursor: pointer;
	line-height: 1;
}

/* File upload */
.at-dropzone {
	display: flex;
	flex-direction: column;
	align-items: center;
	justify-content: center;
	gap: var(--space-3);
	padding: var(--space-8);
	border: 2px dashed var(--border-strong);
	border-radius: 0;
	background: var(--surface-subtle);
	text-align: center;
	cursor: pointer;
	transition: border-color var(--duration-fast) var(--ease-out), background var(--duration-fast) var(--ease-out);
}

.at-dropzone:hover,
.at-dropzone.is-dragover {
	border-color: var(--brand-accent);
	background: var(--brand-accent-soft);
}

.at-dropzone__title {
	font-size: var(--text-md);
	font-weight: var(--weight-semibold);
	color: var(--text-primary);
}

.at-dropzone__hint {
	font-size: var(--text-sm);
	color: var(--text-tertiary);
}

.at-file-input {
	position: absolute;
	width: 1px;
	height: 1px;
	opacity: 0;
	overflow: hidden;
}

/* Date / range */
.at-date {
	display: block;
	width: 100%;
	height: 36px;
	padding: 0 var(--space-3);
	font-family: var(--font-sans);
	font-size: var(--text-md);
	font-weight: var(--weight-medium);
	color: var(--text-primary);
	background: var(--surface-elevated);
	border: 1px solid var(--border-default);
	border-radius: 0;
}

.at-date:focus {
	outline: none;
	border-color: var(--brand-accent);
	box-shadow: var(--focus-ring);
}

.at-range {
	width: 100%;
	height: 6px;
	accent-color: var(--brand-accent);
}

/* Inline edit */
.at-inline-edit {
	display: inline-flex;
	align-items: center;
	gap: var(--space-2);
	cursor: pointer;
	border-radius: 0;
	padding: 2px 4px;
	margin: -2px -4px;
}

.at-inline-edit:hover {
	background: var(--surface-subtle);
}

.at-inline-edit__value {
	font-weight: var(--weight-semibold);
	color: var(--text-primary);
}

.at-inline-edit__icon {
	width: var(--icon-sm);
	height: var(--icon-sm);
	color: var(--text-tertiary);
	opacity: 0;
	transition: opacity var(--duration-fast);
}

.at-inline-edit:hover .at-inline-edit__icon {
	opacity: 1;
}

.at-inline-edit.is-editing .at-inline-edit__value {
	display: none;
}

/* Required / optional */
.at-required::after {
	content: " *";
	color: var(--brand-danger);
	font-weight: var(--weight-semibold);
}

.at-optional::after {
	content: " (optional)";
	color: var(--text-tertiary);
	font-weight: var(--weight-regular);
	font-size: var(--text-xs);
}
