/**
 * v1.2.0 — bug report: "When changed to dark mode, the transactions by
 * town cannot be seen." Root cause: every card/tile/form in this stylesheet
 * hardcoded a light background (`background: #fff`) and left its text
 * color to inherit from the page. That was fine standalone, but on
 * anything.com.sg the KampungKey theme flips the *inherited* text color to
 * a light tone in dark mode (`--am-text: #eef1ec`) while this plugin's own
 * cards stayed hardcoded white — producing near-white text on a white
 * card, i.e. invisible "Latest transactions by town" rows.
 *
 * Fixed by giving this plugin its own light/dark token set, exactly
 * mirroring the mechanism the theme itself uses (see anything-theme's
 * style.css and header.php): light values live on plain `.hdb-rpc`, dark
 * overrides are declared twice — once for the OS-level
 * `prefers-color-scheme: dark` (guarded so an explicit `data-theme="light"`
 * always wins) and again for `[data-theme="dark"]` (so a manual toggle
 * always wins in both directions) — and every element that used to
 * hardcode a color now references a token instead. This makes the plugin
 * correctly dark-mode-aware on ITS OWN, whether or not the KampungKey
 * theme (or any other dark-mode-capable theme) is active, and with no
 * dependency on the theme's own `--am-*` variables.
 *
 * v1.3.1 — full visual redesign. Wei Yun: "looks messy and i wont want to
 * stay at the page any longer." (The page itself was also split into
 * tabs on the theme side — see anything-theme's
 * template-hdb-resale-checker.php — so only one tool is visible at a
 * time now.) This pass is CSS-only: every class name below is unchanged
 * from before, so the shortcodes' PHP/markup and all 124 existing
 * offline tests are untouched. What changed is spacing, elevation,
 * typography and hover/focus feedback throughout — stat tiles read as a
 * dashboard instead of bare bordered boxes, the search/compare forms
 * are a single elevated card with a search icon and a clearer primary
 * action, tables have a sticky header + zebra rows + a rounded frame
 * instead of a flat bottom-border list, and notices/banners get a
 * left accent + icon so guests actually notice the free-search limit
 * and signup nudge instead of skimming past another grey box.
 */
.hdb-rpc {
	--hdb-rpc-primary: #1f5e4a;
	--hdb-rpc-primary-dark: #123d31;
	--hdb-rpc-border: #e2e6df;
	--hdb-rpc-muted: #667066;
	--hdb-rpc-success: #1f7a4d;
	--hdb-rpc-error: #b23b3b;
	--hdb-rpc-text: #1a1f1c;
	--hdb-rpc-surface: #ffffff;
	--hdb-rpc-bg-soft: #f6f8f5;
	--hdb-rpc-notice-info-bg: #eef2fb;
	--hdb-rpc-notice-info-text: #33507a;
	--hdb-rpc-banner-bg: #fff7e6;
	--hdb-rpc-banner-border: #e6a53a;
	--hdb-rpc-banner-text: #1a1f1c;
	--hdb-rpc-shadow-sm: 0 1px 3px rgba(20, 40, 30, .06), 0 1px 2px rgba(20, 40, 30, .08);
	--hdb-rpc-shadow-md: 0 8px 24px rgba(20, 40, 30, .10);
	color: var(--hdb-rpc-text);
	font-size: 1rem;
	line-height: 1.55;
}

@media (prefers-color-scheme: dark) {
	html:not([data-theme="light"]) .hdb-rpc {
		--hdb-rpc-primary: #4fae8b;
		--hdb-rpc-primary-dark: #6fd99a;
		--hdb-rpc-border: #2a3129;
		--hdb-rpc-muted: #a3ada1;
		--hdb-rpc-success: #6fd99a;
		--hdb-rpc-error: #f5948f;
		--hdb-rpc-text: #eef1ec;
		--hdb-rpc-surface: #171c15;
		--hdb-rpc-bg-soft: #1b211a;
		--hdb-rpc-notice-info-bg: #172032;
		--hdb-rpc-notice-info-text: #9db6e6;
		--hdb-rpc-banner-bg: #3a2b0d;
		--hdb-rpc-banner-border: #a5761f;
		--hdb-rpc-banner-text: #eec27a;
		--hdb-rpc-shadow-sm: 0 1px 3px rgba(0, 0, 0, .35);
		--hdb-rpc-shadow-md: 0 8px 24px rgba(0, 0, 0, .45);
	}
}
html[data-theme="dark"] .hdb-rpc,
.hdb-rpc[data-theme="dark"] {
	--hdb-rpc-primary: #4fae8b;
	--hdb-rpc-primary-dark: #6fd99a;
	--hdb-rpc-border: #2a3129;
	--hdb-rpc-muted: #a3ada1;
	--hdb-rpc-success: #6fd99a;
	--hdb-rpc-error: #f5948f;
	--hdb-rpc-text: #eef1ec;
	--hdb-rpc-surface: #171c15;
	--hdb-rpc-bg-soft: #1b211a;
	--hdb-rpc-notice-info-bg: #172032;
	--hdb-rpc-notice-info-text: #9db6e6;
	--hdb-rpc-banner-bg: #3a2b0d;
	--hdb-rpc-banner-border: #a5761f;
	--hdb-rpc-banner-text: #eec27a;
	--hdb-rpc-shadow-sm: 0 1px 3px rgba(0, 0, 0, .35);
	--hdb-rpc-shadow-md: 0 8px 24px rgba(0, 0, 0, .45);
}

