/* ============================================================
   TASKS ("Zadaci"): warm board, list by due date, "Moj dan"
   Each project gets an accent color through --proj (set inline).
   ============================================================ */
:root {
  --task-radius: 14px;
  --task-card-radius: 12px;
  --task-col-todo: rgba(232, 163, 23, 0.07);
  --task-col-doing: rgba(79, 70, 229, 0.06);
  --task-col-done: rgba(34, 160, 107, 0.07);
  --task-overdue: #D9433B;
  --task-overdue-soft: rgba(217, 67, 59, 0.11);
  --task-sun: #F2A93B;
  --task-sun-soft: rgba(242, 169, 59, 0.16);
  --task-ease: cubic-bezier(0.2, 0.8, 0.2, 1);
}

body[data-theme="dark"] {
  --task-col-todo: rgba(245, 158, 11, 0.07);
  --task-col-doing: rgba(99, 102, 241, 0.08);
  --task-col-done: rgba(52, 211, 153, 0.07);
  --task-overdue: #F87171;
  --task-overdue-soft: rgba(248, 113, 113, 0.14);
  --task-sun-soft: rgba(242, 169, 59, 0.14);
}

/* ── Toolbar: filter tabs + client/project selects ── */
.tasks-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 32px;
  background: var(--bg-elevated);
  border-bottom: 1px solid var(--border);
  flex-shrink: 0;
}

.task-tabs {
  display: flex;
  gap: 4px;
  padding: 4px;
  background: var(--surface-2);
  border-radius: 999px;
  overflow-x: auto;
  scrollbar-width: none;
  min-width: 0;
  flex: 0 1 auto;
}
.task-tabs::-webkit-scrollbar { display: none; }

.task-tab {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  height: 32px;
  padding: 0 14px;
  border: 0;
  border-radius: 999px;
  background: transparent;
  color: var(--fg-3);
  font: 500 13px var(--font-sans);
  white-space: nowrap;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, box-shadow 0.15s;
}
.task-tab:hover { color: var(--fg); }
.task-tab:focus-visible { outline: 2px solid var(--indigo); outline-offset: 1px; }
.task-tab.active {
  background: var(--surface);
  color: var(--fg);
  box-shadow: var(--shadow-sm);
}

.task-tab-count {
  min-width: 20px;
  padding: 0 6px;
  border-radius: 999px;
  background: var(--surface-3);
  color: var(--fg-3);
  font: 600 11px/18px var(--font-mono);
  text-align: center;
}
.task-tab.active .task-tab-count { background: var(--indigo-soft); color: var(--indigo); }
.task-tab.alert .task-tab-count { background: var(--task-overdue-soft); color: var(--task-overdue); }

.tasks-toolbar-filters { display: flex; gap: 8px; flex: 0 1 auto; min-width: 0; }
.tasks-toolbar-filters .select-input { width: 200px; min-width: 0; flex: 0 1 200px; border-radius: 999px; }

/* ── Layout ── */
.tasks-container {
  flex: 1;
  display: flex;
  min-height: 0;
  background: var(--canvas);
}

.tasks-board {
  flex: 1;
  overflow-y: auto;
  padding: 20px 28px 40px;
  display: flex;
  flex-direction: column;
  gap: 14px;
  min-width: 0;
}
.tasks-board > * { flex-shrink: 0; }

.tasks-empty {
  margin: auto;
  padding: 80px 20px;
  text-align: center;
  color: var(--fg-3);
}
.tasks-empty-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 64px;
  height: 64px;
  margin-bottom: 14px;
  border-radius: 20px;
  background: var(--indigo-soft);
  color: var(--indigo);
}

/* ── Project block ── */
.task-project-block {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--task-radius);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
  position: relative;
  transition: box-shadow 0.2s, opacity 0.2s;
}
.task-project-block::before {
  content: '';
  position: absolute;
  inset: 0 auto 0 0;
  width: 4px;
  background: var(--proj);
}
.task-project-block:hover { box-shadow: var(--shadow-md); }
.task-project-block.dragging { opacity: 0.4; }

.task-project-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 14px;
  padding: 14px 18px 14px 20px;
  background: color-mix(in srgb, var(--proj) 7%, var(--surface));
  cursor: pointer;
  user-select: none;
  transition: background 0.15s;
}
.task-project-header:hover { background: color-mix(in srgb, var(--proj) 11%, var(--surface)); }
.task-project-block:not(.collapsed) .task-project-header { border-bottom: 1px solid var(--border); }

