/* ═══════════════════════════════════════════════════════════
 * crm-checklist.css — CRM Task Checklists Styles
 * Dark theme aligned with AI Design Club design system
 * ═══════════════════════════════════════════════════════════ */

/* ── Root ── */
.crm-checklists-root {
  margin: 16px 0 0 0;
}

/* ── Checklist block ── */
.checklist {
  margin: 0 0 12px 0;
  border: 1px solid rgba(255,255,255,0.06);
  border-radius: 10px;
  background: rgba(255,255,255,0.02);
  overflow: hidden;
}

/* ── Header ── */
.checklist-header {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border-bottom: 1px solid rgba(255,255,255,0.06);
  background: rgba(255,255,255,0.02);
}

.checklist-icon {
  color: #00A5FF;
  display: flex;
  align-items: center;
  flex-shrink: 0;
}

.checklist-title {
  font-weight: 700;
  font-size: 13px;
  color: #f6f6ff;
  flex: 1;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  cursor: default;
  padding: 2px 4px;
  border-radius: 4px;
}

.checklist-title[contenteditable="true"] {
  outline: none;
  border-bottom: 1px dashed rgba(255,255,255,0.25);
  background: rgba(255,255,255,0.04);
  cursor: text;
}

/* ── Progress ── */
.checklist-progress {
  display: flex;
  align-items: center;
  gap: 6px;
  flex-shrink: 0;
}

.checklist-progress-text {
  font-size: 11px;
  color: rgba(255,255,255,0.45);
  white-space: nowrap;
}

.checklist-progress-bar {
  width: 80px;
  height: 4px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
  overflow: hidden;
}

.checklist-progress-fill {
  height: 100%;
  background: #00A5FF;
  border-radius: 2px;
  transition: width 0.3s ease;
}

.checklist-progress-fill--done {
  background: #4CAF50;
}

/* ── Header buttons ── */
.checklist-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.35);
  cursor: pointer;
  padding: 4px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  transition: color 0.15s, background 0.15s;
}

.checklist-btn:hover {
  color: rgba(255,255,255,0.7);
  background: rgba(255,255,255,0.06);
}

/* ── Body (collapsible) ── */
.checklist-body.is-collapsed {
  display: none;
}

/* ── Items list ── */
.checklist-items {
  min-height: 2px;
  counter-reset: checklist-item-counter;
}

/* ── Single item row ── */
.checklist-item {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 7px 12px 7px 8px;
  border-bottom: 1px solid rgba(255,255,255,0.03);
  transition: background 0.12s;
  counter-increment: checklist-item-counter;
}

.checklist-item:hover {
  background: rgba(255,255,255,0.03);
}

.checklist-item:last-child {
  border-bottom: none;
}

/* Drag grip */
.checklist-item-grip {
  cursor: grab;
  display: flex;
  align-items: center;
  padding: 0 2px;
  opacity: 0;
  transition: opacity 0.15s;
  flex-shrink: 0;
}

/* Item number */
.checklist-item-num {
  font-size: 11px;
  color: rgba(255,255,255,0.3);
  min-width: 18px;
  text-align: right;
  flex-shrink: 0;
  user-select: none;
}

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

/* Checkbox */
.checklist-item-checkbox-wrap {
  display: flex;
  align-items: center;
  flex-shrink: 0;
  cursor: pointer;
}

.checklist-item-checkbox {
  width: 16px;
  height: 16px;
  border-radius: 4px;
  border: 2px solid rgba(255,255,255,0.2);
  appearance: none;
  -webkit-appearance: none;
  background: transparent;
  cursor: pointer;
  transition: all 0.15s;
  position: relative;
}

.checklist-item-checkbox:checked {
  background: #00A5FF;
  border-color: #00A5FF;
}

.checklist-item-checkbox:checked::after {
  content: '';
  position: absolute;
  top: 1px;
  left: 4px;
  width: 5px;
  height: 9px;
  border: solid #fff;
  border-width: 0 2px 2px 0;
  transform: rotate(45deg);
}

