/* ========================================================================
   CUSTOM FILTERS — Settings → Custom Filters
   List table + two-column detail (Details / option list | Option settings).
   Typography follows the app's established scale:
     page title 26/600 · section title 18/600 · field label 12/500 ·
     body + inputs 14/400 · helper 13/400 · buttons 13/500 ·
     700 reserved for data emphasis (match counts) only.
   ======================================================================== */

.cf-body { padding: 0; display: block; overflow: hidden; }
.cf-scroll { height: 100%; overflow-y: auto; }

/* ---- header "Create new" ---------------------------------------------- */
.cf-create-new { padding: 8px 14px; font-size: 13px; }

/* ===== LIST VIEW ======================================================== */
/* Centered + max-width to match the Worksheets library. */
.cf-page { max-width: 1180px; margin-inline: auto; padding: 28px 40px 64px 40px; }
.cf-page-head { margin-bottom: 20px; }
.cf-page-title {
  font: 600 26px/1.2 var(--font-body);
  letter-spacing: -0.01em; color: var(--foreground); margin: 0;
}
.cf-page-sub {
  font: 400 14px/1.5 var(--font-body); color: var(--muted-foreground);
  margin: 6px 0 0;
}

.cf-table { padding: 0; overflow: hidden; border-radius: var(--radius-md); }
.cf-table-head,
.cf-row {
  display: grid;
  grid-template-columns: minmax(240px, 1fr) 150px minmax(160px, 240px) 96px 64px;
  align-items: center;
}
.cf-table-head {
  background: var(--ps-neutral-115);
  border-bottom: 1px solid var(--divider);
  padding: 0 20px;
  height: 44px;
}
.cf-th {
  display: inline-flex; align-items: center; gap: 6px;
  background: none; border: 0; padding: 4px 0;
  font: 600 13px/1 var(--font-body); color: var(--foreground);
  cursor: pointer;
}
.cf-th-arrow { color: var(--ps-primary-500); }
.cf-th-arrow--idle { color: var(--ps-neutral-300); }

.cf-row {
  padding: 0 20px; min-height: 60px;
  border-bottom: 1px solid var(--divider);
  cursor: pointer; transition: background 120ms;
}
.cf-row:last-child { border-bottom: 0; }
.cf-row:hover { background: var(--ps-neutral-100); }
.cf-row--expanded { background: var(--ps-neutral-100); }
.cf-row-name { display: inline-flex; align-items: center; gap: 10px; }

/* expand / collapse chevron on parent filter rows */
.cf-row-expand {
  width: 22px; height: 22px; border-radius: 6px; border: 0; flex-shrink: 0;
  background: transparent; color: var(--ps-neutral-400);
  display: inline-flex; align-items: center; justify-content: center;
  cursor: pointer; transition: background 120ms, color 120ms, transform 140ms ease;
}
.cf-row-expand:hover { background: var(--ps-neutral-200); color: var(--foreground); }
.cf-row-expand.open { transform: rotate(90deg); color: var(--foreground); }
.cf-expand-spacer { width: 22px; flex-shrink: 0; }

/* child option rows revealed on expand */
.cf-row--child { min-height: 48px; background: var(--ps-neutral-75); }
.cf-row--child:hover { background: var(--ps-neutral-100); }
.cf-child-name { gap: 0; }
.cf-child-rail {
  width: 22px; align-self: stretch; flex-shrink: 0; margin-right: 12px;
  border-left: 1.5px solid var(--ps-neutral-200);
  margin-left: 10px;
}
.cf-child-label { font: 500 14px/1.3 var(--font-body); color: var(--foreground); }
.cf-child-meta { font: 400 13px/1.3 var(--font-body); color: var(--muted-foreground); }
.cf-row--child .cf-row-chev { color: var(--ps-neutral-300); }
.cf-row-icon { color: var(--muted-foreground); }
.cf-row-label { font: 600 14px/1.3 var(--font-body); color: var(--foreground); }
.cf-row-chev { color: var(--ps-neutral-300); }
.cf-type-badge { font-size: 12px; padding: 3px 10px; border-radius: 6px; }
.cf-key-code {
  font: 400 13px/1.3 var(--font-mono); color: var(--ps-neutral-600);
  background: var(--ps-neutral-115); border-radius: 6px; padding: 3px 8px;
  max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap;
}
.cf-items-count { font: 400 14px/1 var(--font-body); color: var(--ps-neutral-700); }
.cf-col-menu { display: flex; justify-content: flex-end; }
.cf-row-menu {
  width: 32px; height: 32px; border-radius: 8px; border: 0;
  background: transparent; color: var(--ps-neutral-500);
  display: inline-flex; align-items: center; justify-content: center;
  transition: background 120ms, color 120ms;
}
.cf-row-menu:hover { background: var(--ps-neutral-125); color: var(--foreground); }

