/* Inspections: list, new, editor, photo tiles, finalized view. Mobile first (390 px). */

.min0 { min-width: 0; }
.pre { white-space: pre-wrap; overflow-wrap: anywhere; margin: 0; }
.text-danger { color: var(--danger); }
.btn-lg { min-height: 56px; font-size: 1.05rem; }

/* Header */
.insp-title { font-size: 1.35rem; margin: 0; overflow-wrap: anywhere; }
.insp-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 6px 12px; margin: -6px 0 16px; color: var(--muted); font-size: 0.9rem; }
.start-card p { margin-bottom: 12px; }

/* List filters */
.filter-pills { display: flex; gap: 8px; overflow-x: auto; margin: 16px 0 12px; padding-bottom: 2px; scrollbar-width: none; }
.filter-pills::-webkit-scrollbar { display: none; }
.filter-pill {
  flex: none; display: inline-flex; align-items: center; min-height: 44px; padding: 6px 16px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
  color: var(--text); font-weight: 600; font-size: 0.95rem; text-decoration: none;
}
.filter-pill.active { background: var(--brand); border-color: var(--brand); color: var(--brand-contrast); }

/* New inspection */
.label-row { display: flex; align-items: center; justify-content: space-between; gap: 8px; margin-bottom: 2px; }
.field .label-row label { margin: 0; }
.label-row a { display: inline-flex; align-items: center; min-height: 44px; font-weight: 600; font-size: 0.95rem; text-decoration: none; }
.kind-pills { display: grid; grid-template-columns: 1fr 1fr; }
.kind-pills label { justify-content: center; text-align: center; min-height: 56px; border-radius: var(--radius-sm); }