.hdb-rpc h3 { font-size: 1.15rem; margin: 2rem 0 1rem; }
.hdb-rpc h3:first-child { margin-top: 0; }

/* ---- Stat tiles ---- */
.hdb-rpc-stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(160px, 1fr)); gap: 1rem; margin: 0 0 1.75rem; }
.hdb-rpc-stat-card {
	background: var(--hdb-rpc-surface);
	border: 1px solid var(--hdb-rpc-border);
	border-radius: 12px;
	padding: 1.1rem 1rem;
	text-align: center;
	box-shadow: var(--hdb-rpc-shadow-sm);
	transition: box-shadow .15s ease, transform .15s ease;
}
.hdb-rpc-stat-card:hover { box-shadow: var(--hdb-rpc-shadow-md); transform: translateY(-1px); }
.hdb-rpc-stat-number { font-size: 1.55rem; font-weight: 800; color: var(--hdb-rpc-primary); letter-spacing: -.01em; }
.hdb-rpc-stat-number.positive { color: var(--hdb-rpc-success); }
.hdb-rpc-stat-number.negative { color: var(--hdb-rpc-error); }
.hdb-rpc-stat-label { color: var(--hdb-rpc-muted); font-size: .8rem; margin-top: .35rem; }

/* ---- Biggest movers — pill chips instead of a plain bordered list ---- */
.hdb-rpc-movers { list-style: none; padding: 0; margin: 0 0 1.75rem; display: flex; flex-wrap: wrap; gap: .6rem; }
.hdb-rpc-movers li {
	display: flex;
	align-items: center;
	gap: .6rem;
	padding: .55rem .9rem;
	border-radius: 999px;
	background: var(--hdb-rpc-surface);
	border: 1px solid var(--hdb-rpc-border);
	color: var(--hdb-rpc-text);
	font-size: .88rem;
	box-shadow: var(--hdb-rpc-shadow-sm);
}
.hdb-rpc-up { color: var(--hdb-rpc-success); font-weight: 700; }
.hdb-rpc-down { color: var(--hdb-rpc-error); font-weight: 700; }

/* ---- Per-town cards ---- */
.hdb-rpc-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr)); gap: 1.1rem; }
.hdb-rpc-card {
	background: var(--hdb-rpc-surface);
	border: 1px solid var(--hdb-rpc-border);
	border-radius: 12px;
	padding: 1.1rem 1.15rem;
	color: var(--hdb-rpc-text);
	box-shadow: var(--hdb-rpc-shadow-sm);
	transition: box-shadow .15s ease, transform .15s ease;
}
.hdb-rpc-card:hover { box-shadow: var(--hdb-rpc-shadow-md); transform: translateY(-2px); }
.hdb-rpc-card h4 { margin: 0 0 .5rem; color: var(--hdb-rpc-text); font-size: 1rem; }
.hdb-rpc-card table { width: 100%; border-collapse: collapse; font-size: .85rem; color: var(--hdb-rpc-text); }
.hdb-rpc-card table td { padding: .4rem 0; border-top: 1px solid var(--hdb-rpc-border); }
.hdb-rpc-card table td:last-child { text-align: right; font-weight: 700; color: var(--hdb-rpc-primary); }
.hdb-rpc-muted { color: var(--hdb-rpc-muted); font-size: .85rem; margin: 0 0 .75rem; }

