/* TaskFlow — minimal task board
   Palette: bg #F7F7F5, surface #FFFFFF, ink #1A1A19, muted #6B6B67, line #E4E3DF
   Accent (primary) #3457D5. Status: todo #8A8A85, progress #C98A2A, done #2F8F5B.
   Priority: low #8A8A85, medium #C98A2A, high #C1443A.
*/

:root {
  --bg: #F7F7F5;
  --surface: #FFFFFF;
  --ink: #1A1A19;
  --muted: #6B6B67;
  --line: #E4E3DF;
  --accent: #3457D5;
  --accent-ink: #FFFFFF;
  --todo: #8A8A85;
  --progress: #C98A2A;
  --done: #2F8F5B;
  --danger: #C1443A;
  --radius: 10px;
  --radius-sm: 6px;
  --shadow: 0 1px 2px rgba(20, 20, 18, 0.06), 0 1px 1px rgba(20, 20, 18, 0.04);
  --font: -apple-system, BlinkMacSystemFont, "Inter", "Segoe UI", Roboto, Helvetica, Arial, sans-serif;

  /* Predefined 8-color palette for statuses + task color tags */
  --pal-slate: #8A8A85;
  --pal-blue: #3457D5;
  --pal-teal: #1E8A82;
  --pal-green: #2F8F5B;
  --pal-amber: #C98A2A;
  --pal-orange: #D9722E;
  --pal-red: #C1443A;
  --pal-purple: #7A4FC9;
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: var(--font);
  -webkit-font-smoothing: antialiased;
}

body { min-height: 100vh; }

a { color: inherit; }

button {
  font-family: inherit;
  cursor: pointer;
}

:focus-visible {
  outline: 2px solid var(--accent);
  outline-offset: 2px;
}

/* ---------- Buttons ---------- */

.btn {
  border: 1px solid var(--line);
  background: var(--surface);
  color: var(--ink);
  border-radius: var(--radius-sm);
  padding: 9px 14px;
  font-size: 14px;
  font-weight: 500;
  transition: background 0.15s ease, border-color 0.15s ease;
}
.btn:hover { border-color: #C9C8C2; }

.btn-primary {
  background: var(--accent);
  border-color: var(--accent);
  color: var(--accent-ink);
}
.btn-primary:hover { background: #2A46B8; border-color: #2A46B8; }

.btn-ghost {
  border-color: transparent;
  background: transparent;
}
.btn-ghost:hover { background: rgba(0,0,0,0.04); }

.btn-danger { color: var(--danger); }

.btn-block { width: 100%; }

.btn-sm { padding: 6px 10px; font-size: 13px; }

.icon-btn {
  border: none;
  background: transparent;
  color: var(--muted);
  padding: 6px;
  border-radius: var(--radius-sm);
  display: inline-flex;
  align-items: center;
  justify-content: center;
}
.icon-btn:hover { background: rgba(0,0,0,0.05); color: var(--ink); }

/* ---------- Auth ---------- */

.auth-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  padding: 24px;
}

.auth-card {
  width: 100%;
  max-width: 360px;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: var(--radius);
  padding: 32px 28px;
  box-shadow: var(--shadow);
  text-align: center;
}

.auth-mark {
  width: 40px;
  height: 40px;
  border-radius: 10px;
  background: var(--accent);
  color: #fff;
  font-weight: 700;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 18px;
  letter-spacing: 0.5px;
}

.auth-card h1 { font-size: 19px; margin: 0 0 4px; }
.auth-sub { color: var(--muted); font-size: 14px; margin: 0 0 20px; }

.auth-form { text-align: left; display: flex; flex-direction: column; gap: 6px; }
.auth-form label { font-size: 13px; font-weight: 600; margin-top: 10px; }
.auth-form input {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 14px;
  font-family: inherit;
  width: 100%;
}
.auth-form input:focus { border-color: var(--accent); }
.auth-form button { margin-top: 18px; }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-top: 14px;
  font-size: 13px;
  color: var(--muted);
  font-weight: 500;
  cursor: pointer;
}
.checkbox-row input { width: auto; margin: 0; }

.auth-error {
  background: #FBEAE8;
  color: var(--danger);
  border-radius: var(--radius-sm);
  padding: 10px 12px;
  font-size: 13px;
  margin-bottom: 12px;
}

