/*
 * Postal codes: lookup box, code + copy button, prefix chips, province grid, toast.
 * Builds on vnp-frontend.css tokens when inside .vnp; the shortcode also works on any page
 * (own fallbacks below), scoped under .vnp-plookup / .vnp-pcode.
 */

.vnp-plookup,
.vnp-pcode,
.vnp-toast {
	--vnpp-primary: var(--vnp-primary, #2563eb);
	--vnpp-ink: var(--vnp-ink, #0f172a);
	--vnpp-muted: var(--vnp-muted, #64748b);
	--vnpp-line: var(--vnp-line, #e2e8f0);
	box-sizing: border-box;
}
.vnp-plookup *,
.vnp-plookup *::before,
.vnp-plookup *::after {
	box-sizing: inherit;
}

/* Code + copy -------------------------------------------------------------------------------- */
.vnp-pcode {
	display: inline-flex;
	align-items: center;
	gap: 0.5rem;
	white-space: nowrap;
}
.vnp-pcode__num {
	padding: 0.15rem 0.55rem;
	border-radius: 8px;
	background: #fff7ed;
	color: #c2410c;
	font-size: 1.15rem;
	font-weight: 800;
	font-variant-numeric: tabular-nums;
	letter-spacing: 0.04em;
}
.vnp-pcode__copy {
	display: none;
	align-items: center;
	gap: 0.3rem;
	min-height: 2rem;
	padding: 0.25rem 0.6rem;
	border: 1px solid var(--vnpp-line);
	border-radius: 8px;
	background: #fff;
	color: var(--vnpp-ink);
	font: inherit;
	font-size: 0.8rem;
	font-weight: 600;
	line-height: 1;
	cursor: pointer;
	transition: border-color 0.15s, background 0.15s, color 0.15s;
}
.vnp-js .vnp-pcode__copy {
	display: inline-flex;
}
.vnp-pcode__copy:hover {
	border-color: var(--vnpp-primary);
	color: var(--vnpp-primary);
}
.vnp-pcode__copy:focus-visible {
	outline: 2px solid var(--vnpp-primary);
	outline-offset: 2px;
}
.vnp-pcode__copy.is-copied {
	border-color: #16a34a;
	background: #f0fdf4;
	color: #15803d;
}
.vnp-pcode__copy svg {
	flex: none;
}
.vnp-pcode--pending {
	padding: 0.15rem 0.55rem;
	border: 1px dashed #f59e0b;
	border-radius: 8px;
	background: #fffbeb;
	color: #92400e;
	font-size: 0.8rem;
	font-weight: 600;
	cursor: help;
}

/* Toast ---------------------------------------------------------------------------------------- */
.vnp-toast {
	position: fixed;
	left: 50%;
	bottom: 1.5rem;
	z-index: 100000;
	transform: translate(-50%, 1rem);
	padding: 0.7rem 1.1rem;
	border-radius: 12px;
	background: #0f172a;
	color: #fff;
	font-size: 0.9rem;
	font-weight: 600;
	box-shadow: 0 10px 30px rgba(15, 23, 42, 0.3);
	opacity: 0;
	transition: opacity 0.2s, transform 0.2s;
	pointer-events: none;
}
.vnp-toast.is-on {
	opacity: 1;
	transform: translate(-50%, 0);
}

/* Lookup box ------------------------------------------------------------------------------------- */
.vnp-plookup {
	margin: 1.5rem 0;
	padding: clamp(0.9rem, 2.5vw, 1.25rem);
	border: 1px solid var(--vnpp-line);
	border-radius: 16px;
	background: #fff;
	color: var(--vnpp-ink);
	text-align: left;
}
.vnp .vnp-plookup__title {
	margin: 0 0 0.75rem;
	font-size: 1.05rem;
}
.vnp-plookup__form {
	display: flex;
	flex-wrap: wrap;
	gap: 0.5rem;
}
.vnp-plookup__field {
	position: relative;
	flex: 1 1 280px;
}
.vnp .vnp-plookup__field input,
.vnp-plookup__field input {
	width: 100%;
	min-height: 3rem;
	padding: 0.6rem 2.6rem 0.6rem 2.5rem;
	border: 1px solid var(--vnpp-line);
	border-radius: 12px;
	background: #fff no-repeat 0.85rem center / 1.05rem
		url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='m20 20-3.5-3.5'/%3E%3C/svg%3E");
	color: var(--vnpp-ink);
	font: inherit;
	font-size: 1rem;
}
.vnp-plookup__field input:focus {
	border-color: var(--vnpp-primary);
	outline: 3px solid color-mix(in srgb, var(--vnpp-primary) 18%, transparent);
	outline-offset: 0;
}
.vnp-plookup__spin {
	position: absolute;
	right: 0.9rem;
	top: 50%;
	width: 1.1rem;
	height: 1.1rem;
	margin-top: -0.55rem;
	border: 2px solid var(--vnpp-line);
	border-top-color: var(--vnpp-primary);
	border-radius: 50%;
	opacity: 0;
	animation: vnp-spin 0.7s linear infinite;
	transition: opacity 0.15s;
}
.vnp-plookup.is-busy .vnp-plookup__spin {
	opacity: 1;
}
@keyframes vnp-spin {
	to { transform: rotate(360deg); }
}
.vnp-plookup__select {
	flex: 0 1 220px;
}
.vnp .vnp-plookup__select select,
.vnp-plookup__select select {
	width: 100%;
	min-height: 3rem;
	padding: 0.5rem 0.8rem;
	border: 1px solid var(--vnpp-line);
	border-radius: 12px;
	background: #fff;
	color: var(--vnpp-ink);
	font: inherit;
}
.vnp .vnp-plookup__submit,
.vnp-plookup__submit {
	min-height: 3rem;
	padding: 0 1.4rem;
	border: 0;
	border-radius: 12px;
	background: #0f172a;
	color: #fff;
	font: inherit;
	font-weight: 600;
	cursor: pointer;
}
.vnp-plookup__hint,
.vnp-plookup__status {
	margin: 0.5rem 0 0;
	color: var(--vnpp-muted);
	font-size: 0.85rem;
}
.vnp-plookup__status:empty {
	display: none;
}
.vnp-plookup__results:not(:empty) {
	margin-top: 0.75rem;
}
.vnp-plookup__list {
	display: grid;
	gap: 0.5rem;
	margin: 0;
	padding: 0;
	list-style: none;
}
.vnp-presult {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5rem 1rem;
	padding: 0.65rem 0.85rem;
	border: 1px solid var(--vnpp-line);
	border-radius: 12px;
	background: #f8fafc;
}
.vnp-presult__body {
	display: flex;
	flex-direction: column;
	min-width: 0;
}
.vnp .vnp-presult__name {
	color: var(--vnpp-ink);
	font-weight: 700;
}
.vnp-presult__meta,
.vnp-presult__old {
	color: var(--vnpp-muted);
	font-size: 0.82rem;
}
.vnp-presult__old {
	color: #7c2d12;
}
.vnp-plookup__empty {
	margin: 0;
	color: var(--vnpp-muted);
}

/* Inside the hero -------------------------------------------------------------------------------- */
.vnp-hero .vnp-plookup {
	max-width: 860px;
	margin: 1.75rem auto 0;
	border-color: rgba(255, 255, 255, 0.25);
	background: rgba(255, 255, 255, 0.14);
	color: #e0e7ff;
}
.vnp .vnp-hero .vnp-plookup__title {
	color: #fff;
}
.vnp-hero .vnp-plookup__field input,
.vnp-hero .vnp-plookup__select select {
	border: 0;
}
.vnp-hero .vnp-plookup__hint,
.vnp-hero .vnp-plookup__status {
	color: rgba(255, 255, 255, 0.8);
}
.vnp-hero .vnp-plookup__results:not(:empty) {
	padding: 0.75rem;
	border-radius: 12px;
	background: #fff;
}

/* Prefix chips ----------------------------------------------------------------------------------- */
.vnp-prefix {
	display: inline-flex;
	align-items: baseline;
	padding: 0.1rem 0.5rem;
	border-radius: 8px;
	background: #fff7ed;
	color: #c2410c;
	font-weight: 800;
	font-variant-numeric: tabular-nums;
}
.vnp-prefix small {
	font-weight: 500;
	opacity: 0.6;
}
.vnp-prefix--lg {
	padding: 0.2rem 0.7rem;
	background: #fff;
	font-size: 1.5rem;
}
.vnp-hero__prefixes {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: 0.5rem;
	margin: 0.25rem 0 0;
}

/* Province grid on the hub ----------------------------------------------------------------------- */
.vnp-pgrid {
	display: grid;
	grid-template-columns: repeat(auto-fill, minmax(min(100%, 280px), 1fr));
	gap: var(--vnp-gap, 1rem);
}
.vnp .vnp-pcard {
	display: flex;
	align-items: center;
	gap: 0.85rem;
	padding: 0.7rem;
	border: 1px solid var(--vnp-line, #e2e8f0);
	border-radius: 14px;
	background: #fff;
	color: inherit;
	text-decoration: none;
	box-shadow: var(--vnp-shadow, none);
	transition: transform 0.15s, box-shadow 0.15s, border-color 0.15s;
}
.vnp .vnp-pcard:hover {
	transform: translateY(-2px);
	border-color: color-mix(in srgb, var(--vnp-primary, #2563eb) 35%, #e2e8f0);
	box-shadow: var(--vnp-shadow-hover, none);
	text-decoration: none;
}
.vnp-pcard__img {
	flex: none;
	width: 5.6rem;
	aspect-ratio: 4 / 3;
	overflow: hidden;
	border-radius: 10px;
	background: #f1f5f9;
}
.vnp .vnp-pcard__img img {
	display: block;
	width: 100%;
	height: 100%;
	max-width: none;
	object-fit: cover;
}
.vnp-pcard__body {
	display: flex;
	flex-direction: column;
	gap: 0.3rem;
	min-width: 0;
}
.vnp-pcard__name {
	color: var(--vnp-ink, #0f172a);
	font-weight: 700;
	line-height: 1.3;
}
.vnp-pcard__prefixes {
	display: flex;
	flex-wrap: wrap;
	gap: 0.3rem;
}
.vnp-pcard__meta {
	overflow: hidden;
	color: var(--vnp-muted, #64748b);
	font-size: 0.78rem;
	text-overflow: ellipsis;
	white-space: nowrap;
}

/* Guide ------------------------------------------------------------------------------------------ */
.vnp-steps {
	display: grid;
	grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr));
	gap: 0.75rem;
	margin: 0;
	padding: 0;
	list-style: none;
	counter-reset: vnp-step;
}
.vnp-steps li {
	position: relative;
	padding: 2.6rem 1rem 1rem;
	border-radius: 12px;
	background: var(--vnp-soft, #f8fafc);
	line-height: 1.6;
	counter-increment: vnp-step;
}
.vnp-steps li::before {
	content: counter(vnp-step);
	position: absolute;
	left: 1rem;
	top: 0.85rem;
	display: grid;
	place-items: center;
	width: 1.6rem;
	height: 1.6rem;
	border-radius: 50%;
	background: var(--vnp-primary, #2563eb);
	color: #fff;
	font-size: 0.85rem;
	font-weight: 700;
}
.vnp-steps strong {
	display: block;
	color: var(--vnp-ink, #0f172a);
}

/* Province postal table -------------------------------------------------------------------------- */
.vnp .vnp-table--postal td {
	vertical-align: middle;
}
.vnp-table--postal td:nth-child(2) {
	min-width: 12rem;
}
.vnp-table--postal tbody tr[hidden] {
	display: none;
}
.vnp-ptable .vnp-toolbar {
	margin-top: 0.5rem;
}
.vnp .vnp-code {
	color: var(--vnp-muted, #64748b);
}

/* Single province page: code column -------------------------------------------------------------- */
.vnp .vnp-table .vnp-pcode__num {
	font-size: 1rem;
}
.vnp-postal-link {
	margin: 0.25rem 0 1rem;
	font-size: 0.9rem;
}

@media (max-width: 640px) {
	.vnp-plookup__select {
		flex: 1 1 100%;
	}
	.vnp-plookup__submit {
		width: 100%;
	}
	.vnp-pcode__copy span {
		display: none; /* icon only on phones */
	}
	.vnp-prefix--lg {
		font-size: 1.25rem;
	}
}

@media (prefers-reduced-motion: reduce) {
	.vnp-toast,
	.vnp .vnp-pcard,
	.vnp-pcode__copy {
		transition: none;
	}
	.vnp-plookup__spin {
		animation-duration: 2s;
	}
}
