/* pamgis: one stylesheet, no framework. */

:root {
  --fg: #1d2330;
  --muted: #5f6b7a;
  --line: #d9dee5;
  --bg: #f4f6f9;
  --card: #fff;
  --accent: #1565c0;
  --danger: #c62828;
  /* asset status colours; app.js reads these for the map markers */
  --st-active: #2e7d32;
  --st-vacant: #607d8b;
  --st-maintenance: #ef6c00;
  --st-degraded: #c62828;
  font-family: system-ui, "Segoe UI", Roboto, "Noto Sans", Arial, sans-serif;
  color: var(--fg);
}
* { box-sizing: border-box; }
[hidden] { display: none !important; }
body { margin: 0; background: var(--bg); font-size: 15px; line-height: 1.45; }
h1 { font-size: 20px; margin: 0; }
h2 { font-size: 17px; margin: 0 0 8px; }
a { color: var(--accent); }
input, select, textarea, button { font: inherit; color: inherit; }
input:not(.inline), select:not(.status), textarea:not(.inline) {
  padding: 6px 8px; border: 1px solid #c3cad3; border-radius: 4px; background: #fff;
}
:focus-visible { outline: 2px solid var(--accent); outline-offset: 1px; }
.hint, .muted { color: var(--muted); font-size: 13px; }
.hint { margin: 4px 0; }