.task-project-title { display: flex; align-items: center; gap: 10px; min-width: 0; }

.drag-handle {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 22px;
  height: 22px;
  color: var(--fg-4);
  font-size: 13px;
  letter-spacing: -2px;
  border-radius: 6px;
  cursor: grab;
  user-select: none;
  transition: color 0.1s, background 0.1s;
}
.drag-handle:hover { color: var(--indigo); background: var(--indigo-soft); }
.drag-handle:active { cursor: grabbing; }

.task-project-dot {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  width: 14px;
  height: 14px;
  border-radius: 50%;
  background: var(--proj);
  box-shadow: 0 0 0 4px color-mix(in srgb, var(--proj) 18%, transparent);
  color: #fff;
}

.task-project-names { min-width: 0; }
.task-project-name {
  font-size: 15px;
  font-weight: 650;
  letter-spacing: -0.015em;
  color: var(--fg);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.task-project-client { font-size: 12px; color: var(--fg-3); margin-top: 1px; }

.task-project-right { display: flex; align-items: center; gap: 12px; flex-shrink: 0; }

.task-project-doing {
  padding: 3px 9px;
  border-radius: 999px;
  background: var(--indigo-soft);
  color: var(--indigo);
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
}

.task-progress { display: flex; align-items: center; gap: 8px; }
.task-progress-track {
  width: 96px;
  height: 6px;
  border-radius: 999px;
  background: color-mix(in srgb, var(--proj, var(--emerald)) 16%, var(--surface-2));
  overflow: hidden;
}
.task-progress-fill {
  height: 100%;
  border-radius: inherit;
  background: var(--proj, var(--emerald));
  transition: width 0.5s var(--task-ease);
}
.task-progress-label { font: 600 12px var(--font-mono); color: var(--fg-3); min-width: 38px; }

.task-project-chevron { display: inline-flex; color: var(--fg-4); transition: transform 0.2s var(--task-ease); }
.task-project-block.collapsed .task-project-chevron { transform: rotate(-90deg); }
.task-project-block.collapsed .task-columns { display: none; }

.task-project-del {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--fg-4);
  cursor: pointer;
}
.task-project-del:hover { color: var(--rose); background: var(--rose-soft); }

/* Finished projects sink to the bottom and step back visually */
.task-project-block.all-done { opacity: 0.72; }
.task-project-block.all-done:hover { opacity: 1; }

/* ── Columns ── */
.task-columns {
  display: grid;
  grid-template-columns: repeat(3, minmax(0, 1fr));
  gap: 12px;
  padding: 14px 14px 16px 18px;
}
.task-project-block.single .task-columns { grid-template-columns: minmax(0, 1fr); }

.task-column {
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 110px;
  padding: 10px;
  border-radius: 12px;
  background: var(--task-col-todo);
  transition: background 0.15s, box-shadow 0.15s;
}
.task-column[data-status="in_progress"] { background: var(--task-col-doing); }
.task-column[data-status="done"] { background: var(--task-col-done); }
.task-column.drag-over { box-shadow: inset 0 0 0 2px var(--indigo); background: var(--indigo-soft); }

.task-column-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 2px 2px 4px;
}
.task-column-label {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  font-size: 12.5px;
  font-weight: 600;
  color: var(--fg-2);
}
.task-column-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--amber); }
.task-column[data-status="in_progress"] .task-column-dot { background: var(--indigo); }
.task-column[data-status="done"] .task-column-dot { background: var(--emerald); }

.task-column-count {
  padding: 0 7px;
  border-radius: 999px;
  background: var(--surface);
  color: var(--fg-3);
  font: 600 11px/18px var(--font-mono);
}

.col-add {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 24px;
  height: 24px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--fg-4);
  font-size: 16px;
  cursor: pointer;
  transition: background 0.12s, color 0.12s;
}
.col-add:hover { background: var(--surface); color: var(--indigo); }

.task-column-empty {
  padding: 16px 8px;
  border: 1.5px dashed var(--border-strong);
  border-radius: 10px;
  color: var(--fg-4);
  font-size: 12px;
  text-align: center;
}