/* ---- Search / compare form — one elevated card, not a bare row of fields ---- */
.hdb-rpc-form {
	display: flex;
	flex-wrap: wrap;
	gap: 1.1rem;
	align-items: flex-end;
	background: var(--hdb-rpc-bg-soft);
	border: 1px solid var(--hdb-rpc-border);
	border-radius: 14px;
	padding: 1.5rem;
	margin-bottom: 1.75rem;
}
.hdb-rpc-field { display: flex; flex-direction: column; gap: .35rem; }
.hdb-rpc-field label { font-size: .8rem; color: var(--hdb-rpc-muted); font-weight: 700; text-transform: uppercase; letter-spacing: .02em; }
.hdb-rpc-field select,
.hdb-rpc-field input[type="text"] {
	padding: .65rem .8rem;
	border: 1.5px solid var(--hdb-rpc-border);
	border-radius: 8px;
	min-width: 160px;
	background: var(--hdb-rpc-surface);
	color: var(--hdb-rpc-text);
	font: inherit;
	transition: border-color .15s ease, box-shadow .15s ease;
}
.hdb-rpc-field select:focus,
.hdb-rpc-field input[type="text"]:focus {
	outline: none;
	border-color: var(--hdb-rpc-primary);
	box-shadow: 0 0 0 3px color-mix(in srgb, var(--hdb-rpc-primary) 18%, transparent);
}
.hdb-rpc-field-query { flex: 1 1 260px; }
.hdb-rpc-field-query input[type="text"] {
	min-width: 220px;
	width: 100%;
	padding-left: 2.35rem;
	background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' fill='none' stroke='%23667066' stroke-width='2' viewBox='0 0 24 24'%3E%3Ccircle cx='11' cy='11' r='7'/%3E%3Cpath d='M21 21l-4.3-4.3'/%3E%3C/svg%3E");
	background-repeat: no-repeat;
	background-position: .75rem center;
}

.hdb-rpc-btn {
	background: var(--hdb-rpc-primary);
	color: #fff !important;
	border: none;
	border-radius: 8px;
	padding: .7rem 1.35rem;
	font-weight: 700;
	font-size: .95rem;
	cursor: pointer;
	text-decoration: none !important;
	display: inline-block;
	margin: 0 .3rem;
	box-shadow: var(--hdb-rpc-shadow-sm);
	transition: background .15s ease, transform .15s ease, box-shadow .15s ease;
}
.hdb-rpc-btn:hover { background: var(--hdb-rpc-primary-dark); transform: translateY(-1px); box-shadow: var(--hdb-rpc-shadow-md); }
.hdb-rpc-btn-secondary { background: var(--hdb-rpc-surface); color: var(--hdb-rpc-primary) !important; border: 1.5px solid var(--hdb-rpc-primary); box-shadow: none; }
.hdb-rpc-btn-secondary:hover { background: var(--hdb-rpc-bg-soft); }

/* ---- Notices / banners — a left accent + icon so they're actually noticed ---- */
.hdb-rpc-notice {
	position: relative;
	padding: .85rem 1rem .85rem 2.6rem;
	border-radius: 10px;
	margin-bottom: 1.25rem;
	font-size: .92rem;
	line-height: 1.5;
}
.hdb-rpc-notice::before {
	content: "ℹ";
	position: absolute;
	left: 1rem;
	top: .8rem;
	font-weight: 800;
	font-size: 1rem;
}
.hdb-rpc-notice-info {
	background: var(--hdb-rpc-notice-info-bg);
	color: var(--hdb-rpc-notice-info-text);
	border-left: 4px solid var(--hdb-rpc-notice-info-text);
}

.hdb-rpc-signup-nudge {
	padding-left: 2.6rem;
	border-left: 4px solid var(--hdb-rpc-primary);
}
.hdb-rpc-signup-nudge::before { content: "✦"; color: var(--hdb-rpc-primary); }
.hdb-rpc-signup-nudge .hdb-rpc-btn { margin: .75rem 0 0; }
.hdb-rpc-signup-nudge p { margin: 0 0 .25rem; }

.hdb-rpc-limit-banner {
	background: var(--hdb-rpc-banner-bg);
	border: 1px solid var(--hdb-rpc-banner-border);
	color: var(--hdb-rpc-banner-text);
	border-radius: 14px;
	padding: 1.5rem;
	text-align: center;
	margin: 1.75rem 0;
	box-shadow: var(--hdb-rpc-shadow-sm);
}
.hdb-rpc-limit-banner p { margin: 0 0 1rem; font-size: .98rem; }

/* ---- Transactions table — framed, sticky header, zebra rows ---- */
.hdb-rpc-table-wrap {
	overflow-x: auto;
	margin-top: 1.5rem;
	border: 1px solid var(--hdb-rpc-border);
	border-radius: 12px;
	box-shadow: var(--hdb-rpc-shadow-sm);
}
.hdb-rpc-table { width: 100%; border-collapse: collapse; color: var(--hdb-rpc-text); }
.hdb-rpc-table th,
.hdb-rpc-table td { padding: .65rem .85rem; border-bottom: 1px solid var(--hdb-rpc-border); text-align: left; font-size: .87rem; white-space: nowrap; }
.hdb-rpc-table thead th {
	background: var(--hdb-rpc-bg-soft);
	color: var(--hdb-rpc-muted);
	font-size: .74rem;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: .03em;
	position: sticky;
	top: 0;
}
.hdb-rpc-table tbody tr:nth-child(even) { background: var(--hdb-rpc-bg-soft); }
.hdb-rpc-table tbody tr:hover { background: color-mix(in srgb, var(--hdb-rpc-primary) 8%, transparent); }
.hdb-rpc-table tbody tr:last-child td { border-bottom: none; }
.hdb-rpc-table td:last-child { font-weight: 700; color: var(--hdb-rpc-primary); }

