/* Bug sheet — full-width sheet, auth gate, add/edit modal. */

/* .page-head--row is gone: the email and Sign out button that sat beside the
   heading now live in the navbar account menu, on every page. */

.mt-0 { margin-top: 0; }

/* The auth gate, .linkish and the modal shell live in app.css — the code
   preview's sign-in dialog uses the same styles. */

/* --- sheet ---------------------------------------------------------------- */

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 12px;
}
.form-grid > * { min-width: 0; }
.form-grid .field--wide { grid-column: 1 / -1; }
@media (max-width: 640px) {
  .form-grid { grid-template-columns: 1fr; }
}

.req { color: var(--danger); margin-left: 2px; }

.textarea--form {
  min-height: 70px;
  font-family: var(--sans);
  font-size: 13px;
}

.row--editing td { outline: 2px solid var(--accent); outline-offset: -2px; }

.row-actions { display: flex; gap: 4px; }

table.data td.actions {
  position: sticky;
  right: 0;
  background: var(--surface);
  border-left: 1px solid var(--border);
  padding: 5px 8px;
  white-space: nowrap;
}
table.data tbody tr:hover td.actions { background: var(--bg-soft); }
table.data th.actions-head {
  position: sticky;
  right: 0;
  z-index: 3;
  background: var(--bg-soft);
  border-left: 1px solid var(--border);
}

.cell-clamp {
  display: block;
  max-width: 320px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

/* proof thumbnails inside a sheet row */
.cell-proof { display: flex; gap: 4px; align-items: center; }

/* A button, not the media itself, so opening an attachment is keyboard
   reachable and announced — the <img>/<video> inside is decorative. */
.cell-proof__tile {
  position: relative;
  display: block;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 1px solid var(--border);
  border-radius: 4px;
  overflow: hidden;
  background: var(--bg-sunken);
  cursor: zoom-in;
}
.cell-proof__tile:hover { border-color: var(--accent); }
.cell-proof__img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}
.cell-proof__more { font-size: 11px; color: var(--text-faint); }

/* --- dropzone ------------------------------------------------------------- */

.dropzone {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 3px;
  padding: 22px 16px;
  border: 1.5px dashed var(--border-strong);
  border-radius: var(--radius);
  background: var(--bg-soft);
  cursor: pointer;
  text-align: center;
  transition: border-color .12s, background .12s;
}
.dropzone:hover { border-color: var(--accent); background: var(--accent-soft); }
.dropzone--over {
  border-color: var(--accent);
  background: var(--accent-soft);
}
.dropzone__text { font-size: 13px; color: var(--text-muted); }
.dropzone__text strong { color: var(--accent); font-weight: 600; }

.thumbs {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}
.thumbs:empty { display: none; }

.thumb {
  position: relative;
  width: 84px;
  height: 84px;
  border-radius: var(--radius-sm);
  overflow: hidden;
  border: 1px solid var(--border);
  background: var(--bg-sunken);
}
.thumb img,
.thumb video { width: 100%; height: 100%; object-fit: cover; display: block; }

/* Play badge over a video tile, in both the modal thumbs and the sheet cell. */
.thumb__play {
  position: absolute;
  inset: 0;
  display: grid;
  place-items: center;
  pointer-events: none;
  color: #fff;
  background: rgba(16, 24, 40, .35);
}
.thumb__play svg { filter: drop-shadow(0 1px 2px rgba(0, 0, 0, .6)); }

.thumb__remove {
  position: absolute;
  top: 3px;
  right: 3px;
  width: 20px;
  height: 20px;
  border: 0;
  border-radius: 50%;
  background: rgba(16, 24, 40, .78);
  color: #fff;
  font-size: 13px;
  line-height: 1;
  cursor: pointer;
  display: grid;
  place-items: center;
}
.thumb__remove:hover { background: var(--danger); }

.thumb__bar {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  background: var(--accent);
  transform-origin: left;
  transition: transform .2s;
}
.thumb--uploading img,
.thumb--uploading video { opacity: .45; }
.thumb--error { border-color: var(--danger); }

/* --- lightbox ------------------------------------------------------------- */

.lightbox {
  padding: 0;
  border: 0;
  background: transparent;
  max-width: 92vw;
  max-height: 92vh;
  overflow: visible;
}
.lightbox::backdrop { background: rgba(0, 0, 0, .8); }
.lightbox__stage { display: block; }
.lightbox__media {
  display: block;
  max-width: 92vw;
  max-height: 92vh;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  background: var(--surface);
}
.lightbox__close {
  position: absolute;
  top: -12px;
  right: -12px;
  border-radius: 50%;
  background: var(--surface);
  z-index: 1;
}

/* --- column builder dialog ------------------------------------------------ */

.radio-row { display: flex; gap: 18px; }
.radio {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  cursor: pointer;
  font-size: 14px;
}
.radio input { accent-color: var(--accent); }

