/**
 * TaskBuilder - Change Status dialogs (task, project, bulk), SaaS theme
 * Picker styles are scoped to .wppm-cs (includes/admin/wppm_status_picker.php).
 * The shared popup frame is only restyled while it contains the picker
 * (:has(.wppm-cs)), so every other dialog keeps its current look.
 * Colors from Settings > Appearance > Modal (header/body/footer backgrounds,
 * label/text colors, action button) are applied inline and are never overridden.
 * Each status keeps its own configured color (bg_color) via --cs-color.
 */

/* ===================== Popup frame (only for this dialog) ===================== */
#wppm_task_popup:has(.wppm-cs),
#wppm_popup:has(.wppm-cs) {
  height: auto !important;
  /* Compact dialog; recenter since the col-*-offset margins assume full column width */
  max-width: 460px;
  left: 0;
  right: 0;
  margin-left: auto !important;
  margin-right: auto !important;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 24px 64px -12px rgba(15,23,42,.35), 0 2px 8px rgba(15,23,42,.08);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}
#wppm_task_popup:has(.wppm-cs) #wppm_task_popup_title,
#wppm_popup:has(.wppm-cs) #wppm_popup_title {
  margin: 0;
  padding: 18px 24px !important;
  border-bottom: 1px solid #e5e7eb;
}
#wppm_task_popup:has(.wppm-cs) #wppm_task_popup_title h3,
#wppm_popup:has(.wppm-cs) #wppm_popup_title h3 {
  font: 700 17px/1.3 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  letter-spacing: -0.01em;
}
#wppm_task_popup:has(.wppm-cs) #wppm_task_popup_body,
#wppm_popup:has(.wppm-cs) #wppm_popup_body {
  margin: 0;
  max-height: calc(100vh - 210px);
  padding: 18px 24px 10px !important;
}
#wppm_task_popup:has(.wppm-cs) #wppm_task_popup_footer,
#wppm_popup:has(.wppm-cs) #wppm_popup_footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin: 0;
  padding: 14px 24px !important;
  border-top: 1px solid #e5e7eb;
}
#wppm_task_popup:has(.wppm-cs) #wppm_task_popup_footer button,
#wppm_popup:has(.wppm-cs) #wppm_popup_footer button {
  width: auto;
  min-width: 96px;
  height: 38px;
  margin: 0;
  padding: 0 18px;
  border-radius: 9px !important;
  font: 600 13px/1 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  box-shadow: none;
}
#wppm_task_popup:has(.wppm-cs) .wppm_task_popup_close,
#wppm_popup:has(.wppm-cs) .wppm_popup_close {
  border: 1px solid #e5e7eb;
}
#wppm_task_popup:has(.wppm-cs) .wppm_task_popup_action:hover,
#wppm_popup:has(.wppm-cs) .wppm_popup_action:hover {
  filter: brightness(.94);
}

/* ===================== Picker ===================== */
.wppm-cs,
.wppm-cs *,
.wppm-cs *::before,
.wppm-cs *::after {
  box-sizing: border-box;
}
.wppm-cs {
  --cs-primary: #4f46e5;
  --cs-ink: #111827;
  --cs-muted: #6b7280;
  --cs-border: #e5e7eb;
  --cs-soft: #f8fafc;
  position: relative;
  margin: 0 0 8px;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  font-size: 13.5px;
  color: var(--cs-ink);
}

.wppm-cs-head {
  margin-bottom: 12px;
}
.wppm-cs .wppm-cs-label {
  display: block;
  margin: 0;
  font-size: 12px;
  font-weight: 600;
  letter-spacing: .04em;
  text-transform: uppercase;
  color: var(--cs-muted);
}
.wppm-cs .wppm-cs-note {
  margin: 4px 0 0;
  padding: 0;
  font-size: 13px;
  line-height: 1.45;
  color: var(--cs-muted);
}

/* Search (only rendered when there are many statuses) */
.wppm-cs-search {
  position: relative;
  margin-bottom: 10px;
}
.wppm-cs-search svg {
  position: absolute;
  top: 50%;
  left: 11px;
  width: 15px;
  height: 15px;
  transform: translateY(-50%);
  fill: none;
  stroke: #9ca3af;
  stroke-width: 2;
  stroke-linecap: round;
  pointer-events: none;
}
.wppm-cs .wppm-cs-search input[type="text"] {
  width: 100%;
  height: 38px;
  margin: 0;
  padding: 0 12px 0 34px;
  border: 1px solid var(--cs-border);
  border-radius: 9px;
  background: #fff;
  font-size: 13.5px;
  color: var(--cs-ink);
  box-shadow: none;
  transition: border-color .15s, box-shadow .15s;
}
.wppm-cs .wppm-cs-search input[type="text"]:focus {
  outline: none;
  border-color: var(--cs-primary);
  box-shadow: 0 0 0 3px rgba(79,70,229,.15);
}