/* ── Task card ── */
.task-card {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 11px 10px 11px 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--task-card-radius);
  box-shadow: var(--shadow-xs);
  cursor: grab;
  transition: transform 0.15s var(--task-ease), box-shadow 0.15s, border-color 0.15s, opacity 0.3s;
}
.task-card:hover { transform: translateY(-1px); box-shadow: var(--shadow-md); border-color: var(--border-strong); }
.task-card:active { cursor: grabbing; }
.task-card.dragging { opacity: 0.4; }
.task-card.prio-high { box-shadow: inset 3px 0 0 var(--task-overdue), var(--shadow-xs); }

.task-card-body { flex: 1; min-width: 0; cursor: pointer; }
.task-card-title {
  font-size: 13.5px;
  font-weight: 550;
  line-height: 1.4;
  color: var(--fg);
  word-break: break-word;
}
.task-card-desc {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-top: 3px;
  font-size: 12.5px;
  line-height: 1.45;
  color: var(--fg-3);
  word-break: break-word;
}
.task-card[data-status="done"] .task-card-title,
.task-row[data-status="done"] .task-row-title,
.my-day-item[data-status="done"] .my-day-title { text-decoration: line-through; color: var(--fg-4); }
.task-card[data-status="done"] { opacity: 0.75; box-shadow: none; }

.task-card-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
  opacity: 0;
  transition: opacity 0.15s;
}
.task-card:hover .task-card-actions,
.task-row:hover .task-card-actions,
.task-card:focus-within .task-card-actions,
.task-row:focus-within .task-card-actions { opacity: 1; }
.task-card-actions button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 26px;
  height: 26px;
  padding: 0;
  border: 0;
  border-radius: 7px;
  background: transparent;
  color: var(--fg-4);
  cursor: pointer;
}
.task-card-actions button:hover { color: var(--indigo); background: var(--indigo-soft); }
.task-card-actions button.del:hover { color: var(--rose); background: var(--rose-soft); }

/* Round checkbox in the project's color */
.task-check {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  margin-top: 1px;
  padding: 0;
  border: 2px solid color-mix(in srgb, var(--proj, var(--indigo)) 65%, var(--border-strong));
  border-radius: 50%;
  background: transparent;
  color: transparent;
  cursor: pointer;
  transition: background 0.15s, color 0.15s, transform 0.15s var(--task-ease);
}
.task-check:hover { background: color-mix(in srgb, var(--proj, var(--indigo)) 14%, transparent); color: var(--proj, var(--indigo)); }
.task-check:active { transform: scale(0.88); }
.task-check:focus-visible { outline: 2px solid var(--indigo); outline-offset: 2px; }
.task-check[aria-pressed="true"] { background: var(--proj, var(--emerald)); border-color: var(--proj, var(--emerald)); color: #fff; }

.completing .task-check { background: var(--proj, var(--emerald)); border-color: var(--proj, var(--emerald)); color: #fff; animation: task-pop 0.32s var(--task-ease); }
.completing .task-card-title, .completing .task-row-title, .completing .my-day-title { text-decoration: line-through; color: var(--fg-4); }
.completing { opacity: 0.55; }
@keyframes task-pop {
  0% { transform: scale(1); }
  45% { transform: scale(1.25); }
  100% { transform: scale(1); }
}

/* Chips: priority, due date, "Moj dan" */
.task-chips { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 7px; }
.task-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  height: 21px;
  padding: 0 8px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--fg-3);
  font-size: 11.5px;
  font-weight: 550;
  white-space: nowrap;
}
.task-chip.prio-high { background: var(--task-overdue-soft); color: var(--task-overdue); }
.task-chip.prio-medium { background: var(--amber-soft); color: var(--amber); }
.task-chip.prio-low { background: var(--indigo-soft); color: var(--indigo); }
.task-chip.due.overdue { background: var(--task-overdue-soft); color: var(--task-overdue); }
.task-chip.due.today { background: var(--emerald-soft); color: var(--emerald); }
.task-chip.due.soon { background: var(--violet-soft); color: var(--violet); }
.task-chip.myday { padding: 0 6px; background: var(--task-sun-soft); color: var(--task-sun); }
.task-chip.doing { background: var(--indigo-soft); color: var(--indigo); }