.col-opts { display: flex; flex-direction: column; gap: 8px; margin: 8px 0; }
.col-opt {
  display: flex;
  align-items: center;
  gap: 8px;
}
.col-opt__label { flex: 1; min-width: 0; }
.col-opt__swatches { display: flex; gap: 5px; flex-shrink: 0; }
.col-opt__remove { flex-shrink: 0; }

.swatch {
  width: 20px;
  height: 20px;
  padding: 0;
  border-radius: 50%;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: box-shadow .12s, transform .12s;
}
.swatch:hover { transform: scale(1.1); }
.swatch--none { background: var(--bg-sunken); }
.swatch--red { background: var(--danger); border-color: transparent; }
.swatch--amber { background: var(--warn); border-color: transparent; }
.swatch--green { background: var(--success); border-color: transparent; }
.swatch--accent { background: var(--accent); border-color: transparent; }
.swatch--on { box-shadow: 0 0 0 2px var(--surface), 0 0 0 4px var(--accent); }

/* ==========================================================================
   Share dialog (owner side) + the public shared page
   ========================================================================== */

/* One checkbox row per column in the share dialog's permission list. Capped
   and scrollable because a sheet can legitimately carry 20-odd columns, and
   the dialog must not grow taller than the viewport. */
.share-perms {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 4px 14px;
  max-height: 220px;
  overflow-y: auto;
  margin: 8px 0;
  padding: 8px 10px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
}

/* "editable" marker in a shared table's header */
.th-badge {
  margin-left: 6px;
  padding: 1px 5px;
  border-radius: 999px;
  background: var(--accent-soft);
  color: var(--accent);
  font-size: 10px;
  font-weight: 600;
  letter-spacing: .02em;
  text-transform: none;
}

/* A cell on the public page stacks its value, the "edited by" note and the
   pencil, so the note never pushes the value out of a clamped line. */
.cell-stack { display: flex; align-items: center; gap: 6px; }
.cell-editor {
  flex-shrink: 0;
  color: var(--text-faint);
  font-size: 11px;
  font-style: italic;
  white-space: nowrap;
}
/* The pencil stays out of the way until the row is hovered or it has keyboard
   focus, so a wide read-only-ish table doesn't look like a form. */
.cell-edit { opacity: 0; transition: opacity .12s; }
table.data tbody tr:hover .cell-edit,
.cell-edit:focus-visible { opacity: 1; }
@media (hover: none) {
  .cell-edit { opacity: 1; }   /* no hover on touch — always show it */
}
td.td--editable { background: color-mix(in srgb, var(--accent-soft) 45%, transparent); }

/* comment thread */
.comment-thread {
  display: flex;
  flex-direction: column;
  gap: 10px;
  max-height: 320px;
  overflow-y: auto;
}
.comment {
  padding: 10px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
}
/* center, not baseline: the owner's copy of this row carries a delete button,
   which baseline alignment drags out of line with the name beside it. */
.comment__head { display: flex; align-items: center; gap: 8px; margin-bottom: 4px; }
.comment__body { margin: 0; white-space: pre-wrap; word-break: break-word; }

/* ---------------------------------------------------------------------------
   Shared page: stretch the table to fill the viewport
   -----------------------------------------------------------------------
   The owner's own Bug Sheet has a whole "Sheet columns" section above the
   table, so app.css's `.table-wrap { max-height: 62vh }` reads as reasonable
   there. The shared page has almost nothing above it, so that same 62vh
   looks like a small box floating in a mostly empty page. Scoped to
   `.shared-page` (set on <body> in shared-bug-sheet.html) so the owner's page
   and every other tool that reuses `.table-wrap` (json-extractor.js) are
   untouched. */
/* `height` (not `min-height`) + `overflow: hidden` hard-caps the document at
   exactly one viewport: with only `min-height`, a handful of stray pixels
   anywhere below (border rounding, a sticky cell's computed `left`, anything)
   is enough for the browser to grow the whole page and hand it its own
   scrollbars — on top of table-wrap's, which is the only scrolling this page
   should ever show. Capping the outer box makes table-wrap absorb all of it
   internally instead, exactly like the owner's own Bug Sheet page. */
.shared-page { display: flex; flex-direction: column; height: 100vh; overflow: hidden; }
/* app.css's base `.page` still carries `padding: 28px 20px 72px` (sized for a
   normal scrolling page). That bottom 72px doesn't disappear just because this
   page is a flex column now — it silently eats into the space #app/.card/
   .table-wrap are supposed to fill, which is exactly why the table stopped
   short with a dead gap above the footer instead of reaching it. Zero out top
   and bottom explicitly; the 20px left/right from the base rule is still fine. */
.shared-page .page {
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 0;
  padding-top: 18px;
  padding-bottom: 0;
}
.shared-page #app { flex: 1; display: flex; flex-direction: column; min-height: 0; min-width: 0; }
.shared-page #app > .card { flex: 1; display: flex; flex-direction: column; min-height: 0; min-width: 0; }

/* The toolbar shares the card head with the title; on a narrow window it drops
   to its own line rather than squeezing the search box to nothing. */