/* Item text */
.checklist-item-text {
  flex: 1;
  font-size: 13px;
  color: #e8ebff;
  min-width: 0;
  overflow: hidden;
  text-overflow: ellipsis;
  cursor: default;
  padding: 2px 4px;
  border-radius: 3px;
  line-height: 1.4;
}

.checklist-item-text[contenteditable="true"] {
  outline: none;
  border-bottom: 1px dashed rgba(255,255,255,0.2);
  background: rgba(255,255,255,0.04);
  cursor: text;
}

.checklist-item--done .checklist-item-text {
  text-decoration: line-through;
  color: rgba(255,255,255,0.3);
}

/* Item meta (due date, assignee) */
.checklist-item-meta {
  display: flex;
  gap: 6px;
  align-items: center;
  flex-shrink: 0;
}

.checklist-item-due {
  color: rgba(255,255,255,0.35);
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
}

.checklist-item-due--soon {
  color: #FFB800;
}

.checklist-item-due--overdue {
  color: #FF4444;
}

.checklist-item-assignee {
  color: rgba(255,255,255,0.4);
  font-size: 11px;
  display: flex;
  align-items: center;
  gap: 3px;
  white-space: nowrap;
  max-width: 100px;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Item actions (edit, delete) — visible on hover */
.checklist-item-actions {
  display: flex;
  gap: 2px;
  opacity: 0;
  transition: opacity 0.15s;
  flex-shrink: 0;
}

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

.checklist-item-edit,
.checklist-item-delete {
  padding: 3px;
  font-size: 0;
}

.checklist-item-delete:hover {
  color: #FF4444;
}

/* ── Drag states ── */
.checklist-item--dragging {
  opacity: 0.4;
}

.checklist-item--dragover {
  border-top: 2px solid #00A5FF;
}

/* ── Add item ── */
.checklist-add-item {
  padding: 8px 12px 8px 36px;
  color: rgba(255,255,255,0.35);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  transition: color 0.15s;
}

.checklist-add-item:hover {
  color: #00A5FF;
}

.checklist-add-input {
  flex: 1;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 6px;
  color: #f6f6ff;
  font-size: 13px;
  padding: 6px 10px;
  outline: none;
  width: 100%;
}

.checklist-add-input::placeholder {
  color: rgba(255,255,255,0.3);
}

.checklist-add-input:focus {
  border-color: #00A5FF;
}

/* ── New checklist button ── */
.checklist-new {
  padding: 10px 12px;
  color: rgba(255,255,255,0.35);
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px dashed rgba(255,255,255,0.08);
  border-radius: 10px;
  transition: color 0.15s, border-color 0.15s;
  margin-top: 4px;
}

.checklist-new:hover {
  color: #00A5FF;
  border-color: rgba(0,165,255,0.3);
}

/* ── Context menu ── */
.checklist-context-menu {
  background: #1a1b2e;
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  padding: 4px;
  box-shadow: 0 8px 24px rgba(0,0,0,0.5);
  min-width: 180px;
  z-index: 100010;
}

.checklist-menu-item {
  padding: 8px 12px;
  font-size: 13px;
  color: #e8ebff;
  cursor: pointer;
  border-radius: 6px;
  display: flex;
  align-items: center;
  gap: 8px;
  transition: background 0.12s;
}

.checklist-menu-item:hover {
  background: rgba(255,255,255,0.06);
}

.checklist-menu-item--danger {
  color: #FF4444;
}

.checklist-menu-item--danger:hover {
  background: rgba(255,68,68,0.1);
}

/* ── Edit Item Modal ── */
.checklist-edit-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.6);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100020;
  backdrop-filter: blur(2px);
}

.checklist-edit-modal {
  background: #181928;
  border: 1px solid rgba(255,255,255,0.08);
  border-radius: 14px;
  width: 520px;
  max-width: 95vw;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 12px 40px rgba(0,0,0,0.5);
  color: #f6f6ff;
}

