/* ==========================================================================
   Tìm kiếm v2 — nút header + hộp tìm kiếm dạng command palette (desktop: hộp nổi; mobile: toàn màn hình)
   ========================================================================== */

/* ---------- Nút trên header ---------- */
.ak-hsearch { display: flex; align-items: center; }
.ak-hsearch__btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	width: 42px;
	height: 42px;
	margin: 0;
	padding: 0;
	border: 1px solid var(--ak-line, #e5e8f0);
	border-radius: 12px;
	background: #fff;
	color: var(--ak-ink, #0f172a);
	cursor: pointer;
	transition: border-color 0.2s ease, color 0.2s ease, background 0.2s ease, box-shadow 0.2s ease;
}
.ak-hsearch__btn:hover,
.ak-hsearch__btn:focus-visible {
	border-color: var(--ak-primary, #1c22cc);
	background: #f3f4ff;
	color: var(--ak-primary, #1c22cc);
	box-shadow: 0 0 0 4px rgba(28, 34, 204, 0.1);
	outline: none;
}
/* header mobile: nút tìm + nút gọi cạnh nhau */
.header-wrapper .mobile-nav .ak-hsearch { margin-right: 8px; }
@media (max-width: 849px) {
	.ak-hsearch__btn { width: 42px; height: 42px; border-radius: 50%; background: var(--ak-soft, #f5f7fb); border-color: transparent; }
}

/* ---------- Hộp tìm kiếm ---------- */
html.ak-search-open { overflow: hidden; }
.ak-search[hidden] { display: none !important; }
.ak-search {
	position: fixed;
	inset: 0;
	z-index: 100000;
	display: flex;
	justify-content: center;
	align-items: flex-start;
	padding: min(12vh, 110px) 16px 24px;
	font-family: var(--ak-font, inherit);
}
.ak-search__backdrop {
	position: absolute;
	inset: 0;
	background: rgba(13, 20, 80, 0.45);
	backdrop-filter: blur(6px);
	-webkit-backdrop-filter: blur(6px);
	opacity: 0;
	transition: opacity 0.18s ease;
}
.ak-search__panel {
	position: relative;
	display: flex;
	flex-direction: column;
	width: min(720px, 100%);
	max-height: min(680px, calc(100vh - 140px));
	overflow: hidden;
	border-radius: 20px;
	background: #fff;
	box-shadow: 0 30px 80px rgba(13, 20, 80, 0.35), 0 0 0 1px rgba(13, 20, 80, 0.06);
	opacity: 0;
	transform: translateY(-10px) scale(0.98);
	transition: opacity 0.18s ease, transform 0.18s ease;
}
.ak-search.is-open .ak-search__backdrop { opacity: 1; }
.ak-search.is-open .ak-search__panel { opacity: 1; transform: none; }
@media (prefers-reduced-motion: reduce) {
	.ak-search__backdrop, .ak-search__panel { transition: none; }
}

/* ô nhập */
.ak-search__form {
	position: relative;
	display: flex;
	align-items: center;
	gap: 10px;
	margin: 0;
	padding: 14px 14px 14px 18px;
	border-bottom: 1px solid var(--ak-line, #e5e8f0);
}
.ak-search__icon { display: inline-flex; color: var(--ak-primary, #1c22cc); flex: 0 0 auto; }
.ak-search.is-loading .ak-search__icon { animation: ak-pulse 0.9s ease-in-out infinite; }
@keyframes ak-pulse { 50% { opacity: 0.35; } }
.ak-search .ak-search__input {
	flex: 1;
	min-width: 0;
	height: 48px;
	margin: 0;
	padding: 0;
	border: 0 !important;
	background: transparent !important;
	box-shadow: none !important;
	color: var(--ak-ink, #0f172a);
	font-size: 19px;
	font-weight: 500;
	outline: none;
}
.ak-search__input::placeholder { color: #94a3b8; font-weight: 400; }
.ak-search__input::-webkit-search-cancel-button { display: none; }
.ak-search__clear,
.ak-search__close {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	flex: 0 0 auto;
	margin: 0;
	border: 0;
	cursor: pointer;
	font: inherit;
}
.ak-search__clear { width: 30px; height: 30px; padding: 0; border-radius: 50%; background: var(--ak-soft, #f5f7fb); color: var(--ak-muted, #64748b); }
.ak-search__clear:hover { background: #e7eaf3; color: var(--ak-ink, #0f172a); }
.ak-search__close,
.ak-search__clear,
.ak-chip { text-transform: none !important; letter-spacing: 0 !important; }
.ak-search__close { min-height: 30px; padding: 0 10px; border-radius: 8px; background: var(--ak-soft, #f5f7fb); color: var(--ak-muted, #64748b); font-size: 12px; font-weight: 700; }
.ak-search__close:hover { color: var(--ak-ink, #0f172a); }
.ak-search__x { display: none; }

/* thân */
.ak-search__body { flex: 1; overflow-y: auto; overscroll-behavior: contain; padding: 6px 18px 18px; }
.ak-search__label {
	margin: 16px 0 10px;
	color: var(--ak-muted, #64748b);
	font-size: 12px;
	font-weight: 700;
	letter-spacing: 0.06em;
	text-transform: uppercase;
}
.ak-search__chips { display: flex; flex-wrap: wrap; gap: 8px; }
.ak-chip {
	display: inline-flex;
	align-items: center;
	min-height: 36px;
	margin: 0;
	padding: 0 14px;
	border: 1px solid var(--ak-line, #e5e8f0);
	border-radius: 999px;
	background: #fff;
	color: var(--ak-ink, #0f172a);
	font: inherit;
	font-size: 14px;
	font-weight: 500;
	text-transform: none;
	letter-spacing: 0;
	cursor: pointer;
	transition: all 0.15s ease;
}
.ak-chip:hover { border-color: var(--ak-primary, #1c22cc); background: #f3f4ff; color: var(--ak-primary, #1c22cc); }
.ak-chip--recent::before { content: "↺"; margin-right: 6px; color: var(--ak-muted, #64748b); }

.ak-search__cats { display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 8px; }
.ak-search__cat {
	display: flex;
	flex-direction: column;
	gap: 2px;
	padding: 12px 14px;
	border-radius: 12px;
	background: var(--ak-soft, #f5f7fb);
	color: var(--ak-ink, #0f172a) !important;
	transition: background 0.15s ease, transform 0.15s ease;
}
.ak-search__cat span { font-size: 14.5px; font-weight: 700; }
.ak-search__cat small { color: var(--ak-muted, #64748b); font-size: 12.5px; }
.ak-search__cat:hover { background: #eceffd; transform: translateY(-1px); }
.ak-search__cat--project { background: #fdecee; }
.ak-search__cat--project:hover { background: #fbdde1; }

/* kết quả */
.ak-sres { display: flex; flex-direction: column; gap: 2px; }
.ak-sres__item {
	display: flex;
	align-items: center;
	gap: 14px;
	padding: 8px 10px;
	border-radius: 12px;
	color: var(--ak-ink, #0f172a) !important;
	scroll-margin: 8px;
}
.ak-sres__item:hover,
.ak-sres__item.is-active { background: #f3f4ff; }
.ak-sres__item img,
.ak-sres__ph {
	flex: 0 0 56px;
	width: 56px;
	height: 56px;
	border: 1px solid var(--ak-line, #e5e8f0);
	border-radius: 10px;
	background: #fff;
	object-fit: contain;
}
.ak-sres:not(.ak-sres--products) .ak-sres__item img { object-fit: cover; }
.ak-sres__ph { display: grid; place-items: center; color: #94a3b8; }
.ak-sres__text { display: flex; flex: 1; min-width: 0; flex-direction: column; gap: 3px; }
.ak-sres__title {
	overflow: hidden;
	font-size: 15px;
	font-weight: 600;
	line-height: 1.35;
	display: -webkit-box;
	-webkit-line-clamp: 2;
	-webkit-box-orient: vertical;
}
.ak-sres__title mark,
.ak-sres__code mark { padding: 0 1px; border-radius: 3px; background: #fff1a8; color: inherit; }
.ak-sres__meta { display: flex; flex-wrap: wrap; align-items: center; gap: 8px; color: var(--ak-muted, #64748b); font-size: 13px; }
.ak-sres__code { padding: 1px 7px; border-radius: 6px; background: var(--ak-soft, #f5f7fb); color: var(--ak-navy, #16206b); font-weight: 700; font-size: 12.5px; }
.ak-sres__tag { padding: 1px 8px; border-radius: 999px; background: #eceffd; color: var(--ak-primary, #1c22cc); font-size: 12px; font-weight: 700; }
.ak-sres__tag--project { background: #fdecee; color: var(--ak-red, #c0182f); }
.ak-sres__go { color: #cbd5e1; font-size: 18px; transition: transform 0.15s ease, color 0.15s ease; }
.ak-sres__item:hover .ak-sres__go,
.ak-sres__item.is-active .ak-sres__go { color: var(--ak-primary, #1c22cc); transform: translateX(3px); }
.ak-sres__empty { display: flex; flex-direction: column; gap: 6px; padding: 22px 6px 6px; text-align: center; color: var(--ak-muted, #64748b); font-size: 14.5px; }
.ak-sres__empty strong { color: var(--ak-ink, #0f172a); font-size: 16px; }
.ak-sres__all {
	display: flex;
	align-items: center;
	justify-content: center;
	min-height: 46px;
	margin-top: 14px;
	border-radius: 12px;
	background: var(--ak-navy, #16206b);
	color: #fff !important;
	font-size: 14.5px;
	font-weight: 700;
}
.ak-sres__all:hover { background: var(--ak-primary, #1c22cc); }

/* chân hộp */
.ak-search__foot {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 11px 18px;
	border-top: 1px solid var(--ak-line, #e5e8f0);
	background: #fafbfe;
	color: var(--ak-muted, #64748b);
	font-size: 12.5px;
}
.ak-search__foot kbd {
	display: inline-block;
	min-width: 20px;
	margin: 0 1px;
	padding: 1px 5px;
	border: 1px solid var(--ak-line, #e5e8f0);
	border-bottom-width: 2px;
	border-radius: 5px;
	background: #fff;
	color: var(--ak-ink, #0f172a);
	font: 600 11px/1.5 var(--ak-font, inherit);
	text-align: center;
}
.ak-search__call { color: var(--ak-muted, #64748b) !important; }
.ak-search__call strong { color: var(--ak-red, #c0182f); }

/* ---------- Mobile: toàn màn hình ---------- */
@media (max-width: 600px) {
	.ak-search { padding: 0; }
	.ak-search__backdrop { display: none; }
	.ak-search__panel { width: 100%; max-height: none; height: 100%; height: 100dvh; border-radius: 0; transform: translateY(12px); }
	.ak-search__form { padding: 10px 12px 10px 14px; padding-top: max(10px, env(safe-area-inset-top)); }
	.ak-search .ak-search__input { height: 46px; font-size: 16px; } /* 16px: iOS không tự phóng to */
	.ak-search__esc { display: none; }
	.ak-search__x { display: inline; }
	.ak-search__close { min-height: 40px; padding: 0 12px; border-radius: 10px; font-size: 14px; color: var(--ak-primary, #1c22cc); background: transparent; }
	.ak-search__body { padding: 4px 14px 20px; }
	.ak-chip { min-height: 40px; }
	.ak-search__cats { grid-template-columns: 1fr 1fr; }
	.ak-sres__item { padding: 10px 6px; }
	.ak-search__keys { display: none; }
	.ak-search__foot { justify-content: center; padding: 12px 16px; padding-bottom: max(12px, env(safe-area-inset-bottom)); font-size: 14px; }
}
