/* Bootstrap 5 with a few variables changed; everything else is stock. */
:root {
  --bs-body-font-family: "Public Sans", system-ui, sans-serif;
  --bs-body-bg: #f6f7f6;
  --bs-body-color: #1b1f1e;
  --bs-secondary-color: #545b59;
  --bs-border-color: #d3d8d6;
  --bs-border-radius: 6px;
  --bs-link-color: #0f4f48;
  --bs-link-color-rgb: 15, 79, 72;
  --bs-link-hover-color: #09342f;
  --bs-link-hover-color-rgb: 9, 52, 47;
  --accent: #0f4f48;
  --accent-hover: #0b3e38;
  /* Darker red so error text and the Delete link pass 4.5:1 on the page background. */
  --bs-danger-rgb: 176, 42, 55;
  --bs-form-invalid-color: #b02a37;
  --bs-form-invalid-border-color: #b02a37;
}

.btn-primary {
  --bs-btn-bg: var(--accent);
  --bs-btn-border-color: var(--accent);
  --bs-btn-hover-bg: var(--accent-hover);
  --bs-btn-hover-border-color: var(--accent-hover);
  --bs-btn-active-bg: var(--accent-hover);
  --bs-btn-active-border-color: var(--accent-hover);
  --bs-btn-disabled-bg: var(--accent);
  --bs-btn-disabled-border-color: var(--accent);
}

.btn-outline-secondary {
  --bs-btn-color: #2c3331;
  --bs-btn-border-color: #b9c1be;
  --bs-btn-hover-bg: #e8ecea;
  --bs-btn-hover-color: #1b1f1e;
  --bs-btn-hover-border-color: #a3aca9;
  --bs-btn-active-bg: var(--accent);
  --bs-btn-active-border-color: var(--accent);
  --bs-btn-active-color: #fff;
}

.form-control:focus, .form-select:focus, .form-check-input:focus, .btn:focus-visible, .btn-check:focus-visible + .btn {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(15, 79, 72, 0.25);
}
.form-check-input:checked { background-color: var(--accent); border-color: var(--accent); }

.skip { position: absolute; left: 8px; top: 8px; z-index: 50; background: #fff; padding: 8px 12px; }

/* ---------- App bar ---------- */

.appbar { background: var(--accent); color: #fff; }
.appbar-inner { display: flex; align-items: center; gap: 16px; min-height: 52px; max-width: 760px; }
.appbar-title { color: #fff; font-weight: 600; text-decoration: none; }
.appbar-title:hover { color: #fff; text-decoration: underline; }
.appbar-link { margin-left: auto; color: #d7e7e3; font-size: 14px; }
.appbar-link:hover { color: #fff; }
.appbar a:focus-visible { outline: 2px solid #fff; outline-offset: 2px; }
.net-status { font-size: 13px; padding: 2px 8px; border-radius: 6px; background: #f5d77a; color: #3d2e00; }

main.container { max-width: 760px; }
main:focus { outline: none; }
h1:focus { outline: none; }

/* ---------- List ---------- */

.list-group-item { padding: 12px 16px; }
.status { font-size: 13px; font-weight: 500; white-space: nowrap; }
.status-draft { color: #6b5300; }
.status-done { color: #17603a; }

/* ---------- Form ---------- */

.section {
  background: #fff;
  border: 1px solid var(--bs-border-color);
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 16px;
}
.section legend { margin-bottom: 12px; font-weight: 600; }
.form-control, .form-select { background-color: #fff; }

.condition-options { display: flex; flex-wrap: wrap; gap: 8px; }
.condition-options .btn { min-width: 84px; }
.condition-options .is-invalid + .btn { border-color: var(--bs-form-invalid-border-color); }

.followup { max-width: 320px; }

.error-summary:focus { outline: 3px solid #842029; outline-offset: 2px; }
.error-summary a { color: #842029; font-weight: 500; }

.dropzone {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  border: 1px dashed #b9c1be;
  border-radius: 8px;
  background: #fafbfa;
  transition: background-color 120ms ease, border-color 120ms ease;
}
.dropzone.is-over { background: #e6f0ee; border-color: var(--accent); }
.dropzone input:focus-visible + label { outline: 2px solid var(--accent); outline-offset: 2px; }

.photos {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 12px;
  list-style: none;
  padding: 0;
  margin: 12px 0 8px;
}
.photos:empty { display: none; }
.photo { position: relative; background: #fff; border: 1px solid var(--bs-border-color); border-radius: 6px; overflow: hidden; }
.photo img { display: block; width: 100%; height: 110px; object-fit: cover; }
.photo-meta { display: block; padding: 4px 8px 0; font-size: 12px; color: var(--bs-secondary-color); }
.photo-remove { margin: 4px 4px 6px; font-size: 12px; }

.sigpad { position: relative; }
.sigpad canvas {
  display: block;
  width: 100%;
  height: 160px;
  background: #fff;
  border: 1px solid #b9c1be;
  border-radius: 6px;
  touch-action: none;
  cursor: crosshair;
}
.sigpad::after {
  content: "";
  position: absolute;
  left: 16px; right: 16px; bottom: 36px;
  border-bottom: 1px solid #d3d8d6;
  pointer-events: none;
}
.sigpad-clear { position: absolute; top: 4px; right: 4px; }

/* ---------- Finished report ---------- */

.report { background: #fff; border: 1px solid var(--bs-border-color); border-radius: 8px; padding: 24px; }
.report-fields { display: grid; grid-template-columns: 160px 1fr; gap: 8px 16px; margin: 16px 0 0; }
.report-fields dt { font-weight: 500; color: var(--bs-secondary-color); }
.report-fields dd { margin: 0; white-space: pre-wrap; }
.report-photos { display: grid; grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); gap: 12px; }
.report-photos img { width: 100%; height: auto; border-radius: 4px; border: 1px solid var(--bs-border-color); }
.signature-image { max-width: 360px; width: 100%; height: auto; border-bottom: 1px solid #b9c1be; }
.typed-signature { font-size: 22px; font-style: italic; margin: 0 0 4px; }

@media (max-width: 575.98px) {
  .report { padding: 16px; }
  .report-fields { grid-template-columns: 1fr; gap: 2px; }
  .report-fields dd { margin-bottom: 10px; }
}

/* ---------- Print: just the report ---------- */

@media print {
  .appbar, .no-print, .skip { display: none !important; }
  body { background: #fff; }
  main.container { max-width: none; padding: 0 !important; }
  .report { border: 0; padding: 0; }
  .report-photos { grid-template-columns: repeat(3, 1fr); }
  .report-photos img { break-inside: avoid; }
  a[href^="http"]::after { content: " (" attr(href) ")"; font-size: 10px; word-break: break-all; }
}
