/* Artwork Catalog portal — Phase 1 faceted search (task 9.1).
 *
 * Small, self-contained stylesheet. The palette is inspired by the
 * Kinetiq/Interplas POC (navy / red / blue-gray) as a VISUAL reference only —
 * this is a clean server-rendered UI, not the POC wired in as a live frontend.
 */

:root {
  --navy: #0F1A2D;
  --red: #E02B2B;
  --gray: #5A636E;
  --bluegray: #8FA2B5;
  --offwhite: #F2F4F7;
  --white: #FFFFFF;
  --line: #E2E7EE;
  --sans: -apple-system, "Segoe UI", Helvetica, Arial, sans-serif;
  --mono: "IBM Plex Mono", Consolas, monospace;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
  background: var(--offwhite);
  color: var(--navy);
  font-family: var(--sans);
  font-size: 14.5px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

/* ---------- header / internal-only banner ---------- */
.brandline { height: 4px; background: var(--red); }

.topbar {
  background: var(--white);
  border-bottom: 1px solid var(--line);
  padding: 14px 32px;
  display: flex;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
}
.topbar .product { font-weight: 800; font-size: 19px; letter-spacing: -0.01em; }
.topbar .product span { color: var(--red); }
.topbar .tag { font-size: 11.5px; color: var(--gray); }

.internal-banner {
  background: var(--navy);
  color: var(--white);
  font-family: var(--mono);
  font-size: 11.5px;
  letter-spacing: 0.04em;
  padding: 7px 32px;
  text-align: center;
}
.internal-banner strong { color: #fff; }

/* ---------- layout ---------- */
.wrap { max-width: 1240px; margin: 24px auto 40px; padding: 0 28px; }
/* Architecture page renders the wide D3 diagram; widen only that page's
   wrapper (additive modifier) so the SVG has room for legible link labels. */
.wrap-wide { max-width: 1500px; }
.panel {
  background: var(--white);
  border: 1px solid var(--line);
  border-radius: 10px;
  padding: 22px 24px;
  box-shadow: 0 1px 3px rgba(15, 26, 45, 0.06);
}
.panel + .panel { margin-top: 20px; }
.panel h2 { font-size: 15px; font-weight: 800; margin-bottom: 14px; }

/* ---------- filter form ---------- */
.filter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(190px, 1fr));
  gap: 14px 16px;
}
.field { display: flex; flex-direction: column; gap: 4px; }
.field label {
  font-size: 10.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--bluegray);
}
.field input, .field select {
  border: 1px solid var(--line);
  border-radius: 7px;
  padding: 9px 11px;
  font-size: 14px;
  font-family: var(--sans);
  color: var(--navy);
  background: var(--white);
  width: 100%;
}
.field input:focus, .field select:focus {
  outline: 2px solid var(--bluegray);
  outline-offset: 1px;
  border-color: var(--navy);
}
.field .hint { font-size: 10.5px; color: var(--gray); }