/* Inline quick add */
.task-quick-add {
  display: flex;
  align-items: center;
  gap: 8px;
  height: 36px;
  padding: 0 10px;
  border-radius: 10px;
  color: var(--fg-4);
  transition: background 0.15s, box-shadow 0.15s;
}
.task-quick-add:hover { background: color-mix(in srgb, var(--surface) 70%, transparent); }
.task-quick-add:focus-within { background: var(--surface); box-shadow: 0 0 0 2px var(--indigo-border), var(--shadow-sm); color: var(--indigo); }
.task-quick-plus { font-size: 17px; line-height: 1; }
.task-quick-add input {
  flex: 1;
  min-width: 0;
  height: 100%;
  border: 0;
  outline: none;
  background: transparent;
  color: var(--fg);
  font: 13.5px var(--font-sans);
}
.task-quick-add input::placeholder { color: var(--fg-4); }

/* ── List view ── */
.task-group {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--task-radius);
  box-shadow: var(--shadow-xs);
  overflow: hidden;
}
.task-group-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 18px;
  border-bottom: 1px solid var(--border);
}
.task-group-head h3 { margin: 0; font-size: 14.5px; font-weight: 650; letter-spacing: -0.01em; color: var(--fg); }
.task-group[data-group="overdue"] .task-group-head h3 { color: var(--task-overdue); }
.task-group[data-group="today"] .task-group-head h3 { color: var(--emerald); }
.task-group[data-group="done"] { opacity: 0.8; }

.task-group-count {
  padding: 0 7px;
  border-radius: 999px;
  background: var(--surface-2);
  color: var(--fg-3);
  font: 600 11px/18px var(--font-mono);
}

.task-row {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 11px 14px 11px 18px;
  transition: background 0.12s, opacity 0.3s;
}
.task-row + .task-row { border-top: 1px solid var(--border-subtle); }
.task-row:hover { background: var(--surface-2); }
.task-row .task-chips { margin-top: 0; flex-shrink: 0; justify-content: flex-end; }
.task-row-body { flex: 1; min-width: 0; cursor: pointer; }
.task-row-title { font-size: 13.5px; font-weight: 550; color: var(--fg); word-break: break-word; }
.task-row-meta, .my-day-meta {
  display: flex;
  align-items: center;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 2px;
  font-size: 12px;
  color: var(--fg-3);
}
.task-proj-name { min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.my-day-meta .task-proj-name { max-width: calc(100% - 14px); }
.task-proj-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--proj); flex-shrink: 0; }

/* ── "Moj dan" panel ── */
.tasks-sidebar-wrapper.my-day {
  width: 320px;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
  min-height: 0;
  background: var(--surface);
  border-left: 1px solid var(--border);
}

.my-day-header {
  padding: 20px 18px 16px;
  background:
    radial-gradient(120% 90% at 100% 0%, var(--task-sun-soft), transparent 60%),
    var(--surface);
  border-bottom: 1px solid var(--border);
}
.my-day-greeting { font-size: 12.5px; color: var(--fg-3); margin-bottom: 8px; }
.my-day-top { display: flex; align-items: center; gap: 12px; }
.my-day-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 12px;
  background: var(--task-sun-soft);
  color: var(--task-sun);
}
.my-day-top h3 { margin: 0; font-size: 19px; font-weight: 700; letter-spacing: -0.02em; color: var(--fg); }
.my-day-date { font-size: 12.5px; color: var(--fg-3); }

.my-day-progress { display: flex; align-items: center; gap: 10px; margin-top: 14px; font-size: 12px; color: var(--fg-3); }
.my-day-progress .task-progress-track { flex: 1; width: auto; --proj: var(--task-sun); }
.my-day-progress.complete { color: var(--emerald); font-weight: 600; }
.my-day-progress.complete .task-progress-track { --proj: var(--emerald); }

.tasks-sidebar {
  flex: 1;
  overflow-y: auto;
  padding: 10px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.my-day-list, .my-day-section { display: flex; flex-direction: column; gap: 4px; }
.my-day-section-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 8px 8px 4px;
  font-size: 11.5px;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--fg-4);
}

