/*
Shared styling for the SOS admin pages (login, listing, map views).
Deployed to public_html/css/admin.css.

Deliberately one plain stylesheet with no build step and no external
requests, to match how these pages are maintained and deployed.
*/

:root {
	--bg: #f4f6f8;
	--surface: #ffffff;
	--surface-alt: #fafbfc;
	--border: #dfe3e8;
	--border-strong: #c9cfd6;
	--text: #1b1f24;
	--muted: #667180;
	--accent: #b91c1c;
	--accent-hover: #991b1b;
	--accent-soft: #fdeceb;
	--link: #1d4ed8;
	--focus: #2563eb;
	--radius: 6px;
	--shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
}

@media (prefers-color-scheme: dark) {
	:root {
		--bg: #0f1215;
		--surface: #171b20;
		--surface-alt: #1c2127;
		--border: #2b3239;
		--border-strong: #3a434c;
		--text: #e6e9ed;
		--muted: #98a2ae;
		--accent: #ef4444;
		--accent-hover: #f87171;
		--accent-soft: #2a1618;
		--link: #7ea2ff;
		--focus: #7ea2ff;
		--shadow: 0 1px 2px rgba(0, 0, 0, .4);
	}
}

* { box-sizing: border-box; }

body {
	margin: 0;
	background: var(--bg);
	color: var(--text);
	font: 15px/1.5 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto,
		"Helvetica Neue", Arial, sans-serif;
	-webkit-text-size-adjust: 100%;
}

a { color: var(--link); }

/* ---------- top bar ---------- */

.topbar {
	display: flex;
	align-items: center;
	gap: 12px;
	flex-wrap: wrap;
	padding: 12px 20px;
	background: var(--surface);
	border-bottom: 1px solid var(--border);
	box-shadow: var(--shadow);
	position: sticky;
	top: 0;
	z-index: 20;
}

.topbar .brand {
	display: flex;
	align-items: baseline;
	gap: 8px;
	font-size: 16px;
	font-weight: 600;
	margin: 0;
}

.topbar .brand .mark {
	color: var(--accent);
	font-weight: 700;
	letter-spacing: .04em;
}

.topbar .spacer { flex: 1 1 auto; }

.topbar .who {
	color: var(--muted);
	font-size: 13px;
}

/* ---------- layout ---------- */

.page {
	max-width: 1400px;
	margin: 0 auto;
	padding: 20px;
}

.card {
	background: var(--surface);
	border: 1px solid var(--border);
	border-radius: var(--radius);
	box-shadow: var(--shadow);
}

.toolbar {
	padding: 16px;
	margin-bottom: 16px;
}

.toolbar-row {
	display: flex;
	flex-wrap: wrap;
	gap: 16px;
	align-items: flex-end;
}

.field { display: flex; flex-direction: column; gap: 6px; }

.field > label,
.field-label {
	font-size: 12px;
	font-weight: 600;
	text-transform: uppercase;
	letter-spacing: .05em;
	color: var(--muted);
}

input[type="text"],
input[type="password"],
input[type="datetime"],
input[type="datetime-local"] {
	font: inherit;
	color: var(--text);
	background: var(--surface);
	border: 1px solid var(--border-strong);
	border-radius: var(--radius);
	padding: 8px 10px;
	min-width: 220px;
}

input:focus-visible,
button:focus-visible,
a:focus-visible {
	outline: 2px solid var(--focus);
	outline-offset: 1px;
}

/* keyword checkboxes as pills */

.chips { display: flex; flex-wrap: wrap; gap: 8px; }

.chip {
	display: inline-flex;
	align-items: center;
	gap: 7px;
	padding: 7px 12px;
	border: 1px solid var(--border-strong);
	border-radius: 999px;
	background: var(--surface);
	cursor: pointer;
	user-select: none;
	font-size: 14px;
}

.chip:hover { border-color: var(--accent); }
.chip input { margin: 0; accent-color: var(--accent); }
.chip:has(input:checked) {
	background: var(--accent-soft);
	border-color: var(--accent);
	font-weight: 600;
}

