/*
 * Public EV charger registry ([pea_charger_catalog]).
 * Palette and shapes follow peavoltaev.pea.co.th: purple primary (#6938ef),
 * deep purple headings (#27115f / #3e1c96), lavender surfaces, 8/16/99px radii,
 * Noto Sans Thai. Everything is scoped under .pea-cl-catalog so it can't leak
 * into the host theme.
 */

.pea-cl-catalog {
	--pea-primary: #6938ef;
	--pea-primary-dark: #3e1c96;
	--pea-ink: #27115f;
	--pea-text: #383839;
	--pea-muted: #4f4f4f;
	--pea-lavender: #f9f8ff;
	--pea-lavender-2: #ebe9fe;
	--pea-lavender-3: #bdb4fe;
	--pea-line: #e4e0f7;
	--pea-success: #66b169;

	/*
	 * Centre the registry at up to 1200px even when the theme puts page content
	 * in a narrow column: the negative side margins widen it symmetrically, and
	 * on small screens min() collapses it to the viewport minus a 16px gutter.
	 */
	max-width: none !important; /* block themes cap direct children of post content */
	margin-block: 0;
	margin-inline: calc(50% - min(600px, 50vw - 16px)) !important;
	box-sizing: border-box;
	color: var(--pea-text);
	font-family: "Noto Sans Thai", "Sarabun", system-ui, -apple-system, "Segoe UI", sans-serif;
	line-height: 1.55;
}
.pea-cl-catalog *,
.pea-cl-catalog *::before,
.pea-cl-catalog *::after {
	box-sizing: border-box;
}

/* Tabs (single "EV Charger" pill for now) ------------------------------ */

.pea-cl-catalog-tabs {
	display: flex;
	gap: 4px;
	background: var(--pea-lavender-2);
	border-radius: 99px;
	padding: 4px;
	width: fit-content;
	margin: 0 auto 24px;
}
.pea-cl-tab {
	padding: 8px 26px;
	border-radius: 99px;
	font-weight: 600;
	font-size: 15px;
	color: var(--pea-primary-dark);
}
.pea-cl-tab.is-active {
	background: #fff;
	color: var(--pea-primary);
	box-shadow: 0 1px 4px rgba(39, 17, 95, 0.15);
}

/* Toolbar + download ---------------------------------------------------- */

.pea-cl-catalog-toolbar {
	display: flex;
	justify-content: flex-end;
	margin-bottom: 12px;
}
.pea-cl-download-btn {
	display: inline-flex;
	align-items: center;
	justify-content: center;
	gap: 8px;
	background: var(--pea-primary);
	color: #fff;
	text-decoration: none;
	padding: 10px 22px;
	border-radius: 99px;
	font-weight: 600;
	font-size: 14px;
	transition: background 0.15s ease;
}
.pea-cl-download-btn:hover,
.pea-cl-download-btn:focus-visible {
	background: var(--pea-primary-dark);
	color: #fff;
}

/* Search card ----------------------------------------------------------- */

.pea-cl-search-form {
	background: var(--pea-lavender);
	border: 1px solid var(--pea-line);
	border-radius: 16px;
	padding: 16px;
	margin-bottom: 20px;
}
.pea-cl-search-row {
	display: grid;
	grid-template-columns: minmax(200px, 2fr) repeat(3, minmax(150px, 1fr)) auto;
	gap: 10px;
	align-items: center;
}
.pea-cl-search-row input[type="text"],
.pea-cl-search-row select {
	width: 100%;
	min-height: 44px;
	padding: 8px 14px;
	border: 1px solid var(--pea-lavender-3);
	border-radius: 8px;
	background: #fff;
	color: var(--pea-text);
	font: inherit;
	font-size: 14px;
}
.pea-cl-search-row input[type="text"]:focus,
.pea-cl-search-row select:focus {
	outline: 2px solid var(--pea-primary);
	outline-offset: 1px;
	border-color: var(--pea-primary);
}
.pea-cl-search-btn {
	min-height: 44px;
	padding: 0 28px;
	border: none;
	border-radius: 99px;
	background: var(--pea-primary);
	color: #fff;
	font: inherit;
	font-weight: 600;
	cursor: pointer;
	transition: background 0.15s ease;
}
.pea-cl-search-btn:hover,
.pea-cl-search-btn:focus-visible {
	background: var(--pea-primary-dark);
}

/* Results --------------------------------------------------------------- */

.pea-cl-count {
	margin: 0 0 12px;
	font-weight: 700;
	font-size: 18px;
	color: var(--pea-ink);
}
.pea-cl-empty {
	padding: 32px 16px;
	text-align: center;
	color: var(--pea-muted);
	background: var(--pea-lavender);
	border-radius: 16px;
}
.is-loading {
	opacity: 0.5;
	pointer-events: none;
	transition: opacity 0.15s ease;
}

