/* The tickets page — BRIP1's editor look and feel, on brip4's model.
 *
 * Grey's call (2026-07-26): adopt BRIP1's look, don't invent one. So the
 * palette, the split pane, the filter buttons, the table, the type badges,
 * the triple rendering and the field groups are all ported from
 * archives/brip1/code/src/brip/static/css/editor.css, and only the parts that
 * encode brip1's MODEL are rebuilt (see the rebuild ruling in
 * memories/project_brip1_gui_reference.md).
 *
 * ⚠️ LIGHT THEME, deliberately: brip1's editor is light, and it is the
 * reference for the AUTHORING pages (A7's two stances, two surfaces). The
 * top bar itself is nav.css's business and follows the app theme.
 */

.tk-light {
  --bg:       #ffffff;
  --surface:  #fafafa;
  --text:     #212121;
  --text-dim: #757575;
  --accent:   #1e88e5;
  --border:   #e0e0e0;
  --orange:   #e65100;
  --red:      #e53935;
  --green:    #43a047;
  --cyan:     #00897b;
  --violet:   #6c71c4;
  --yellow:   #f9a825;
  --blue:     #1e88e5;
  --magenta:  #d81b60;

  /* triple colours: optimistic / median / pessimistic */
  --t-green:  #2e7d32;
  --t-dark:   #212121;
  --t-brown:  #a06000;

  background: var(--bg);
  color: var(--text);
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  font-size: 14px;
}

/* re-skin the shared nav to brip1's light bar (nav.css owns the layout) */

/* ── split pane ──────────────────────────────────────────────────────── */

.split-pane { position: absolute; inset: 0; display: flex; overflow: hidden; }

.left-pane {
  flex: 1 1 60%;
  min-width: 350px;
  overflow-y: auto;
  padding: 0 24px 20px;
}

.right-pane {
  flex: 0 0 420px;
  min-width: 280px;
  overflow-y: auto;
  padding: 20px 24px;
  background: var(--surface);
  border-left: 1px solid var(--border);
}

.splitter {
  flex: 0 0 5px;
  cursor: col-resize;
  background: var(--border);
  transition: background .12s;
}
.splitter:hover, .splitter.dragging { background: var(--accent); }

/* ── toolbar: type filters with live counts ──────────────────────────── */

/* Two stacked rows — type (exclusive) above status (per-status on/off). They
   are separate rows because they are orthogonal filters: one flat run of
   buttons would read as a single choice. */
.toolbar {
  display: flex;
  flex-direction: column;
  align-items: stretch;
  gap: 6px;
  padding: 16px 0 12px;
  position: sticky;
  top: 0;
  z-index: 10;
  background: var(--bg);
  border-bottom: 2px solid #000;
}

.filter-row {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px;
}

.filter-label {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--text-dim);
  width: 44px;                 /* fixed: the two rows' buttons line up */
  flex: none;
}

.filter-btn {
  font-size: 12px;
  padding: 4px 10px;
  border-radius: 4px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text);
  cursor: pointer;
  font-family: inherit;
}
.filter-btn:hover { background: rgba(0,0,0,.04); }
/* Both rows are toggles, so ON is the resting state and looks like a plain
   button — filling every on-button with accent would just be a wall of colour
   saying nothing. OFF is what needs to be loud: struck through, unmistakably
   "excluded", and still carrying its count so you know what you are hiding. */
.toggle-btn.off {
  opacity: .45;
  text-decoration: line-through;
  background: rgba(0,0,0,.05);
}

.search-box {
  margin-left: auto;
  padding: 4px 9px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font: 12px inherit;
  font-family: inherit;
  min-width: 180px;
}
.search-box:focus { outline: none; border-color: var(--accent); }

.summary-bar { font-size: 13px; color: var(--text-dim); padding: 10px 0 6px; }

/* ── ticket table ────────────────────────────────────────────────────── */