.form-actions { display: flex; gap: 10px; margin-top: 18px; align-items: center; }
.btn {
  border: 0;
  border-radius: 7px;
  font-family: var(--sans);
  font-weight: 700;
  font-size: 13.5px;
  letter-spacing: 0.03em;
  padding: 11px 26px;
  cursor: pointer;
  text-transform: uppercase;
  transition: background 0.15s;
}
.btn-primary { background: var(--red); color: #fff; }
.btn-primary:hover { background: #C42121; }
.btn-secondary { background: var(--offwhite); color: var(--navy); border: 1px solid var(--line); }
.btn-secondary:hover { border-color: var(--navy); }
.htmx-indicator { opacity: 0; transition: opacity 0.2s; font-size: 12px; color: var(--gray); }
.htmx-request .htmx-indicator, .htmx-request.htmx-indicator { opacity: 1; }

/* ---------- results ---------- */
.result-meta {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  flex-wrap: wrap;
  gap: 6px;
  margin-bottom: 12px;
}
.result-meta .count {
  font-size: 12.5px;
  font-weight: 600;
  color: var(--gray);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

.result-row {
  display: grid;
  grid-template-columns: 1.6fr 1fr 1fr 1.2fr 1fr auto;
  gap: 12px;
  align-items: center;
  padding: 12px 8px;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
}
.result-row:last-child { border-bottom: 0; }
.result-head {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--bluegray);
  border-bottom: 2px solid var(--line);
}
.result-row .cnum { font-family: var(--mono); font-weight: 600; }
.result-row .muted { color: var(--bluegray); }
.result-row a.detail {
  color: var(--red);
  font-weight: 700;
  text-decoration: none;
  font-size: 12.5px;
}
.result-row a.detail:hover { text-decoration: underline; }

/* ---------- empty / error states ---------- */
.empty-state, .error-state {
  padding: 34px 20px;
  text-align: center;
  border-radius: 8px;
}
.empty-state {
  background: var(--offwhite);
  border: 1px dashed var(--line);
  color: var(--gray);
}
.empty-state .big { font-size: 16px; font-weight: 700; color: var(--navy); margin-bottom: 4px; }
.error-state {
  background: #FCEDED;
  border: 1px solid var(--red);
  color: #8A1B1B;
  font-weight: 600;
}

/* ---------- pagination ---------- */
.pagination {
  display: flex;
  gap: 10px;
  align-items: center;
  margin-top: 18px;
  flex-wrap: wrap;
}
.pagination .page-info { font-size: 12.5px; color: var(--gray); }
.pagination button {
  border: 1px solid var(--line);
  background: var(--white);
  border-radius: 7px;
  padding: 8px 16px;
  font-family: var(--sans);
  font-weight: 600;
  font-size: 12.5px;
  color: var(--navy);
  cursor: pointer;
}
.pagination button:hover:not(:disabled) { border-color: var(--navy); }
.pagination button:disabled { color: var(--bluegray); cursor: not-allowed; opacity: 0.6; }

/* ---------- job/file detail view (task 9.2) ---------- */
.detail-breadcrumb { margin: 4px 0 16px; }
.detail-breadcrumb a {
  color: var(--red);
  font-weight: 700;
  font-size: 12.5px;
  text-decoration: none;
}
.detail-breadcrumb a:hover { text-decoration: underline; }

.detail-headline {
  display: flex;
  align-items: baseline;
  gap: 14px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}
.detail-headline .cnum-title {
  font-family: var(--mono);
  font-size: 22px;
  font-weight: 800;
  letter-spacing: -0.01em;
  margin: 0;
}
.detail-headline .sub { font-size: 15px; color: var(--gray); font-weight: 600; }

.detail-facts {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 12px 20px;
}
.detail-facts .fact { display: flex; flex-direction: column; gap: 2px; }
.detail-facts .fact .k {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--bluegray);
}
.detail-facts .fact .v { font-size: 14px; color: var(--navy); }
.detail-facts .muted { color: var(--bluegray); }

.panel-note { font-size: 12px; color: var(--gray); margin-bottom: 14px; }
.empty-inline {
  font-size: 13px;
  color: var(--gray);
  padding: 12px 4px;
  font-style: italic;
}

/* provenance table */
.prov-table { display: flex; flex-direction: column; }
.prov-row {
  display: grid;
  grid-template-columns: 1.2fr 1.4fr 2fr;
  gap: 14px;
  padding: 10px 6px;
  border-bottom: 1px solid var(--line);
  align-items: center;
  font-size: 13.5px;
}
.prov-row:last-child { border-bottom: 0; }
.prov-head {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--bluegray);
  border-bottom: 2px solid var(--line);
}
.prov-field { font-family: var(--mono); font-weight: 600; }
.prov-sources { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; }