/* buttons */
button, .btn {
  display: inline-block; padding: 6px 12px; border: 1px solid #c3cad3; border-radius: 4px;
  background: #fff; color: var(--fg); text-decoration: none; cursor: pointer; white-space: nowrap;
}
button:hover, .btn:hover { background: #eef2f7; }
.btn.primary { background: var(--accent); border-color: var(--accent); color: #fff; }
.btn.primary:hover { background: #0d47a1; }
.btn.danger { color: var(--danger); border-color: #e3b4b4; }
.btn.danger:hover { background: #fdecea; }

/* generic table + dialog (shared with the folder/equipment sections) */
table { border-collapse: collapse; width: 100%; background: var(--card); }
th, td { padding: 6px 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
th { font-size: 12px; font-weight: 600; color: var(--muted); }
dialog { border: 0; border-radius: 8px; padding: 0; box-shadow: 0 10px 40px rgb(0 0 0 / .35); }
dialog::backdrop { background: rgb(0 0 0 / .6); }

/* status chips: .st-* sets --c */
.st-active { --c: var(--st-active); }
.st-vacant { --c: var(--st-vacant); }
.st-maintenance { --c: var(--st-maintenance); }
.st-degraded { --c: var(--st-degraded); }
.chip {
  display: inline-block; padding: 1px 8px; border-radius: 999px; font-size: 12px;
  color: #fff; background: var(--c, #777); white-space: nowrap;
}

/* error toast */
#toast {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%); z-index: 2000;
  max-width: min(560px, 92vw); padding: 10px 16px; border-radius: 6px;
  background: #b71c1c; color: #fff; box-shadow: 0 4px 16px rgb(0 0 0 / .3);
}

/* "/" split view */
.split { display: grid; grid-template-columns: minmax(320px, 420px) 1fr; height: 100vh; height: 100dvh; }
.pane { display: flex; flex-direction: column; min-height: 0; background: var(--card); border-right: 1px solid var(--line); }
.pane-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; padding: 12px 16px; border-bottom: 1px solid var(--line); }
.filters { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1.3fr) minmax(0, .9fr); gap: 6px; padding: 10px 16px; border-bottom: 1px solid var(--line); }
.filters input[type=search] { grid-column: 1 / -1; }
.filters select { min-width: 0; }
.asset-list { flex: 1; overflow-y: auto; }
.count { margin: 6px 16px; color: var(--muted); font-size: 13px; }
.empty { margin: 16px; color: var(--muted); }
.asset-row {
  display: flex; justify-content: space-between; gap: 8px; padding: 8px 16px;
  border-bottom: 1px solid var(--line); color: inherit; text-decoration: none;
}
.asset-row:hover, .asset-row.hl { background: #e8f0fe; }
.asset-row:focus-visible { outline: none; background: #e8f0fe; box-shadow: inset 4px 0 0 var(--accent); }
.row-main { display: flex; flex-direction: column; flex: 1; min-width: 0; }
.row-main small { color: var(--muted); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.row-side { flex-shrink: 0; display: flex; flex-direction: column; align-items: flex-end; gap: 2px; }
.map { height: 100%; min-height: 300px; }
body:has(#asset-form) #map.leaflet-grab { cursor: crosshair; }

/* add form (in #panel) */
.asset-form { margin: 10px 16px; padding: 12px; border: 1px solid var(--line); border-radius: 8px; background: #f7faff; }
.asset-form label { display: block; margin-top: 8px; font-size: 13px; color: var(--muted); }
.asset-form label input, .asset-form label select { display: block; width: 100%; margin-top: 2px; }
.asset-form .two { display: grid; grid-template-columns: 1fr 1fr; gap: 8px; }
.asset-form .actions { display: flex; gap: 8px; margin-top: 12px; }

/* "/assets/{id}" detail */
.topbar { padding: 10px 24px; background: var(--card); border-bottom: 1px solid var(--line); }
.topbar a { text-decoration: none; }
.detail { max-width: 1200px; margin: 0 auto; padding: 16px 24px 48px; }
.detail > section { margin-top: 28px; }
.detail-top { display: grid; grid-template-columns: minmax(0, 1fr) 380px; gap: 24px; align-items: start; }
.asset-header { background: var(--card); border: 1px solid var(--line); border-radius: 8px; padding: 12px 16px; }
.title-row { display: flex; flex-wrap: wrap; gap: 8px 12px; align-items: center; margin-bottom: 8px; }
.fields { display: grid; grid-template-columns: 1fr 1fr; gap: 2px 16px; }
.field { display: flex; flex-direction: column; }
.field > span { font-size: 12px; color: var(--muted); padding-left: 7px; }
.field.wide { grid-column: 1 / -1; }
#f-coords { display: block; padding: 4px 7px; font-variant-numeric: tabular-nums; }
.asset-header .btn.danger { margin-top: 8px; }
.inset { height: 340px; border: 1px solid var(--line); border-radius: 8px; }

/* inline edit: looks like text until hovered/focused; flashes green when a save lands */
.inline {
  width: 100%; padding: 4px 6px; border: 1px solid transparent; border-radius: 4px;
  background: transparent; transition: background-color 1.2s;
}
textarea.inline { resize: vertical; field-sizing: content; min-height: 2.4em; }
.inline::placeholder { color: #a0a8b3; }
.inline:hover { border-color: var(--line); background: #fff; }
.inline:focus { border-color: var(--accent); background: #fff; outline: 2px solid rgb(21 101 192 / .2); outline-offset: 0; }
.inline.htmx-added { background: #d7f5dd; transition: none; }
.inline.invalid { border-color: var(--danger); background: #fdecea; }
.inline.title { flex: 1 1 280px; min-width: 0; font-size: 22px; font-weight: 600; }
select.status {
  padding: 5px 8px; border: 1px solid var(--c); border-radius: 999px; font-weight: 600;
  color: var(--c); background: #fff; transition: background-color 1.2s;
}
select.status.htmx-added { background: #d7f5dd; transition: none; }

@media (max-width: 860px) {
  .detail-top { grid-template-columns: minmax(0, 1fr); }
  .detail { padding: 12px; }
}
@media (max-width: 760px) {
  .split { grid-template-columns: minmax(0, 1fr); grid-template-rows: 40vh minmax(0, 1fr); }
  .map { order: -1; }
  .pane { border-right: 0; }
  .fields { grid-template-columns: 1fr; }
  .inline.title { font-size: 18px; }
}
@media print {
  .topbar, .userbar, .build, #toast { display: none; }
}

/* language toggle: bottom-right so it never covers the map controls or the page header */

/* auth: login/settings cards, user bar, read-only lock for viewers */
.card { max-width: 560px; margin: 24px auto; padding: 20px 24px; background: var(--card); border: 1px solid var(--line); border-radius: 8px; }
.card.login { max-width: 380px; margin-top: 12vh; }
.card h1 { margin-bottom: 12px; }
.card h2 { margin-top: 24px; }
.stack { display: flex; flex-direction: column; gap: 10px; }
.stack label { display: flex; flex-direction: column; gap: 3px; font-size: 13px; color: var(--muted); }
.stack button { align-self: flex-start; }
.error { color: var(--danger); margin: 0 0 8px; }
.notice { color: var(--st-active); margin: 0 0 8px; }
.settings .actions { white-space: nowrap; }
.settings tr.disabled td { color: var(--muted); }
.settings .actions .btn { margin-right: 4px; }
.userbar { display: flex; align-items: center; gap: 8px; padding: 8px 16px; border-top: 1px solid var(--line); font-size: 13px; }
.topbar { display: flex; align-items: center; justify-content: space-between; gap: 12px; }
.topbar .userbar { border: 0; padding: 0; }
.userbar .avatar { width: 28px; height: 28px; border-radius: 50%; background: var(--accent); color: #fff; display: grid; place-items: center; font-weight: 600; text-transform: uppercase; }
.userbar .who { display: flex; flex-direction: column; line-height: 1.2; flex: 1; min-width: 0; }
.userbar .who a { text-decoration: none; color: var(--fg); font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.userbar .who small { color: var(--muted); }
.userbar form { margin: 0; }
.btn.small { padding: 3px 8px; font-size: 13px; }
/* viewer role: the server already rejects writes; this just hides the controls that would be refused */
body.viewer .btn.primary, body.viewer .btn.danger, body.viewer [hx-delete], body.viewer [hx-post], body.viewer form[hx-post],
body.viewer .dropzone, body.viewer .item-add, body.viewer .landing-actions, body.viewer #inset-hint { display: none !important; }
body.viewer [hx-patch] { pointer-events: none; }
body.viewer input[hx-patch], body.viewer textarea[hx-patch], body.viewer select[hx-patch] { border-color: transparent; background: transparent; appearance: none; }

/* depreciation */
.depreciation { margin-top: 24px; }
.dep-head { display: flex; align-items: center; justify-content: space-between; gap: 12px; flex-wrap: wrap; margin-bottom: 8px; }
.dep-controls { display: flex; align-items: center; gap: 12px; }
.dep-controls .years { width: 64px; }
.depreciation td.num, .depreciation th.num { text-align: right; white-space: nowrap; font-variant-numeric: tabular-nums; }
.card.wide { max-width: 1100px; }

/* campuses */
.pane-head { flex-direction: column; align-items: stretch; gap: 6px; padding: 10px 16px; }
.head-row { display: flex; align-items: center; justify-content: space-between; gap: 6px; flex-wrap: nowrap; }
.pane-head h1 { overflow: hidden; text-overflow: ellipsis; }
/* native dropdown: <details class="menu"><summary class="btn">...</summary><div>links</div></details> */
.menu { position: relative; }
.menu > summary { list-style: none; cursor: pointer; }
.menu > summary::-webkit-details-marker { display: none; }
.menu > div { position: absolute; right: 0; top: calc(100% + 4px); z-index: 1200; min-width: 180px; padding: 4px 0;
  background: var(--card); border: 1px solid var(--line); border-radius: 6px; box-shadow: 0 6px 20px rgb(0 0 0 / .15); }
.menu > div a { display: block; padding: 6px 12px; color: var(--fg); text-decoration: none; white-space: nowrap; }
.menu > div a:hover { background: #eef2f7; }
.head-actions { display: flex; gap: 6px; flex-wrap: nowrap; }
.pane-head h1 { white-space: nowrap; }
.pane-head .btn { white-space: nowrap; }
.pane .userbar { margin-top: auto; }
.pane .build { padding: 0 16px 6px; font-size: 11px; text-align: right; }
.campus-label { background: rgb(255 255 255 / .75); border: 0; box-shadow: none; color: #4a148c; font-weight: 600; font-size: 12px; padding: 1px 6px; }
.campus-label::before { display: none; }
.campus-popup .popup-actions { display: flex; flex-wrap: wrap; gap: 4px; margin-top: 8px; }
.campus-popup .btn { padding: 3px 8px; font-size: 12px; }
.leaflet-pm-toolbar { display: none; } /* draw/edit are driven from our own buttons */
.card.login .build { margin-top: 16px; font-size: 12px; text-align: right; }