.ticket-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.ticket-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-dim);
  padding: 8px 10px;
  border-bottom: 2px solid var(--border);
}
.ticket-table th.right { text-align: right; }
.ticket-table td {
  padding: 7px 10px;
  border-bottom: 1px solid #eee;
  vertical-align: middle;
}
.ticket-table td.right { text-align: right; }
.ticket-table td.nowrap { white-space: nowrap; }
.ticket-table tr {
  cursor: pointer;
  transition: background .08s;
  border-left: 4px solid transparent;   /* reserved, so selecting won't reflow */
}
.ticket-table tr:hover:not(.selected) { background: rgba(46,125,50,.12); }
.ticket-table tr.selected {
  background: #e8f0fe;
  border-left: 4px solid var(--accent);
  outline: 2px solid var(--accent);
  outline-offset: -2px;
}

.ticket-id {
  font-family: 'SF Mono', Consolas, ui-monospace, monospace;
  font-size: 12px;
  color: var(--blue);
  background: rgba(30,136,229,.08);
  padding: 2px 7px;
  border-radius: 4px;
  white-space: nowrap;
}

/* ── type badges: brip4's four types, not brip1's eight ──────────────── */

.type-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  font-weight: 500;
  white-space: nowrap;
  display: inline-block;
}
.type-badge.task     { background: rgba(67,160,71,.10);  color: var(--green); }
.type-badge.group    { background: rgba(108,113,196,.12); color: var(--violet); }
.type-badge.purchase { background: rgba(30,136,229,.10);  color: var(--blue); }
.type-badge.travel   { background: rgba(0,137,123,.10);   color: var(--cyan); }

/* ── row visual state (brip1's item-done / item-error) ───────────────── */

.item-done { opacity: .4; }
.item-done .ticket-title { text-decoration: line-through; text-decoration-color: var(--text-dim); }
.item-error { background: rgba(229,57,53,.07) !important; border-left-color: var(--red) !important; }

.status-cell { font-size: 11px; color: var(--text-dim); white-space: nowrap; }
.status-cell.active { color: var(--green); font-weight: 600; }

/* ── the triple: median large + bold, ends colour-coded ──────────────── */

.days-triple {
  font-family: 'SF Mono', Consolas, ui-monospace, monospace;
  font-size: 12px;
  font-variant-numeric: tabular-nums;
  white-space: nowrap;
}
.days-triple .min { color: var(--t-green); }
.days-triple .exp { color: var(--t-dark); font-weight: 600; font-size: 1.3em; }
.days-triple .max { color: var(--t-brown); }
.key-value-dim { color: var(--text-dim); }

/* ── right pane: header + schema-driven fields ───────────────────────── */

.editor-header {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  margin-bottom: 16px;
  padding-bottom: 12px;
  border-bottom: 1px solid var(--border);
}
.editor-header h2 { font-size: 15px; font-weight: 600; margin: 0; flex-basis: 100%; }

.editor-empty {
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  height: 60%; color: var(--text-dim); text-align: center;
}
.editor-empty .icon { font-size: 48px; margin-bottom: 12px; opacity: .3; }
.editor-empty p { font-size: 13px; max-width: 240px; }