/**
 * v1.3.2 — town picker for [hdb_rpc_compare], replacing the 4 separate
 * "Town 1"–"Town 4" <select> dropdowns. See class-hdb-rpc-shortcodes.php's
 * render_compare()/render_town_picker_script() docblocks for the full
 * story. Every checkbox has a real, visible <label> (below) — this only
 * restyles that label into a chip and visually hides the native checkbox
 * itself (NOT display:none/visibility:hidden, which would drop it from
 * the tab order and break keyboard use — an off-screen absolute position
 * keeps it focusable).
 */
.hdb-rpc-field-town-picker { flex: 1 1 100%; }
.hdb-rpc-town-chip-input {
	position: absolute;
	width: 1px;
	height: 1px;
	padding: 0;
	margin: -1px;
	overflow: hidden;
	clip: rect(0, 0, 0, 0);
	white-space: nowrap;
	border: 0;
}
.hdb-rpc-town-chips { display: flex; flex-wrap: wrap; gap: .5rem; margin-top: .5rem; }
.hdb-rpc-town-chip {
	display: inline-block;
	padding: .5rem .95rem;
	border-radius: 999px;
	border: 1.5px solid var(--hdb-rpc-border);
	background: var(--hdb-rpc-surface);
	color: var(--hdb-rpc-text);
	font-size: .87rem;
	cursor: grab;
	user-select: none;
	transition: background .15s ease, border-color .15s ease, color .15s ease, transform .1s ease;
}
.hdb-rpc-town-chip:active { cursor: grabbing; }
.hdb-rpc-town-chip:hover { border-color: var(--hdb-rpc-primary); transform: translateY(-1px); }
.hdb-rpc-town-chip-input:checked + .hdb-rpc-town-chip {
	background: var(--hdb-rpc-primary);
	border-color: var(--hdb-rpc-primary);
	color: #fff;
}
.hdb-rpc-town-chip-input:focus-visible + .hdb-rpc-town-chip {
	outline: 2px solid var(--hdb-rpc-primary);
	outline-offset: 2px;
}
.hdb-rpc-town-chip-input:disabled + .hdb-rpc-town-chip {
	opacity: .4;
	cursor: not-allowed;
}

.hdb-rpc-town-tray {
	display: flex;
	flex-wrap: wrap;
	align-items: center;
	gap: .5rem;
	min-height: 3rem;
	padding: .75rem;
	border: 2px dashed var(--hdb-rpc-border);
	border-radius: 12px;
	background: var(--hdb-rpc-bg-soft);
	margin-top: .35rem;
	transition: border-color .15s ease, background .15s ease;
}
.hdb-rpc-town-tray-placeholder { color: var(--hdb-rpc-muted); font-size: .87rem; }
.hdb-rpc-town-tray-chip {
	display: inline-flex;
	align-items: center;
	gap: .4rem;
	padding: .4rem .5rem .4rem .85rem;
	border-radius: 999px;
	background: var(--hdb-rpc-primary);
	color: #fff;
	font-size: .87rem;
	font-weight: 600;
}
.hdb-rpc-town-tray-remove {
	background: rgba(255, 255, 255, .25);
	border: none;
	border-radius: 50%;
	color: #fff;
	width: 1.3rem;
	height: 1.3rem;
	line-height: 1;
	font-size: .95rem;
	cursor: pointer;
	display: inline-flex;
	align-items: center;
	justify-content: center;
}
.hdb-rpc-town-tray-remove:hover { background: rgba(255, 255, 255, .4); }
.hdb-rpc-town-tray-count { color: var(--hdb-rpc-muted); font-size: .78rem; margin: .35rem 0 0; }

@media (max-width: 640px) {
	.hdb-rpc-form { flex-direction: column; align-items: stretch; padding: 1.15rem; }
	.hdb-rpc-field select, .hdb-rpc-field input[type="text"] { min-width: 0; width: 100%; }
	.hdb-rpc-btn { width: 100%; text-align: center; margin: 0; }
	.hdb-rpc-stats-grid { grid-template-columns: repeat(2, 1fr); }
}
