/* ==========================================================================
   BẢO HÀNH ĐIỆN TỬ - GIAO DIỆN TRA CỨU (ewd-front.css)
   Khớp phong cách theme: thẻ trắng bo góc, nâu thương hiệu, viền #eef0f3.

   - Thay trực tiếp file assets/ewd-front.css của plugin,
     hoặc dán toàn bộ vào Giao diện > Tùy chỉnh > CSS bổ sung.
   - Đổi màu nút/viền khi focus:  [ewd_tracuu color="#8c5a3a"]
     hoặc sửa --ewd-accent ngay bên dưới.
   - Tự lấy --az-brand, --card-pad, --card-radius từ CSS theme nếu có.
   - Không cần sửa PHP: trạng thái (Còn hạn / Sắp hết hạn / Hết hạn / Đã hủy)
     được nhận diện qua màu inline mà plugin đang xuất ra.
   ========================================================================== */

.ewd-search {
	--ewd-accent: var(--az-brand, #8c5a3a);
	--ewd-ink: #1f2937;
	--ewd-ink-strong: #111827;
	--ewd-muted: #6b7280;
	--ewd-line: #eef0f3;
	--ewd-soft: #f8f9fb;
	--ewd-pad: var(--card-pad, 24px);
	--ewd-radius: var(--card-radius, 16px);
	--ewd-shadow: var(--card-shadow, 0 2px 12px rgba(16, 24, 40, .06));

	max-width: 720px;
	margin: 0 auto 30px;
	color: var(--ewd-ink);
}

/* ---------- 1. Tiêu đề + mô tả ---------- */
.ewd-search .ewd-title {
	margin: 0 0 8px;
	text-align: center;
	font-size: clamp(1.35rem, 2.4vw, 1.75rem);
	font-weight: 700;
	line-height: 1.25;
	letter-spacing: -.01em;
	text-transform: none;
	color: var(--ewd-ink-strong);
}
.ewd-search .ewd-desc {
	max-width: 52ch;
	margin: 0 auto 20px;
	text-align: center;
	line-height: 1.55;
	color: var(--ewd-muted);
}

/* ---------- 2. Thanh tra cứu: ô nhập và nút nằm chung một khung ---------- */
.ewd-search .ewd-form {
	position: relative;
	display: flex;
	align-items: center;
	gap: 8px;
	flex-wrap: nowrap;
	margin: 0;
	padding: 6px;
	background: #fff;
	border: 1px solid #dfe3e8;
	border-radius: 14px;
	box-shadow: var(--ewd-shadow);
	transition: border-color .15s ease, box-shadow .15s ease;
}
.ewd-search .ewd-form:focus-within {
	border-color: var(--ewd-accent);
	box-shadow: 0 0 0 4px rgba(140, 90, 58, .16);
}
@supports (background: color-mix(in srgb, red 10%, white)) {
	.ewd-search .ewd-form:focus-within {
		box-shadow: 0 0 0 4px color-mix(in srgb, var(--ewd-accent) 18%, transparent);
	}
}

.ewd-search .ewd-form input[name="q"] {
	flex: 1 1 auto;
	min-width: 0;
	height: 44px;
	margin: 0;
	padding: 0 14px;
	border: 0;
	border-radius: 10px;
	background: transparent;
	box-shadow: none !important;
	outline: 0;
	font: inherit;
	font-size: 16px; /* >= 16px để iOS không tự phóng to khi bấm vào ô */
	color: var(--ewd-ink-strong);
}
.ewd-search .ewd-form input[name="q"]::placeholder {
	color: #9ca3af;
	opacity: 1;
}

.ewd-search .ewd-form .ewd-btn {
	flex: 0 0 auto;
	min-height: 44px;
	margin: 0;
	padding: 0 26px;
	border: 0;
	border-radius: 10px;
	background: var(--ewd-accent);
	color: #fff;
	box-shadow: none;
	font: inherit;
	font-weight: 600;
	line-height: 44px;
	letter-spacing: 0;
	text-transform: none;
	text-shadow: none;
	cursor: pointer;
	transition: filter .15s ease, transform .15s ease;
}
.ewd-search .ewd-form .ewd-btn:hover {
	background: var(--ewd-accent);
	color: #fff;
	box-shadow: none;
	filter: brightness(.9);
}
.ewd-search .ewd-form .ewd-btn:active {
	transform: translateY(1px);
}
.ewd-search .ewd-form .ewd-btn:focus-visible {
	outline: 2px solid var(--ewd-ink-strong);
	outline-offset: 2px;
}
.ewd-search .ewd-form .ewd-btn:disabled {
	opacity: .6;
	cursor: not-allowed;
	filter: none;
}

/* ---------- 3. Vùng kết quả: đang tra cứu / lỗi / không thấy ---------- */
.ewd-search .ewd-results {
	margin-top: 20px;
}
.ewd-search .ewd-loading,
.ewd-search .ewd-empty {
	margin: 0;
	padding: 16px 18px;
	border-radius: 12px;
	text-align: center;
	line-height: 1.5;
}
.ewd-search .ewd-loading {
	background: var(--ewd-soft);
	border: 1px solid var(--ewd-line);
	color: #4b5563;
}
.ewd-search .ewd-loading::before {
	content: "";
	display: inline-block;
	width: 16px;
	height: 16px;
	margin-right: 10px;
	vertical-align: -3px;
	border: 2px solid #d1d5db;
	border-top-color: var(--ewd-accent);
	border-radius: 50%;
	animation: ewd-spin .7s linear infinite;
}
.ewd-search .ewd-empty {
	background: #fff5f5;
	border: 1px solid #f9d0d0;
	color: #a61b1b;
}
@keyframes ewd-spin {
	to { transform: rotate(360deg); }
}

/* ---------- 4. Thẻ kết quả ---------- */
.ewd-search .ewd-card {
	--ewd-st: #cbd5e1; /* màu thanh trạng thái phía trên thẻ */
	margin: 0 0 16px;
	overflow: hidden;
	background: #fff;
	border: 1px solid var(--ewd-line);
	border-top: 4px solid var(--ewd-st);
	border-radius: var(--ewd-radius);
	box-shadow: var(--ewd-shadow);
	animation: ewd-in .22s ease-out;
}
/* Thanh trên cùng đổi màu theo trạng thái tổng của phiếu */
.ewd-search .ewd-card:has(.ewd-card-head .ewd-badge[style*="16a34a" i]) { --ewd-st: #16a34a; }
.ewd-search .ewd-card:has(.ewd-card-head .ewd-badge[style*="d97706" i]) { --ewd-st: #d97706; }
.ewd-search .ewd-card:has(.ewd-card-head .ewd-badge[style*="dc2626" i]) { --ewd-st: #dc2626; }
.ewd-search .ewd-card:has(.ewd-card-head .ewd-badge[style*="6b7280" i]) { --ewd-st: #9ca3af; }

@keyframes ewd-in {
	from { opacity: 0; transform: translateY(6px); }
	to   { opacity: 1; transform: none; }
}

.ewd-search .ewd-card-head {
	display: flex;
	align-items: center;
	justify-content: space-between;
	gap: 12px;
	padding: 14px var(--ewd-pad);
	background: var(--ewd-soft);
	border-bottom: 1px solid var(--ewd-line);
}
.ewd-search .ewd-code {
	font-size: 1.05rem;
	font-weight: 700;
	letter-spacing: .01em;
	font-variant-numeric: tabular-nums;
	color: var(--ewd-ink-strong);
	overflow-wrap: anywhere;
}

/* ---------- 5. Nhãn trạng thái (ghi đè màu inline của plugin) ---------- */
.ewd-search .ewd-badge {
	display: inline-flex !important;
	align-items: center;
	gap: 6px;
	padding: 4px 12px 4px 10px !important;
	border-radius: 999px !important;
	font-size: 12.5px !important;
	font-weight: 600 !important;
	line-height: 1.3;
	white-space: nowrap;
	background: #eef0f3 !important;
	color: #4b5563 !important;
}
.ewd-search .ewd-badge::before {
	content: "";
	flex: 0 0 auto;
	width: 7px;
	height: 7px;
	border-radius: 50%;
	background: currentColor;
}
.ewd-search .ewd-badge[style*="16a34a" i] { background: #e7f6ec !important; color: #14632f !important; } /* Còn hạn */
.ewd-search .ewd-badge[style*="d97706" i] { background: #fdf1dc !important; color: #8a4b05 !important; } /* Sắp hết hạn */
.ewd-search .ewd-badge[style*="dc2626" i] { background: #fde8e8 !important; color: #a61b1b !important; } /* Hết hạn */
.ewd-search .ewd-badge[style*="6b7280" i] { background: #eef0f3 !important; color: #4b5563 !important; } /* Đã hủy / Chưa xác định */

/* ---------- 6. Thông tin khách hàng & xe: lưới nhãn trên, giá trị dưới ---------- */
.ewd-search .ewd-table,
.ewd-search .ewd-table tbody {
	display: block;
	width: 100%;
	margin: 0;
	border: 0;
	background: none;
}
.ewd-search .ewd-table {
	padding: 18px var(--ewd-pad) 20px;
}
.ewd-search .ewd-table tbody {
	display: grid;
	grid-template-columns: repeat(3, minmax(0, 1fr));
	gap: 16px 28px;
}
.ewd-search .ewd-table tr {
	display: block;
	margin: 0;
	padding: 0;
	border: 0;
	background: none;
}
.ewd-search .ewd-table th,
.ewd-search .ewd-table td {
	display: block;
	width: auto;
	padding: 0;
	border: 0;
	background: none;
	text-align: left;
}
.ewd-search .ewd-table th {
	margin-bottom: 3px;
	font-size: .82rem;
	font-weight: 500;
	line-height: 1.4;
	letter-spacing: 0;
	text-transform: none;
	white-space: normal;
	color: var(--ewd-muted);
}
.ewd-search .ewd-table td {
	font-size: 1rem;
	font-weight: 600;
	line-height: 1.45;
	color: var(--ewd-ink-strong);
	overflow-wrap: anywhere;
}
.ewd-search .ewd-table ul {
	margin: 0 0 0 1.1em;
}
.ewd-search .ewd-table li {
	margin: 0;
}
/* Biển số xe: khung viền đậm như biển thật (plugin chỉ dùng <strong> cho biển số) */
.ewd-search .ewd-table td strong {
	display: inline-block;
	padding: 2px 12px;
	background: #fff;
	border: 2px solid #1f1f1f;
	border-radius: 6px;
	font-size: 1.05rem;
	font-weight: 800;
	letter-spacing: .06em;
	line-height: 1.4;
	color: #111;
}

/* ---------- 7. Bảng dịch vụ & thời hạn bảo hành ---------- */
.ewd-search .ewd-items-title {
	padding: 16px var(--ewd-pad) 12px;
	background: none;
	border-top: 1px solid var(--ewd-line);
	font-size: 1rem;
	font-weight: 700;
	color: var(--ewd-ink-strong);
}
.ewd-search .ewd-items-scroll {
	overflow-x: auto;
	-webkit-overflow-scrolling: touch;
}
.ewd-search .ewd-items {
	width: 100%;
	margin: 0;
	border: 0;
	border-collapse: collapse;
}
.ewd-search .ewd-items th,
.ewd-search .ewd-items td {
	padding: 13px 12px;
	border: 0;
	border-bottom: 1px solid #f1f2f4;
	background: none;
	text-align: left;
	vertical-align: top;
	font-size: .94rem;
	line-height: 1.45;
}
.ewd-search .ewd-items thead th {
	padding-top: 10px;
	padding-bottom: 10px;
	background: var(--ewd-soft);
	border-top: 1px solid var(--ewd-line);
	border-bottom: 1px solid var(--ewd-line);
	font-size: .8rem;
	font-weight: 600;
	letter-spacing: 0;
	text-transform: none;
	white-space: nowrap;
	color: var(--ewd-muted);
}
.ewd-search .ewd-items th:first-child,
.ewd-search .ewd-items td:first-child {
	padding-left: var(--ewd-pad);
}
.ewd-search .ewd-items th:last-child,
.ewd-search .ewd-items td:last-child {
	padding-right: var(--ewd-pad);
}
.ewd-search .ewd-items td:first-child {
	font-weight: 600;
	color: var(--ewd-ink-strong);
}
.ewd-search .ewd-items td:nth-child(2),
.ewd-search .ewd-items td:nth-child(3) {
	white-space: nowrap;
}
.ewd-search .ewd-items td:nth-child(4) {
	white-space: nowrap;
}
.ewd-search .ewd-items tbody tr:last-child td {
	border-bottom: 0;
}
.ewd-search .ewd-items small {
	color: var(--ewd-muted);
	font-size: .85em;
}
/* Dịch vụ đã hết hạn: ngày hết hạn chuyển đỏ */
.ewd-search .ewd-items tbody tr:has(.ewd-badge[style*="dc2626" i]) td:nth-child(3) {
	color: #a61b1b;
	font-weight: 600;
}

/* ---------- 8. Điện thoại: mỗi dịch vụ thành một khối có nhãn ---------- */
@media (max-width: 600px) {
	.ewd-search .ewd-items-scroll {
		overflow-x: visible;
	}
	.ewd-search .ewd-items,
	.ewd-search .ewd-items tbody,
	.ewd-search .ewd-items tr,
	.ewd-search .ewd-items td {
		display: block;
		width: 100%;
	}
	.ewd-search .ewd-items thead {
		display: none;
	}
	.ewd-search .ewd-items tbody tr {
		padding: 14px var(--ewd-pad);
		border-bottom: 1px solid var(--ewd-line);
	}
	.ewd-search .ewd-items tbody tr:last-child {
		border-bottom: 0;
	}
	.ewd-search .ewd-items td,
	.ewd-search .ewd-items td:first-child,
	.ewd-search .ewd-items td:last-child {
		position: relative;
		min-height: 1.6em;
		padding: 4px 0 4px 38%;
		border: 0;
		white-space: normal;
	}
	.ewd-search .ewd-items td:first-child {
		margin-bottom: 4px;
		padding-left: 0;
		font-size: 1rem;
	}
	.ewd-search .ewd-items td:not(:first-child)::before {
		position: absolute;
		left: 0;
		top: 4px;
		width: 34%;
		font-size: .82rem;
		font-weight: 500;
		color: var(--ewd-muted);
	}
	.ewd-search .ewd-items td:nth-child(2)::before { content: "Bảo hành"; }
	.ewd-search .ewd-items td:nth-child(3)::before { content: "Hết hạn"; }
	.ewd-search .ewd-items td:nth-child(4)::before { content: "Trạng thái"; top: 6px; }
}

@media (max-width: 600px) {
	.ewd-search .ewd-table tbody {
		grid-template-columns: repeat(2, minmax(0, 1fr));
		gap: 14px 16px;
	}
}

/* ---------- 9. Màn hình nhỏ: form xếp dọc, nút full chiều ngang ---------- */
@media (max-width: 480px) {
	.ewd-search .ewd-form {
		flex-direction: column;
		align-items: stretch;
		padding: 0;
		background: none;
		border: 0;
		box-shadow: none;
	}
	.ewd-search .ewd-form:focus-within {
		border: 0;
		box-shadow: none;
	}
	.ewd-search .ewd-form input[name="q"] {
		flex: none;
		height: 48px;
		background: #fff;
		border: 1px solid #dfe3e8;
		box-shadow: var(--ewd-shadow) !important;
	}
	.ewd-search .ewd-form input[name="q"]:focus {
		border-color: var(--ewd-accent);
	}
	.ewd-search .ewd-form .ewd-btn {
		width: 100%;
		min-height: 48px;
		line-height: 48px;
	}
	.ewd-search .ewd-card-head {
		flex-wrap: wrap;
	}
}

/* ---------- 10. Giảm chuyển động theo cài đặt hệ thống ---------- */
@media (prefers-reduced-motion: reduce) {
	.ewd-search .ewd-card { animation: none; }
	.ewd-search .ewd-loading::before { animation: none; }
	.ewd-search .ewd-form .ewd-btn { transition: none; }
}
