/**
 * Searchable Select Component Styles
 *
 * Generic styles for searchable dropdowns with AJAX support.
 * Replaces Select2 with a custom implementation that doesn't have scroll issues.
 *
 * @package JAK_Core
 */

/* Custom Searchable Select Styles */
.jak-searchable-select-wrapper {
	position: relative;
	width: 100%;
}

.jak-searchable-select-input-wrapper {
	position: relative;
	display: flex;
	align-items: center;
	flex-wrap: wrap;
	gap: 0;
	padding: 2px 32px 2px 8px;
	border: 1px solid #ccd0d4;
	border-radius: 3px;
	background-color: white;
}

.jak-searchable-select-input-wrapper.has-connection {
	background-color: #e8f4f8;
	border-color: #2271b1;
	padding-left: 32px;
}

.jak-searchable-select-input-wrapper:has(.jak-customer-connection-icon:not([style*="display: none"])),
.jak-searchable-select-input-wrapper:has(.jak-instructor-connection-icon:not([style*="display: none"])),
.jak-searchable-select-input-wrapper:has(.jak-attendee-connection-icon:not([style*="display: none"])) {
	padding-left: 32px;
}

/* Tomt: 100% bredd (jak-w-full). Med valda: kvarvarande bredd, min 80px, samma rad */
.jak-searchable-select-input {
	flex: 1 1 80px;
	min-width: 80px;
	min-height: auto;
	order: 999;
	border: none !important;
	outline: none !important;
	box-shadow: none !important;
	background: transparent !important;
	background-color: transparent !important;
	padding: 2px 4px;
	margin-left: 0;
	font-size: 14px;
	line-height: 1.5;
	transition: all 0.2s;
}

/* Ej fokus: 80px bred. Med fokus: 100% så man får plats att skriva */
.jak-searchable-select-input-wrapper.has-connection .jak-searchable-select-input {
	width: 80px;
	min-width: 80px;
	flex: 0 0 auto;
	transition: width 0.2s ease;
}
.jak-searchable-select-input-wrapper.has-connection:focus-within .jak-searchable-select-input {
	width: 100%;
	flex: 1 1 80px;
}

.jak-searchable-select-input:focus {
	border: none !important;
	outline: none !important;
	box-shadow: none !important;
}

.jak-searchable-select-input-wrapper:focus-within {
	outline: none;
	border-color: #2271b1;
	box-shadow: 0 0 0 1px #2271b1;
}

.jak-searchable-select-input-wrapper.has-connection:focus-within {
	background-color: #f0f8fa;
}

.jak-searchable-select-clear {
	position: absolute;
	right: 6px;
	top: 50%;
	transform: translateY(-50%);
	background: none;
	border: none;
	cursor: pointer;
	color: #999;
	padding: 4px;
	display: flex;
	align-items: center;
	justify-content: center;
	border-radius: 3px;
	transition: all 0.2s;
	z-index: 2;
}

.jak-searchable-select-clear:hover {
	background: #f5f5f5;
	color: #666;
}

.jak-searchable-select-dropdown {
	position: absolute;
	top: 100%;
	left: 0;
	right: 0;
	background: white;
	border: 1px solid #ccd0d4;
	border-radius: 3px;
	box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
	max-height: 300px;
	overflow-y: auto;
	z-index: 1000;
	margin-top: 4px;
}

.jak-searchable-select-option {
	padding: 10px 12px;
	cursor: pointer;
	transition: background 0.2s;
	border-bottom: 1px solid #f0f0f0;
}

.jak-searchable-select-option:last-child {
	border-bottom: none;
}

.jak-searchable-select-option:hover {
	background: #f5f5f5;
}

.jak-searchable-select-option.selected {
	background: #e8f4f8;
	color: #2271b1;
	font-weight: 500;
}

.jak-searchable-select-no-results {
	padding: 12px;
	text-align: center;
	color: #999;
	font-size: 13px;
}

/* max-width så att "Lägg till"-inputen får plats på samma rad när kundnamn är kort */
.jak-selected-items {
	display: flex;
	flex-wrap: wrap;
	gap: 4px;
	align-items: center;
	flex: 0 1 auto;
	min-width: 0;
	max-width: calc(100% - 90px);
	order: 1;
}

.jak-item-tag {
	display: inline-flex;
	align-items: center;
	padding: 2px 6px;
	background-color: #2271b1;
	border: 1px solid #2271b1;
	border-radius: 3px;
	font-size: 12px;
	color: white;
	gap: 4px;
	line-height: 1.4;
}

.jak-item-tag-remove {
	cursor: pointer;
	color: white;
	display: flex;
	align-items: center;
	padding: 0;
	background: none;
	border: none;
	margin-left: 2px;
	opacity: 0.8;
}

.jak-item-tag-remove:hover {
	opacity: 1;
	color: white;
}