/* Sticky section jump bar + upload status */
.editor-sticky { position: sticky; top: 57px; z-index: 10; background: var(--bg); margin: 0 -16px 8px; padding: 8px 16px; }
.jump-nav { display: flex; gap: 8px; }
.jump-nav a {
  flex: 1; display: flex; align-items: center; justify-content: center; gap: 6px; min-height: 44px;
  border: 1px solid var(--border); border-radius: 999px; background: var(--surface);
  color: var(--text); font-weight: 600; font-size: 0.9rem; text-decoration: none;
}
.jump-nav .count { min-width: 22px; padding: 0 6px; border-radius: 999px; background: #eef1f5; font-size: 0.8rem; text-align: center; }
.upload-status {
  margin-top: 8px; padding: 8px 12px; border-radius: var(--radius-sm);
  background: #1b2430; color: #fff; font-weight: 600; font-size: 0.9rem; text-align: center;
}
.upload-status.warn { background: var(--danger); }
.upload-status.ok { background: var(--ok); }
section[id], .finding-card { scroll-margin-top: 130px; }

.section-head { display: flex; align-items: center; justify-content: space-between; gap: 8px; }
.section-head .label, .section-head .checkbox { margin-bottom: 0; }
.err-slot:empty { display: none; }
.form-status:empty { display: none; }
.autosave-error { color: var(--danger); font-size: 0.9rem; font-weight: 600; }
.range-row { display: grid; grid-template-columns: 1fr auto 1fr; align-items: center; gap: 8px; }

/* Condition + severity pills: coloured when chosen */
.cond-pills label, .sev-pills label { flex: 1 1 auto; justify-content: center; }
.cond-pills input:checked + .cond-excellent, .cond-pills input:checked + .cond-good { background: var(--ok); border-color: var(--ok); }
.cond-pills input:checked + .cond-fair { background: var(--warn); border-color: var(--warn); }
.cond-pills input:checked + .cond-poor { background: var(--danger); border-color: var(--danger); }
.cond-pills input:checked + .cond-replace { background: #7f1d14; border-color: #7f1d14; }
.sev-pills { display: grid; grid-template-columns: 1fr 1fr; }
.sev-pills label { font-size: 0.95rem; padding: 6px 12px; }
.sev-pills input:checked + .sev-urgent { background: var(--urgent); border-color: var(--urgent); }
.sev-pills input:checked + .sev-repair_soon { background: var(--repair); border-color: var(--repair); }
.sev-pills input:checked + .sev-monitor { background: var(--monitor); border-color: var(--monitor); }
.sev-pills input:checked + .sev-info { background: var(--muted); border-color: var(--muted); }

/* Finding cards (left edge shows severity) */
.finding-card, .finding-view { border-left: 5px solid var(--border); }
.finding-card:has(input[value=urgent]:checked), .finding-view.sev-urgent { border-left-color: var(--urgent); }
.finding-card:has(input[value=repair_soon]:checked), .finding-view.sev-repair_soon { border-left-color: var(--repair); }
.finding-card:has(input[value=monitor]:checked), .finding-view.sev-monitor { border-left-color: var(--monitor); }
.finding-card:has(input[value=info]:checked), .finding-view.sev-info { border-left-color: var(--muted); }
.finding-top { display: flex; align-items: center; gap: 12px; margin-bottom: 10px; }
.finding-category { flex: 1; font-weight: 600; }
.finding-form textarea { margin-top: 10px; min-height: 80px; }
.finding-foot { display: flex; justify-content: flex-end; margin-top: 8px; }
.finding-view-head { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.finding-view .pre { margin-bottom: 4px; }

/* Add finding */
.add-finding { padding: 0; }
.add-finding > summary {
  list-style: none; display: flex; align-items: center; justify-content: center; min-height: 56px;
  color: var(--brand); font-weight: 700; font-size: 1.05rem; cursor: pointer;
}
.add-finding > summary::-webkit-details-marker { display: none; }
.add-finding[open] > summary { border-bottom: 1px solid var(--border); }
.add-finding form { padding: 16px; }
.add-photos { margin-bottom: 14px; }
.add-photos .help { margin: 6px 0 0; }
.add-errors .errorlist { margin: 0 0 12px; }

/* Camera buttons */
.camera-row { display: grid; grid-template-columns: 2fr 1fr; gap: 8px; }
.camera-row label.btn { position: relative; display: flex; margin: 0; overflow: hidden; }
.camera-btn { min-height: 52px; }
.camera-row svg { width: 22px; height: 22px; flex: none; fill: none; stroke: currentColor; stroke-width: 2; stroke-linecap: round; stroke-linejoin: round; }
.sr-file { position: absolute; width: 1px; height: 1px; opacity: 0; overflow: hidden; clip-path: inset(50%); }
.camera-row label.btn:focus-within { outline: 2px solid var(--brand); outline-offset: 2px; }

/* Photo grid + tiles */
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 6px; margin: 12px 0; }
.photo-grid:empty { display: none; }
.photo-tile { position: relative; aspect-ratio: 1; margin: 0; overflow: hidden; border-radius: var(--radius-sm); background: #e7ebf0; }
.photo-tile > a { display: block; width: 100%; height: 100%; }
.photo-tile img { display: block; width: 100%; height: 100%; object-fit: cover; }
.tile-delete {
  position: absolute; top: 4px; right: 4px; width: 40px; height: 40px; border: 0; border-radius: 50%;
  display: flex; align-items: center; justify-content: center; background: rgba(0, 0, 0, 0.6); color: #fff;
  font-size: 22px; line-height: 1; cursor: pointer;
}
.tile-overlay {
  position: absolute; inset: 0; display: flex; flex-direction: column; justify-content: flex-end; gap: 6px; padding: 6px;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.1) 65%);
  color: #fff; font-size: 0.75rem; font-weight: 700; line-height: 1.25;
}
.tile-bar { height: 6px; border-radius: 3px; background: rgba(255, 255, 255, 0.35); overflow: hidden; }
.tile-bar i { display: block; width: 0; height: 100%; background: #fff; transition: width 0.2s; }
.photo-tile.is-failed .tile-overlay { justify-content: center; align-items: center; text-align: center; background: rgba(160, 40, 28, 0.85); }
.tile-actions { display: flex; gap: 6px; }
.tile-btn {
  min-height: 36px; min-width: 36px; padding: 4px 10px; border: 1px solid rgba(255, 255, 255, 0.8); border-radius: 999px;
  background: transparent; color: #fff; font: inherit; font-weight: 700; cursor: pointer;
}
.tile-retry { background: #fff; color: var(--danger); }

/* Cover photo */
.cover-block { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }
.cover-block > .label { margin-bottom: 8px; }
.cover-img { position: relative; aspect-ratio: 4 / 3; margin-bottom: 12px; overflow: hidden; border-radius: var(--radius-sm); background: #e7ebf0; }
.cover-img img { width: 100%; height: 100%; object-fit: cover; display: block; }
.cover-block .photo-grid { grid-template-columns: 1fr; }
.cover-block .photo-tile { aspect-ratio: 4 / 3; }
.loose-photos { margin-top: 16px; padding-top: 16px; border-top: 1px solid var(--border); }

/* Finalize */
.finalize-box { margin-top: 8px; scroll-margin-top: 130px; }
.finalize-box h2 { margin-bottom: 6px; }
.finalize-errors { margin: 6px 0 0; padding-left: 20px; }
.when-busy { display: none; }
.htmx-request .when-busy { display: inline; }
.htmx-request .when-idle { display: none; }

/* Finalized view */
.report-card { padding: 0; overflow: hidden; }
.report-card .kv { padding: 16px; }
.report-cover { display: block; width: 100%; aspect-ratio: 16 / 9; object-fit: cover; }
.report-actions .btn { width: 100%; }