/* ---------- buttons ---------- */

.btn,
button,
input[type="submit"] {
	font: inherit;
	font-weight: 600;
	padding: 8px 14px;
	border-radius: var(--radius);
	border: 1px solid var(--border-strong);
	background: var(--surface);
	color: var(--text);
	cursor: pointer;
	white-space: nowrap;
}

.btn:hover,
button:hover,
input[type="submit"]:hover { border-color: var(--accent); color: var(--accent); }

.btn-primary,
input[type="submit"] {
	background: var(--accent);
	border-color: var(--accent);
	color: #fff;
}

.btn-primary:hover,
input[type="submit"]:hover {
	background: var(--accent-hover);
	border-color: var(--accent-hover);
	color: #fff;
}

.btn-row { display: flex; flex-wrap: wrap; gap: 8px; }

/* ---------- table ---------- */

.table-wrap {
	overflow-x: auto;
	border: 1px solid var(--border);
	border-radius: var(--radius);
	background: var(--surface);
	box-shadow: var(--shadow);
}

table#sos_list {
	width: 100%;
	border-collapse: collapse;
	font-size: 14px;
	/* neutralise the legacy border="1" attribute kept for the Excel export */
	border: 0;
}

table#sos_list th,
table#sos_list td {
	border: 0;
	border-bottom: 1px solid var(--border);
	padding: 10px 12px;
	text-align: left;
	vertical-align: top;
}

table#sos_list th {
	position: sticky;
	top: 0;
	z-index: 1;
	background: var(--surface-alt);
	font-size: 11px;
	font-weight: 700;
	text-transform: uppercase;
	letter-spacing: .06em;
	color: var(--muted);
	white-space: nowrap;
	border-bottom: 1px solid var(--border-strong);
}

table#sos_list tr:nth-child(even) td { background: var(--surface-alt); }
table#sos_list tr:hover td { background: var(--accent-soft); }

/* column treatments, applied by class from data.php */
.c-id { color: var(--muted); font-variant-numeric: tabular-nums; }
.c-name { font-weight: 600; }
.c-coord {
	font-family: ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
	font-size: 13px;
	font-variant-numeric: tabular-nums;
	white-space: nowrap;
}
.c-msg { max-width: 520px; word-wrap: break-word; }
.c-addr { max-width: 300px; word-wrap: break-word; color: var(--muted); }
.c-time { white-space: nowrap; font-variant-numeric: tabular-nums; color: var(--muted); }

.map-link {
	display: inline-block;
	padding: 4px 10px;
	border: 1px solid var(--border-strong);
	border-radius: var(--radius);
	text-decoration: none;
	font-size: 13px;
	font-weight: 600;
	white-space: nowrap;
}
.map-link:hover { border-color: var(--accent); color: var(--accent); }

.empty {
	padding: 40px 20px;
	text-align: center;
	color: var(--muted);
}

/* ---------- pagination ---------- */

.pagination {
	display: flex;
	flex-wrap: wrap;
	gap: 6px;
	justify-content: center;
	padding: 16px 0 4px;
}

.pagination a {
	min-width: 36px;
	padding: 6px 10px;
	text-align: center;
	border: 1px solid var(--border-strong);
	border-radius: var(--radius);
	background: var(--surface);
	text-decoration: none;
	font-size: 14px;
	font-weight: 600;
}

.pagination a:hover { border-color: var(--accent); color: var(--accent); }

.pagination a.is-current {
	background: var(--accent);
	border-color: var(--accent);
	color: #fff;
	cursor: default;
}

.count-note {
	text-align: center;
	color: var(--muted);
	font-size: 13px;
	padding-top: 4px;
}

/* ---------- login ---------- */

.login-wrap {
	min-height: 100vh;
	display: flex;
	align-items: center;
	justify-content: center;
	padding: 24px;
}

.login-card {
	width: 100%;
	max-width: 380px;
	padding: 28px;
}

