/* ============================================================
   OTO - TRANG TÌM XE (archive)
   ============================================================ */
.hm-archive { padding: 16px 0 50px; }

.hm-archive-title { font-size: 30px; font-weight: 800; color: var(--hm-text); margin: 0 0 6px; }
.hm-archive-sub { font-size: 14px; color: var(--hm-muted); margin: 0 0 20px; }
.hm-archive-seo-desc { font-size: 14px; color: #4b5563; line-height: 1.7; margin: -12px 0 20px; max-width: 900px; }

/* Nội dung SEO (viết ở term Hãng xe / Dòng xe / Đời xe), hiển thị dưới danh sách tin xe */
.hm-seo-content { margin-top: 36px; padding-top: 28px; border-top: 1px solid var(--hm-border); }
.hm-seo-content h2, .hm-seo-content h3 { color: var(--hm-text); font-weight: 800; margin: 24px 0 12px; }
.hm-seo-content h2:first-child, .hm-seo-content h3:first-child { margin-top: 0; }
.hm-seo-content p { color: #4b5563; line-height: 1.8; margin: 0 0 14px; }
.hm-seo-content ul, .hm-seo-content ol { color: #4b5563; line-height: 1.8; margin: 0 0 14px; padding-left: 22px; }
.hm-seo-content img { max-width: 100%; height: auto; border-radius: 8px; }
.hm-seo-content a { color: var(--hm-red); }

/* ---------- Ô TÌM KIẾM ---------- */
.hm-archive-search { display: flex; gap: 12px; margin-bottom: 18px; }
.hm-archive-search-input { position: relative; flex: 1; }
.hm-archive-search-input i { position: absolute; left: 16px; top: 50%; transform: translateY(-50%); color: #9aa5b1; font-size: 14px; }
.hm-archive-search-input input { width: 100%; height: 46px; border: 1px solid var(--hm-border); border-radius: 8px; padding: 0 16px 0 42px; font-size: 14px; background: #fff; }
.hm-archive-search-input input:focus { outline: none; border-color: var(--hm-red); }
.hm-archive-search .hm-btn-red { height: 46px; padding: 0 26px; }

/* ---------- CHIP LỌC NHANH ---------- */
.hm-chips { display: flex; gap: 10px; flex-wrap: wrap; margin-bottom: 22px; }
.hm-chip { display: inline-flex; align-items: center; gap: 7px; height: 38px; padding: 0 14px; border: 1px solid var(--hm-border); border-radius: 8px; background: #fff; font-size: 13px; color: #374151; cursor: pointer; white-space: nowrap; transition: border-color .2s, color .2s; }
.hm-chip:hover { border-color: var(--hm-red); color: var(--hm-red); }
.hm-chip-drop { position: relative; }
.hm-chip-menu { position: absolute; top: calc(100% + 6px); left: 0; z-index: 60; min-width: 210px; max-height: 300px; overflow-y: auto; background: #fff; border: 1px solid var(--hm-border); border-radius: 8px; box-shadow: 0 10px 30px rgba(16,24,40,.12); padding: 6px; display: none; }
.hm-chip-drop.is-open .hm-chip-menu { display: block; }
/* Sắp xếp giờ nằm ở .hm-archive-bar-right (cạnh hm-view-toggle), dropdown mở về bên trái để không tràn viewport. */
.hm-chip-sort .hm-chip-menu { left: auto; right: 0; }
.hm-chip-menu a { display: flex; justify-content: space-between; gap: 10px; padding: 8px 12px; font-size: 13px; color: #374151; text-decoration: none; border-radius: 6px; }
.hm-chip-menu a:hover { background: var(--hm-bg); color: var(--hm-red); }
.hm-chip-menu a span { color: var(--hm-muted); }

/* Chip đang có lựa chọn (sau khi bấm Tìm kiếm) -> tô đỏ để thấy rõ bộ lọc nào đang áp dụng. */
.hm-chip.is-active { border-color: var(--hm-red); color: var(--hm-red); background: #fff5f5; }

/* Nút "Tìm kiếm" cuối thanh chip -> áp dụng toàn bộ lựa chọn đã chọn ở các chip cùng lúc. */
.hm-chip-apply { background: var(--hm-red); border-color: var(--hm-red); color: #fff; font-weight: 600; margin-left: auto; }
.hm-chip-apply:hover { background: var(--hm-red-dark); border-color: var(--hm-red-dark); color: #fff; }

/* Dropdown chứa select (thay cho danh sách link) -> rộng rãi hơn để dễ thao tác. */
.hm-chip-menu-form { padding: 14px; min-width: 240px; }
.hm-chip-menu-price { min-width: 300px; }
/* Xếp dọc nhiều select trong cùng 1 chip (VD: Hãng xe + Dòng xe). */
.hm-chip-stack { display: flex; flex-direction: column; gap: 10px; }

/* ---------- BỐ CỤC ---------- */
.hm-archive-row { display: grid; grid-template-columns: 250px minmax(0, 1fr); gap: 24px; align-items: start; }

/* ---------- BỘ LỌC TRÁI ---------- */
.hm-filter { background: #fff; border: 1px solid var(--hm-border); border-radius: 10px; padding: 18px; position: sticky; top: calc(var(--hm-header-h) + 16px); }
.hm-filter-head { display: flex; align-items: center; justify-content: space-between; gap: 10px; padding-bottom: 14px; border-bottom: 1px solid var(--hm-border); margin-bottom: 6px; }
.hm-filter-title { font-size: 14px; font-weight: 800; text-transform: uppercase; color: var(--hm-text); margin: 0; }
.hm-filter-clear { font-size: 13px; color: var(--hm-red); text-decoration: none; }
.hm-filter-clear:hover { text-decoration: underline; }

.hm-filter-group { padding: 14px 0; border-bottom: 1px solid var(--hm-border); }
.hm-filter-group:last-of-type { border-bottom: none; }
.hm-filter-label { width: 100%; display: flex; align-items: center; justify-content: space-between; background: none; border: none; padding: 0 0 12px; font-size: 14px; font-weight: 700; color: var(--hm-text); cursor: pointer; }
.hm-filter-label i { font-size: 11px; color: var(--hm-muted); transition: transform .2s; }
.hm-filter-group.is-collapsed .hm-filter-label i { transform: rotate(180deg); }
.hm-filter-group.is-collapsed .hm-filter-body { display: none; }

/* Khoảng giá */
.hm-price-values { display: flex; justify-content: space-between; font-size: 14px; font-weight: 600; color: var(--hm-text); margin-bottom: 12px; }
.hm-price-slider { position: relative; height: 26px; margin-bottom: 14px; }
.hm-price-track { position: absolute; left: 0; right: 0; top: 11px; height: 4px; background: #e6e9ed; border-radius: 4px; }
.hm-price-fill { position: absolute; top: 0; height: 100%; background: var(--hm-red); border-radius: 4px; }
.hm-price-slider input[type=range] { position: absolute; left: 0; width: 100%; top: 0; height: 26px; margin: 0; background: none; pointer-events: none; -webkit-appearance: none; appearance: none; }
.hm-price-slider input[type=range]::-webkit-slider-thumb { pointer-events: auto; -webkit-appearance: none; width: 16px; height: 16px; border-radius: 50%; background: var(--hm-red); border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.3); cursor: pointer; }
.hm-price-slider input[type=range]::-moz-range-thumb { pointer-events: auto; width: 16px; height: 16px; border-radius: 50%; background: var(--hm-red); border: 2px solid #fff; box-shadow: 0 1px 4px rgba(0,0,0,.3); cursor: pointer; }
.hm-price-slider input[type=range]::-moz-range-track { background: none; }

.hm-price-quick { display: flex; flex-wrap: wrap; gap: 8px; }
.hm-price-btn { border: 1px solid var(--hm-border); border-radius: 6px; background: #fff; padding: 7px 10px; font-size: 12px; color: #374151; cursor: pointer; transition: all .2s; }
.hm-price-btn:hover, .hm-price-btn.active { border-color: var(--hm-red); color: var(--hm-red); background: #fff5f5; }

/* Tìm hãng + checkbox */
.hm-filter-search { position: relative; margin-bottom: 12px; }
.hm-filter-search i { position: absolute; left: 11px; top: 50%; transform: translateY(-50%); font-size: 12px; color: #9aa5b1; }
.hm-filter-search input { width: 100%; height: 36px; border: 1px solid var(--hm-border); border-radius: 6px; padding: 0 10px 0 32px; font-size: 13px; }
.hm-filter-search input:focus { outline: none; border-color: var(--hm-red); }

.hm-check-list { display: flex; flex-direction: column; gap: 10px; }
.hm-check { display: flex; align-items: center; gap: 9px; font-size: 13px; color: #374151; cursor: pointer; }
.hm-check input { width: 15px; height: 15px; accent-color: var(--hm-red); cursor: pointer; flex: 0 0 auto; }
.hm-check.is-hidden { display: none; }
.hm-check-list.is-expanded .hm-check.is-hidden { display: flex; }
.hm-filter-more { background: none; border: none; color: var(--hm-red); font-size: 13px; padding: 12px 0 0; cursor: pointer; }

.hm-year-row { display: grid; grid-template-columns: 1fr 1fr; gap: 10px; }

.hm-filter-submit { width: 100%; margin-top: 16px; border: 1px solid var(--hm-red); border-radius: 8px; background: #fff; color: var(--hm-red); font-size: 14px; font-weight: 700; padding: 12px; cursor: pointer; transition: background .2s; }
.hm-filter-submit:hover { background: var(--hm-red); color: #fff; }

/* ---------- KẾT QUẢ ---------- */
.hm-archive-bar { display: flex; align-items: center; justify-content: space-between; margin-bottom: 16px; gap: 12px; flex-wrap: wrap; }
.hm-archive-count { font-size: 15px; font-weight: 700; color: var(--hm-text); }
.hm-archive-bar-right { display: flex; align-items: center; gap: 12px; }
.hm-archive-bar-right .hm-chip-sort { margin-left: 0; } /* huỷ margin-left:auto gốc (dành cho khi còn nằm trong .hm-chips) */
.hm-view-toggle { display: flex; gap: 6px; }
.hm-view-btn { width: 34px; height: 34px; border: 1px solid var(--hm-border); border-radius: 6px; background: #fff; color: var(--hm-muted); cursor: pointer; font-size: 13px; }
.hm-view-btn.active { background: var(--hm-red); border-color: var(--hm-red); color: #fff; }

.hm-archive-grid { grid-template-columns: repeat(3, 1fr); }
.hm-badge-hot { background: var(--hm-red); }
.hm-badge-fresh { background: #22a06b; }

/* ---------- DẠNG DANH SÁCH (nhớ qua localStorage -> class trên <html>) ---------- */
.oto-view-list .hm-archive-grid { grid-template-columns: 1fr; gap: 16px; }
.oto-view-list .hm-car-card { display: grid; grid-template-columns: 230px minmax(0, 1fr); align-items: stretch; }
.oto-view-list .hm-car-thumb { aspect-ratio: auto; height: 100%; min-height: 150px; }
.oto-view-list .hm-car-body { padding: 18px 56px 18px 22px; display: flex; flex-direction: column; justify-content: center; }
.oto-view-list .hm-car-title { font-size: 17px; font-weight: 700; margin-bottom: 6px; min-height: auto; -webkit-line-clamp: 1; line-clamp: 1; }
.oto-view-list .hm-car-price { font-size: 19px; margin-bottom: 14px; }
.oto-view-list .hm-car-meta { border-top: none; padding-top: 0; gap: 26px; margin-top: 0; min-height: 0; }
.oto-view-list .hm-car-meta2 { display: flex; }
.oto-view-list .hm-fav { top: 16px; right: 16px; background: transparent; font-size: 17px; }
.oto-view-list .hm-fav:hover { background: transparent; }

/* ---------- RESPONSIVE ---------- */
@media (max-width: 1199px) {
	.hm-archive-grid { grid-template-columns: repeat(2, 1fr); }
}
@media (max-width: 991px) {
	.hm-archive-row { grid-template-columns: 1fr; }
	.hm-filter { position: static; display: none; }
	.hm-filter.is-open { display: block; }
}
@media (max-width: 640px) {
	.hm-archive-title { font-size: 24px; }
	.hm-archive-search { flex-direction: column; }
	.hm-archive-search .hm-btn-red { justify-content: center; }

	/* Mobile: LUÔN hiển thị dạng danh sách (ảnh trái - nội dung phải), bỏ toggle. */
	.hm-view-toggle { display: none; }
	.hm-archive-grid { grid-template-columns: 1fr; gap: 14px; }
	.hm-archive-grid .hm-car-card { display: grid; grid-template-columns: 132px minmax(0, 1fr); align-items: stretch; }
	.hm-archive-grid .hm-car-thumb { aspect-ratio: auto; height: 100%; min-height: 112px; }
	.hm-archive-grid .hm-car-body { padding: 12px 42px 12px 14px; display: flex; flex-direction: column; justify-content: center; }
	.hm-archive-grid .hm-car-title { font-size: 15px; font-weight: 700; margin-bottom: 5px; min-height: auto; -webkit-line-clamp: 1; line-clamp: 1; }
	.hm-archive-grid .hm-car-price { font-size: 17px; margin-bottom: 10px; }
	.hm-archive-grid .hm-car-meta { border-top: none; padding-top: 0; gap: 14px; margin-top: 0; min-height: 0; }
	.hm-archive-grid .hm-car-meta2 { display: none; }
	.hm-archive-grid .hm-fav { top: 12px; right: 12px; background: transparent; font-size: 16px; }
	.hm-archive-grid .hm-fav:hover { background: transparent; }
	/* Chips xuống dòng thay vì cuộn ngang -> dropdown không bị cắt. */
	.hm-chips { flex-wrap: wrap; gap: 8px; }
	.hm-chip { height: 34px; padding: 0 12px; font-size: 12px; }
	/* Menu dropdown bám mép trái, rộng thoáng trên mobile (riêng Sắp xếp bám phải - xem .hm-archive-bar-right). */
	.hm-chip-menu { left: 0; right: auto; min-width: 200px; max-width: 78vw; }
}