.auth-hint {
  margin-top: 20px;
  font-size: 12px;
  color: var(--muted);
  line-height: 1.6;
}
.auth-hint code {
  background: var(--bg);
  padding: 1px 5px;
  border-radius: 4px;
}

/* ---------- App shell ---------- */

.topbar {
  position: sticky;
  top: 0;
  z-index: 20;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 12px 20px;
  background: var(--surface);
  border-bottom: 1px solid var(--line);
}

.topbar-left { display: flex; align-items: center; gap: 10px; min-width: 0; }

.brand {
  display: flex;
  align-items: center;
  gap: 8px;
  font-weight: 700;
  font-size: 15px;
  white-space: nowrap;
}
.brand-mark {
  width: 26px;
  height: 26px;
  border-radius: 7px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
}

.topbar-right { display: flex; align-items: center; gap: 8px; }

.user-chip {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 5px 10px 5px 5px;
  border: 1px solid var(--line);
  border-radius: 999px;
  font-size: 13px;
}
.avatar {
  width: 24px;
  height: 24px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  font-size: 11px;
  font-weight: 700;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}
.avatar.sm { width: 20px; height: 20px; font-size: 9.5px; }

.role-badge {
  font-size: 10px;
  text-transform: uppercase;
  letter-spacing: 0.4px;
  color: var(--muted);
}

main.board-wrap {
  max-width: 1180px;
  margin: 0 auto;
  padding: 20px;
}

/* ---------- Mobile tabs ---------- */

.mobile-tabs {
  display: none;
  gap: 6px;
  margin-bottom: 16px;
  border-bottom: 1px solid var(--line);
}
.mobile-tabs button {
  flex: 1;
  border: none;
  background: none;
  padding: 10px 4px;
  font-size: 13px;
  font-weight: 600;
  color: var(--muted);
  border-bottom: 2px solid transparent;
}
.mobile-tabs button.active {
  color: var(--ink);
  border-bottom-color: var(--accent);
}
.mobile-tabs .count {
  display: inline-block;
  margin-left: 4px;
  color: var(--muted);
  font-weight: 500;
}

/* ---------- Board ---------- */

.board {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  align-items: start;
}

.column {
  background: transparent;
}

.column-head {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 4px 12px;
  font-size: 12.5px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--muted);
}
.dot { width: 8px; height: 8px; border-radius: 999px; flex-shrink: 0; }
.dot.todo { background: var(--todo); }
.dot.in_progress { background: var(--progress); }
.dot.done { background: var(--done); }

.column-head .count {
  margin-left: auto;
  background: var(--surface);
  border: 1px solid var(--line);
  border-radius: 999px;
  padding: 1px 8px;
  font-weight: 600;
  color: var(--ink);
}

.card-list {
  display: flex;
  flex-direction: column;
  gap: 10px;
  min-height: 40px;
}

.card-list.drag-over { background: rgba(52, 87, 213, 0.05); border-radius: var(--radius); }

.task-card {
  background: var(--surface);
  border: 1px solid var(--line);
  border-left: 3px solid var(--todo);
  border-radius: var(--radius);
  padding: 12px 12px 10px;
  box-shadow: var(--shadow);
  cursor: grab;
}
.task-card[data-priority="low"] { border-left-color: var(--todo); }
.task-card[data-priority="medium"] { border-left-color: var(--progress); }
.task-card[data-priority="high"] { border-left-color: var(--danger); }
.task-card.dragging { opacity: 0.4; }

.task-title {
  font-size: 14px;
  font-weight: 600;
  margin: 0 0 6px;
  cursor: pointer;
  line-height: 1.35;
}
.task-title:hover { color: var(--accent); }