.jira-badge {
  font-family: 'SF Mono', Consolas, monospace; font-size: 11px;
  color: var(--cyan); background: rgba(0,137,123,.10);
  padding: 2px 7px; border-radius: 4px;
}
.jira-badge.local { color: var(--text-dim); background: rgba(0,0,0,.05); }
.loc-badge { font-family: 'SF Mono', Consolas, monospace; font-size: 11px; color: #9e9e9e; }
.type-help { font-size: 11.5px; color: #9e9e9e; flex-basis: 100%; margin: 0; }

.field-group { margin-bottom: 16px; }
.field-group > label {
  display: block;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .5px;
  color: var(--text-dim);
  margin-bottom: 4px;
}
.field-group .hint { font-size: 11px; color: #9e9e9e; margin-top: 2px; }
.field-value { font-size: 13px; }
.field-value.multiline { white-space: pre-wrap; }

/* ── inputs (brip1's field-group controls) ───────────────────────────── */

.field-group input[type="text"],
.field-group input[type="number"],
.field-group textarea,
.field-group select {
  width: 100%;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: 4px;
  font-size: 13px;
  font-family: inherit;
  background: #fff;
  color: var(--text);
  transition: border-color .15s;
}
.field-group input:focus,
.field-group textarea:focus,
.field-group select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 2px rgba(30,136,229,.15);
}
.field-group textarea { min-height: 80px; resize: vertical; }

/* a required field with nothing in it is the one thing worth nagging about:
   `days` drives the whole forecast, and an empty estimate is not a zero */
.field-group.required input:placeholder-shown { border-color: var(--orange); }

.flag-row {
  display: flex; align-items: center; gap: 7px;
  font-size: 13px; color: var(--text); cursor: pointer;
  text-transform: none; letter-spacing: 0; font-weight: 400;
}
.flag-row input[type="checkbox"] { width: auto; accent-color: var(--accent); }

/* the triple, editable: three boxes with brip1's plain-word labels under
   them. Grid keeps the columns equal so digits do not shift the layout. */
.triple-input { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 6px; }
.triple-cell { display: flex; flex-direction: column; }
.triple-cell input { text-align: center; font-variant-numeric: tabular-nums; }
.triple-cell .triple-label {
  font-size: 10px; color: var(--text-dim); text-align: center;
  margin-top: 3px; white-space: nowrap;
}
/* the median is the number people actually argue about — make it the anchor */
.triple-cell:nth-child(1) input { color: var(--t-green); }
.triple-cell:nth-child(2) input { color: var(--t-dark); font-weight: 600; }
.triple-cell:nth-child(3) input { color: var(--t-brown); }

/* ── save feedback ───────────────────────────────────────────────────── */
/* Deliberately NOT a spinner or a text swap. A local write confirms in far
   under 100 ms, so anything that appears and vanishes reads as a blink, and
   a label that grows ("saving…") reflows the row. The tick lives in space
   already reserved by the label, so showing it moves nothing. */

.saved-tick {
  display: inline-block;
  margin-left: 6px;
  color: var(--green);
  opacity: 0;
  transition: opacity .15s;
}
.field-group.just-saved .saved-tick { opacity: 1; transition: none; }

.write-error {
  margin: 0 0 12px;
  padding: 7px 10px;
  font-size: 12px;
  color: var(--red);
  background: rgba(229,57,53,.07);
  border: 1px solid rgba(229,57,53,.3);
  border-radius: 4px;
}

/* ── links section ───────────────────────────────────────────────────── */

.links-section { margin-top: 22px; border-top: 1px solid var(--border); padding-top: 14px; }
.links-header { display: flex; align-items: center; gap: 8px; margin-bottom: 8px; }
.links-header label {
  font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .5px; color: var(--text-dim);
}
.link-toggle-btn {
  margin-left: auto; width: 24px; height: 24px; line-height: 1;
  border: 1px solid var(--border); border-radius: 4px;
  background: #fff; color: var(--text); cursor: pointer; font-size: 15px;
}
.link-toggle-btn:hover { border-color: var(--accent); color: var(--accent); }

.link-group { margin-bottom: 10px; }
.link-group-header {
  display: flex; align-items: center; gap: 6px;
  font-size: 11px; color: var(--text-dim); cursor: pointer; user-select: none;
  padding: 2px 0;
}
.link-group-chevron { transition: transform .12s; display: inline-block; }
.link-group-chevron.collapsed { transform: rotate(-90deg); }
.link-group-count {
  background: rgba(0,0,0,.06); border-radius: 8px; padding: 0 6px; font-size: 10px;
}
.link-row {
  display: flex; align-items: baseline; gap: 8px;
  padding: 4px 0 4px 16px; border-bottom: 1px solid #f0f0f0;
}
.link-target {
  font-family: 'SF Mono', Consolas, monospace; font-size: 12px;
  color: var(--blue); text-decoration: none; white-space: nowrap;
}
.link-target:hover { text-decoration: underline; }
.link-target.dangling { color: var(--red); cursor: help; }
.link-other-title {
  font-size: 12px; color: var(--text-dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1;
}
.link-remove-btn {
  border: none; background: none; color: #bbb; cursor: pointer;
  font-size: 16px; line-height: 1; padding: 0 2px;
}
.link-remove-btn:hover { color: var(--red); }
.link-empty { font-size: 12px; color: var(--text-dim); padding: 4px 0; }

/* an OR-group renders as one unit — the AND-of-ORs shape must stay visible */
.or-group {
  display: inline-flex; align-items: baseline; gap: 5px;
  border: 1px solid var(--border); border-radius: 10px; padding: 1px 8px;
}
.or-sep { color: var(--text-dim); font-size: 10px; text-transform: uppercase; }

/* ── add-link form: relationship select + type-search-select combo ───── */

.link-add-form {
  margin-top: 8px; padding: 10px; background: #fff;
  border: 1px solid var(--border); border-radius: 5px;
}
.link-select, .link-search-input {
  width: 100%; padding: 7px 9px; border: 1px solid var(--border);
  border-radius: 4px; font: 13px inherit; font-family: inherit; background: #fff;
}
.link-select:focus, .link-search-input:focus {
  outline: none; border-color: var(--accent); box-shadow: 0 0 0 2px rgba(30,136,229,.15);
}
.link-combo { position: relative; margin-top: 8px; }
.link-dropdown {
  position: absolute; left: 0; right: 0; top: 100%; z-index: 50;
  max-height: 240px; overflow-y: auto; background: #fff;
  border: 1px solid var(--border); border-top: none;
  border-radius: 0 0 4px 4px; box-shadow: 0 4px 12px rgba(0,0,0,.12);
}
.link-dropdown-item {
  display: flex; align-items: baseline; gap: 8px;
  padding: 6px 9px; cursor: pointer;
}
.link-dropdown-item:hover, .link-dropdown-item.hi { background: #e8f0fe; }
.link-dropdown-title {
  font-size: 12px; color: var(--text-dim);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.link-dropdown-empty { padding: 8px 9px; font-size: 12px; color: var(--text-dim); }
.link-add-error { margin-top: 6px; font-size: 12px; color: var(--red); }

/* ── places: the other surfaces this ticket exists on ────────────────── */

.places-section {
  margin-top: 22px; border-top: 1px solid var(--border); padding-top: 14px;
}
.places-section > label {
  display: block; font-size: 11px; font-weight: 600; text-transform: uppercase;
  letter-spacing: .5px; color: var(--text-dim); margin-bottom: 8px;
}
.places-row { display: flex; flex-wrap: wrap; gap: 6px; }

.place-btn {
  font-size: 12px; padding: 5px 11px; border-radius: 4px;
  border: 1px solid var(--border); background: #fff; color: var(--text);
  cursor: pointer; font-family: inherit;
}
.place-btn:hover:not(:disabled) { border-color: var(--accent); color: var(--accent); }
/* greyed, not hidden: a place that cannot show THIS ticket still says so,
   and its tooltip carries the reason */
.place-btn:disabled { color: #bdbdbd; border-color: #eee; cursor: not-allowed; }
.place-btn[data-pending="true"] { border-color: var(--accent); }

.places-status { font-size: 11px; color: var(--text-dim); margin-top: 7px;
                 min-height: 14px; }
.places-status.error { color: var(--red); }

.save-indicator {
  font-size: 11px; color: var(--green); opacity: 0; transition: opacity .2s;
}
.save-indicator.visible { opacity: 1; }
