/*
 * KPRATIVE Mini App v1.1 — Tasks screen (TASK 4/N).
 * Geometry from get_design_context on Tasks RU Light (205:388),
 * TaskInventoryTabs (161:1043/205:391), TaskSectionHeader (163:1004),
 * TaskInventoryRow / Corrected / Direction=Divider (197:1010),
 * EnergyIndicator (159:1007), TaskEmptyState (163:1016).
 * Colors exclusively via tokens.css custom properties.
 */

.kp-tasks {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 4px;
}

/* ---- TaskInventoryTabs (161:1043 / 205:391): active state is purely
   typographic (weight + color) -- confirmed via get_design_context, no
   tab carries a distinct background class in the canonical instance. ---- */
.kp-tasks-tabs {
  display: flex;
  gap: 4px;
  height: 44px;
  padding: 4px;
  border-radius: 14px;
  background: var(--kp-surface);
}
.kp-tasks-tab {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border: none;
  border-radius: 10px;
  background: transparent;
  color: var(--kp-text-secondary);
  font-family: "Manrope", Arial, sans-serif;
  font-weight: 400;
  font-size: 12px;
  line-height: 16px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.kp-tasks-tab.is-active { color: var(--kp-text-primary); font-weight: 600; }
.kp-tasks-tab:focus-visible { outline: 2px solid var(--kp-accent-primary); outline-offset: -2px; }

/* ---- TaskSectionHeader (163:1004 / 205:392) ---- */
.kp-tasks-section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  min-height: 36px;
}
.kp-tasks-section-header__heading {
  display: flex;
  align-items: baseline;
  gap: 8px;
  min-width: 0;
}
.kp-tasks-section-header__label {
  margin: 0;
  color: var(--kp-text-primary);
  font-family: "Manrope", Arial, sans-serif;
  font-weight: 600;
  font-size: 13px;
}
.kp-tasks-section-header__count {
  margin: 0;
  color: var(--kp-text-secondary);
  font-family: "Manrope", Arial, sans-serif;
  font-weight: 400;
  font-size: 11px;
}
.kp-tasks-section-header--selection { gap: 10px; }
.kp-tasks-section-header__selection-count {
  min-width: 0;
  margin: 0;
  color: var(--kp-text-primary);
  font-family: "Manrope", Arial, sans-serif;
  font-size: 13px;
  font-weight: 600;
}
.kp-tasks-selection-actions {
  display: flex;
  flex: none;
  align-items: center;
  gap: 2px;
}
.kp-tasks-selection-actions button {
  min-height: 36px;
  padding: 8px;
  border: 0;
  border-radius: 10px;
  background: transparent;
  color: var(--kp-text-secondary);
  font-family: "Manrope", Arial, sans-serif;
  font-size: 12px;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.kp-tasks-selection-actions button:focus-visible { outline: 2px solid var(--kp-accent-primary); outline-offset: 1px; }
.kp-tasks-selection-actions button:active:not(:disabled) { background: var(--kp-surface-raised); }
.kp-tasks-selection-actions__all { font-weight: 600; }
.kp-tasks-selection-actions__delete {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  color: var(--kp-recovery) !important;
}
.kp-tasks-selection-actions__delete .kp-icon { width: 20px; height: 20px; }
.kp-tasks-selection-actions__delete:disabled { opacity: 0.32; cursor: default; }
.kp-tasks-selection-actions__cancel { padding-right: 0 !important; }

/* ---- TaskInventoryRow / Corrected / Direction=Divider (197:1010):
   quiet inventory row -- bottom border only, no card background (the
   canonical instance carries no bg-color class, confirmed via
   get_design_context). ---- */
.kp-tasks-list { list-style: none; margin: 0; padding: 0; }
.kp-tasks-search { display: flex; gap: 8px; align-items: center; flex-wrap: wrap; min-width: 0; padding: 8px 0; }
.kp-tasks-search input { flex: 1 1 180px; min-width: 0; padding: 10px 12px; border: 1px solid var(--kp-border-subtle); border-radius: 10px; background: var(--kp-surface-raised); color: inherit; }
.kp-tasks-search button, .kp-tasks-row-delete { border: 0; background: transparent; color: inherit; padding: 8px; cursor: pointer; }
.kp-tasks-select-row { display: flex; align-items: center; gap: 8px; min-width: 0; }
.kp-tasks-select-row.is-selected .kp-tasks-row {
  margin: 4px 0;
  padding: 8px 10px;
  border: 1px solid var(--kp-border-subtle);
  border-radius: 12px;
  background: var(--kp-surface-raised);
}
.kp-tasks-select-row.is-selected + .kp-tasks-select-row .kp-tasks-row { border-top-color: transparent; }
.kp-tasks-select-row > input { flex: 0 0 22px; width: 22px; height: 22px; }
.kp-tasks-select-row > input[type="checkbox"] {
  appearance: auto;
  width: 22px;
  height: 22px;
  min-height: 22px;
  padding: 0;
  border-radius: 4px;
  accent-color: var(--kp-accent-primary);
}
.kp-tasks-select-row > input[type="checkbox"]:disabled { opacity: 0.35; }
.kp-tasks-select-row .kp-tasks-row { flex: 1 1 auto; min-width: 0; }
.kp-tasks-row-delete { flex: 0 0 32px; font-size: 22px; }
.kp-tasks-row {
  width: 100%;
  box-sizing: border-box;
  display: flex;
  flex-direction: column;
  gap: 4px;
  padding: 12px 0;
  border: none;
  border-bottom: 1px solid var(--kp-border-subtle);
  background: transparent;
  text-align: left;
  cursor: pointer;
  -webkit-tap-highlight-color: transparent;
}
.kp-tasks-list li:last-child .kp-tasks-row { border-bottom: none; }
.kp-tasks-row:active { background: var(--kp-surface-raised); }
.kp-tasks-row:focus-visible { outline: 2px solid var(--kp-accent-primary); outline-offset: -2px; }
.kp-tasks-row--static { cursor: default; }
.kp-tasks-row--static:active { background: transparent; }

.kp-tasks-row__head {
  display: flex;
  align-items: flex-start;
  gap: 8px;
}
.kp-tasks-row__title {
  flex: 1 1 auto;
  min-width: 0;
  margin: 0;
  color: var(--kp-text-primary);
  font-family: "Manrope", Arial, sans-serif;
  font-weight: 500;
  font-size: 16px;
  line-height: 1.3;
  overflow-wrap: break-word;
}
/* Completed rows read quieter -- same energy identity, never erased,
   never a second color system (matches the old prototype's own
   --completed precedent, carried forward as the disclosed treatment
   for a state Figma's canonical instance does not itself demonstrate). */
.kp-tasks-row--completed .kp-tasks-row__title,
.kp-tasks-row--completed .kp-tasks-row__meta { opacity: 0.6; }

/* PRIORITY-UI-ENERGY-AUTO-001: priority is the ONLY task-color signal on
   this row now, replacing the old EnergyIndicator dot (159:1007) --
   same geometry, same --kp-priority-* set Today/Projects already use. */
.kp-tasks-row__priority {
  flex: none;
  width: 24px;
  height: 24px;
  border-radius: 50%;
}
.kp-tasks-row__priority--P1 { background: var(--kp-priority-1); }
.kp-tasks-row__priority--P2 { background: var(--kp-priority-2); }
.kp-tasks-row__priority--P3 { background: var(--kp-priority-3); }
.kp-tasks-row__priority--P0 {
  background: var(--kp-priority-0);
  border: 1px solid var(--kp-priority-0-border);
  color: var(--kp-priority-0-mark);
  display: flex;
  align-items: center;
  justify-content: center;
  font-family: "Manrope", Arial, sans-serif;
  font-weight: 700;
  font-size: 13px;
  line-height: 1;
}

.kp-tasks-row__meta {
  margin: 0;
  color: var(--kp-text-secondary);
  font-family: "Manrope", Arial, sans-serif;
  font-weight: 400;
  font-size: 13px;
}

/* State badge (ready_to_start/started/in_progress/blocked) -- DR-201:
   no literal Figma example row demonstrates this; quiet, textual,
   token-driven, never color-only. 'planned' is never shown (treated as
   the quiet default, matching the old prototype's own precedent). */
.kp-tasks-row__badge {
  align-self: flex-start;
  margin-top: 2px;
  padding: 2px 8px;
  border-radius: 8px;
  border: 1px solid var(--kp-border-subtle);
  color: var(--kp-text-secondary);
  font-family: "Manrope", Arial, sans-serif;
  font-weight: 600;
  font-size: 11px;
}
.kp-tasks-row__badge--blocked { color: var(--kp-recovery); border-color: var(--kp-recovery); }

/* ---- Empty state (163:1016) ---- */
.kp-tasks-empty {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 6px;
  padding: 24px 20px;
  border: 1px solid var(--kp-border-subtle);
  border-radius: 16px;
  background: var(--kp-surface);
  text-align: center;
}
.kp-tasks-empty__title {
  margin: 0;
  color: var(--kp-text-primary);
  font-family: "Manrope", Arial, sans-serif;
  font-weight: 600;
  font-size: 15px;
}
.kp-tasks-empty__body {
  margin: 0;
  max-width: 260px;
  color: var(--kp-text-secondary);
  font-family: "Manrope", Arial, sans-serif;
  font-size: 12px;
  line-height: 17px;
}

.kp-tasks-load-more {
  align-self: center;
  border: 1px solid var(--kp-border-subtle);
  border-radius: 12px;
  padding: 8px 16px;
  background: transparent;
  color: var(--kp-text-primary);
  cursor: pointer;
}
.kp-tasks-load-more[aria-busy="true"] { opacity: 0.6; }

.kp-tasks-loading { padding: 14px 0; color: var(--kp-text-secondary); }
.kp-tasks-error { padding: 14px 0; display: flex; flex-direction: column; gap: 10px; align-items: flex-start; }
.kp-tasks-error__title { margin: 0; color: var(--kp-text-primary); }
.kp-tasks-error__detail { margin: 0; color: var(--kp-text-secondary); }
.kp-tasks-error__retry {
  border: 1px solid var(--kp-border-subtle);
  border-radius: 12px;
  padding: 8px 16px;
  background: transparent;
  color: var(--kp-text-primary);
  cursor: pointer;
}
.kp-tasks-banner {
  padding: 10px 16px;
  border-radius: 14px;
  background: var(--kp-surface-raised);
  color: var(--kp-recovery);
  cursor: pointer;
}