/* Option list */
.wppm-cs-list {
  display: flex;
  flex-direction: column;
  gap: 6px;
  max-height: 320px;
  overflow-y: auto;
  margin: 0 -4px;
  padding: 2px 4px;
}
.wppm-cs-option {
  --cs-color: #94a3b8;
  position: relative;
  display: flex;
  align-items: center;
  gap: 12px;
  min-height: 46px;
  padding: 10px 14px;
  border: 1px solid var(--cs-border);
  border-radius: 11px;
  background: #fff;
  cursor: pointer;
  user-select: none;
  transition: border-color .15s, background-color .15s, box-shadow .15s, transform .15s;
}
.wppm-cs-option:hover {
  border-color: #d1d5db;
  background: var(--cs-soft);
}
.wppm-cs-option:active {
  transform: scale(.995);
}
.wppm-cs-option:focus {
  outline: none;
}
.wppm-cs-option:focus-visible {
  box-shadow: 0 0 0 3px rgba(79,70,229,.25);
}

.wppm-cs-dot {
  flex: 0 0 auto;
  width: 12px;
  height: 12px;
  border-radius: 50%;
  background: var(--cs-color);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--cs-color) 18%, transparent);
}
.wppm-cs-name {
  flex: 1 1 auto;
  min-width: 0;
  overflow: hidden;
  font-weight: 500;
  white-space: nowrap;
  text-overflow: ellipsis;
}
.wppm-cs-current {
  flex: 0 0 auto;
  padding: 3px 8px;
  border-radius: 999px;
  background: #f1f5f9;
  font-size: 11px;
  font-weight: 600;
  line-height: 1.2;
  color: #475569;
}
.wppm-cs-check {
  display: flex;
  flex: 0 0 auto;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border: 1.5px solid #d1d5db;
  border-radius: 50%;
  background: #fff;
  transition: background-color .15s, border-color .15s;
}
.wppm-cs-check svg {
  width: 12px;
  height: 12px;
  fill: none;
  stroke: #fff;
  stroke-width: 3;
  stroke-linecap: round;
  stroke-linejoin: round;
  opacity: 0;
  transition: opacity .15s;
}

/* Selected */
.wppm-cs-option.is-active {
  border-color: var(--cs-color);
  background: color-mix(in srgb, var(--cs-color) 8%, #fff);
  box-shadow: 0 0 0 1px var(--cs-color);
}
.wppm-cs-option.is-active .wppm-cs-name {
  font-weight: 600;
}
.wppm-cs-option.is-active .wppm-cs-check {
  border-color: var(--cs-primary);
  background: var(--cs-primary);
}
.wppm-cs-option.is-active .wppm-cs-check svg {
  opacity: 1;
}

/* Empty search result */
.wppm-cs .wppm-cs-empty {
  display: none;
  margin: 0;
  padding: 18px 0;
  font-size: 13px;
  text-align: center;
  color: var(--cs-muted);
}
.wppm-cs-list.is-empty .wppm-cs-empty {
  display: block;
}

/* Native select stays in the form for submission but is visually hidden */
.wppm-cs select.wppm-cs-native {
  position: absolute !important;
  width: 1px !important;
  height: 1px !important;
  margin: -1px !important;
  padding: 0 !important;
  overflow: hidden !important;
  clip: rect(0 0 0 0) !important;
  border: 0 !important;
  white-space: nowrap !important;
}

/* Small screens */
@media (max-width: 600px) {
  #wppm_task_popup:has(.wppm-cs) #wppm_task_popup_body,
  #wppm_popup:has(.wppm-cs) #wppm_popup_body,
  #wppm_task_popup:has(.wppm-cs) #wppm_task_popup_title,
  #wppm_popup:has(.wppm-cs) #wppm_popup_title,
  #wppm_task_popup:has(.wppm-cs) #wppm_task_popup_footer,
  #wppm_popup:has(.wppm-cs) #wppm_popup_footer {
    padding-left: 16px !important;
    padding-right: 16px !important;
  }
  .wppm-cs-list {
    max-height: 50vh;
  }
}
