/* ═══════════════════════════════════════════════════════════════════════
   SOT CS — Phase 2 (operator workbench)

   Search, bulk selection, saved views, keyboard focus, and the mobile
   navigation that ≤768px never had. Kept in its own file so the two large
   existing stylesheets stay diffable; loaded last in base.html, so it wins
   ties without !important.
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Row selection checkbox ─────────────────────────────────────────────
   The list used to draw a fake checkbox (an empty <div class="check">)
   inside an <a> row, so it could not be clicked without navigating. It is
   now a real <input type="checkbox"> visually hidden behind the same
   .check box, wrapped in a <label> so the whole 26px cell is a tap target.
   The checkmark styling in style-botanical.css keys off .row-bot.selected,
   which static/js/bulk.js sets — and :checked below covers the header's
   select-all, which lives outside a row. */

.check-wrap {
  display: flex; align-items: center; justify-content: center;
  width: 26px; min-height: 30px; margin-left: -6px;
  cursor: pointer;
}
.check-wrap input.row-check {
  position: absolute; opacity: 0;
  width: 1px; height: 1px; margin: 0; pointer-events: none;
}
.list-head-bot .check,
.row-bot .check {
  width: 14px; height: 14px; position: relative;
  border: 1.5px solid var(--rule-2); border-radius: 4px;
  background: var(--bg-card); flex: 0 0 auto;
}
.check-wrap input.row-check:checked + .check {
  background: var(--row-brand, var(--brand)); border-color: var(--row-brand, var(--brand));
}
.check-wrap input.row-check:checked + .check::after {
  content: ''; position: absolute; left: 3px; top: 1.5px;
  width: 6px; height: 3.5px; border: 2px solid #fff;
  border-top: 0; border-right: 0; transform: rotate(-45deg);
}
.check-wrap input.row-check:indeterminate + .check::after {
  content: ''; position: absolute; left: 2.5px; top: 5px;
  width: 7px; height: 0; border-top: 2px solid var(--ink-2);
  transform: none;
}
/* Keyboard focus has to be visible on a visually-hidden input. */
.check-wrap input.row-check:focus-visible + .check {
  outline: 2px solid var(--brand); outline-offset: 2px;
}

/* ── Keyboard row focus (j / k) ────────────────────────────────────── */
.row-bot.kb-focus {
  box-shadow: inset 3px 0 0 var(--brand), inset 0 0 0 1px var(--brand);
  background: color-mix(in oklab, var(--brand) 8%, var(--bg-card));
}

/* ── List toolbar: search + save view ───────────────────────────────── */
.list-toolbar { display: flex; align-items: center; gap: 10px; flex-wrap: wrap; }
.list-search { position: relative; }
.list-search .ico {
  position: absolute; left: 10px; top: 50%;
  transform: translateY(-50%); color: var(--ink-3); font-size: 13px;
}
.list-search input {
  width: 260px; max-width: 100%;
  background: var(--bg-input); border: 1px solid var(--rule);
  border-radius: 999px; padding: 7px 12px 7px 30px;
  color: var(--ink); font-size: 12.5px; font-family: inherit; outline: none;
}
.list-search input:focus { border-color: var(--brand); background: var(--bg-card); }

/* ── Assignee badge in the subject cell ─────────────────────────────── */
.assignee-badge {
  margin-left: 8px; flex-shrink: 0;
  padding: 1px 7px; border-radius: 999px;
  background: var(--bg-input); border: 1px solid var(--rule);
  font-size: 10.5px; font-weight: 600; color: var(--ink-2);
  max-width: 120px; overflow: hidden; text-overflow: ellipsis;
}

/* ── Floating bulk toolbar ──────────────────────────────────────────── */
.bulk-bar {
  position: fixed; left: 50%; bottom: 20px; transform: translateX(-50%);
  z-index: 60; max-width: calc(100vw - 32px);
  display: flex; align-items: center; gap: 8px; flex-wrap: wrap;
  padding: 10px 14px; border-radius: 10px;
  background: var(--bg-card); border: 1px solid var(--rule);
  box-shadow: 0 8px 28px rgba(0, 0, 0, 0.18);
  font-size: 12px;
}
.bulk-bar[hidden] { display: none; }
.bulk-bar .grow { flex: 1; }
.bulk-bar .bulk-count { color: var(--ink-2); white-space: nowrap; }
.bulk-bar .bulk-count strong { color: var(--ink); font-family: 'JetBrains Mono', monospace; }
.bulk-bar.over-cap .bulk-count strong { color: var(--danger); }
.bulk-bar .btn-bot { padding: 5px 10px; font-size: 11.5px; border-color: var(--rule); }
.bulk-field {
  display: flex; align-items: center; gap: 5px;
  color: var(--ink-3); font-size: 11px;
}
.bulk-field select {
  background: var(--bg-input); border: 1px solid var(--rule);
  border-radius: 5px; padding: 5px 8px; font-size: 11.5px;
  color: var(--ink); font-family: inherit; max-width: 150px;
}
.bulk-status { font-size: 11px; color: var(--ink-3); white-space: nowrap; }
.bulk-status.err { color: var(--danger); font-weight: 600; }

