/**
 * tasks.css — Styles for Tasks pages (list, create/edit modal, detail panel)
 */

/* --- Status badges --- */
.badge-open        { background: #dbeafe; color: #1e40af; border: 1px solid #93c5fd; }
.badge-in_progress { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.badge-done        { background: #dcfce7; color: #166534; border: 1px solid #86efac; }
.badge-cancelled   { background: #f3f4f6; color: #6b7280; border: 1px solid #d1d5db; }

/* --- Priority badges --- */
.badge-high   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }
.badge-medium { background: #fef3c7; color: #92400e; border: 1px solid #fcd34d; }
.badge-low    { background: #f3f4f6; color: #6b7280; border: 1px solid #d1d5db; }

/* --- Priority radio pills in modal --- */
.task-priority-pills {
  display: flex;
  gap: 8px;
}

.task-priority-pill {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 6px 14px;
  border: 1.5px solid var(--border-strong);
  border-radius: var(--radius-full);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  cursor: pointer;
  transition: border-color var(--duration-fast) var(--easing-default),
              background var(--duration-fast) var(--easing-default);
  user-select: none;
}

.task-priority-pill input[type="radio"] { display: none; }

.task-priority-pill:hover { background: #f8fafc; }

.task-priority-pill.selected[data-priority="high"] {
  border-color: #ef4444;
  background: #fef2f2;
  color: #991b1b;
}

.task-priority-pill.selected[data-priority="medium"] {
  border-color: #f59e0b;
  background: #fffbeb;
  color: #92400e;
}

.task-priority-pill.selected[data-priority="low"] {
  border-color: #9ca3af;
  background: #f9fafb;
  color: #6b7280;
}

/* --- Entity link section --- */
.task-entity-section {
  background: #f8fafc;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 10px 12px;
}

.task-entity-chip-wrap {
  display: flex;
  align-items: center;
  gap: 6px;
}

.task-entity-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: var(--info-bg);
  color: var(--info-text);
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
  padding: 2px 10px;
  border-radius: var(--radius-full);
}

/* --- Pre-linked banner --- */
.task-prelinked-banner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: var(--info-bg);
  color: var(--info-text);
  font-size: var(--font-size-sm);
  padding: 8px 12px;
  border-radius: var(--radius-md);
  margin-bottom: 12px;
  border: 1px solid #93c5fd;
}

/* --- Detail sidebar panel --- */
.task-detail-panel {
  position: fixed;
  top: 0;
  right: 0;
  width: 420px;
  height: 100vh;
  background: var(--panel-bg);
  border-left: 1px solid var(--panel-border);
  box-shadow: var(--panel-shadow);
  z-index: var(--z-panel);
  display: flex;
  flex-direction: column;
}

.panel-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.panel-title {
  font-size: var(--font-size-lg);
  font-weight: var(--font-weight-semibold);
  color: var(--text-primary);
}

.panel-close {
  background: none;
  border: none;
  font-size: 22px;
  color: var(--text-muted);
  cursor: pointer;
  padding: 0 4px;
  line-height: 1;
}
.panel-close:hover { color: var(--text-primary); }

.panel-body {
  flex: 1;
  overflow-y: auto;
  padding: 20px;
}

.panel-footer {
  padding: 12px 20px;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 8px;
  flex-shrink: 0;
}

/* --- Detail field rows --- */
.task-detail-section {
  margin-bottom: 20px;
}

.task-detail-section + .task-detail-section {
  padding-top: 16px;
  border-top: 1px solid var(--border);
}

.task-detail-field {
  display: flex;
  align-items: flex-start;
  gap: 8px;
  padding: 6px 0;
  font-size: var(--font-size-base);
}

.task-detail-field .field-label {
  width: 110px;
  flex-shrink: 0;
  color: var(--text-muted);
  font-size: var(--font-size-sm);
  padding-top: 1px;
}

.task-detail-field .field-value {
  flex: 1;
  color: var(--text-primary);
  word-break: break-word;
}

/* --- Overdue styling --- */
.task-due-overdue {
  color: var(--danger-text);
  font-weight: var(--font-weight-medium);
}

.task-overdue-badge {
  display: inline-block;
  background: var(--danger-bg);
  color: var(--danger-text);
  font-size: 11px;
  font-weight: var(--font-weight-medium);
  padding: 1px 6px;
  border-radius: var(--radius-sm);
  border: 1px solid #fca5a5;
}

/* --- Row urgency styling (spec: tasks-list-ux-improvement.md) --- */
.ag-row.ag-row-overdue {
  border-left: 3px solid #ef4444 !important;
  background-color: #fef2f2 !important;
}
.ag-row.ag-row-due-today {
  border-left: 3px solid #f59e0b !important;
  background-color: #fffbeb !important;
}
.ag-row.ag-row-done {
  opacity: 0.55;
}
.ag-row.ag-row-done .cell-truncate {
  text-decoration: line-through;
}

/* --- Summary bar --- */
.task-summary-bar {
  display: flex;
  align-items: center;
  gap: 20px;
  padding: 8px 16px;
  background: var(--content-bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  margin-bottom: 12px;
  font-size: var(--font-size-sm);
  color: var(--text-secondary);
}
.task-summary-item {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}
.task-summary-item[role="button"] {
  cursor: pointer;
  border-radius: var(--radius-sm);
  padding: 2px 6px;
  margin: -2px -6px;
}
.task-summary-item[role="button"]:hover {
  background: var(--hover-bg);
}
.task-summary-dot {
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.dot-overdue { background: #ef4444; }
.dot-today { background: #f59e0b; }
.dot-upcoming { background: #3b82f6; }

/* --- Priority dot --- */
.task-priority-dot {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  font-size: var(--font-size-sm);
  font-weight: var(--font-weight-medium);
}
.task-priority-dot::before {
  content: '';
  width: 8px;
  height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}
.task-priority-dot.dot-high { color: #991b1b; }
.task-priority-dot.dot-high::before { background: #ef4444; }
.task-priority-dot.dot-medium { color: #92400e; }
.task-priority-dot.dot-medium::before { background: #f59e0b; }
.task-priority-dot.dot-low { color: #6b7280; }
.task-priority-dot.dot-low::before { background: #9ca3af; }

/* --- Short task number --- */
.task-short-no {
  font-family: var(--font-mono, 'SF Mono', 'Consolas', monospace);
  font-size: var(--font-size-sm);
  color: var(--text-muted);
}

/* --- Overdue toggle button active state --- */
#overdueToggle.active {
  border-color: #ef4444;
  background: #fef2f2;
  color: #dc2626;
}

/* --- Quick-done checkbox in grid --- */
.task-done-check {
  width: 16px;
  height: 16px;
  border: 1.5px solid #d1d5db;
  border-radius: var(--radius-sm);
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  transition: background var(--duration-fast) var(--easing-default),
              border-color var(--duration-fast) var(--easing-default);
}
.task-done-check:hover { border-color: var(--color-success); }
.task-done-check.checked {
  background: var(--color-success);
  border-color: var(--color-success);
  color: #fff;
}

/* --- Grid entity link --- */
.task-grid-entity-link {
  color: var(--primary);
  font-size: var(--font-size-sm);
  cursor: pointer;
  text-decoration: none;
}
.task-grid-entity-link:hover { text-decoration: underline; }

/* --- Repeat / Recurrence section ----------------------------------------- */

.repeat-toggle {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
}
.repeat-toggle input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--primary);
}

.repeat-section {
  margin-top: 10px;
  padding: 12px;
  background: var(--surface-secondary, #f8f9fa);
  border: 1px solid var(--border-light, #e5e7eb);
  border-radius: 8px;
}

.repeat-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 8px;
}
.repeat-row:last-child { margin-bottom: 0; }

.form-label-sm {
  font-size: 12px;
  font-weight: 500;
  color: var(--text-secondary);
  min-width: 70px;
  flex-shrink: 0;
}

.repeat-freq-pills, .dow-pills {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
}

.repeat-pill, .dow-pill {
  display: inline-flex;
  align-items: center;
  padding: 4px 10px;
  font-size: 12px;
  border: 1px solid var(--border-light, #d1d5db);
  border-radius: 6px;
  cursor: pointer;
  transition: all 0.15s;
  background: var(--surface, #fff);
  color: var(--text-secondary);
  user-select: none;
}
.repeat-pill input, .dow-pill input { display: none; }
.repeat-pill.selected, .dow-pill.selected {
  background: var(--primary-light, #eff6ff);
  border-color: var(--primary, #3b82f6);
  color: var(--primary, #3b82f6);
  font-weight: 600;
}
.repeat-pill:hover, .dow-pill:hover {
  border-color: var(--primary, #3b82f6);
}

.end-rules {
  display: flex;
  flex-direction: column;
  gap: 6px;
}
.end-rule {
  display: flex;
  align-items: center;
  gap: 4px;
  font-size: 12px;
  color: var(--text-primary);
  cursor: pointer;
}
.end-rule input[type="radio"] {
  accent-color: var(--primary);
}

.repeat-summary {
  margin-top: 8px;
  padding: 10px 12px;
  background: var(--surface-secondary, #f0f4ff);
  border: 1px solid var(--border-light, #c7d2fe);
  border-radius: 8px;
  font-size: 12px;
  color: var(--text-secondary);
}

.btn-danger-outline {
  color: var(--danger, #ef4444);
  border: 1px solid var(--danger, #ef4444);
  background: transparent;
}
.btn-danger-outline:hover {
  background: var(--danger, #ef4444);
  color: #fff;
}

/* Recurrence badge in AG Grid title */
.recurrence-badge {
  display: inline-flex;
  align-items: center;
  margin-right: 4px;
  color: var(--primary, #3b82f6);
  font-size: 13px;
  font-weight: 600;
}

/* Detail panel recurrence info */
.recurrence-info {
  margin-bottom: 16px;
  padding: 10px 12px;
  background: var(--surface-secondary, #f0f4ff);
  border: 1px solid var(--border-light, #c7d2fe);
  border-radius: 8px;
}
.recurrence-info .recurrence-label {
  font-size: 11px;
  font-weight: 600;
  color: var(--primary, #3b82f6);
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 4px;
}
.recurrence-info .recurrence-summary-text {
  font-size: 13px;
  color: var(--text-primary);
}

/* --- Responsive --- */
@media (max-width: 768px) {
  .task-detail-panel {
    width: 100%;
  }
}