.login-card .logo {
	display: block;
	max-width: 190px;
	height: auto;
	margin: 0 auto 20px;
}

.login-card h1 {
	margin: 0 0 4px;
	font-size: 19px;
	text-align: center;
}

.login-card .sub {
	margin: 0 0 22px;
	text-align: center;
	color: var(--muted);
	font-size: 13px;
}

.login-card .field { margin-bottom: 14px; }
.login-card input { width: 100%; min-width: 0; }
.login-card input[type="submit"] { width: 100%; margin-top: 6px; padding: 10px; }

.error {
	background: var(--accent-soft);
	border: 1px solid var(--accent);
	color: var(--accent);
	border-radius: var(--radius);
	padding: 9px 12px;
	margin: 0 0 16px;
	font-size: 13px;
	font-weight: 600;
}

.footnote {
	text-align: center;
	color: var(--muted);
	font-size: 12px;
	padding: 18px 0;
}

.footnote a { color: var(--muted); }

/* ---------- map pages ---------- */

body.map-page { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
body.map-page .topbar { position: static; }
body.map-page .map-controls {
	padding: 12px 20px;
	background: var(--surface);
	border-bottom: 1px solid var(--border);
}
body.map-page #map { flex: 1 1 auto; min-height: 0; height: auto; }

/* ---------- map cluster popup (fragment from data1.php) ---------- */

/*
 * Google renders the infowindow on its own white surface in both colour
 * schemes, so this content is pinned to light colours rather than following
 * the theme variables.
 *
 * Every table rule here is written as `.sos-popup table#sos_list ...` on
 * purpose: the listing rules above are keyed on the #sos_list id, and an id
 * beats a class, so plain `.sos-popup td` selectors lose to them and the dark
 * zebra striping bleeds through.
 */
.sos-popup {
	max-width: min(72vw, 820px);
	max-height: 46vh;
	overflow: auto;
	color: #1b1f24;
	font-size: 13px;
}

.sos-popup .popup-title {
	margin: 0 0 8px;
	font-size: 14px;
	color: #1b1f24;
}

.sos-popup table#sos_list {
	width: 100%;
	border-collapse: collapse;
	background: #ffffff;
}

.sos-popup table#sos_list th,
.sos-popup table#sos_list td {
	border: 0;
	border-bottom: 1px solid #e3e6ea;
	padding: 6px 8px;
	text-align: left;
	vertical-align: top;
	background: #ffffff;
	color: #1b1f24;
}

.sos-popup table#sos_list th {
	background: #f4f6f8;
	font-size: 10px;
	text-transform: uppercase;
	letter-spacing: .05em;
	color: #667180;
	white-space: nowrap;
}

.sos-popup table#sos_list tr:nth-child(even) td { background: #fafbfc; }
.sos-popup table#sos_list tr:hover td { background: #f1f4f7; }

.sos-popup table#sos_list td.c-msg { max-width: 220px; }
.sos-popup table#sos_list td.c-addr { max-width: 190px; color: #667180; }
.sos-popup table#sos_list td.c-coord { white-space: nowrap; }
.sos-popup table#sos_list td.c-name { color: #1b1f24; }

.sos-popup .map-link {
	background: #ffffff;
	border-color: #c9cfd6;
	color: #1d4ed8;
}

.sos-popup button {
	margin-top: 10px;
	background: #ffffff;
	border-color: #c9cfd6;
	color: #1b1f24;
}
.sos-popup button:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- narrow screens ---------- */

@media (max-width: 700px) {
	.page { padding: 12px; }
	.topbar { padding: 10px 12px; }
	.toolbar-row { flex-direction: column; align-items: stretch; }
	input[type="text"],
	input[type="password"],
	input[type="datetime"],
	input[type="datetime-local"] { min-width: 0; width: 100%; }
	.btn-row .btn, .btn-row button { flex: 1 1 auto; }
	table#sos_list { font-size: 13px; }
	table#sos_list th, table#sos_list td { padding: 8px; }
}