/* ── Topbar suggestion dropdown ─────────────────────────────────────── */
.search .suggest {
  position: absolute; top: calc(100% + 6px); right: 0;
  width: 380px; max-width: calc(100vw - 32px); max-height: 60vh;
  overflow-y: auto; z-index: 80;
  background: var(--bg-card); border: 1px solid var(--rule);
  border-radius: 8px; box-shadow: 0 10px 30px rgba(0, 0, 0, 0.16);
  padding: 4px;
}
.search .suggest[hidden] { display: none; }
.suggest-row {
  display: grid; grid-template-columns: 54px minmax(0, 1fr) minmax(0, 40%);
  align-items: baseline; gap: 8px;
  padding: 7px 10px; border-radius: 5px;
  font-size: 12.5px; color: var(--ink); text-decoration: none;
}
.suggest-row:hover, .suggest-row.active { background: var(--bg-hover); }
.suggest-row .sg-kind {
  font-size: 9.5px; text-transform: uppercase; letter-spacing: .1em;
  color: var(--ink-3); font-weight: 700;
}
.suggest-row .sg-label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.suggest-row .sg-sub {
  font-size: 11px; color: var(--ink-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap; text-align: right;
}
.suggest-all {
  display: block; text-align: center; color: var(--brand);
  font-weight: 600; font-size: 11.5px; padding: 8px;
  border-top: 1px solid var(--rule); margin-top: 4px;
}
.sot-palette .item .sub, #palette-list .item .sub {
  color: var(--ink-3); font-size: 11px; margin-left: 8px;
}

