/* TaskTracker — стили. Светлая чистая тема, без тёмного режима, без CDN. */

:root {
  --bg: #f2f4f7;
  --panel: #ffffff;
  --col-bg: #eceff3;
  --border: #e2e5ea;
  --text: #1e2530;
  --muted: #69707d;
  --primary: #2f6fed;
  --primary-dark: #2861d0;
  --primary-weak: #e3ecfd;
  --danger: #e5484d;
  --high: #ef4444;
  --medium: #f59e0b;
  --low: #22c55e;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .08), 0 1px 3px rgba(16, 24, 40, .06);
}

* { box-sizing: border-box; }
html, body { margin: 0; height: 100%; }
body {
  font: 14px/1.45 -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  color: var(--text);
  background: var(--bg);
  -webkit-tap-highlight-color: transparent;
  touch-action: manipulation; /* без задержки/зума при двойном тапе */
}
button { font: inherit; cursor: pointer; }
input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }

/* ---------- Кнопки ---------- */
.btn {
  border: 1px solid var(--border);
  background: var(--panel);
  border-radius: 8px;
  padding: 7px 12px;
}
.btn:hover { background: #f6f8fa; }
.btn-primary { background: var(--primary); border-color: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-ghost { background: transparent; }
.btn-danger { color: var(--danger); }
.btn-danger:hover { background: #fdebec; }
.btn-block { width: 100%; }
.btn-icon { padding: 5px 9px; }

.icon-btn {
  border: 0;
  background: transparent;
  color: var(--muted);
  border-radius: 6px;
  padding: 2px 6px;
  font-size: 13px;
  line-height: 1.4;
}
.icon-btn:hover { background: rgba(15, 23, 42, .08); color: var(--text); }
.icon-danger:hover { color: var(--danger); }

/* Кнопки действий в строках — видны при наведении, на тач-экранах всегда */
.row-actions { display: inline-flex; gap: 2px; margin-left: auto; opacity: 0; transition: opacity .12s; white-space: nowrap; }
.project:hover .row-actions, .col-head:hover .row-actions, .row-actions:focus-within { opacity: 1; }
@media (hover: none) { .row-actions { opacity: 1; } }

/* ---------- Экран входа ---------- */
.login-wrap { position: fixed; inset: 0; display: grid; place-items: center; background: var(--bg); }
.login-card {
  background: var(--panel);
  border: 1px solid var(--border);
  border-radius: 14px;
  box-shadow: var(--shadow);
  padding: 28px;
  width: min(360px, 92vw);
  display: flex;
  flex-direction: column;
  gap: 14px;
}
.login-card h1 { margin: 0; font-size: 20px; }
.login-logo { color: var(--primary); font-weight: 700; font-size: 15px; }
.login-card label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; color: var(--muted); }
.login-card input {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 9px 10px;
  background: #fff;
}
.login-card input:focus { outline: 2px solid var(--primary-weak); border-color: var(--primary); }
.login-error { color: var(--danger); font-size: 13px; }

/* ---------- Каркас ---------- */
#app { display: flex; height: 100vh; height: 100dvh; }

#sidebar {
  width: 264px;
  flex: none;
  background: var(--panel);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  gap: 10px;
  padding: 14px;
  overflow-y: auto;
}
.side-title { font-weight: 700; font-size: 16px; color: var(--primary); padding: 2px 2px 4px; }
.side-sub { font-size: 11.5px; text-transform: uppercase; letter-spacing: .05em; color: var(--muted); margin-top: 6px; padding: 0 2px; }
.side-list { list-style: none; margin: 0; padding: 0; display: flex; flex-direction: column; gap: 2px; }
.side-list .project {
  display: flex;
  align-items: center;
  gap: 4px;
  padding: 7px 8px;
  border-radius: 8px;
  cursor: pointer;
  min-width: 0;
}
.project:hover { background: #f1f4f8; }
.project.active { background: var(--primary-weak); color: var(--primary); font-weight: 600; }
.project.archived .project-name { color: var(--muted); }
.project-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.side-empty { color: var(--muted); padding: 4px 8px; font-size: 13px; }
.side-foot { margin-top: auto; padding-top: 10px; }

/* ---------- Шапка доски ---------- */
#content { flex: 1; min-width: 0; display: flex; flex-direction: column; }
#board-head {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  padding: 12px 18px;
  background: var(--panel);
  border-bottom: 1px solid var(--border);
}
#board-title {
  font-size: 18px;
  margin: 0;
  flex: none;
  max-width: 26vw;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}
