/* ---- Design tokens (Bold Insight brand palette) ---- */
:root {
  --blue: #2F53AC;
  --blue-dark: #284792;
  --blue-light: #00BBE7;
  /* Button shades. Light blue is too pale for white text (2.3:1), so solid
     buttons pair it with dark text; outline buttons need the darker tint to
     stay legible against white. */
  --btn-bg: #00BBE7;
  --btn-bg-hover: #009fc4;
  --btn-ink: #062831;
  --btn-outline-ink: #007a96;
  --green: #73C06D;
  --purple: #3B2B6F;
  --pink: #A0036C;
  --yellow: #F0C808;
  --red: #A62325;
  --orange: #EE7008;
  --border: #e5e7eb;
  --border-strong: #d1d5db;
  --muted: #6b7280;
  --bg-soft: #f9fafb;
  --text: #111827;
  --text-secondary: #6b7280;
}

body {
  color: var(--text);
  background: #fff;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

a { text-decoration: none; }
a:hover { text-decoration: underline; }

/* ---- Bootstrap primary/link re-theme (Bootstrap's compiled CSS bakes
   .btn-primary/.btn-outline-primary colors into local --bs-btn-* vars per
   rule, so --bs-primary alone doesn't reach them; both layers are set here) ---- */
:root {
  --bs-primary: var(--blue);
  --bs-primary-rgb: 47, 83, 172;
  --bs-link-color-rgb: 47, 83, 172;
  --bs-link-hover-color-rgb: 40, 71, 146;
}

.btn-primary {
  --bs-btn-color: var(--btn-ink);
  --bs-btn-bg: var(--btn-bg);
  --bs-btn-border-color: var(--btn-bg);
  --bs-btn-hover-color: var(--btn-ink);
  --bs-btn-hover-bg: var(--btn-bg-hover);
  --bs-btn-hover-border-color: var(--btn-bg-hover);
  --bs-btn-active-color: var(--btn-ink);
  --bs-btn-active-bg: var(--btn-bg-hover);
  --bs-btn-active-border-color: var(--btn-bg-hover);
  --bs-btn-disabled-color: var(--btn-ink);
  --bs-btn-disabled-bg: var(--btn-bg);
  --bs-btn-disabled-border-color: var(--btn-bg);
  --bs-btn-focus-shadow-rgb: 0, 187, 231;
}

.btn-outline-primary {
  --bs-btn-color: var(--btn-outline-ink);
  --bs-btn-border-color: var(--btn-outline-ink);
  --bs-btn-hover-color: var(--btn-ink);
  --bs-btn-hover-bg: var(--btn-bg);
  --bs-btn-hover-border-color: var(--btn-bg);
  --bs-btn-active-color: var(--btn-ink);
  --bs-btn-active-bg: var(--btn-bg);
  --bs-btn-active-border-color: var(--btn-bg);
  --bs-btn-disabled-color: var(--btn-outline-ink);
  --bs-btn-disabled-border-color: var(--btn-outline-ink);
  --bs-btn-focus-shadow-rgb: 0, 187, 231;
}

.form-control:focus,
.form-select:focus,
.form-check-input:focus {
  border-color: rgba(47, 83, 172, .5);
  box-shadow: 0 0 0 .25rem rgba(47, 83, 172, .25);
}

.form-check-input:checked {
  background-color: var(--blue);
  border-color: var(--blue);
}

/* ---- App header (top bar) ---- */
.app-header {
  background: #fff;
  border-bottom: 1px solid var(--border);
  padding-top: 14px;
  padding-bottom: 14px;
  display: flex;
  align-items: center;
}

.app-header .navbar-brand {
  font-weight: 600;
  font-size: 0.9375rem;
}

.brand-logo {
  width: 125px;
  height: auto;
  display: block;
}

.brand-app-name {
  color: var(--text);
  border-left: 1px solid var(--border-strong);
  padding-left: 14px;
  line-height: 1;
}

.brand-app-name:hover {
  color: var(--blue);
}

/* ---- Tab navigation bar ---- */
.app-nav {
  background: #fff;
  border-bottom: 1px solid var(--border);
}

.nav-underline-tabs {
  display: flex;
  align-items: flex-end;
  gap: 0;
  overflow-x: auto;
  scrollbar-width: none;
}

.nav-underline-tabs::-webkit-scrollbar { display: none; }

.nav-underline-tabs .nav-link {
  border: none;
  border-bottom: 2px solid transparent;
  border-radius: 0;
  padding: 10px 16px;
  color: var(--text-secondary);
  font-weight: 500;
  font-size: 0.875rem;
  line-height: 1;
  white-space: nowrap;
  text-decoration: none;
  transition: color 0.12s, border-color 0.12s;
}

.nav-underline-tabs .nav-link.active {
  color: var(--blue);
  border-bottom-color: var(--blue);
  background: none;
}

.nav-underline-tabs .nav-link:hover:not(.active) {
  color: var(--text);
  border-bottom-color: var(--border-strong);
  background: none;
  text-decoration: none;
}

.nav-count {
  font-size: 0.72rem;
  color: var(--muted);
  margin-left: 3px;
  font-weight: 400;
}

/* ---- Cards ---- */
.card {
  border: 1px solid var(--border) !important;
  box-shadow: none !important;
  border-radius: 8px;
}

.card-header {
  background: #fff !important;
  border-bottom: 1px solid var(--border);
}

.card .form-label,
.card label {
  font-weight: 600;
  color: #344054;
}

/* ---- Filter toolbar ---- */
.filter-toolbar {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 0;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}

.filter-btn {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  font-size: 0.8125rem;
  color: #374151;
  cursor: pointer;
  white-space: nowrap;
  line-height: 1.5;
  text-decoration: none;
  transition: background 0.1s, border-color 0.1s;
}

.filter-btn:hover {
  background: var(--bg-soft);
  color: var(--text);
  text-decoration: none;
}

.filter-btn.active-filter {
  background: #e2e7f3;
  border-color: #c1cbe6;
  color: var(--blue);
}

.filter-search-wrap {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 5px 10px;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  min-width: 160px;
  max-width: 220px;
  flex: 0 1 220px;
}

.filter-search-wrap:focus-within {
  border-color: var(--blue);
  box-shadow: 0 0 0 3px rgba(47,83,172,0.08);
}

.filter-search-wrap svg { flex-shrink: 0; color: var(--muted); }

.filter-search-wrap input {
  border: none;
  outline: none;
  font-size: 0.8125rem;
  color: var(--text);
  width: 100%;
  padding: 0;
  background: transparent;
}

.filter-search-wrap input::placeholder { color: var(--muted); }

/* ---- Participant table ---- */
.participant-table thead th {
  color: #374151;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.03em;
  text-transform: uppercase;
  white-space: nowrap;
  background: #f9fafb;
  border-bottom: 1px solid var(--border);
  padding: 10px 12px;
}

.participant-table td {
  white-space: nowrap;
  border-bottom: 1px solid #f3f4f6;
  vertical-align: middle;
  padding: 10px 12px;
}

.participant-table tbody tr:hover td { background: #fafafa; }
.participant-table tbody tr:last-child td { border-bottom: none; }

/* Participant name + subtitle cell */
.participant-name {
  font-weight: 600;
  color: var(--text);
  display: block;
}

.participant-subtitle {
  font-size: 0.73rem;
  color: var(--muted);
  display: block;
  margin-top: 1px;
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ---- Status badges (flat, UserInterviews-style) ---- */
.badge-qualified, .badge-reliable {
  background: #ebf6eb !important;
  color: #4b7d47 !important;
  border: none !important;
}

.badge-completed, .badge-paid {
  background: #e2e7f3 !important;
  color: #1f3670 !important;
  border: none !important;
}

.badge-dnc, .badge-removed, .badge-disqualified, .badge-no-show {
  background: #f3e0e0 !important;
  color: #6c1718 !important;
  border: none !important;
}

.badge-neutral, .badge-unknown {
  background: #f3f4f6 !important;
  color: #374151 !important;
  border: none !important;
}

.badge-warning-soft {
  background: #fdf7dc !important;
  color: #9c8205 !important;
  border: none !important;
}

/* ---- Pagination ---- */
.table-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-top: 1px solid var(--border);
  font-size: 0.8125rem;
  color: var(--muted);
  flex-wrap: wrap;
  gap: 8px;
}

.table-pagination .page-numbers {
  display: flex;
  align-items: center;
  gap: 2px;
}

.table-pagination .page-numbers a,
.table-pagination .page-numbers span {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-width: 30px;
  height: 30px;
  padding: 0 4px;
  border-radius: 5px;
  font-size: 0.8125rem;
  color: var(--text-secondary);
  border: 1px solid transparent;
  text-decoration: none;
  transition: background 0.1s;
}

.table-pagination .page-numbers a:hover {
  background: var(--bg-soft);
  color: var(--text);
  text-decoration: none;
}

.table-pagination .page-numbers .current-page {
  background: var(--blue);
  color: #fff !important;
  border-color: var(--blue);
  font-weight: 600;
}

.table-pagination .page-numbers .page-ellipsis {
  color: var(--muted);
  border: none;
}

/* ---- Form section labels (inside card) ---- */
.form-section {
  padding-top: 20px;
  margin-top: 8px;
  border-top: 1px solid var(--border);
}

.form-section.form-section-first {
  padding-top: 0;
  margin-top: 0;
  border-top: none;
}

.form-section-label {
  font-size: 0.72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 14px;
}

/* Inline checkbox group */
.check-group {
  display: flex;
  flex-wrap: wrap;
  gap: 24px;
}

.check-item {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.check-item input[type="checkbox"] {
  flex-shrink: 0;
}

.check-item label {
  margin: 0;
  font-weight: 500;
  font-size: 0.875rem;
  cursor: pointer;
  color: var(--text);
}

/* ---- Collapsible layout helpers ---- */
.narrow { width: min(720px, 100%); margin: 0 auto; }

.panel {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 20px;
  margin-bottom: 20px;
  background: #fff;
}

.grid.two {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 20px;
  align-items: start;
}

.title-row { display: flex; justify-content: space-between; gap: 16px; align-items: center; }

h1, h2, h3 { line-height: 1.2; }
h1 { margin: 0 0 20px; }
h2 { margin-top: 0; font-size: 20px; }

.field { margin-bottom: 14px; }
.field label { display: block; font-weight: 650; margin-bottom: 5px; }
.checkbox label { display: inline; font-weight: 500; }

/* ---- Panel/narrow form elements ---- */
.panel input:not([type="checkbox"]),
.panel select,
.panel textarea,
.narrow input:not([type="checkbox"]),
.narrow select,
.narrow textarea {
  width: 100%;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: 9px 10px;
  font: inherit;
}

input[type="checkbox"] { width: auto; margin-right: 6px; }

.panel button:not(.btn),
.narrow button:not(.btn),
.button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 38px;
  padding: 0.375rem 0.75rem;
  border: 1px solid var(--btn-bg);
  border-radius: 0.375rem;
  background: var(--btn-bg);
  color: var(--btn-ink);
  font-weight: 600;
}

.panel button:not(.btn):hover,
.narrow button:not(.btn):hover,
.button:hover {
  background: var(--btn-bg-hover);
  border-color: var(--btn-bg-hover);
  color: var(--btn-ink);
  text-decoration: none;
}

.button.secondary, .secondary {
  background: #fff;
  color: var(--btn-outline-ink);
}

.button.secondary:hover, .secondary:hover {
  background: var(--bg-soft);
  color: var(--btn-ink);
}

/* ---- Misc components ---- */
.contact-methods .btn { min-width: 72px; }

.filter-empty-state {
  background: #f8fafc;
  border-style: dashed !important;
}

.filter-row {
  box-shadow: 0 1px 2px rgba(16, 24, 40, 0.04);
}

.response-card { background: #fff; }
.response-card th { color: #344054; font-weight: 600; white-space: normal; }
.response-card td { white-space: normal; }

.pill { display: inline-block; border: 1px solid var(--border); border-radius: 999px; padding: 2px 8px; margin: 0 4px 4px 0; font-size: 13px; }
.muted, small { color: var(--muted); }
.error { color: var(--red); font-size: 14px; }
.messages { border-left: 4px solid var(--blue); padding: 8px 14px; background: var(--bg-soft); margin-bottom: 20px; }
article.item { border-top: 1px solid var(--border); padding: 12px 0; }
.question-block { border-bottom: 1px solid var(--border); padding: 14px 0; }
.pagination { margin: 18px 0; display: flex; gap: 16px; align-items: center; }

/* ---- Responsive ---- */
@media (max-width: 820px) {
  .site-header, .title-row { align-items: flex-start; flex-direction: column; }
  .grid.two { grid-template-columns: 1fr; }
  .filter-toolbar { gap: 4px; }
}

/* ---- Clickable profile values and collapsible history ---- */
.clickable-row { cursor: pointer; }

.chevron-icon {
  display: inline-block;
  transition: transform 0.2s ease;
  font-size: 0.75rem;
}

.clickable-row[aria-expanded="true"] .chevron-icon {
  transform: rotate(90deg);
}

/* ---- Checkbox fix ---- */
.checkbox {
  display: flex !important;
  align-items: center !important;
}

input[type="checkbox"] {
  appearance: checkbox !important;
  -webkit-appearance: checkbox !important;
  -moz-appearance: checkbox !important;
  width: 16px !important;
  height: 16px !important;
  margin: 0 8px 0 0 !important;
  padding: 0 !important;
  border: none !important;
  flex-shrink: 0 !important;
}

.checkbox label {
  display: inline-block !important;
  font-weight: 500;
  margin: 0 !important;
  line-height: 1.2 !important;
  cursor: pointer;
}

/* ---- Tom Select sizing ---- */
/* Strip Bootstrap's visual chrome from the wrapper (border, padding, arrow)
   so only .ts-control renders them, then pin .ts-control to Bootstrap's form-control height. */
.ts-wrapper.form-select,
.ts-wrapper.form-control {
  padding: 0 !important;
  background-image: none !important;
  border: none !important;
  box-shadow: none !important;
  height: auto !important;
}

.ts-wrapper.single .ts-control {
  min-height: calc(1.5em + 0.75rem + 2px) !important;
  padding: 0.375rem 2.25rem 0.375rem 0.75rem !important;
  font-size: 1rem !important;
  line-height: 1.5 !important;
  border: 1px solid var(--border) !important;
  border-radius: 0.375rem !important;
}

.ts-wrapper.single .ts-control input {
  font-size: 1rem !important;
  line-height: 1.5 !important;
}

/* ---- Participants hub: segments sidebar ---- */
.hub-layout {
  display: flex;
  gap: 24px;
  align-items: flex-start;
}

.hub-main {
  flex: 1 1 auto;
  min-width: 0; /* lets the responsive table shrink instead of overflowing the flex row */
}

.segments-sidebar {
  flex: 0 0 232px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
  padding: 12px;
  position: sticky;
  top: 106px;
  max-height: calc(100vh - 130px);
  overflow-y: auto;
}

.segment-link {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 8px;
  padding: 6px 8px;
  border-radius: 6px;
  color: var(--text);
  font-size: 0.85rem;
  text-decoration: none;
}

.segment-link:hover {
  background: var(--bg-soft);
  color: var(--text);
  text-decoration: none;
}

.segment-link.active {
  background: #e2e7f3;
  color: var(--blue);
  font-weight: 600;
}

.segment-link .nav-count { margin-left: auto; }

.segment-empty {
  display: block;
  padding: 4px 8px;
  font-size: 0.8rem;
  color: var(--muted);
}

.segments-group {
  margin-top: 12px;
  padding-top: 10px;
  border-top: 1px solid var(--border);
}

.segments-group-title {
  display: flex;
  justify-content: space-between;
  align-items: baseline;
  gap: 8px;
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--muted);
  margin-bottom: 4px;
  padding: 0 8px;
}

.segments-group-title a {
  font-weight: 500;
  text-transform: none;
  letter-spacing: 0;
  font-size: 0.75rem;
}

@media (max-width: 991px) {
  .hub-layout { flex-direction: column; }
  .segments-sidebar {
    position: static;
    width: 100%;
    flex: none;
    max-height: none;
  }
}

/* ---- Study recruiting funnel strip ---- */
.funnel-strip {
  display: flex;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: var(--bg-soft);
  overflow-x: auto;
}

.funnel-stage {
  flex: 1 1 0;
  min-width: 84px;
  text-align: center;
  padding: 8px 10px;
}

.funnel-stage + .funnel-stage { border-left: 1px solid var(--border); }

.funnel-stage .funnel-label {
  display: block;
  font-size: 0.68rem;
  color: var(--muted);
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.funnel-stage .funnel-value {
  font-weight: 600;
  font-size: 0.95rem;
}

.funnel-stage-empty .funnel-value { color: var(--border-strong); }

.funnel-stage-meta { background: #fff; }

/* ---- Sortable table headers ---- */
.sort-link {
  color: inherit;
  text-decoration: none;
  white-space: nowrap;
}

.sort-link:hover {
  color: var(--blue);
  text-decoration: none;
}

/* ---- Participant detail prev/next pager ---- */
.detail-pager {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.detail-pager .filter-btn.disabled {
  opacity: 0.45;
  cursor: default;
}

/* ---- Screener review verdict chips ---- */
.verdict-chip-row {
  display: flex;
  align-items: baseline;
  gap: 6px;
  margin-bottom: 3px;
  white-space: normal;
}
