/* ============================================
   TODOS - To-Do List, Kanban Board, Labels
   ============================================ */

/* ========== TODOS TAB CONTAINER ========== */

.todos-container {
  padding: 20px;
}

.todos-container .list-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
  flex-wrap: wrap;
  gap: 12px;
}

.todos-container .list-header-actions {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

/* ========== SEARCH FILTER ========== */

.todo-search-input {
  padding: 6px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 13px;
  color: var(--text);
  background: var(--bg-card);
  width: 160px;
  transition: border-color var(--transition-fast);
}

.todo-search-input:focus {
  outline: none;
  border-color: var(--primary);
}

.todo-search-input::placeholder {
  color: var(--text-light);
}

/* ========== VIEW TOGGLE ========== */

.todo-view-toggle {
  display: flex;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
}

.todo-view-btn {
  padding: 6px 12px;
  border: none;
  background: var(--bg-card);
  cursor: pointer;
  font-size: 14px;
  color: var(--text-light);
  transition: all var(--transition-fast);
}

.todo-view-btn.active {
  background: var(--primary);
  color: white;
}

.todo-view-btn:hover:not(.active) {
  background: var(--bg-subtle);
}

/* ========== KANBAN BOARD ========== */

.kanban-board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  min-height: 400px;
}

@media (max-width: 900px) {
  .kanban-board {
    grid-template-columns: 1fr;
  }
}

.kanban-column {
  background: var(--bg-subtle);
  border-radius: var(--radius);
  padding: 12px;
  min-height: 200px;
}

.kanban-column-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 4px 12px;
  font-weight: 600;
  font-size: 13px;
  color: var(--text);
  border-bottom: 2px solid var(--border);
  margin-bottom: 12px;
}

.kanban-count {
  background: var(--bg-muted);
  color: var(--text-light);
  padding: 2px 8px;
  border-radius: 10px;
  font-size: 11px;
  font-weight: 500;
}

.kanban-column.kanban-drop-target {
  background: var(--primary-subtle);
  outline: 2px dashed var(--primary);
  outline-offset: -2px;
}

.kanban-cards {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 40px;
}

/* ========== KANBAN CARD ========== */

.kanban-card {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.08);
  cursor: pointer;
  transition: box-shadow var(--transition-fast), transform 0.1s;
  border-left: 3px solid transparent;
}

.kanban-card:hover {
  box-shadow: 0 4px 12px rgba(0,0,0,0.12);
  transform: translateY(-1px);
}

.kanban-card.kanban-dragging {
  opacity: 0.5;
  transform: rotate(2deg);
}

.kanban-card.todo-overdue {
  border-left-color: var(--danger);
}

.kanban-card.todo-due-soon {
  border-left-color: var(--warning);
}

/* ========== KANBAN CARD TOP ROW (labels + menu) ========== */

.kanban-card-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 4px;
  position: relative;
}

.kanban-card-menu-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  font-weight: 700;
  color: var(--text-light);
  padding: 0 4px;
  border-radius: 4px;
  line-height: 1;
  letter-spacing: 1px;
  opacity: 0;
  transition: opacity var(--transition-fast), background var(--transition-fast);
  flex-shrink: 0;
}

.kanban-card:hover .kanban-card-menu-btn {
  opacity: 1;
}

.kanban-card-menu-btn:hover {
  background: var(--bg-subtle);
  color: var(--text);
}

.kanban-card-menu {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  z-index: 100;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 4px 16px rgba(0,0,0,0.12);
  min-width: 120px;
  overflow: hidden;
}

.kanban-card-menu.active {
  display: flex;
  flex-direction: column;
}

.kanban-card-menu button {
  background: none;
  border: none;
  padding: 8px 14px;
  font-size: 12px;
  text-align: left;
  cursor: pointer;
  color: var(--text);
  transition: background var(--transition-fast);
}

.kanban-card-menu button:hover {
  background: var(--bg-subtle);
}

.kanban-card-menu button.danger {
  color: var(--danger);
}

.kanban-card-menu button.danger:hover {
  background: var(--danger-bg);
}

.kanban-card-labels {
  display: flex;
  gap: 4px;
  flex-wrap: wrap;
}

.kanban-card-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text);
  margin-bottom: 4px;
  line-height: 1.4;
}