#search {
  flex: 1 1 160px;
  min-width: 130px;
  max-width: 320px;
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
}
#search:focus, #filter-priority:focus { outline: 2px solid var(--primary-weak); border-color: var(--primary); }
#filter-priority { border: 1px solid var(--border); border-radius: 8px; padding: 8px 10px; background: #fff; }
#btn-menu { display: none; }

/* ---------- Доска ---------- */
#board {
  flex: 1;
  display: flex;
  align-items: stretch;
  gap: 12px;
  overflow-x: auto;
  overflow-y: hidden;
  padding: 16px;
}
.board-empty { color: var(--muted); padding: 48px 24px; font-size: 15px; }

.column {
  flex: 0 0 284px;
  display: flex;
  flex-direction: column;
  min-height: 120px;
  max-height: 100%;
  background: var(--col-bg);
  border-radius: var(--radius);
}
.col-head {
  display: flex;
  align-items: center;
  gap: 6px;
  padding: 10px 12px 6px;
  cursor: grab;
  user-select: none;
  -webkit-user-select: none;
  min-width: 0;
}
.col-name { font-weight: 600; font-size: 14px; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; flex: 1; }
.col-count {
  flex: none;
  background: #dfe3ea;
  color: #4b5563;
  border-radius: 999px;
  padding: 0 8px;
  font-size: 12px;
  line-height: 20px;
}
.col-cards {
  flex: 1;
  overflow-y: auto;
  padding: 0 8px 8px;
  display: flex;
  flex-direction: column;
  gap: 8px;
  min-height: 60px;
}

/* ---------- Карточка задачи ---------- */
.task-card {
  display: flex;
  gap: 8px;
  background: #fff;
  border-radius: 8px;
  box-shadow: var(--shadow);
  padding: 9px 10px;
  cursor: grab;
  border-left: 3px solid transparent;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none; /* без системного меню при долгом тапе (iOS) */
}
.task-card:active { cursor: grabbing; }
.task-card.prio-high { border-left-color: var(--high); }
.task-card.prio-medium { border-left-color: var(--medium); }
.task-card.prio-low { border-left-color: var(--low); }
.task-check { margin: 3px 0 0; accent-color: var(--primary); flex: none; width: 15px; height: 15px; cursor: pointer; }
.card-main { flex: 1; min-width: 0; }
.card-title { font-weight: 600; overflow-wrap: break-word; }
.card-desc {
  color: var(--muted);
  font-size: 12.5px;
  margin-top: 2px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}