.pea-cl-table-scroll {
	overflow-x: auto;
	border: 1px solid var(--pea-line);
	border-radius: 16px;
	background: #fff;
}
table.pea-catalog-table {
	width: 100%;
	border-collapse: collapse;
	font-size: 14px;
}
table.pea-catalog-table th,
table.pea-catalog-table td {
	padding: 12px 10px;
	border-bottom: 1px solid var(--pea-line);
	text-align: center;
	vertical-align: middle;
}
/* Brand + Model columns stay left-aligned (desktop table only). */
@media (min-width: 721px) {
	table.pea-catalog-table th:nth-child(-n+2),
	table.pea-catalog-table td:nth-child(-n+2) {
		text-align: left;
	}
}
table.pea-catalog-table thead th {
	background: var(--pea-primary-dark);
	color: #fff;
	font-weight: 600;
	font-size: 13px;
	white-space: nowrap;
}
table.pea-catalog-table tbody tr:nth-child(even) {
	background: var(--pea-lavender);
}
table.pea-catalog-table tbody tr:hover {
	background: var(--pea-lavender-2);
}
table.pea-catalog-table tbody tr:last-child td {
	border-bottom: none;
}
table.pea-catalog-table td.pea-cl-brand {
	font-weight: 700;
	color: var(--pea-ink);
}
table.pea-catalog-table td.pea-cl-num {
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}
.pea-cl-chips {
	display: flex;
	flex-wrap: wrap;
	justify-content: center;
	gap: 4px;
	min-width: 0;
}
.pea-cl-empty-value {
	color: var(--pea-lavender-3);
}

/* Badges ---------------------------------------------------------------- */

.pea-cl-badge {
	display: inline-block;
	padding: 2px 12px;
	margin: 0;
	border-radius: 99px;
	background: var(--pea-lavender-2);
	color: var(--pea-primary-dark);
	font-size: 12px;
	font-weight: 600;
	white-space: nowrap;
}
.pea-cl-badge--dc {
	background: var(--pea-primary);
	color: #fff;
}
.pea-cl-badge--ac {
	background: var(--pea-success);
	color: #fff;
}

/* Pagination ------------------------------------------------------------ */

.pea-cl-pagination {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	margin-top: 20px;
	justify-content: center;
}
.pea-cl-page-btn {
	min-width: 40px;
	min-height: 40px;
	border: 1px solid var(--pea-lavender-3);
	background: #fff;
	color: var(--pea-primary-dark);
	border-radius: 8px;
	padding: 4px 12px;
	font: inherit;
	cursor: pointer;
}
.pea-cl-page-btn:hover {
	background: var(--pea-lavender-2);
}
.pea-cl-page-btn.is-active {
	background: var(--pea-primary);
	color: #fff;
	border-color: var(--pea-primary);
}

/* Responsive ------------------------------------------------------------ */

@media (max-width: 1024px) {
	.pea-cl-search-row {
		grid-template-columns: 1fr 1fr;
	}
	.pea-cl-search-row input[type="text"] {
		grid-column: 1 / -1;
	}
	.pea-cl-search-btn {
		grid-column: 1 / -1;
	}
}

@media (max-width: 720px) {
	.pea-cl-catalog-toolbar {
		justify-content: stretch;
	}
	.pea-cl-download-btn {
		width: 100%;
	}
	.pea-cl-search-row {
		grid-template-columns: 1fr;
	}

	/* Table rows become stacked cards; each cell shows its column label. */
	.pea-cl-table-scroll {
		border: none;
		background: transparent;
		overflow: visible;
	}
	table.pea-catalog-table,
	table.pea-catalog-table tbody,
	table.pea-catalog-table tr,
	table.pea-catalog-table td {
		display: block;
		width: 100%;
	}
	table.pea-catalog-table thead {
		position: absolute;
		width: 1px;
		height: 1px;
		overflow: hidden;
		clip: rect(0 0 0 0);
	}
	table.pea-catalog-table tbody tr,
	table.pea-catalog-table tbody tr:nth-child(even) {
		background: #fff;
		border: 1px solid var(--pea-line);
		border-radius: 16px;
		padding: 8px 4px;
		margin-bottom: 12px;
		box-shadow: 0 1px 3px rgba(39, 17, 95, 0.08);
	}
	table.pea-catalog-table td,
	table.pea-catalog-table tbody tr:last-child td {
		display: flex;
		justify-content: space-between;
		align-items: flex-start;
		gap: 16px;
		padding: 8px 12px;
		border-bottom: 1px dashed var(--pea-line);
		text-align: right;
	}
	table.pea-catalog-table td:last-child {
		border-bottom: none;
	}
	table.pea-catalog-table td .pea-cl-chips {
		justify-content: flex-end;
	}
	table.pea-catalog-table td::before {
		content: attr(data-label);
		flex: 0 0 42%;
		text-align: left;
		font-size: 12px;
		font-weight: 600;
		color: var(--pea-primary-dark);
	}
	table.pea-catalog-table td.pea-cl-brand {
		font-size: 16px;
	}
}