.kanban-card-desc {
  font-size: 11px;
  color: var(--text-light);
  line-height: 1.3;
  margin-bottom: 6px;
  max-height: 40px;
  overflow: hidden;
  text-overflow: ellipsis;
}

.kanban-card-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  align-items: center;
  font-size: 11px;
  color: var(--text-light);
}

.kanban-due {
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 11px;
}

.kanban-due.todo-overdue {
  background: var(--danger-bg);
  color: var(--danger);
  font-weight: 500;
}

.kanban-due.todo-due-soon {
  background: var(--warning-bg);
  color: var(--warning);
}

.kanban-lead {
  font-size: 11px;
  color: var(--primary);
}

/* ========== KANBAN PROGRESS BAR ========== */

.kanban-progress {
  display: flex;
  align-items: center;
  gap: 4px;
  width: 100%;
  margin-top: 4px;
}

.kanban-progress-bar {
  height: 4px;
  background: var(--primary);
  border-radius: 2px;
  transition: width 0.3s;
  flex: 1;
  position: relative;
}

.kanban-progress-bar::before {
  content: '';
  position: absolute;
  inset: 0;
  background: var(--bg-muted);
  border-radius: 2px;
  z-index: -1;
  width: 100%;
  /* Make it full-width as track */
}

.kanban-progress-text {
  font-size: 10px;
  color: var(--text-light);
  white-space: nowrap;
}

/* ========== LABEL BADGES ========== */

.todo-label-badge {
  display: inline-block;
  padding: 1px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: 500;
  white-space: nowrap;
}

.todo-label-dot {
  display: inline-block;
  width: 8px;
  height: 8px;
  border-radius: 50%;
  margin-right: 2px;
  vertical-align: middle;
}

/* ========== INLINE CHECKLIST (on cards) ========== */

.todo-inline-checklist {
  display: flex;
  flex-direction: column;
  gap: 3px;
  margin: 6px 0;
  padding: 0;
}

.todo-inline-check-item {
  display: flex;
  align-items: center;
  gap: 5px;
  font-size: 12px;
  color: var(--text);
  cursor: pointer;
  padding: 1px 0;
}

.todo-inline-check-item input[type="checkbox"] {
  width: auto;
  margin: 0;
  cursor: pointer;
  flex-shrink: 0;
}

.todo-check-done {
  text-decoration: line-through;
  color: var(--text-light);
}

/* ========== CHECKLIST BADGE ========== */

.todo-checklist-badge {
  display: inline-block;
  margin-left: 6px;
  padding: 0 5px;
  background: var(--bg-subtle);
  border-radius: 3px;
  font-size: 10px;
  color: var(--text-light);
  font-weight: 500;
  vertical-align: middle;
}

/* ========== DUE DATE INDICATORS ========== */

.todo-overdue {
  color: var(--danger);
}

tr.todo-overdue td {
  color: var(--danger);
}

.task-list li.todo-overdue {
  background: var(--danger-bg);
  border-left: 3px solid var(--danger);
}

.task-list li.todo-due-soon {
  background: var(--warning-bg);
  border-left: 3px solid var(--warning);
}

/* ========== TASK COUNT BADGE (DASHBOARD) ========== */

.task-count.todo {
  background: var(--info);
  color: white;
}

/* ========== QUICK ADD INPUT ========== */

.todo-quick-add {
  width: 100%;
  padding: 8px 12px;
  border: 1px dashed var(--border);
  border-radius: var(--radius);
  font-size: 12px;
  background: var(--bg-subtle);
  color: var(--text);
  margin-bottom: 8px;
  transition: border-color var(--transition-fast);
}

.todo-quick-add:focus {
  outline: none;
  border-color: var(--primary);
  border-style: solid;
  background: var(--bg-card);
}

.todo-quick-add::placeholder {
  color: var(--text-light);
  font-style: italic;
}

/* ========== TODO MODAL FORM ========== */

.todo-form {
  padding: 20px;
}

.todo-form .form-group {
  margin-bottom: 15px;
  position: relative;
}

.todo-form label {
  display: block;
  font-size: 12px;
  font-weight: 500;
  color: var(--text-light);
  margin-bottom: 5px;
}

.todo-form input[type="text"],
.todo-form input[type="date"],
.todo-form textarea,
.todo-form select {
  width: 100%;
  padding: 8px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  font-size: 14px;
  color: var(--text);
  background: var(--bg-card);
}

