/* Task Manager — оформление.
   Визуальный язык наследуется от Creative Desk (Onest / Space Grotesk), разметка своя. */

@import url("https://fonts.googleapis.com/css2?family=Onest:wght@400;500;600;700&family=Space+Grotesk:wght@500;600;700&display=swap");

:root {
  --bg: #0f1115;
  --surface: #171a21;
  --surface-2: #1e222b;
  --border: #2a2f3a;
  --text: #e8eaf0;
  --text-dim: #9aa3b2;
  --text-faint: #6b7484;
  --accent: #6366f1;
  --accent-soft: #6366f126;
  --danger: #ef4444;
  --warn: #f59e0b;
  --ok: #10b981;
  --radius: 10px;
  --shadow: 0 8px 24px rgba(0, 0, 0, 0.35);
}

* { box-sizing: border-box; }

body {
  margin: 0;
  font-family: Onest, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

button, input, select, textarea { font: inherit; color: inherit; }
button { cursor: pointer; }
a { color: var(--accent); }

/* ---------- Раскладка ---------- */

#app { display: grid; grid-template-columns: 248px 1fr; height: 100vh; }

.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.brand {
  font-family: "Space Grotesk", sans-serif;
  font-weight: 700;
  font-size: 19px;
  letter-spacing: -0.02em;
  padding: 18px 18px 14px;
  border-bottom: 1px solid var(--border);
}
.brand span { color: var(--accent); }

.side-section {
  padding: 14px 12px 6px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.side-section h3 {
  margin: 0;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--text-faint);
}

.side-list { overflow-y: auto; flex: 1; padding: 0 8px 12px; }

.side-item {
  display: flex;
  align-items: center;
  gap: 9px;
  padding: 8px 10px;
  border-radius: 8px;
  cursor: pointer;
  color: var(--text-dim);
  border: none;
  background: none;
  width: 100%;
  text-align: left;
}
.side-item:hover { background: var(--surface-2); color: var(--text); }
.side-item.active { background: var(--accent-soft); color: var(--text); font-weight: 500; }
.side-item .dot { width: 9px; height: 9px; border-radius: 50%; flex: none; }
.side-item .label { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-item .count { margin-left: auto; font-size: 12px; color: var(--text-faint); }

.side-foot { border-top: 1px solid var(--border); padding: 10px 12px; }

.me { display: flex; align-items: center; gap: 9px; }
.me img, .me .avatar-fallback {
  width: 28px; height: 28px; border-radius: 50%; flex: none;
  background: var(--accent); display: grid; place-items: center;
  font-size: 11px; font-weight: 600;
}
.me .who { overflow: hidden; }
.me .who b { display: block; font-weight: 500; font-size: 13px; }
.me .who small { color: var(--text-faint); font-size: 11px; }

/* ---------- Главная область ---------- */

.main { display: flex; flex-direction: column; overflow: hidden; }

.topbar {
  display: flex;
  align-items: center;
  gap: 14px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
  flex-wrap: wrap;
}
.topbar h1 { margin: 0; font-size: 17px; font-weight: 600; }

.views { display: flex; gap: 3px; background: var(--surface); padding: 3px; border-radius: 9px; }
.views button {
  border: none; background: none; color: var(--text-dim);
  padding: 6px 13px; border-radius: 7px; font-size: 13px;
}
.views button.active { background: var(--surface-2); color: var(--text); }

.spacer { flex: 1; }

.field {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 8px; padding: 7px 11px; color: var(--text);
}
.field:focus { outline: none; border-color: var(--accent); }
input.field::placeholder { color: var(--text-faint); }

.btn {
  background: var(--accent); color: #fff; border: none;
  border-radius: 8px; padding: 8px 15px; font-weight: 500; font-size: 13px;
}
.btn:hover { filter: brightness(1.1); }
.btn.ghost { background: var(--surface); border: 1px solid var(--border); color: var(--text-dim); }
.btn.ghost:hover { color: var(--text); }
.btn.danger { background: var(--danger); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* ---------- Тулбар над контентом (как в Creative Desk) ---------- */

.toolbar {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 14px 20px 2px;
  flex-wrap: wrap;
}

/* Заметная primary-кнопка создания задачи: плюс-иконка, свечение, hover-подъём. */
.btn.cta {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 15px;
  box-shadow: 0 8px 22px rgba(99, 102, 241, 0.4);
  transition: transform 0.14s ease, filter 0.15s ease, box-shadow 0.15s ease;
}
.btn.cta:hover { filter: brightness(1.08); transform: translateY(-1px); }
.btn.cta:active { transform: translateY(0) scale(0.98); }
.btn.cta:disabled { box-shadow: none; transform: none; filter: none; }
.btn.cta .icon { flex: none; }

.search-box { position: relative; display: inline-flex; align-items: center; }
.search-box .icon { position: absolute; left: 10px; color: var(--text-faint); pointer-events: none; }
.search-box .field { width: 240px; max-width: 100%; padding-left: 32px; }

.filters { display: flex; gap: 8px; align-items: center; padding: 10px 20px; flex-wrap: wrap; }
.filters:empty { padding: 0; }
.chip {
  border: 1px solid var(--border); background: var(--surface);
  color: var(--text-dim); border-radius: 999px; padding: 4px 11px; font-size: 12px;
}
.chip.active { background: var(--accent); border-color: var(--accent); color: #fff; }

#view { flex: 1; overflow: auto; padding: 16px 20px 40px; }

/* ---------- Доска ---------- */

.board { display: flex; gap: 14px; align-items: flex-start; min-height: 100%; }

.lane {
  width: 300px; flex: none;
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); display: flex; flex-direction: column; max-height: 100%;
}
.lane.drop-target { border-color: var(--accent); background: var(--accent-soft); }

.lane-head {
  display: flex; align-items: center; gap: 8px;
  padding: 11px 13px; border-bottom: 1px solid var(--border);
}
.lane-head h4 {
  margin: 0; font-size: 12px; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-dim);
}
.lane-head .n {
  font-size: 11px; color: var(--text-faint);
  background: var(--surface-2); border-radius: 999px; padding: 1px 7px;
}
.lane-head .x {
  margin-left: auto; background: none; border: none;
  color: var(--text-faint); font-size: 15px; line-height: 1; padding: 2px 4px;
}
.lane-head .x:hover { color: var(--danger); }

.lane-body { padding: 9px; display: flex; flex-direction: column; gap: 8px; overflow-y: auto; }

.card {
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 9px; padding: 11px; cursor: pointer;
  touch-action: none; user-select: none;
}
.card:hover { border-color: var(--accent); }
.card.dragging { opacity: 0.35; }
.card-ghost {
  position: fixed; pointer-events: none; z-index: 999;
  width: 282px; box-shadow: var(--shadow); transform: rotate(2deg); opacity: 0.95;
}
.drop-line { height: 2px; background: var(--accent); border-radius: 2px; margin: -3px 0; }

.card h5 { margin: 0 0 7px; font-size: 13px; font-weight: 500; line-height: 1.35; }
.card-meta { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; font-size: 11px; color: var(--text-faint); }

.pri { border-radius: 4px; padding: 1px 6px; font-size: 10px; font-weight: 600; letter-spacing: 0.03em; }
.pri.Urgent { background: #ef444426; color: #fca5a5; }
.pri.High   { background: #f59e0b26; color: #fcd34d; }
.pri.Medium { background: #6366f126; color: #a5b4fc; }
.pri.Low    { background: #6b748426; color: var(--text-dim); }

.due.overdue { color: #fca5a5; font-weight: 600; }
.due.soon { color: #fcd34d; }

.tag {
  background: var(--accent-soft); color: #a5b4fc;
  border-radius: 4px; padding: 1px 6px; font-size: 10px;
}

.avatar-mini {
  width: 20px; height: 20px; border-radius: 50%; margin-left: auto;
  background: var(--accent); display: grid; place-items: center;
  font-size: 9px; font-weight: 600; color: #fff;
}
.avatar-mini img { width: 100%; height: 100%; border-radius: 50%; }

.add-lane {
  width: 300px; flex: none; border: 1px dashed var(--border);
  border-radius: var(--radius); background: none; color: var(--text-faint);
  padding: 13px; font-size: 13px;
}
.add-lane:hover { border-color: var(--accent); color: var(--accent); }

/* ---------- Таблица ---------- */

.group { margin-bottom: 22px; }
.group-head {
  display: flex; align-items: center; gap: 9px;
  margin-bottom: 8px; font-size: 12px; font-weight: 600;
  letter-spacing: 0.06em; text-transform: uppercase; color: var(--text-dim);
}
.group-head .n { font-size: 11px; color: var(--text-faint); background: var(--surface); border-radius: 999px; padding: 1px 7px; }

table.tasks { width: 100%; border-collapse: collapse; }
table.tasks th {
  text-align: left; font-size: 11px; font-weight: 600; color: var(--text-faint);
  padding: 7px 10px; border-bottom: 1px solid var(--border);
  text-transform: uppercase; letter-spacing: 0.05em;
}
table.tasks td { padding: 9px 10px; border-bottom: 1px solid var(--border); font-size: 13px; }
table.tasks tr { cursor: pointer; }
table.tasks tbody tr:hover td { background: var(--surface); }
table.tasks th.sortable:hover { color: var(--text); cursor: pointer; }

/* ---------- Модалка ---------- */

.overlay {
  position: fixed; inset: 0; background: rgba(0, 0, 0, 0.6);
  display: grid; place-items: center; padding: 24px; z-index: 100;
}
.overlay[hidden] { display: none; }

.modal {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: 14px; box-shadow: var(--shadow);
  width: min(760px, 100%); max-height: 90vh; overflow-y: auto;
}
.modal.narrow { width: min(420px, 100%); }
.modal-head {
  display: flex; align-items: center; gap: 10px;
  padding: 16px 20px; border-bottom: 1px solid var(--border);
}
.modal-head h2 { margin: 0; font-size: 16px; font-weight: 600; flex: 1; }
.modal-head .x { background: none; border: none; color: var(--text-faint); font-size: 20px; line-height: 1; }
.modal-body { padding: 18px 20px; display: flex; flex-direction: column; gap: 16px; }
.modal-foot {
  padding: 14px 20px; border-top: 1px solid var(--border);
  display: flex; gap: 9px; justify-content: flex-end;
}

.row { display: flex; gap: 12px; flex-wrap: wrap; }
.row > * { flex: 1; min-width: 150px; }

label.lb { display: block; font-size: 11px; color: var(--text-faint); margin-bottom: 5px;
  text-transform: uppercase; letter-spacing: 0.05em; font-weight: 600; }
.field { width: 100%; }
textarea.field { min-height: 84px; resize: vertical; }

.sub-list, .comment-list { display: flex; flex-direction: column; gap: 7px; }
.sub-item { display: flex; align-items: center; gap: 9px; }
.sub-item input[type="checkbox"] { width: 15px; height: 15px; accent-color: var(--accent); }
.sub-item .txt.done { text-decoration: line-through; color: var(--text-faint); }
.sub-item .rm, .tag .rm {
  margin-left: auto; background: none; border: none; color: var(--text-faint); font-size: 15px;
}
.sub-item .rm:hover { color: var(--danger); }

.tag-row { display: flex; gap: 6px; flex-wrap: wrap; align-items: center; }
.tag-row .tag { display: inline-flex; align-items: center; gap: 4px; padding: 3px 8px; font-size: 11px; }
.tag-row .tag .rm { margin: 0; font-size: 13px; padding: 0; line-height: 1; }

.comment {
  background: var(--surface-2); border-radius: 9px; padding: 10px 12px;
}
.comment .head { display: flex; gap: 8px; align-items: baseline; margin-bottom: 4px; }
.comment .head b { font-size: 12px; font-weight: 600; }
.comment .head small { font-size: 11px; color: var(--text-faint); }
.comment .body { font-size: 13px; white-space: pre-wrap; }

.file-item { display: flex; align-items: center; gap: 9px; font-size: 13px; }
.file-item .rm { margin-left: auto; background: none; border: none; color: var(--text-faint); }

.empty { color: var(--text-faint); font-size: 13px; padding: 26px 0; text-align: center; }

/* ---------- Вход ---------- */

#loginScreen {
  position: fixed; inset: 0; background: var(--bg);
  display: grid; place-items: center; z-index: 200;
}
#loginScreen[hidden] { display: none; }
.login-card { text-align: center; max-width: 340px; }
.login-card h1 { font-family: "Space Grotesk", sans-serif; font-size: 27px; margin: 0 0 8px; }
.login-card p { color: var(--text-dim); margin: 0 0 22px; }
.login-error { color: #fca5a5; font-size: 13px; margin-top: 14px; }

.toast {
  position: fixed; bottom: 22px; left: 50%; transform: translateX(-50%);
  background: var(--surface-2); border: 1px solid var(--border);
  border-radius: 9px; padding: 10px 16px; font-size: 13px;
  box-shadow: var(--shadow); z-index: 300;
}
.toast.err { border-color: var(--danger); color: #fca5a5; }

@media (max-width: 860px) {
  #app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
}