.src-tag {
  display: inline-flex;
  align-items: baseline;
  gap: 5px;
  font-family: var(--mono);
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 0.04em;
  padding: 3px 8px;
  border-radius: 5px;
  background: var(--offwhite);
  border: 1px solid var(--line);
  color: var(--navy);
}
.src-tag em { font-style: normal; font-weight: 600; color: var(--gray); }
.src-file { border-color: #B7C6D8; background: #EEF3F8; }
.src-meta { border-color: #C6BEE0; background: #F1EEF9; }
.src-proof { border-color: #C9DEC2; background: #EFF6EC; }
.src-uncommitted {
  font-size: 10.5px;
  font-weight: 700;
  color: var(--red);
  text-transform: uppercase;
  letter-spacing: 0.06em;
}

/* files + provenance path */
.file-card {
  border: 1px solid var(--line);
  border-radius: 8px;
  padding: 14px 16px;
  margin-bottom: 12px;
}
.file-card:last-child { margin-bottom: 0; }
.file-missing { border-color: var(--red); background: #FCEDED; }
.file-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 12px;
  flex-wrap: wrap;
  margin-bottom: 10px;
}
.file-name { font-weight: 700; font-size: 14.5px; word-break: break-all; }
.file-meta { display: flex; gap: 6px; flex-wrap: wrap; }
.chip {
  font-size: 11px;
  font-family: var(--mono);
  color: var(--gray);
  background: var(--offwhite);
  border: 1px solid var(--line);
  border-radius: 5px;
  padding: 2px 8px;
}
.chip-missing { color: #8A1B1B; border-color: var(--red); background: #fff; font-weight: 700; }

.file-path-row {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}
.file-path-row .path-label {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: var(--bluegray);
  width: 100%;
}
.path-input {
  flex: 1 1 320px;
  border: 1px solid var(--line);
  border-radius: 6px;
  padding: 8px 10px;
  font-family: var(--mono);
  font-size: 12px;
  color: var(--navy);
  background: var(--white);
}
.path-input:focus { outline: 2px solid var(--bluegray); outline-offset: 1px; }
.path-reveal {
  color: var(--red);
  font-weight: 700;
  font-size: 12px;
  text-decoration: none;
  white-space: nowrap;
}
.path-reveal:hover { text-decoration: underline; }
.path-open {
  color: var(--red);
  font-weight: 700;
  font-size: 12px;
  text-decoration: none;
  white-space: nowrap;
}
.path-open:hover { text-decoration: underline; }
.path-open-missing {
  color: var(--bluegray);
  cursor: not-allowed;
  text-decoration: none;
}

/* App version footer */
.appfoot {
  margin: 28px 0 18px;
  padding: 10px 16px;
  text-align: center;
  font-size: 12px;
  color: #6b7a8d;
  border-top: 1px solid #e3e8ef;
}
.appfoot .ver {
  font-weight: 600;
  color: #0047AB;
}

/* ---- Customer name (editable) + source badge (customer-name refinement) ---- */
.cust-badge {
  display: inline-block;
  margin-left: 8px;
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  vertical-align: middle;
}
.cust-badge-scan   { background: #e6eff7; color: #2b5a83; }
.cust-badge-manual { background: #fdf0d9; color: #8a5a12; }
.cust-badge-odoo   { background: #e3f5e6; color: #1f6b34; }

.customer-block {
  margin: 12px 0 16px;
  padding: 12px 14px;
  background: #fafbfc;
  border: 1px solid #e6e9ee;
  border-radius: 8px;
}
.customer-block .fact { display: flex; flex-direction: column; gap: 2px; margin-bottom: 10px; }
.customer-block .fact .k {
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--bluegray);
}
.customer-block .fact .v { font-size: 14px; color: var(--navy); }
.customer-edit .k {
  display: block;
  font-size: 10px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--bluegray);
  margin-bottom: 4px;
}
.customer-edit-row { display: flex; gap: 8px; align-items: center; }
.customer-input {
  flex: 1;
  padding: 6px 10px;
  font-size: 14px;
  border: 1px solid #ccd2da;
  border-radius: 6px;
}
.customer-note { margin-top: 8px; margin-bottom: 0; }

/* Version badge in the top bar (next to the product name) */
.topbar .product .version-badge {
  display: inline-block;
  margin-left: 10px;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.4;
  color: #ffffff;
  background: rgba(255, 255, 255, 0.18);
  border: 1px solid rgba(255, 255, 255, 0.35);
  border-radius: 10px;
  vertical-align: middle;
  letter-spacing: 0.3px;
}

/* ---------- data architecture page ---------- */
/* The D3 SVG fills the panel width and scales via its viewBox. Its internal
   palette is intentionally left untouched (it is the diagram's own legend). */
#diagram { display: block; width: 100%; height: auto; }

/* Red-accent nav link, matching .detail-breadcrumb a (bold, no underline until
   hover). Used on the search page and (optionally) the top bar. */
.nav-link {
  color: var(--red);
  font-weight: 700;
  font-size: 12.5px;
  text-decoration: none;
  white-space: nowrap;
}
.nav-link:hover { text-decoration: underline; }

/* Search page heading row: title on the left, architecture link on the right. */
.panel-nav {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.panel-nav h2 { margin-bottom: 0; }

/* Top-bar variant sits at the end of the flex row. */
.topbar-nav { margin-left: auto; }

/* Cross-links grouping: the architecture / governance pages carry a "← Back to
   search" link plus a sibling cross-link to the other diagram page. Lay the
   breadcrumb out as a row with the cross-link pushed to the right; group the
   two search-page nav links so they sit together at the end of .panel-nav. */
.detail-breadcrumb-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 16px;
}
.panel-nav-links { display: inline-flex; align-items: center; gap: 16px; }