.todo-form input:focus,
.todo-form textarea:focus,
.todo-form select:focus {
  outline: none;
  border-color: var(--primary);
}

.todo-form textarea {
  resize: vertical;
}

.todo-form .form-actions-inline {
  display: flex;
  gap: 10px;
  justify-content: flex-end;
}

/* ========== LABELS SELECTOR (MODAL) ========== */

.todo-labels-selector {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.todo-label-option {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 3px 8px;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 500;
  cursor: pointer;
  transition: opacity var(--transition-fast);
}

.todo-label-option:hover {
  opacity: 0.8;
}

.todo-label-checkbox {
  width: auto !important;
  margin: 0;
}

/* ========== CHECKLIST (MODAL) ========== */

.todo-checklist {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.todo-checklist-item {
  display: flex;
  align-items: center;
  gap: 6px;
}

.todo-checklist-item input[type="checkbox"] {
  width: auto;
  flex-shrink: 0;
}

.checklist-text-input {
  flex: 1;
  padding: 4px 8px !important;
  font-size: 12px !important;
  border: 1px solid var(--border) !important;
  border-radius: 4px !important;
}

.btn-icon-danger {
  background: none;
  border: none;
  color: var(--danger);
  cursor: pointer;
  font-size: 16px;
  padding: 2px 6px;
  border-radius: 4px;
}

.btn-icon-danger:hover {
  background: var(--danger-bg);
}

.todo-checklist-add {
  display: flex;
  gap: 6px;
  margin-top: 6px;
}

.todo-checklist-add input {
  flex: 1;
  padding: 6px 8px !important;
  font-size: 12px !important;
}

/* ========== ASSIGN SELECTOR (MODAL) ========== */

.todo-assign-container {
  display: flex;
  flex-direction: column;
  gap: 4px;
  max-height: 120px;
  overflow-y: auto;
}

.todo-assign-option {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 12px;
  cursor: pointer;
  padding: 3px 0;
}

.todo-assign-option input[type="checkbox"] {
  width: auto;
}

/* ========== LINKED LEAD DISPLAY ========== */

.linked-lead-display {
  display: inline-block;
  padding: 4px 10px;
  background: var(--primary-subtle);
  color: var(--primary-dark);
  border-radius: var(--radius);
  font-size: 12px;
  font-weight: 500;
}

/* ========== LEAD CHIP (in todo modal) ========== */

.todo-lead-chip {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 6px 10px;
  background: var(--primary-subtle);
  color: var(--primary-dark);
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
}

.todo-lead-chip-remove {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 16px;
  color: var(--primary-dark);
  padding: 0 2px;
  line-height: 1;
  border-radius: 50%;
  opacity: 0.6;
  transition: opacity var(--transition-fast);
}

.todo-lead-chip-remove:hover {
  opacity: 1;
}

/* ========== TABLE OVERRIDES FOR TODOS ========== */

#todosTable .actions-cell {
  white-space: nowrap;
}

#todosTable .actions-cell .btn {
  margin-right: 3px;
}

.tag-info {
  background: var(--info-bg);
  color: var(--info);
  border: 1px solid var(--info-border);
}

.tag-pending {
  background: var(--warning-bg);
  color: var(--warning);
  border: 1px solid var(--warning-border);
}

.tag-neutral {
  background: var(--bg-subtle);
  color: var(--text-light);
  border: 1px solid var(--border);
}

/* ========== RESPONSIVE ========== */

@media (max-width: 768px) {
  .todos-container .list-header {
    flex-direction: column;
    align-items: flex-start;
  }

  .todos-container .list-header-actions {
    width: 100%;
  }

  .kanban-board {
    grid-template-columns: 1fr;
  }
}

/* ========== DARK MODE ========== */

[data-theme="dark"] .kanban-column {
  background: var(--bg-elevated);
}

[data-theme="dark"] .kanban-card {
  background: var(--bg-card);
  box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

[data-theme="dark"] .kanban-card-menu {
  box-shadow: 0 4px 16px rgba(0,0,0,0.4);
  border-color: var(--border);
}

[data-theme="dark"] .todo-quick-add {
  background: var(--bg-elevated);
  border-color: var(--border);
}
