/* ==================
   STICKY TOP BAR
   ================== */

.sticky-top-bar {
  position: sticky;
  top: 48px;
  z-index: 2;
  background: #f5f5f0;
}

/* ==================
   PAGE HEADER
   ================== */

.page-header {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  margin-bottom: 0.875rem;
}

.page-header h1 { margin-bottom: 0; white-space: nowrap; }

.page-header-right {
  display: flex;
  align-items: center;
  flex-wrap: nowrap;
  gap: 0.5rem;
  margin-left: auto;
  padding-left: 1rem;
  white-space: nowrap;
}

.page-header-right .record-count    { margin-bottom: 0; }

.page-header-right .select-action-bar {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0;
}

/* ==================
   RECORD COUNT
   ================== */

.record-count { font-size: var(--font-size-sm); color: #888; margin-bottom: 0.75rem; }

/* ==================
   FILTER BAR
   ================== */

.filter-bar {
  display: flex;
  gap: 0.75rem;
  flex-wrap: wrap;
  align-items: center;
  background: #fff;
  border: 1px solid #e5e5e5;
  border-radius: 10px;
  padding: 0.875rem 1rem;
  margin-bottom: 0;
  box-shadow: 0 1px 3px rgba(0,0,0,0.04);
}

.filter-bar-actions { margin-left: auto; display: flex; align-items: center; gap: 0.25rem; flex-shrink: 0; }

/* Keep filter bar visible on desktop even when Bootstrap marks it collapsed */
@media (min-width: 768px) {
  .filter-bar.collapse { display: flex !important; }
}

/* ==================
   ACTION BAR (PILL)
   ================== */

.action-bar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 12px;
  background: var(--cat-off-white);
  border-radius: 8px;
  border: 0.5px solid rgba(0,0,0,0.08);
  margin: 8px 12px;
  font-size: 13px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
  flex-wrap: nowrap;
}

/* Scoped input/select overrides inside the action bar pill only */
.action-bar input[type="text"] { width: 130px; font-size: 12px; padding: 4px 8px; border-radius: 6px; }
.action-bar select             { font-size: 12px; padding: 4px 6px; border-radius: 6px; max-width: 110px; }

.action-bar-filters {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-wrap: nowrap;
  flex-shrink: 1;
  min-width: 0;
  overflow-x: auto;
}