.checklist-edit-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px 12px;
  font-weight: 700;
  font-size: 15px;
  color: #f6f6ff;
  border-bottom: 1px solid rgba(255,255,255,0.06);
}

.checklist-edit-body {
  padding: 16px 20px;
}

.checklist-edit-group {
  margin-bottom: 14px;
}

.checklist-edit-group label {
  display: block;
  font-size: 12px;
  font-weight: 600;
  color: rgba(255,255,255,0.5);
  margin-bottom: 6px;
}

.checklist-edit-group label svg {
  vertical-align: middle;
  margin-right: 4px;
}

.checklist-edit-input {
  width: 100%;
  background: rgba(255,255,255,0.04);
  border: 1px solid rgba(255,255,255,0.1);
  border-radius: 8px;
  color: #f6f6ff;
  font-size: 13px;
  padding: 8px 12px;
  outline: none;
  transition: border-color 0.15s;
}

.checklist-edit-input:focus {
  border-color: #00A5FF;
}

.checklist-edit-row {
  display: flex;
  gap: 12px;
}

.checklist-edit-row .checklist-edit-group {
  flex: 1;
}

.checklist-edit-footer {
  display: flex;
  justify-content: flex-end;
  gap: 8px;
  padding: 12px 20px 16px;
  border-top: 1px solid rgba(255,255,255,0.06);
}

/* ── Mini progress on kanban card ── */
.crm-task-card__checklist-progress {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}

.crm-task-card__progress-bar {
  display: inline-block;
  width: 40px;
  height: 3px;
  background: rgba(255,255,255,0.08);
  border-radius: 2px;
  overflow: hidden;
  vertical-align: middle;
}

.crm-task-card__progress-fill {
  display: block;
  height: 100%;
  background: #00A5FF;
  border-radius: 2px;
  transition: width 0.3s ease;
}

.crm-task-card__progress-fill--done {
  background: #4CAF50;
}

/* ── Select styling for edit modal ── */
.checklist-edit-input option {
  background: #181928;
  color: #f6f6ff;
}
select.checklist-edit-input {
  appearance: none;
  -webkit-appearance: none;
  background: rgba(255,255,255,0.04) url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6'%3E%3Cpath d='M0 0l5 6 5-6z' fill='%23aaa'/%3E%3C/svg%3E") no-repeat right 12px center;
  padding-right: 32px;
  color-scheme: dark;
}

/* ── Date/time inputs for dark theme ── */
.checklist-edit-input[type="time"] {
  color-scheme: dark;
}

/* ── Custom calendar in edit item modal ── */
.crm-deadline-row--cl {
  display: flex;
  align-items: center;
  gap: 8px;
}
.crm-deadline-row--cl .crm-date-input-wrap {
  display: flex;
  align-items: center;
  gap: 0;
  flex: 1;
  position: relative;
}
.crm-deadline-row--cl .crm-date-display {
  cursor: pointer;
  padding-right: 32px;
}
.crm-deadline-row--cl .crm-date-btn {
  background: none;
  border: none;
  color: rgba(255,255,255,0.5);
  cursor: pointer;
  padding: 6px;
  display: flex;
  align-items: center;
  position: absolute;
  right: 4px;
  top: 50%;
  transform: translateY(-50%);
  z-index: 1;
}
.checklist-edit-modal .crm-calendar-panel {
  display: none;
  margin-top: 4px;
  margin-bottom: 14px;
}
.checklist-edit-modal .crm-calendar-panel.open {
  display: block;
}

/* ── Responsive ── */
@media (max-width: 500px) {
  .checklist-edit-modal {
    width: 98vw;
    border-radius: 10px;
  }
  .checklist-edit-row {
    flex-direction: column;
    gap: 0;
  }
  .checklist-progress-bar {
    width: 50px;
  }
}