.task-desc {
  font-size: 12.5px;
  color: var(--muted);
  margin: 0 0 8px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.task-meta {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  font-size: 12px;
  color: var(--muted);
}

.tag {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 2px 7px;
  border-radius: 999px;
  background: var(--bg);
  border: 1px solid var(--line);
  font-size: 11px;
  font-weight: 600;
}
.tag.overdue { background: #FBEAE8; border-color: #F1CFCB; color: var(--danger); }

.task-actions {
  display: flex;
  align-items: center;
  gap: 2px;
  margin-left: auto;
}

.empty-col {
  border: 1px dashed var(--line);
  border-radius: var(--radius);
  padding: 20px 12px;
  text-align: center;
  color: var(--muted);
  font-size: 12.5px;
}

.fab {
  display: none;
  position: fixed;
  right: 18px;
  bottom: 18px;
  width: 52px;
  height: 52px;
  border-radius: 999px;
  background: var(--accent);
  color: #fff;
  border: none;
  font-size: 26px;
  align-items: center;
  justify-content: center;
  box-shadow: 0 4px 14px rgba(52, 87, 213, 0.35);
  z-index: 30;
}

/* ---------- Modal ---------- */

.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(20, 20, 18, 0.32);
  display: none;
  align-items: flex-end;
  justify-content: center;
  z-index: 50;
  padding: 0;
}
.modal-backdrop.open { display: flex; }

.modal {
  background: var(--surface);
  width: 100%;
  max-width: 480px;
  border-radius: 16px 16px 0 0;
  padding: 20px 20px calc(20px + env(safe-area-inset-bottom));
  max-height: 88vh;
  overflow-y: auto;
}

.modal-head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 14px;
}
.modal-head h2 { font-size: 16px; margin: 0; }

.field { margin-bottom: 14px; }
.field label {
  display: block;
  font-size: 12.5px;
  font-weight: 600;
  margin-bottom: 5px;
  color: var(--muted);
}
.field input,
.field select,
.field textarea {
  width: 100%;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 9px 11px;
  font-size: 14px;
  font-family: inherit;
  background: var(--surface);
  color: var(--ink);
}
.field input:focus, .field select:focus, .field textarea:focus { border-color: var(--accent); }
.field textarea { resize: vertical; min-height: 64px; }

.field-row { display: flex; gap: 10px; }
.field-row .field { flex: 1; }

.modal-footer {
  display: flex;
  gap: 8px;
  margin-top: 6px;
  flex-wrap: wrap;
}
.modal-footer .btn { flex: 1; min-width: 120px; }

