/* Redmine Checklist plugin styles */
.checklist-panel {
  margin: 1em 0;
  padding: 0.5em 0;
  border-top: 1px solid var(--border-color, #ddd);
}

.checklist-title {
  font-size: 1em;
  font-weight: bold;
  margin-bottom: 0.25em;
}

.checklist-progress-wrap {
  margin-bottom: 0.5em;
}

.checklist-badge {
  display: inline-block;
  font-size: 0.8em;
  font-weight: normal;
  color: var(--secondary-text-color, #666);
  margin-bottom: 0.25em;
}

/* Progress bar */
.checklist-progress-bar {
  height: 6px;
  background: var(--border-color, #ddd);
  border-radius: 3px;
  margin-bottom: 0.75em;
  overflow: hidden;
}

.checklist-progress-fill {
  height: 100%;
  background: var(--success-color, #5cb85c);
  border-radius: 3px;
  transition: width 0.3s ease;
}

/* Item list */
.checklist-items {
  list-style: none;
  margin: 0;
  padding: 0;
}

.checklist-item {
  display: flex;
  align-items: center;
  gap: 0.5em;
  padding: 0.3em 0.25em;
  border-radius: 3px;
}

.checklist-item:hover {
  background: var(--hover-bg, rgba(0,0,0,0.04));
}

.checklist-item.is-done .checklist-item-text {
  text-decoration: line-through;
  color: var(--secondary-text-color, #888);
}

/* Section rows */
.checklist-section {
  font-weight: bold;
  font-size: 0.9em;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: var(--secondary-text-color, #555);
  border-bottom: 1px solid var(--border-color, #e0e0e0);
  padding-top: 0.6em;
  padding-bottom: 0.2em;
  margin-top: 0.4em;
}

.checklist-section-label {
  flex: 1;
}

.checklist-handle {
  /* Vertical (up/down) reorder affordance */
  cursor: ns-resize;
  color: var(--border-color, #ccc);
  user-select: none;
  flex-shrink: 0;
}

.ui-sortable-helper .checklist-handle {
  cursor: grabbing;
}

.checklist-checkbox {
  flex-shrink: 0;
}

.checklist-checkbox:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.checklist-item-text {
  flex: 1;
}

.checklist-item-actions {
  opacity: 0;
  transition: opacity 0.15s;
  flex-shrink: 0;
}

.checklist-item:hover .checklist-item-actions {
  opacity: 1;
}

.checklist-delete {
  text-decoration: none;
  font-size: 0.85em;
  padding: 0 0.25em;
}

/* Add form */
.checklist-add-form {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4em;
  margin-top: 0.5em;
  align-items: center;
}

.checklist-new-item-input {
  flex: 1;
  min-width: 160px;
  padding: 0.3em 0.5em;
  font-size: 0.9em;
}

.checklist-add-btn {
  padding: 0.3em 0.75em;
  font-size: 0.9em;
}

.checklist-add-section-btn {
  font-size: 0.9em;
  padding: 0.3em 0.75em;
  background: var(--bg-color, #fff);
  color: var(--link-color, #169);
  border: 1px solid var(--border-color, #ddd);
  cursor: pointer;
  white-space: nowrap;
}

/* Non-section items indented so they visually group under section headers */
.checklist-item:not(.checklist-section) {
  padding-left: 1.25em;
}

/* Edit control */
.checklist-edit {
  color: var(--secondary-text-color, #888);
  text-decoration: none;
  font-size: 0.85em;
  padding: 0 0.2em;
}

.checklist-edit:hover {
  color: var(--link-color, #169);
}

/* Inline edit input replaces the text span */
.checklist-edit-input {
  flex: 1;
  font-size: inherit;
  padding: 0.1em 0.3em;
  border: 1px solid var(--link-color, #169);
  border-radius: 2px;
  outline: none;
}

/* Inline validation error */
.checklist-inline-error {
  color: var(--danger-color, #c0392b);
  font-size: 0.9em;
  margin: 0.25em 0;
  padding: 0.25em 0.5em;
  border: 1px solid var(--danger-color, #c0392b);
  border-radius: 3px;
  background: rgba(192, 57, 43, 0.05);
}

/* Delete control uses Redmine's native trashcan sprite icon (#icon--del),
   styled exactly like core action icons — it inherits currentColor rather than
   forcing red, so it matches the issue delete icon. */
.checklist-delete .icon-svg,
.checklist-delete svg {
  width: 16px;
  height: 16px;
  vertical-align: middle;
}

/* History tab: muted parenthetical note after each checklist change */
.checklist-journal-note {
  color: var(--secondary-text-color, #888);
  font-size: 0.9em;
}

/* Template bar: "Apply template" dropdown + button row */
.checklist-template-bar {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4em;
  margin-top: 0.35em;
  align-items: center;
}

.checklist-template-select {
  flex: 1;
  min-width: 160px;
  padding: 0.3em 0.5em;
  font-size: 0.9em;
  border: 1px solid var(--border-color, #ddd);
  border-radius: 3px;
  background: var(--bg-color, #fff);
  color: var(--text-color, #333);
}

/* Admin template list: hint text under tracker selector */
.checklist-template-default-hint {
  color: var(--secondary-text-color, #888);
  font-size: 0.85em;
}

/* Template textarea */
.checklist-template-textarea {
  font-family: monospace;
  font-size: 0.9em;
}

/* --- Phase 4: Enforcement & assignment ---------------------------------- */

/* Allow the detail panel to wrap to its own line inside the flex <li> */
.checklist-item {
  flex-wrap: wrap;
}

/* Mandatory asterisk flag */
.checklist-mandatory-flag {
  color: var(--danger-color, #c0392b);
  font-weight: bold;
  margin-left: 0.25em;
  flex-shrink: 0;
}

/* Inline meta: assignee / due date / completion stamp */
.checklist-item-meta {
  margin-left: 0.5em;
  font-size: 0.85em;
  color: var(--secondary-text-color, #888);
  display: inline-flex;
  gap: 0.5em;
  align-items: center;
  flex-shrink: 0;
}

.checklist-due.overdue {
  color: var(--danger-color, #c0392b);
}

/* Expand chevron button — a rotating angle icon */
.checklist-expand {
  background: none;
  border: none;
  cursor: pointer;
  padding: 0 0.2em;
  line-height: 1;
  display: inline-flex;
  align-items: center;
}

.checklist-expand .icon-svg,
.checklist-expand svg {
  width: 14px;
  height: 14px;
  transition: transform 0.15s ease;
}

.checklist-expand.expanded .icon-svg,
.checklist-expand.expanded svg {
  transform: rotate(90deg);
}

/* Row action icons (expand / edit / delete) share ONE colour scheme — the
   muted edit-pencil grey, going to the link colour on hover. Scoped under
   #checklist-panel so it outranks the theme's `#content a { color: … }`. */
#checklist-panel .checklist-edit,
#checklist-panel .checklist-expand,
#checklist-panel a.checklist-convert,
#checklist-panel a.checklist-quick-convert,
#checklist-panel a.checklist-delete {
  color: var(--secondary-text-color, #888);
}

#checklist-panel .checklist-edit:hover,
#checklist-panel .checklist-expand:hover,
#checklist-panel a.checklist-convert:hover,
#checklist-panel a.checklist-quick-convert:hover,
#checklist-panel a.checklist-delete:hover {
  color: var(--link-color, #169);
}

/* "Next checklist due" chip in the panel header — small, muted, red when overdue */
#checklist-panel .checklist-next-due {
  margin-left: 8px;
  font-size: 0.8em;
  font-weight: normal;
  color: var(--secondary-text-color, #888);
}
#checklist-panel .checklist-next-due .icon-svg {
  width: 14px;
  height: 14px;
  vertical-align: -2px;
}
#checklist-panel .checklist-next-due.overdue {
  color: #c22;
}

/* Converted (locked) rows — the item was promoted to a child issue. Muted, with
   a subtask arrow and the linked issue + its status shown on the meta line. */
#checklist-panel .checklist-converted {
  opacity: 0.9;
}
#checklist-panel .checklist-converted-icon {
  color: var(--secondary-text-color, #888);
  margin-right: 4px;
}
#checklist-panel .checklist-converted.is-done .checklist-item-text {
  text-decoration: line-through;
  color: var(--secondary-text-color, #888);
}
#checklist-panel .checklist-converted-status {
  margin-left: 6px;
  font-size: 0.85em;
  color: var(--secondary-text-color, #888);
}

/* Clickable row body (manage users) — pointer cursor invites expand/collapse */
.checklist-expandable .checklist-item-text {
  cursor: pointer;
}

/* Detail panel — spans the full row width below the main row content */
.checklist-item-details {
  flex-basis: 100%;
  margin: 0.4em 0 0.2em 1.5em;
  padding: 0.5em;
  border: 1px solid var(--border-color, #ddd);
  border-radius: 3px;
  background: var(--hover-bg, rgba(0, 0, 0, 0.02));
  display: flex;
  flex-wrap: wrap;
  gap: 0.5em;
  align-items: center;
  font-size: 0.9em;
}

.checklist-item-details label {
  display: inline-flex;
  align-items: center;
  gap: 0.3em;
  white-space: nowrap;
}

.checklist-detail-cancel {
  background: none;
  border: 1px solid var(--border-color, #ddd);
  border-radius: 3px;
  cursor: pointer;
  padding: 0.3em 0.75em;
  font-size: 0.9em;
  color: var(--secondary-text-color, #888);
}

.checklist-detail-cancel:hover {
  color: var(--text-color, #333);
  border-color: var(--secondary-text-color, #888);
}
