/**
 * ACM Select — giao diện custom select cho Contact Form 7
 * Đổi màu bằng các biến ở khối :root bên dưới.
 *
 * @version 1.0.0
 */

.acm-select {
	--acm-accent:      var( --dsn-blue, #0090CC );
	--acm-accent-soft: var( --dsn-blue-light, #E8F8FF );
	--acm-border:      var( --dsn-gray-300, #d1d5db );
	--acm-text:        var( --dsn-text-dark, #1f2937 );
	--acm-muted:       var( --dsn-gray-400, #9ca3af );
	--acm-hover:       var( --dsn-blue-light, #f0f7ff );
	--acm-radius:      6px;
	--acm-height:      44px;

	position: relative;
	width: 100%;
	font-size: 15px;
	line-height: 1.45;
	color: var( --acm-text );
}

/* Select gốc: ẩn khỏi mắt nhưng vẫn focus được, nên CF7 validate bình thường
   và trình duyệt không báo lỗi "not focusable" khi field có required. */
.acm-select__native {
	position: absolute;
	width: 1px;
	height: 1px;
	margin: -1px;
	padding: 0;
	overflow: hidden;
	border: 0;
	opacity: 0;
	clip: rect( 0 0 0 0 );
	clip-path: inset( 50% );
	white-space: nowrap;
	pointer-events: none;
}

/* ----------------------------- control ------------------------------ */

.acm-select__control {
	display: flex;
	align-items: center;
	gap: 8px;
	min-height: var( --acm-height );
	padding: 6px 12px 6px 14px;
	background: #fff;
	border: 1px solid var( --acm-border );
	border-radius: var( --acm-radius );
	cursor: pointer;
	transition: border-color .15s ease, box-shadow .15s ease;
	box-sizing: border-box;
}

.acm-select__control:hover {
	border-color: #b9c3ce;
}

.acm-select__control:focus-visible,
.acm-select.is-open .acm-select__control {
	outline: none;
	border-color: var( --acm-accent );
	box-shadow: 0 0 0 3px var( --acm-accent-soft );
}

.acm-select__value {
	flex: 1 1 auto;
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 6px;
	min-width: 0;
}

.acm-select__placeholder {
	color: var( --acm-muted );
}

.acm-select__single {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.acm-select__arrow {
	flex: 0 0 auto;
	display: flex;
	color: var( --acm-muted );
	transition: transform .18s ease;
}

.acm-select.is-open .acm-select__arrow {
	transform: rotate( 180deg );
}

.acm-select.is-disabled .acm-select__control {
	background: #f6f8fa;
	cursor: not-allowed;
	opacity: .7;
}

/* ------------------------------- tag -------------------------------- */

.acm-select__tag {
	display: inline-flex;
	align-items: center;
	gap: 5px;
	max-width: 100%;
	padding: 3px 6px 3px 9px;
	background: var( --acm-accent-soft );
	border-radius: 4px;
	font-size: 13.5px;
	line-height: 1.4;
}

.acm-select__tag > span {
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.acm-select__tag-remove {
	display: flex;
	align-items: center;
	justify-content: center;
	width: 17px;
	height: 17px;
	padding: 0;
	margin: 0;
	background: transparent;
	border: 0;
	border-radius: 3px;
	color: var( --acm-accent );
	cursor: pointer;
	transition: background .12s ease;
	min-height: unset;
}

.acm-select__tag-remove:hover {
	background: rgba( 0, 144, 204, .2 );
}

/* ------------------------------ panel ------------------------------- */

.acm-select__panel {
	position: absolute;
	z-index: 9999;
	top: calc( 100% + 6px );
	left: 0;
	right: 0;
	background: #fff;
	border: 1px solid var( --acm-border );
	border-radius: var( --acm-radius );
	box-shadow: 0 8px 24px rgba( 16, 30, 54, .12 );
	overflow: hidden;
}

.acm-select--up .acm-select__panel {
	top: auto;
	bottom: calc( 100% + 6px );
}

.acm-select__search-wrap {
	padding: 10px;
	border-bottom: 1px solid #eef1f5;
}

.acm-select__search {
	display: block;
	width: 100%;
	height: 36px;
	padding: 0 12px;
	background: #fff;
	border: 1px solid var( --acm-border );
	border-radius: var( --acm-radius );
	font-size: 14.5px;
	color: var( --acm-text );
	box-sizing: border-box;
}

.acm-select__search:focus {
	outline: none;
	border-color: var( --acm-accent );
	box-shadow: 0 0 0 3px var( --acm-accent-soft );
}

/* ------------------------------ danh sách --------------------------- */

.acm-select__list {
	max-height: 240px;
	margin: 0;
	padding: 4px 0;
	list-style: none;
	overflow-y: auto;
	overscroll-behavior: contain;
	scrollbar-width: thin;
	scrollbar-color: #c5ccd6 transparent;
}

.acm-select__list::-webkit-scrollbar {
	width: 8px;
}

.acm-select__list::-webkit-scrollbar-thumb {
	background: #c5ccd6;
	border: 2px solid #fff;
	border-radius: 4px;
}

.acm-select__option {
	display: flex;
	align-items: center;
	gap: 10px;
	margin: 0;
	margin-left: 0 !important;
	padding: 9px 16px;
	cursor: pointer;
	list-style: none;
}

.acm-select__option-label {
	flex: 1 1 auto;
	min-width: 0;
	overflow: hidden;
	text-overflow: ellipsis;
	white-space: nowrap;
}

.acm-select__option.is-active {
	background: var( --acm-hover );
}

.acm-select__option.is-selected {
	color: var( --acm-accent );
	font-weight: 500;
}

.acm-select__option-check {
	flex: 0 0 auto;
	display: flex;
	color: var( --acm-accent );
	opacity: 0;
}

.acm-select__option.is-selected .acm-select__option-check {
	opacity: 1;
}

.acm-select__empty {
	padding: 16px;
	text-align: center;
	color: var( --acm-muted );
	font-size: 14px;
}

/* ------------------------- validation của CF7 ----------------------- */

.acm-select:has( > select.wpcf7-not-valid ) .acm-select__control {
	border-color: #ef4444;
}

.acm-select:has( > select.wpcf7-not-valid ) .acm-select__control:focus-visible {
	box-shadow: 0 0 0 3px rgba( 239, 68, 68, .1 );
}

/* thông báo lỗi nằm cùng cấp với wrapper */
.wpcf7-form-control-wrap .acm-select + .wpcf7-not-valid-tip {
	display: block;
	margin-top: 6px;
}

/* --------------------------- di động, motion ------------------------ */

@media ( max-width: 600px ) {
	.acm-select {
		font-size: 16px; /* dưới 16px iOS tự zoom khi focus */
	}

	.acm-select__search {
		font-size: 16px;
	}

	.acm-select__list {
		max-height: 200px;
	}
}

@media ( prefers-reduced-motion: reduce ) {
	.acm-select__arrow,
	.acm-select__control,
	.acm-select__tag-remove {
		transition: none;
	}
}