.gcal-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 12px;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
  font-size: 13px;
}
.gcal-row.synced { border-color: #BFE0CC; background: #F1FAF4; color: var(--done); }
.gcal-row svg { flex-shrink: 0; }
.gcal-row .btn { margin-left: auto; }

/* ---------- Admin panel ---------- */

.user-row {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
}
.user-row:last-child { border-bottom: none; }
.user-row .who { min-width: 0; }
.user-row .who div:first-child { font-weight: 600; }
.user-row .who div:last-child { color: var(--muted); font-size: 12px; }
.user-row .role-badge { border: 1px solid var(--line); padding: 2px 8px; border-radius: 999px; }

.divider { border: none; border-top: 1px solid var(--line); margin: 16px 0; }

/* ---------- Toast ---------- */

.toast {
  position: fixed;
  left: 50%;
  bottom: 20px;
  transform: translateX(-50%) translateY(20px);
  background: var(--ink);
  color: #fff;
  padding: 10px 16px;
  border-radius: 999px;
  font-size: 13px;
  opacity: 0;
  transition: opacity 0.2s ease, transform 0.2s ease;
  z-index: 60;
  pointer-events: none;
}
.toast.show { opacity: 1; transform: translateX(-50%) translateY(0); }

/* ---------- Responsive ---------- */

@media (max-width: 720px) {
  .board { display: block; }
  .column { display: none; }
  .column.active { display: block; }
  .mobile-tabs { display: flex; }
  .fab { display: flex; }
  .topbar { padding: 12px 14px; }
  main.board-wrap { padding: 14px 14px 90px; }
  .new-task-desktop { display: none; }
  .hide-mobile { display: none; }
  .board-select { max-width: 110px; }
}

@media (min-width: 721px) {
  .fab { display: none !important; }
}

/* ---------- Board select + toolbar ---------- */

.board-select {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 6px 8px;
  font-size: 13px;
  font-weight: 600;
  max-width: 200px;
}

.hide-mobile { display: inline; }

.toolbar {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 14px;
  flex-wrap: wrap;
}

.search-wrap {
  flex: 1;
  min-width: 180px;
  display: flex;
  align-items: center;
  gap: 6px;
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 7px 10px;
  color: var(--muted);
}
.search-wrap input {
  border: none;
  outline: none;
  font-size: 13.5px;
  width: 100%;
  font-family: inherit;
  color: var(--ink);
  background: transparent;
}

.sort-select {
  border: 1px solid var(--line);
  background: var(--surface);
  border-radius: var(--radius-sm);
  padding: 7px 8px;
  font-size: 13px;
}

.icon-btn.active { background: rgba(52, 87, 213, 0.1); color: var(--accent); }

.board-empty {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}
.board-empty p { margin-bottom: 14px; }

/* ---------- Color swatches ---------- */

.swatch-row { display: flex; gap: 8px; flex-wrap: wrap; }
.swatch {
  width: 26px;
  height: 26px;
  border-radius: 999px;
  border: 2px solid transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-size: 12px;
}
.swatch.selected { border-color: var(--ink); box-shadow: 0 0 0 2px var(--surface) inset; }
.swatch-none {
  background: var(--surface);
  border: 1px dashed var(--line);
  color: var(--muted);
}

.color-select { border: 1px solid var(--line); border-radius: var(--radius-sm); padding: 8px; font-size: 13px; }

.color-dot { width: 8px; height: 8px; border-radius: 999px; display: inline-block; }

/* ---------- Checklist ---------- */

.muted-inline { color: var(--muted); font-weight: 500; font-size: 12px; }

.checklist-items { display: flex; flex-direction: column; gap: 6px; margin-bottom: 8px; max-height: 180px; overflow-y: auto; }
.checklist-item { display: flex; align-items: center; gap: 8px; font-size: 13.5px; }
.checklist-item input[type="checkbox"] { width: 16px; height: 16px; flex-shrink: 0; }
.checklist-item span { flex: 1; }
.checklist-item.done span { text-decoration: line-through; color: var(--muted); }
.checklist-item button { flex-shrink: 0; }

.checklist-add { display: flex; gap: 6px; }
.checklist-add input {
  flex: 1;
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 8px 10px;
  font-size: 13.5px;
  font-family: inherit;
}

.link-list label { display: flex; align-items: center; gap: 8px; font-size: 13.5px; font-weight: 400; }
.link-list input[type="checkbox"] { width: 15px; height: 15px; }

.checklist-badge { display: inline-flex; align-items: center; gap: 3px; }

/* ---------- Inline add rows (statuses/members in board settings) ---------- */

.inline-add { display: flex; gap: 6px; margin-top: 10px; flex-wrap: wrap; }
.inline-add input, .inline-add select {
  border: 1px solid var(--line);
  border-radius: var(--radius-sm);
  padding: 7px 9px;
  font-size: 13px;
  font-family: inherit;
}
.inline-add input { flex: 1; min-width: 110px; }

.section-title { font-size: 13.5px; margin: 0 0 8px; font-weight: 700; }

.status-row, .archived-row, .note-row {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 0;
  border-bottom: 1px solid var(--line);
  font-size: 13.5px;
}
.status-row:last-child, .archived-row:last-child, .note-row:last-child { border-bottom: none; }
.status-row input[type="text"] {
  flex: 1;
  border: 1px solid transparent;
  background: transparent;
  font-size: 13.5px;
  font-family: inherit;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
}
.status-row input[type="text"]:focus { border-color: var(--line); background: var(--bg); }
.status-row .actions, .archived-row .actions { display: flex; gap: 2px; margin-left: auto; }

.note-row { align-items: flex-start; flex-direction: column; gap: 4px; }
.note-row .note-head { display: flex; align-items: center; gap: 8px; width: 100%; }
.note-row .note-head strong { flex: 1; font-size: 13.5px; }
.note-row .note-body { font-size: 12.5px; color: var(--muted); white-space: pre-wrap; }
.note-row .note-links { display: flex; gap: 6px; flex-wrap: wrap; }

/* ---------- Notification bell ---------- */

#notifyBtn.enabled { color: var(--accent); }

/* ---------- Pointer-based drag & drop ---------- */

.task-card { touch-action: none; }
.task-card.dragging-source { opacity: 0.35; }

.drag-ghost {
  position: fixed;
  z-index: 200;
  pointer-events: none;
  box-shadow: 0 10px 24px rgba(20, 20, 18, 0.22);
  transform: rotate(-1.5deg);
  border-radius: var(--radius);
}