.shared-page #app > .card > .card__head > .row { min-width: 0; }
.shared-page #app-sub {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  min-width: 0;
}
.shared-page #app > .card .card__body { flex: 1; display: flex; min-height: 0; min-width: 0; }
/* min-width:0 is load-bearing, not tidiness: a flex item defaults to
   min-width:auto, so without it the table's min-content width (every column at
   its natural size) pushes the card wider than the viewport instead of
   scrolling inside it — the toolbar then hangs off the right edge. */
.shared-page .table-wrap { flex: 1; min-height: 0; min-width: 0; max-height: none; }

/* Slim scrollbars: the table is the page here, so the default chunky bars eat
   real estate on both axes and frame the content like a widget. */
.shared-page .table-wrap {
  scrollbar-width: thin;
  scrollbar-color: var(--border-strong) transparent;
}
.shared-page .table-wrap::-webkit-scrollbar { width: 9px; height: 9px; }
.shared-page .table-wrap::-webkit-scrollbar-track { background: transparent; }
.shared-page .table-wrap::-webkit-scrollbar-thumb {
  background: var(--border-strong);
  border-radius: 999px;
  border: 2px solid transparent;
  background-clip: content-box;
}
.shared-page .table-wrap::-webkit-scrollbar-thumb:hover { background-color: var(--text-faint); }
.shared-page .table-wrap::-webkit-scrollbar-corner { background: transparent; }

/* --- header cell: label + filter glyph ------------------------------------ */

.th-inner { display: flex; align-items: center; gap: 6px; }
.th-label { flex: 1 1 auto; min-width: 0; }

/* Same hover-reveal idea as .cell-edit: 20 columns each showing a permanent
   funnel reads as clutter, so it surfaces on hover, focus, or when it is
   actually filtering something. */
.th-filter {
  flex: 0 0 auto;
  display: grid;
  place-items: center;
  width: 20px;
  height: 20px;
  padding: 0;
  border: 0;
  border-radius: var(--radius-sm);
  background: none;
  color: var(--text-faint);
  cursor: pointer;
  opacity: 0;
  transition: opacity .12s, color .12s, background .12s;
}
table.data th:hover .th-filter,
.th-filter:focus-visible { opacity: 1; }
.th-filter:hover { color: var(--text); background: var(--surface); }
.th-filter--on {
  opacity: 1;
  color: var(--accent);
  background: var(--accent-soft);
}
@media (hover: none) {
  .th-filter { opacity: 1; }
}

/* --- frozen (sticky) leading columns -------------------------------------- */

/* `left` is set per cell from JS, because the offset of column i is the summed
   width of the ones before it and only the browser knows those. The header's
   corner cells are sticky on both axes at once, hence the extra z-index. */
table.data td.is-frozen,
table.data th.is-frozen {
  position: sticky;
  z-index: 3;
  background: var(--surface);
}
table.data th.is-frozen { z-index: 4; background: var(--bg-soft); }
table.data tbody tr:hover td.is-frozen { background: var(--bg-soft); }
table.data td.is-frozen.td--editable {
  background: color-mix(in srgb, var(--accent-soft) 45%, var(--surface));
}
/* One firm edge marks where the frozen block ends and the scrolling part
   begins — without it the join is invisible mid-scroll. */
table.data .is-frozen-edge { border-right: 2px solid var(--border-strong); }

/* --- column filter popover ------------------------------------------------ */

.filter-pop {
  position: fixed;
  z-index: 70;
  width: 250px;
  display: flex;
  flex-direction: column;
  gap: 6px;
  padding: 12px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--overlay);
  box-shadow: var(--shadow-lg);
}
.filter-pop[hidden] { display: none; }
.filter-pop .input { padding: 6px 9px; font-size: 12.5px; }
.filter-pop__title {
  font-size: 12.5px;
  font-weight: 650;
  letter-spacing: -.01em;
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
}
.filter-pop__lbl {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: .03em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-top: 2px;
}
.filter-pop__all {
  padding-bottom: 6px;
  border-bottom: 1px solid var(--border);
  font-weight: 550;
}
.filter-pop__list {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 190px;
  overflow-y: auto;
  scrollbar-width: thin;
}
.filter-pop__row { padding: 2px 0; }
.filter-pop__val {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  max-width: 178px;
}
.filter-pop__val--empty { color: var(--text-faint); font-style: italic; }
.filter-pop__foot {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 8px;
  border-top: 1px solid var(--border);
}

/* --- Columns dialog: order + visibility ----------------------------------- */

.col-order {
  display: flex;
  flex-direction: column;
  gap: 2px;
  max-height: 320px;
  overflow-y: auto;
  scrollbar-width: thin;
  margin: 8px 0;
  padding: 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-soft);
}
.col-order__row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
}
.col-order__row:hover { background: var(--surface); }
.col-order__row--off .col-order__name { color: var(--text-faint); }
.col-order__name {
  flex: 1 1 auto;
  min-width: 0;
  gap: 8px;
}
.col-order__name span {
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
.col-order__pin { display: inline-grid; place-items: center; color: var(--accent); }
.icon-btn--xs:disabled { opacity: .35; cursor: default; }