.action-bar-middle {
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.action-bar-right {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-left: auto;
  flex-shrink: 0;
}

.action-bar-sep {
  width: 0.5px;
  height: 20px;
  background: rgba(0,0,0,0.12);
  margin: 0 6px;
  flex-shrink: 0;
}

.action-bar-check {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  font-size: 12px;
  white-space: nowrap;
  cursor: pointer;
}

.btn-filter {
  background: var(--cat-green);
  color: var(--cat-white);
  border: none;
  border-radius: 6px;
  padding: 3px 10px;
  font-size: 12px;
  cursor: pointer;
  white-space: nowrap;
  transition: background 0.15s;
}

.btn-filter:hover { background: #214D3A; }

.action-bar-page         { font-size: 12px; color: #888; white-space: nowrap; }
.action-bar-nav-disabled { font-size: 12px; color: #ccc; padding: 3px 6px; cursor: default; }

/* ==================
   MOBILE ACTION BAR
   ================== */

.action-bar-mobile-strip {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--cat-off-white);
  border-radius: 8px;
  border: 0.5px solid rgba(0,0,0,0.08);
  margin: 8px 4px;
  font-size: 13px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}

.btn-mobile-filter {
  display: inline-flex;
  align-items: center;
  gap: 0.25rem;
  background: transparent;
  border: 1px solid rgba(0,0,0,0.15);
  border-radius: 5px;
  padding: 3px 8px;
  font-size: 12px;
  cursor: pointer;
  color: var(--cat-text);
  transition: background 0.12s, border-color 0.12s;
}

.btn-mobile-filter:hover              { background: rgba(0,0,0,0.04); }
.btn-mobile-filter[aria-expanded="true"] { border-color: var(--cat-green); color: var(--cat-green); }

.action-bar-mobile-panel {
  padding: 10px 12px;
  background: var(--cat-off-white);
  border: 0.5px solid rgba(0,0,0,0.08);
  border-radius: 8px;
  margin: 0 4px 8px;
  box-shadow: 0 2px 6px rgba(0,0,0,0.06);
}

.action-bar-mobile-panel .search-wrap      { width: 100%; margin-bottom: 6px; }
.action-bar-mobile-panel input[type="text"] { width: 100%; }
.action-bar-mobile-panel select            { width: 100%; display: block; margin-bottom: 6px; }

.action-bar-mobile-checks {
  display: flex;
  gap: 1rem;
  align-items: center;
  font-size: 12px;
  margin-bottom: 6px;
}

.action-bar-mobile-checks label { display: inline-flex; align-items: center; gap: 0.3rem; cursor: pointer; }

/* ==================
   BOTTOM SHEET FILTER
   ================== */

/* Search field fills available space in the mobile strip */
.action-bar-mobile-strip .search-wrap {
  flex: 1;
  min-width: 0;
}

.action-bar-mobile-strip .search-wrap input[type="text"] {
  width: 100%;
  padding-left: 1.75rem;
}

/* Search field inside the bottom-sheet filter panel */
.filter-sheet .search-wrap {
  display: flex;
  width: 100%;
}

.filter-sheet .search-wrap input[type="text"] {
  width: 100%;
  padding-left: 1.75rem;
}

.search-icon {
  position: absolute;
  left: 8px;
  color: #aaa;
  font-size: 13px;
  pointer-events: none;
  z-index: 1;
}

/* Sliders icon button — opens the offcanvas filter sheet */
.btn-filter-sheet {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: 1px solid rgba(0,0,0,0.15);
  border-radius: 5px;
  padding: 3px 8px;
  font-size: 14px;
  cursor: pointer;
  color: var(--cat-text);
  flex-shrink: 0;
  position: relative;
  transition: background 0.12s, border-color 0.12s;
}

.btn-filter-sheet:hover           { background: rgba(0,0,0,0.04); }
.btn-filter-sheet.has-filters     { border-color: var(--cat-green); color: var(--cat-green); }

.filter-active-dot {
  position: absolute;
  top: 2px;
  right: 2px;
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: var(--cat-green);
}

/* Bootstrap Offcanvas — bottom sheet */
.filter-sheet.offcanvas-bottom {
  border-radius: 16px 16px 0 0;
  height: auto;
  max-height: 90vh;
}

.filter-sheet .offcanvas-body select { width: 100%; display: block; margin-bottom: 0.6rem; }
.filter-sheet .offcanvas-body .action-bar-mobile-checks { font-size: 13px; }
.filter-sheet-label { font-size: 11px; font-weight: 600; text-transform: uppercase; letter-spacing: 0.05em; color: #888; margin-bottom: 6px; }

/* Edit-trial sheet (mobile). Reuses .filter-sheet for the rounded-top,
   auto-height bottom-sheet shell; only the form layout is specific here. */
.trial-edit-sheet .offcanvas-body {
  /* Room to scroll clear of the home indicator on notched iPhones. */
  padding-bottom: calc(1rem + env(safe-area-inset-bottom));
}

/* "Stopped" pill, sitting directly after the "Edit <code>" heading. The header
   is Bootstrap's flex row; a small left margin separates it from the title and
   the close button keeps itself right-aligned with .ms-auto. */
.trial-active-toggle {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  margin-left: 0.5rem;
  min-height: 30px;
  padding: 3px 10px;
  border: 1px solid #A8DCC9;
  border-radius: 999px;
  background: #E1F5EE;
  color: #0F6E56;
  font-size: 12px;
  font-weight: 600;
  line-height: 1;
  -webkit-tap-highlight-color: transparent;
}

/* Pressed = stopped/finished. */
.trial-active-toggle[aria-pressed="true"] {
  border-color: #E7B9B4;
  background: #FBEDEC;
  color: #B3261E;
}

.trial-active-toggle i { font-size: 13px; }

/* Two dates per row on all but the narrowest phones. */
.trial-edit-dates {
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 0.6rem 0.5rem;
}

@media (max-width: 340px) {
  .trial-edit-dates { grid-template-columns: minmax(0, 1fr); }
}

/* type=date is intrinsically sized by the UA and overflows its grid cell
   otherwise — min-width:0 lets it shrink to the column. */
.trial-edit-sheet input[type="date"] { width: 100%; min-width: 0; }

/* The native input can only render the device locale (mm/dd/yyyy here), so the
   app's DD-MMM-YY reading is painted over the top of it: the input keeps its
   box, border and calendar glyph, but its own text is made transparent and
   this span supplies the visible date. One date per field, native picker
   intact. */
.trial-edit-date-input { position: relative; }

/* transparent, not `display:none` — the input must keep its layout, focus
   behaviour and calendar button. WebKit paints the date text through a shadow
   part that `color` alone doesn't always reach, hence the -webkit rules. */
.trial-edit-date-input input[type="date"] { color: transparent; }
.trial-edit-date-input input[type="date"]::-webkit-datetime-edit { color: transparent; }

.trial-edit-date-display {
  position: absolute;
  /* Match the input's padding so the overlay lands on the same baseline. */
  left: 0.5rem;
  top: 50%;
  transform: translateY(-50%);
  /* Never swallow a tap — the input underneath owns all interaction. */
  pointer-events: none;
  font-size: 13px;
  font-weight: 600;
  color: var(--cat-green);
  font-family: var(--font-mono);
  white-space: nowrap;
}

/* Empty date: the overlay shows a muted dd-mmm-yy placeholder instead. */
.trial-edit-date.is-empty .trial-edit-date-display {
  color: #c2c2bd;
  font-weight: 500;
}

/* While the field has focus, hand the display back to the native input —
   otherwise typing or stepping through the picker updates nothing visible
   until blur, which feels broken.

   Scoped to `.offcanvas.show`: Bootstrap hides a sheet with visibility and a
   transform rather than unmounting it, so an input focused at close time stays
   focused. Without this scope the field would reopen still in its focus state,
   showing the native mm/dd/yyyy with the green overlay hidden. Belt and braces
   with the blur-on-close handler in index.html+mobile.erb — CSS alone can't be
   defeated by a missed event, and JS alone covers browsers that keep focus
   elsewhere. */
.trial-edit-sheet.show .trial-edit-date-input input[type="date"]:focus { color: var(--cat-text); }
.trial-edit-sheet.show .trial-edit-date-input input[type="date"]:focus::-webkit-datetime-edit { color: var(--cat-text); }
.trial-edit-sheet.show .trial-edit-date-input input[type="date"]:focus + .trial-edit-date-display { display: none; }

/* Save only — the X cancels. Right-aligned so it sits under the thumb rather
   than spanning the sheet. */
.trial-edit-actions {
  display: flex;
  justify-content: flex-end;
  border-top: 1px solid #ececec;
  padding-top: 0.75rem;
}

/* Explicit brand green rather than relying on Bootstrap's .btn-success, so
   the button can't pick up a dark default from elsewhere. */
.trial-edit-save {
  min-width: 128px;
  padding: 0.45rem 1.1rem;
  border: 0;
  border-radius: 6px;
  background: var(--cat-green);
  color: #fff;
  font-weight: 600;
}

.trial-edit-save:hover,
.trial-edit-save:focus { background: #214D3A; color: #fff; }

.collection-pills { display: flex; flex-wrap: wrap; gap: 6px; margin-bottom: 0.75rem; }

.collection-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 12px;
  background: rgba(0,0,0,0.06);
  color: var(--cat-text);
  text-decoration: none;
  border: 1px solid rgba(0,0,0,0.1);
  transition: background 0.12s;
}

.collection-pill input[type="checkbox"],
.collection-pill input[type="radio"]    { display: none; }
.collection-pill:hover               { background: rgba(0,0,0,0.1); color: var(--cat-text); }
.collection-pill--active             { background: var(--cat-green); color: #fff; border-color: var(--cat-green); }
.collection-pill--active:hover       { background: #214D3A; color: #fff; }
.collection-pill-count               { font-size: 10px; opacity: 0.7; }

/* ==================
   BOOTSTRAP PAGINATION OVERRIDES
   ================== */

.pagination { margin-bottom: 0; }

.pagination .page-link {
  color: var(--cat-green);
  border-color: rgba(0,0,0,0.1);
  font-size: 12px;
  padding: 3px 8px;
  border-radius: 6px !important;
  line-height: 1.4;
}

.pagination .page-item.active .page-link {
  background-color: var(--cat-green);
  border-color: var(--cat-green);
  color: #fff;
}

.pagination .page-item.disabled .page-link {
  color: var(--cat-muted);
  border-color: rgba(0,0,0,0.06);
}