/* row “more actions” dropdown (fixed-positioned to escape table clip) */
.cf-menu {
  min-width: 180px;
  background: var(--popover);
  border: 1px solid var(--divider);
  border-radius: 12px;
  box-shadow: 0 12px 32px rgba(15,19,51,0.14), 0 2px 6px rgba(15,19,51,0.06);
  padding: 6px;
}
.cf-menu-item {
  display: flex; align-items: center; gap: 10px;
  width: 100%; text-align: left;
  padding: 9px 10px; border: 0; border-radius: 8px;
  background: transparent; cursor: pointer;
  font: 400 14px/1 var(--font-body); color: var(--foreground);
}
.cf-menu-item:hover { background: var(--accent); }
.cf-menu-item i, .cf-menu-item svg { width: 16px; height: 16px; color: var(--ps-neutral-400); }
.cf-menu-item--danger { color: var(--ps-destructive); }
.cf-menu-item--danger:hover { background: #fef2f3; }
.cf-menu-item--danger i, .cf-menu-item--danger svg { color: var(--ps-destructive); }

/* ===== DETAIL VIEW ===================================================== */
.cf-detail { display: flex; align-items: stretch; min-height: 100%; }
.cf-detail-left {
  flex: 0 0 460px;
  padding: 28px 36px 48px 40px;
  border-right: 1px solid var(--divider);
}
.cf-detail-right {
  flex: 1 1 auto; min-width: 0;
  padding: 28px 40px 48px 36px;
}
.cf-detail-right--empty { border: 0; }

.cf-section-title {
  font: 600 18px/1.25 var(--font-body); letter-spacing: -0.01em;
  color: var(--foreground); margin: 0;
}
.cf-section-head {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
}
.cf-section-sub { margin-top: 6px; }

.cf-field { margin-top: 18px; }
.cf-label { font: 500 12px/1.3 var(--font-body); color: var(--foreground); }
.cf-label-row { display: flex; align-items: center; gap: 8px; }
.cf-locked-badge { font-size: 11px; padding: 2px 8px; }
.cf-help { font: 400 13px/1.45 var(--font-body); color: var(--muted-foreground); margin: 6px 0 0; }

.cf-input {
  width: 100%; margin-top: 8px;
  font: 400 14px/1.4 var(--font-body);
  padding: 9px 12px; border-radius: 8px;
  border: 1px solid transparent; background: var(--card); color: var(--foreground);
  outline: none; transition: border-color 120ms, box-shadow 120ms;
}
.cf-input:focus {
  border-color: var(--ps-primary-500);
  box-shadow: 0 0 0 3px var(--ps-primary-75);
}
.cf-input:disabled {
  background: var(--ps-neutral-125); color: var(--ps-neutral-400);
  cursor: default; -webkit-text-fill-color: var(--ps-neutral-400);
}
.cf-input-mono { font-family: var(--font-mono); font-size: 13px; }
.cf-input-value {
  border: 1px solid #fff; border-top: 1.5px solid #fff;
  box-shadow: 0 1px 2px rgba(20,20,23,0.04);
}

/* visibility radios */
.cf-radios { margin-top: 10px; display: flex; flex-direction: column; gap: 8px; }
.cf-radio { display: inline-flex; align-items: center; gap: 10px; cursor: default; }
.cf-radio input { display: none; }
.cf-radio-dot {
  width: 16px; height: 16px; border-radius: 999px; flex-shrink: 0;
  border: 2px solid var(--ps-neutral-300); background: #fff;
  display: inline-flex; align-items: center; justify-content: center;
}
.cf-radio input:checked + .cf-radio-dot {
  border-color: var(--ps-primary-400); background: var(--ps-primary-400);
  box-shadow: inset 0 0 0 3px #fff;
}
.cf-radio-text { font: 400 14px/1.3 var(--font-body); }
.cf-radios--locked .cf-radio-text { color: var(--ps-neutral-400); }
.cf-radios--locked .cf-radio input:checked + .cf-radio-dot {
  border-color: var(--ps-primary-200); background: var(--ps-primary-200);
}

.cf-divider { height: 1px; background: var(--divider); margin: 28px 0; }

.cf-create-option {
  background: var(--ps-neutral-125); color: var(--foreground);
  border: 0; padding: 7px 12px; font-size: 13px; font-weight: 500; border-radius: 8px;
}
.cf-create-option:hover { background: var(--ps-neutral-200); }

/* option list (left) */
.cf-option-list { margin-top: 16px; display: flex; flex-direction: column; gap: 10px; }
.cf-option-card {
  display: flex; align-items: center; justify-content: space-between; gap: 16px;
  width: 100%; text-align: left;
  background: #fbfbfc; border: 1px solid var(--ps-neutral-150);
  border-radius: 10px; padding: 13px 16px;
  cursor: pointer; transition: border-color 120ms, background 120ms, box-shadow 120ms;
}
.cf-option-card:hover { background: #fff; border-color: var(--ps-neutral-200); }
.cf-option-card--active {
  border: 1.5px solid var(--ps-primary-500); background: #fff;
  box-shadow: 0 1px 2px rgba(20,20,23,0.04);
}
.cf-option-text { display: flex; flex-direction: column; gap: 3px; min-width: 0; }
.cf-option-name { font: 600 14px/1.3 var(--font-body); color: var(--foreground); }
.cf-option-card--active .cf-option-name { color: var(--ps-primary-600); }
.cf-option-meta { font: 400 13px/1.3 var(--font-body); color: var(--muted-foreground); }
.cf-option-radio {
  width: 18px; height: 18px; border-radius: 999px; flex-shrink: 0;
  background: var(--ps-neutral-200);
}
.cf-option-radio--on {
  background: var(--ps-primary-500);
  box-shadow: inset 0 0 0 3.5px #fff, 0 0 0 1.5px var(--ps-primary-500);
}

/* ===== OPTION SETTINGS (right) ========================================= */
.cf-filters-head {
  display: flex; align-items: flex-start; justify-content: space-between; gap: 16px;
  flex-wrap: wrap; row-gap: 12px;
  margin-top: 2px;
}
.cf-filters-sub { margin-top: 6px; }
.cf-filter-type {
  display: inline-flex; align-items: center; gap: 10px; flex-shrink: 0;
}
.cf-filter-type-label {
  font: 500 13px/1 var(--font-body); color: var(--muted-foreground);
}
.cf-segment {
  display: inline-flex; gap: 2px; flex-shrink: 0;
  background: var(--ps-neutral-125); border-radius: 8px; padding: 3px;
}
.cf-segment-btn {
  border: 0; background: transparent; color: var(--muted-foreground);
  font: 500 13px/1 var(--font-body); padding: 6px 14px; border-radius: 6px;
  transition: background 120ms, color 120ms;
}
.cf-segment-btn--on {
  background: #fff; color: var(--foreground);
  box-shadow: 0 1px 2px rgba(20,20,23,0.08);
}

.cf-criteria-card {
  margin-top: 14px;
  background: var(--card);
  border: 1px solid #fff; border-top: 1.5px solid #fff;
  border-radius: 16px; box-shadow: 0 1px 2px rgba(20,20,23,0.04);
  padding: 18px;
}

.cf-criteria-controls { display: flex; align-items: center; gap: 10px; }
.cf-select-wrap { position: relative; }
.cf-select-field { flex: 1 1 auto; min-width: 0; }
.cf-select-op { flex: 0 0 220px; }
.cf-select {
  width: 100%; appearance: none; -webkit-appearance: none;
  font: 400 14px/1.3 var(--font-body); color: var(--foreground);
  padding: 9px 36px 9px 12px; border-radius: 8px;
  border: 1px solid var(--ps-neutral-200); background: #fff;
  cursor: pointer; outline: none; transition: border-color 120ms, box-shadow 120ms;
}
.cf-select:focus { border-color: var(--ps-primary-500); box-shadow: 0 0 0 3px var(--ps-primary-75); }
.cf-select-chev {
  position: absolute; right: 11px; top: 50%; transform: translateY(-50%);
  color: var(--ps-neutral-400); pointer-events: none;
}
.cf-trash {
  flex-shrink: 0; width: 36px; height: 36px; border-radius: 8px; border: 0;
  background: transparent; color: var(--ps-neutral-400);
  display: inline-flex; align-items: center; justify-content: center;
  transition: background 120ms, color 120ms;
}
.cf-trash:hover { background: #fef2f3; color: var(--ps-destructive); }
.cf-trash:disabled { opacity: 0.4; cursor: default; }
.cf-trash .luc { width: 16px; height: 16px; }

.cf-chipbox {
  margin-top: 10px;
  display: flex; flex-wrap: wrap; align-items: center; gap: 6px;
  border: 1px solid var(--ps-neutral-200); border-radius: 8px;
  padding: 8px 10px; background: #fff; min-height: 42px;
}
.cf-chip {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--ps-neutral-125); color: var(--foreground);
  border-radius: 6px; padding: 4px 5px 4px 10px;
  font: 400 13px/1.2 var(--font-body);
}
.cf-chip-x {
  display: inline-flex; align-items: center; justify-content: center;
  width: 18px; height: 18px; border-radius: 5px; border: 0;
  background: transparent; color: var(--ps-neutral-500);
  transition: background 120ms, color 120ms;
}
.cf-chip-x:hover { background: var(--ps-neutral-200); color: var(--foreground); }
.cf-chip-input {
  flex: 1 1 80px; min-width: 80px; border: 0; outline: none; background: transparent;
  font: 400 13px/1.2 var(--font-body); color: var(--foreground); padding: 3px 2px;
}
.cf-chipbox-clear {
  margin-left: auto; flex-shrink: 0;
  display: inline-flex; align-items: center; justify-content: center;
  width: 22px; height: 22px; border-radius: 6px; border: 0;
  background: transparent; color: var(--ps-neutral-400);
  transition: background 120ms, color 120ms;
}
.cf-chipbox-clear:hover { background: var(--ps-neutral-125); color: var(--foreground); }

/* connector: centered add dot + (optional) AND/OR joiner */
.cf-connector { display: flex; flex-direction: column; align-items: flex-start; gap: 12px; padding: 12px 0; }
.cf-add-dot {
  align-self: center; flex-shrink: 0;
  width: 26px; height: 26px; border-radius: 999px; border: 0;
  background: var(--ps-primary-500); color: #fff;
  display: inline-flex; align-items: center; justify-content: center;
  box-shadow: 0 1px 3px rgba(77,95,255,0.35); transition: background 120ms;
}
.cf-add-dot:hover { background: var(--ps-primary-600); }
.cf-joiner { display: inline-flex; gap: 4px; }
.cf-joiner-btn {
  border: 0; background: transparent; border-radius: 6px;
  font: 600 13px/1 var(--font-body); color: var(--ps-primary-500);
  padding: 6px 12px; transition: background 120ms, color 120ms;
}
.cf-joiner-btn--on { background: var(--ps-neutral-125); color: var(--ps-neutral-700); }

.cf-add-filter {
  width: 100%; margin-top: 14px;
  display: inline-flex; align-items: center; justify-content: center; gap: 8px;
  border: 1.5px dashed var(--ps-primary-200); border-radius: 12px;
  background: transparent; color: var(--ps-primary-600);
  font: 500 14px/1 var(--font-body); padding: 18px;
  transition: background 120ms, border-color 120ms;
}
.cf-add-filter:hover { background: var(--ps-primary-50); border-color: var(--ps-primary-300); }

/* footer */
.cf-option-footer {
  margin-top: 20px;
  display: flex; align-items: center; gap: 20px;
  background: var(--card);
  border: 1px solid #fff; border-top: 1.5px solid #fff;
  border-radius: 16px; box-shadow: 0 1px 2px rgba(20,20,23,0.04);
  padding: 14px 18px;
}
.cf-match-count {
  display: inline-flex; align-items: center; gap: 8px;
  font: 400 14px/1.3 var(--font-body); color: var(--foreground);
}
.cf-match-count > .luc { color: var(--muted-foreground); width: 16px; height: 16px; }
.cf-match-count strong { font-weight: 600; }
.cf-footer-actions { margin-left: auto; display: flex; align-items: center; gap: 14px; }
.cf-default-toggle { display: inline-flex; align-items: center; gap: 8px; cursor: pointer; }
.cf-default-toggle input { display: none; }
.cf-default-dot {
  width: 16px; height: 16px; border-radius: 999px; flex-shrink: 0;
  border: 2px solid var(--ps-neutral-300); background: #fff;
}
.cf-default-toggle input:checked + .cf-default-dot {
  border-color: var(--ps-primary-500); background: var(--ps-primary-500);
  box-shadow: inset 0 0 0 3px #fff;
}
.cf-default-toggle span:last-child { font: 400 14px/1.3 var(--font-body); color: var(--foreground); }
.cf-delete-item {
  background: var(--ps-destructive); color: #fff;
  border: 0; padding: 8px 16px; font: 500 13px/1 var(--font-body); border-radius: 8px;
}
.cf-delete-item:hover { background: #c40009; }
.cf-save-item {
  background: var(--ps-primary-500); color: #fff;
  border: 1px solid #fff; border-top: 1.5px solid #fff;
  padding: 8px 18px; font: 500 13px/1 var(--font-body); border-radius: 8px;
}
.cf-save-item:hover { background: var(--ps-primary-600); }

@media (max-width: 1100px) {
  .cf-detail { flex-direction: column; }
  .cf-detail-left { flex: none; border-right: 0; border-bottom: 1px solid var(--divider); }
}

/* ===== CREATE / EDIT MODAL extras ====================================== */
.cf-modal-help { font: 400 12.5px/1.45 var(--font-body); color: var(--muted-foreground); margin: 6px 0 0; }
.cf-modal-key { font-family: var(--font-mono); font-size: 13px; }
.cf-share-toggle { display: flex; gap: 8px; }
.cf-share-btn {
  flex: 1 1 0; min-width: 0;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  padding: 10px 12px; border-radius: 9px;
  border: 1px solid var(--ps-neutral-200); background: var(--card);
  font: 500 13px/1.2 var(--font-body); color: var(--muted-foreground);
  cursor: pointer; transition: border-color 120ms, background 120ms, color 120ms;
}
.cf-share-btn:hover { border-color: var(--ps-neutral-300); color: var(--foreground); }
.cf-share-btn .luc { width: 15px; height: 15px; }
.cf-share-btn--on {
  border: 1.5px solid var(--ps-primary-500); background: var(--ps-primary-50);
  color: var(--ps-primary-700);
}
.cf-share-btn--on .luc { color: var(--ps-primary-600); }

/* ===== EMPTY FILTER-OPTIONS STATE ===================================== */
.cf-options-empty {
  margin-top: 20px;
  display: flex; flex-direction: column; align-items: center; text-align: center;
  gap: 10px; padding: 40px 28px;
  border: 1.5px dashed var(--ps-neutral-200); border-radius: 14px;
  background: #fbfbfc;
}
.cf-options-empty-ico {
  width: 52px; height: 52px; border-radius: 13px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--ps-primary-60); color: var(--ps-primary-500);
}
.cf-options-empty-ico .luc { width: 24px; height: 24px; }
.cf-options-empty strong { font: 600 15px/1.3 var(--font-body); color: var(--foreground); }
.cf-options-empty p { margin: 0; max-width: 320px; font: 400 13px/1.5 var(--font-body); color: var(--muted-foreground); }
.cf-options-empty-btn { margin-top: 6px; padding: 9px 16px; font-size: 13px; }

/* ===== DETAIL VIEW (3-column shell: options nav | head + settings) ===== */
/* Centered, readable max-width — matches the Worksheets landing page.
   Scoped to the custom-filter detail so search/worksheet detail are
   unaffected (they share #work-area > [data-role="detail"]). */
.cf-detail-scope { width: 100%; max-width: 1180px; margin-inline: auto; }
.cf-detail-head { align-items: flex-start; }

/* "Create new option" affordance at the top of the options nav. */
.rn-create {
  flex: 0 0 auto; margin: 2px 12px 8px;
  display: inline-flex; align-items: center; justify-content: center; gap: 7px;
  border: 1.5px dashed var(--ps-primary-200); border-radius: 9px;
  background: transparent; color: var(--ps-primary-600);
  font: 500 13px/1 var(--font-body); padding: 10px 12px; cursor: pointer;
  transition: background 120ms, border-color 120ms;
}
.rn-create:hover { background: var(--ps-primary-50); border-color: var(--ps-primary-300); }

/* Locked Key / CRM field rendered as disabled inputs in the head. */
.pv-locked-fields {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 12px 24px; margin-top: 16px; max-width: 720px;
}
.pv-locked-fields .cf-field { margin-top: 0; }
.pv-locked-fields .cf-input { max-width: 100%; }

/* Value chips: alphabetical, wrapping pills styled like the filter-panel
   chips (accent fill, white bevel border). The whole box stays a
   click-to-type input area. */
.cf-chipbox--grid { flex-direction: column; align-items: stretch; gap: 10px; cursor: text; }
.cf-chipgrid { display: flex; flex-wrap: wrap; gap: 6px; width: 100%; }
.cf-chipbox--grid .cf-chip {
  display: inline-flex; align-items: center; justify-content: center; gap: 4px;
  background: var(--accent);
  border: 0.5px solid #fff; border-top-width: 1px;
  border-radius: 8px; padding: 3px 5px 3px 9px;
  font-size: 12px; line-height: 1.3; color: var(--accent-foreground); font-weight: 500;
  white-space: nowrap;
  transition: box-shadow 120ms, background 120ms;
}
.cf-chipbox--grid .cf-chip:hover { background: var(--ps-primary-75); }
.cf-chip-label { color: var(--accent-foreground); font-weight: 500; }
.cf-chipbox--grid .cf-chip-x { color: var(--muted-foreground); background: transparent; }
.cf-chipbox--grid .cf-chip-x:hover { background: transparent; color: var(--foreground); }
.cf-chip-inputrow { display: flex; align-items: center; gap: 6px; width: 100%; }
.cf-chip-inputrow .cf-chip-input { flex: 1 1 auto; }

/* Footer wraps rather than forcing horizontal scroll on narrow viewports. */
.cf-option-footer { flex-wrap: wrap; }

/* Empty state when no option is picked (filter has options).
   Styled to match the "No filter options yet" initial state: a dashed-border
   card on off-white with a primary-tinted icon badge. */
.pv-empty {
  margin-top: 20px;
  display: flex; flex-direction: column; align-items: center; justify-content: center;
  text-align: center; gap: 10px; padding: 40px 28px;
  border: 1.5px dashed var(--ps-neutral-200); border-radius: 14px;
  background: #fbfbfc;
  color: var(--muted-foreground);
}
.pv-empty .pv-empty-ico {
  width: 52px; height: 52px; border-radius: 13px;
  display: inline-flex; align-items: center; justify-content: center;
  background: var(--ps-primary-60); color: var(--ps-primary-500);
}
.pv-empty .pv-empty-ico .luc { width: 24px; height: 24px; }
.pv-empty strong { font: 600 15px/1.3 var(--font-body); color: var(--foreground); }
.pv-empty p { margin: 0; max-width: 320px; font: 400 13px/1.5 var(--font-body); color: var(--muted-foreground); }