/* ── Search results page ────────────────────────────────────────────── */
.search-page-form { display: flex; gap: 8px; margin-bottom: 20px; }
.search-page-input {
  flex: 1; background: var(--bg-input); border: 1px solid var(--rule);
  border-radius: 8px; padding: 10px 14px; font-size: 14px;
  color: var(--ink); font-family: inherit; outline: none;
}
.search-page-input:focus { border-color: var(--brand); background: var(--bg-card); }
.search-group { margin-bottom: 26px; }
.search-group-h {
  font-size: 11px; font-weight: 700; text-transform: uppercase;
  letter-spacing: .14em; color: var(--ink-3); margin: 0 0 8px;
}
.search-group-h .ct {
  font-family: 'JetBrains Mono', monospace; color: var(--ink-2);
  margin-left: 6px; letter-spacing: 0;
}
.search-row {
  display: grid;
  grid-template-columns: 130px minmax(0, 1fr) 100px 90px 90px;
  align-items: center; gap: 10px;
  padding: 10px 14px; border-bottom: 1px solid var(--rule);
  font-size: 12.5px; color: var(--ink); text-decoration: none;
}
.search-row:last-child { border-bottom: 0; }
.search-row:hover { background: var(--bg-hover); }
.search-row .sr-id {
  font-family: 'JetBrains Mono', monospace; font-size: 11px; color: var(--ink-3);
  overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.search-row .sr-main { display: flex; flex-direction: column; min-width: 0; gap: 2px; }
.search-row .sr-subject { font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-row .sr-sub { font-size: 11px; color: var(--ink-3); overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.search-row .sr-meta { font-size: 11px; color: var(--ink-3); text-align: right; }
.search-empty {
  padding: 26px 14px; text-align: center;
  color: var(--ink-3); font-size: 12.5px;
}


/* ── Shortcut overlay (?) ───────────────────────────────────────────── */
.shortcut-overlay {
  display: none; position: fixed; inset: 0; z-index: 120;
  background: rgba(15, 20, 15, 0.45);
  align-items: center; justify-content: center; padding: 20px;
}
.shortcut-overlay.open { display: flex; }
.shortcut-card {
  background: var(--bg-card); border: 1px solid var(--rule);
  border-radius: 12px; padding: 22px 26px;
  width: min(460px, 100%); max-height: 80vh; overflow-y: auto;
  box-shadow: 0 20px 50px rgba(0, 0, 0, 0.3);
}
.shortcut-card h2 {
  margin: 0 0 14px; font-size: 15px; font-weight: 700; color: var(--ink);
}
.shortcut-card dl {
  display: grid; grid-template-columns: 130px minmax(0, 1fr);
  gap: 8px 14px; margin: 0; font-size: 12.5px;
}
.shortcut-card dt { margin: 0; }
.shortcut-card dd { margin: 0; color: var(--ink-2); }
.shortcut-card kbd {
  font-family: 'JetBrains Mono', monospace; font-size: 11px;
  padding: 2px 6px; border: 1px solid var(--rule);
  border-bottom-width: 2px; border-radius: 4px;
  background: var(--bg-input); color: var(--ink);
}
.shortcut-foot { margin: 16px 0 0; font-size: 11px; color: var(--ink-3); }

/* ── Mobile navigation ──────────────────────────────────────────────── */
.nav-toggle {
  display: none; flex-direction: column; justify-content: center; gap: 4px;
  width: 40px; height: 40px; padding: 0 9px; margin-left: -8px;
  background: none; border: 0; cursor: pointer;
}
.nav-toggle span {
  display: block; height: 2px; width: 100%;
  background: var(--ink-2); border-radius: 2px;
}
.nav-scrim {
  display: none; position: fixed; inset: 0; z-index: 90;
  background: rgba(15, 20, 15, 0.45);
}
.nav-scrim[hidden] { display: none; }

@media (max-width: 768px) {
  /* The sidebar is display:none at this width in style.css. Turn it into
     an overlay the hamburger can reveal, and give the grid its one column
     back so main content is not squeezed by a 232px phantom track. */
  .layout { grid-template-columns: minmax(0,1fr); }
  .nav-toggle { display: flex; }
  body.nav-open .nav-scrim { display: block; }

  .sidebar {
    display: none;
    position: fixed; top: 0; left: 0; bottom: 0;
    width: min(280px, 84vw); z-index: 100;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.25);
    overflow-y: auto;
  }
  body.nav-open .sidebar { display: flex; }

  .topbar { padding: 0 12px; gap: 8px; }
  .topbar .crumbs .meta { display: none; }
  .theme-tog { display: none; }
  .search { width: auto; flex: 1; min-width: 0; max-width: 260px; }
  .search .kbd { display: none; }
  .search .suggest { right: 0; width: calc(100vw - 24px); }

  /* Ticket list at 390px: drop the columns an operator does not triage
     on, and grow the tap targets. */
  .list-head-bot,
  .row-bot {
    grid-template-columns: 34px minmax(0, 1fr) 62px 52px;
    padding: 0 8px;
  }
  .row-bot { height: auto; min-height: 56px; padding: 8px; align-items: start; }
  .list-head-bot > div:nth-child(2),
  .list-head-bot > div:nth-child(3),
  .list-head-bot > div:nth-child(4),
  .list-head-bot > div:nth-child(6),
  .row-bot > div:nth-child(2),
  .row-bot .channel-cell,
  .row-bot .priority,
  .row-bot .type-cell { display: none; }
  .row-bot .subj {
    grid-column: 2; padding-left: 0;
    flex-direction: column; align-items: flex-start; white-space: normal;
  }
  .row-bot .subj .sep { display: none; }
  .row-bot .subj .what { white-space: normal; }
  .check-wrap { width: 34px; min-height: 44px; }

  .lede { flex-direction: column; align-items: stretch; gap: 12px; }
  .list-toolbar { width: 100%; }
  .list-search, .list-search input { width: 100%; }
  .filters { gap: 6px; }
  .view-tog { overflow-x: auto; }

  .bulk-bar {
    left: 8px; right: 8px; bottom: 8px; transform: none;
    max-width: none; justify-content: flex-start;
  }
  .bulk-bar .btn-bot { padding: 8px 10px; }

  .search-row { grid-template-columns: minmax(0, 1fr) 80px; }
  .search-row .sr-id { grid-column: 1 / -1; }
  .search-row .sr-meta:nth-of-type(2) { display: none; }
  .view-row .view-qs { grid-column: 1 / -1; }

  /* Ticket detail: stack the rails and keep the composer usable. */
  .detail-grid, .ticket-detail-grid { grid-template-columns: minmax(0,1fr); }
  .composer textarea, .composer-form textarea { min-height: 160px; }
}