.my-day-item {
  position: relative;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 9px 8px;
  border-radius: 10px;
  transition: background 0.12s, opacity 0.3s;
}
.my-day-item[draggable="true"] { cursor: grab; }
.my-day-item:hover { background: var(--surface-2); }
.my-day-item.dragging { opacity: 0.45; }
.my-day-item.drag-over-top::before,
.my-day-item.drag-over-bottom::after {
  content: '';
  position: absolute;
  left: 8px;
  right: 8px;
  height: 2px;
  border-radius: 2px;
  background: var(--indigo);
}
.my-day-item.drag-over-top::before { top: -2px; }
.my-day-item.drag-over-bottom::after { bottom: -2px; }

.my-day-text { flex: 1; min-width: 0; cursor: pointer; }
.my-day-title { font-size: 13.5px; font-weight: 550; line-height: 1.35; color: var(--fg); word-break: break-word; }
.my-day-meta .task-chip { height: 19px; font-size: 11px; }

.my-day-pin {
  flex-shrink: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  padding: 0;
  border: 0;
  border-radius: 8px;
  background: transparent;
  color: var(--fg-4);
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s, color 0.15s;
}
.my-day-item:hover .my-day-pin, .my-day-pin:focus-visible, .my-day-pin.on { opacity: 1; }
.my-day-pin:hover { background: var(--task-sun-soft); color: var(--task-sun); }
.my-day-pin.on { color: var(--task-sun); }

.my-day-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 22px 16px;
  border: 1.5px dashed var(--border-strong);
  border-radius: 12px;
  color: var(--task-sun);
  text-align: center;
}
.my-day-empty p { margin: 0; font-size: 12.5px; line-height: 1.5; color: var(--fg-3); }

/* ── Tablet / phone ── */
@media (max-width: 1100px) {
  .tasks-toolbar { flex-wrap: wrap; }
  .tasks-toolbar-filters { flex: 1 1 100%; }
  .tasks-toolbar-filters .select-input { flex: 1 1 0; width: auto; }
  .tasks-sidebar-wrapper.my-day { width: 280px; }
}

@media (max-width: 860px) {
  .tasks-toolbar { padding: 10px 16px; }
  .task-tabs { max-width: 100%; }
  /* "Moj dan" on top, then the board; the whole view scrolls as one column */
  .tasks-container { flex-direction: column; overflow-y: auto; }
  .tasks-board { flex: none; overflow: visible; padding: 16px; }
  .tasks-sidebar-wrapper.my-day {
    order: -1;
    width: auto;
    margin: 16px 16px 0;
    border: 1px solid var(--border);
    border-radius: var(--task-radius);
    overflow: hidden;
  }
  .tasks-sidebar { flex: none; overflow: visible; }
  .my-day-pin { opacity: 1; }
  .task-card-actions { opacity: 1; }

  .task-project-header { flex-wrap: wrap; row-gap: 10px; padding: 12px 14px 12px 16px; }
  .task-project-title { flex: 1 1 100%; }
  .task-project-right { flex: 1 1 100%; justify-content: flex-end; }
  .task-progress { margin-right: auto; }
  .task-columns { grid-template-columns: minmax(0, 1fr); padding: 12px 12px 14px 14px; }
  .task-column { min-height: 0; }

  .task-row { flex-wrap: wrap; padding: 11px 12px 11px 14px; }
  .task-row .task-chips { flex: 1 1 100%; justify-content: flex-start; padding-left: 32px; }
}

@media (prefers-reduced-motion: reduce) {
  .task-card, .task-check, .task-progress-fill, .task-project-chevron { transition: none; }
  .completing .task-check { animation: none; }
}

/* Task form: "Projekat" / "Bez projekta" */
.task-link-toggle { width: fit-content; }
.task-link-toggle .view-toggle-btn { width: auto; padding: 0 18px; font: 550 13px var(--font-sans); }
.task-link-toggle .view-toggle-btn:disabled { opacity: 0.45; cursor: not-allowed; }
.task-link-toggle .view-toggle-btn { color: var(--fg-3); }
.task-link-toggle .view-toggle-btn.active { background: var(--indigo); color: #fff; box-shadow: 0 4px 10px rgba(79, 70, 229, 0.25); }

/* Rename / delete on every group strip, quiet until the strip is hovered. */
.task-project-edit, .task-project-del { opacity: 0.55; transition: opacity 0.15s; }
.task-project-header:hover .task-project-edit, .task-project-header:hover .task-project-del,
.task-project-edit:focus-visible, .task-project-del:focus-visible { opacity: 1; }
@media (hover: none) { .task-project-edit, .task-project-del { opacity: 1; } }
