/*
  Studio v2, milestone 2: the output preview grid in #previewPane.
  Blue marks a cell that needs you (differs from the approved example); green means it
  matches. Never red against green, and every state also has its words on screen.
*/

.studio-v2 .preview-pane.pv-active {
  display: block;
  padding: 0;
  place-items: unset;
}

.pv-frame {
  display: grid;
  grid-template-rows: auto auto minmax(0, 1fr) auto auto;
  block-size: 100%;
  min-block-size: 0;
}

.pv-toolbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 6px 12px;
  padding: 8px 12px;
  border-block-end: 1px solid var(--line);
}

.pv-title {
  display: flex;
  flex-wrap: wrap;
  align-items: baseline;
  gap: 4px 10px;
  min-inline-size: 0;
}

.pv-title .section-label {
  margin: 0;
  font-size: 11px;
}

.pv-file {
  overflow-wrap: anywhere;
  color: var(--text-muted);
  font-size: 12px;
}

.pv-filter {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
}

/* app.css sizes every input as a full-width text box; a tick box is not one. */
.pv-filter input {
  inline-size: auto;
  min-block-size: 0;
  margin: 0;
  padding: 0;
  accent-color: var(--accent-blue);
}

.pv-filter:has(input:disabled) {
  color: var(--text-subtle);
  cursor: default;
}

/* ---------- Cell bar (as in Rows: reference, column, value) ---------- */
.pv-cellbar {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 12px;
  min-block-size: 34px;
  padding: 5px 12px;
  background: var(--surface-muted);
  border-block-end: 1px solid var(--line);
  font-size: 13px;
}

.pv-cellbar-hint {
  color: var(--text-muted);
}

.pv-ref {
  padding: 1px 6px;
  font-family: var(--font-data);
  font-size: 12px;
  font-weight: 700;
  background: var(--surface);
  border: 1px solid var(--line-strong);
  border-radius: var(--radius-xs);
}

.pv-cellbar-col {
  font-weight: 700;
}

.pv-cellbar-pair {
  display: inline-flex;
  align-items: baseline;
  gap: 6px;
}

.pv-cellbar-label {
  color: var(--text-muted);
  font-size: 12px;
}

.pv-cellbar-value {
  font-family: var(--font-data);
  overflow-wrap: anywhere;
}

.pv-produced {
  color: var(--v2-attn-ink);
}

.pv-expected {
  color: var(--v2-done-ink);
}

.pv-cellbar-source {
  color: var(--text-subtle);
  font-size: 12px;
}

/* ---------- The grid ---------- */
.pv-grid-wrap {
  overflow: auto;
  min-block-size: 0;
  background: var(--surface);
}

.pv-grid {
  border-collapse: separate;
  border-spacing: 0;
  font-family: var(--font-data);
  font-size: 12px;
  line-height: 1.3;
}

.pv-grid :is(th, td) {
  /* As in Orca's CSV viewer: a column is never wider than a readable line; the full
     value is in the cell bar and in the title. */
  max-inline-size: 18rem;
  padding: 4px 8px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border-inline-end: 1px solid var(--line);
  border-block-end: 1px solid var(--line);
}

.pv-grid thead th {
  position: sticky;
  z-index: 2;
  background: var(--surface-muted);
  font-family: var(--font-ui);
  text-align: start;
}

.pv-letters th {
  inset-block-start: 0;
  block-size: 20px;
  padding-block: 1px;
  color: var(--text-subtle);
  font-size: 11px;
  font-weight: 500;
  text-align: center;
}

.pv-names th {
  inset-block-start: 20px;
  font-weight: 700;
  border-block-end-color: var(--line-strong);
}

.pv-rownum,
.pv-corner {
  position: sticky;
  inset-inline-start: 0;
  z-index: 1;
  min-inline-size: 3rem;
  color: var(--text-subtle);
  font-weight: 500;
  text-align: end;
  background: var(--surface-muted);
}

.pv-grid thead :is(.pv-rownum, .pv-corner) {
  z-index: 3;
}

.pv-num {
  font-variant-numeric: tabular-nums;
  text-align: end;
}

td.pv-diff {
  padding: 0;
  background: var(--v2-attn-bg);
  /* A corner mark as well as the tint, so a difference does not rely on colour. */
  background-image: linear-gradient(225deg, var(--v2-attn-ink) 6px, transparent 6px);
}

.pv-diff-button {
  display: block;
  inline-size: 100%;
  min-block-size: 100%;
  padding: 4px 8px;
  overflow: hidden;
  color: var(--v2-attn-ink);
  font: inherit;
  font-weight: 700;
  text-align: inherit;
  text-overflow: ellipsis;
  white-space: nowrap;
  background: none;
  border: 0;
  cursor: pointer;
}

.pv-grid td.pv-selected {
  outline: 2px solid var(--focus);
  outline-offset: -2px;
}

/* ---------- Sheet tabs along the bottom, as in a workbook ---------- */
.pv-tabs {
  display: flex;
  gap: 2px;
  padding: 0 8px;
  overflow-x: auto;
  background: var(--surface-muted);
  border-block-start: 1px solid var(--line-strong);
}

.pv-tab {
  padding: 6px 12px;
  color: var(--text-muted);
  font: inherit;
  font-size: 12px;
  white-space: nowrap;
  background: none;
  border: 0;
  border-block-end: 3px solid transparent;
  cursor: pointer;
}

.pv-tab-count {
  margin-inline-start: 6px;
  padding: 0 6px;
  color: var(--v2-attn-ink);
  font-size: 11px;
  font-weight: 700;
  background: var(--v2-attn-bg);
  border: 1px solid var(--v2-attn-line);
  border-radius: 999px;
}

.pv-tab[aria-selected="true"] {
  color: var(--text);
  font-weight: 700;
  background: var(--surface);
  border-block-end-color: var(--accent-blue);
}

/* ---------- Status bar (as in Hex: facts left, rows and downloads right) ---------- */
.pv-status {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  justify-content: space-between;
  gap: 4px 16px;
  padding: 6px 12px;
  font-size: 12px;
  background: var(--surface-muted);
  border-block-start: 1px solid var(--line);
}

.pv-status-facts,
.pv-status-links {
  display: flex;
  flex-wrap: wrap;
  align-items: center;
  gap: 4px 14px;
}

.pv-status-attn {
  color: var(--v2-attn-ink);
  font-weight: 700;
}

.pv-status-done {
  color: var(--v2-done-ink);
  font-weight: 700;
}

.pv-rows {
  color: var(--text-muted);
  font-variant-numeric: tabular-nums;
}

.pv-download {
  font-weight: 600;
}