.card-meta { display: flex; gap: 6px; margin-top: 6px; align-items: center; flex-wrap: wrap; }
.prio-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--muted); flex: none; }
.task-card.prio-high .prio-dot { background: var(--high); }
.task-card.prio-medium .prio-dot { background: var(--medium); }
.task-card.prio-low .prio-dot { background: var(--low); }
.chip { font-size: 11.5px; background: #eef1f5; color: #475467; border-radius: 6px; padding: 1px 6px; white-space: nowrap; }
.chip-dl.overdue { background: #fde8e8; color: var(--danger); }
.chip-dl.today { background: #fef3c7; color: #b45309; }
.task-card.done { opacity: .72; }
.task-card.done .card-title { text-decoration: line-through; color: var(--muted); }

/* ---------- DnD ---------- */
.src-hidden { display: none; }                /* источник скрыт — плейсхолдер занимает его место */
.dragging { opacity: .4; }                    /* перетаскиваемая колонка затемняется */
.task-ph {
  flex: none;
  border: 2px dashed #a5b0c0;
  border-radius: 8px;
  background: rgba(101, 116, 139, .08);
}
.col-ind {
  flex: 0 0 5px;
  border-radius: 3px;
  background: var(--primary);
  align-self: stretch;
  min-height: 80px;
}
.drag-ghost {
  position: fixed;
  left: 0;
  top: 0;
  z-index: 1000;
  pointer-events: none;
  box-shadow: 0 14px 32px rgba(16, 24, 40, .28);
  rotate: 2deg;
  margin: 0;
  background: #fff;
}

/* ---------- Инлайн-формы ---------- */
.inline-input {
  width: 100%;
  border: 1px solid var(--primary);
  border-radius: 8px;
  padding: 7px 10px;
  background: #fff;
}
.inline-input:focus { outline: 2px solid var(--primary-weak); }
#project-list .inline-input, #archived-list .inline-input { margin: 2px 0; }
#board > .inline-input {
  flex: 0 0 284px;
  border-style: dashed;
  border-color: #b6bfcc;
  border-radius: var(--radius);
  background: rgba(255, 255, 255, .65);
}

/* ---------- Модальное окно ---------- */
dialog {
  border: 0;
  border-radius: 14px;
  box-shadow: 0 20px 50px rgba(16, 24, 40, .3);
  padding: 0;
  width: min(520px, 94vw);
  background: var(--panel);
  color: var(--text);
}
dialog::backdrop { background: rgba(15, 23, 42, .45); }
.modal-head { display: flex; align-items: center; justify-content: space-between; padding: 16px 18px 0; }
.modal-head h2 { margin: 0; font-size: 17px; }
.modal-meta { padding: 3px 18px 0; color: var(--muted); font-size: 12.5px; }
.modal-body { padding: 12px 18px 4px; display: flex; flex-direction: column; gap: 12px; }
.field { display: flex; flex-direction: column; gap: 5px; font-size: 13px; color: var(--muted); }
.field input, .field select, .field textarea {
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 8px 10px;
  background: #fff;
}
.field textarea { resize: vertical; }
.field input:focus, .field select:focus, .field textarea:focus {
  outline: 2px solid var(--primary-weak);
  border-color: var(--primary);
}
.field-row { display: flex; gap: 12px; }
.field-row .field { flex: 1; }
input.invalid { border-color: var(--danger); background: #fff6f6; }
.modal-foot { display: flex; gap: 10px; padding: 12px 18px 16px; justify-content: space-between; align-items: center; }
.modal-foot-right { display: inline-flex; gap: 10px; }

/* ---------- Сообщения ---------- */
#toast {
  position: fixed;
  left: 50%;
  bottom: 22px;
  transform: translateX(-50%);
  background: #1e2530;
  color: #fff;
  padding: 9px 16px;
  border-radius: 8px;
  box-shadow: 0 8px 24px rgba(0, 0, 0, .25);
  z-index: 1200;
  max-width: 90vw;
}

/* ---------- Скроллбары ---------- */
#board::-webkit-scrollbar, .col-cards::-webkit-scrollbar, #sidebar::-webkit-scrollbar { height: 8px; width: 8px; }
#board::-webkit-scrollbar-thumb, .col-cards::-webkit-scrollbar-thumb, #sidebar::-webkit-scrollbar-thumb { background: #c3cad4; border-radius: 4px; }
#board { scrollbar-width: thin; scrollbar-color: #c3cad4 transparent; }

/* ---------- Мобильная версия: колонки в горизонтальный скролл, сайдбар — шторкой ---------- */
@media (max-width: 720px) {
  #btn-menu { display: inline-flex; }
  #sidebar {
    position: fixed;
    z-index: 50;
    top: 0;
    bottom: 0;
    left: 0;
    height: 100dvh;
    transform: translateX(-105%);
    transition: transform .18s ease;
    box-shadow: 0 0 40px rgba(0, 0, 0, .18);
  }
  body.side-open #sidebar { transform: none; }
  #board-head { padding: 10px 12px; gap: 8px; }
  #board-title { max-width: none; flex: 1 1 auto; min-width: 120px; }
  #search { max-width: none; }
  #board { padding: 10px; gap: 10px; }
  .column { flex-basis: min(84vw, 300px); }
  #board > .inline-input { flex-basis: min(84vw, 300px); }
}
