/* Feladatkezelő – letisztult, nyugodt felület rendszer betűtípussal (SPEC 9.) */

:root {
  --bg: #f4f5f7;
  --surface: #ffffff;
  --col-bg: #e9ebef;
  --text: #1f2430;
  --muted: #667085;
  --border: #d9dde3;
  --accent: #2f5bd3;
  --accent-text: #ffffff;
  --danger: #c62828;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .08);
  --shadow-lg: 0 12px 32px rgba(16, 24, 40, .18);
  --prio-high: #dc2626;
  --prio-mid: #f59e0b;
  --prio-low: #3b82f6;
  --t: 180ms;
  --tap: 36px;
  --safe-bottom: env(safe-area-inset-bottom, 0px);
  color-scheme: light;
}

* { box-sizing: border-box; }
html { -webkit-text-size-adjust: 100%; }
body {
  margin: 0;
  background: var(--bg);
  color: var(--text);
  font: 15px/1.45 system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
  overflow-x: hidden;
}
button, input, select, textarea { font: inherit; color: inherit; }
[hidden] { display: none !important; }
:focus-visible { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Gombok, beviteli mezők ---------- */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  min-height: var(--tap); padding: 0 14px;
  border: 1px solid var(--border); border-radius: 8px;
  background: var(--surface); cursor: pointer; white-space: nowrap;
  text-decoration: none; color: var(--text);
}
.btn:hover { background: #f7f8fa; }
.btn-primary { background: var(--accent); border-color: var(--accent); color: var(--accent-text); }
.btn-primary:hover { background: #2549b0; }
.btn-danger { background: var(--danger); border-color: var(--danger); color: #fff; }
.btn-danger:hover { background: #a91f1f; }
.btn-danger-outline { color: var(--danger); border-color: #f0c4c4; }
.btn-danger-outline:hover { background: #fdf2f2; }
.btn-link { border: 0; background: none; color: var(--accent); padding: 0 6px; }
.btn-link:hover { background: none; text-decoration: underline; }
.btn-icon { width: var(--tap); padding: 0; font-size: 18px; }
.btn[disabled] { opacity: .5; cursor: default; }
.badge {
  min-width: 20px; height: 20px; padding: 0 6px; border-radius: 10px;
  background: var(--accent); color: #fff; font-size: 12px; line-height: 20px; text-align: center;
}
.input {
  width: 100%; min-height: var(--tap); padding: 7px 10px;
  border: 1px solid var(--border); border-radius: 8px; background: var(--surface);
}
.input:focus { outline: none; border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47, 91, 211, .15); }
.input-sm { min-height: 32px; padding: 4px 8px; }
textarea.input { resize: vertical; }

/* ---------- Fejléc ---------- */
.topbar {
  display: flex; align-items: center; gap: 16px;
  padding: 14px 24px 10px;
}
.brand { margin: 0; font-size: 19px; font-weight: 650; letter-spacing: -.01em; }
.actionbar { flex: 1; display: flex; gap: 8px; max-width: 640px; }
.quickadd { flex: 1; display: flex; gap: 8px; }
.quickadd-btn { flex: none; width: var(--tap); padding: 0; font-size: 22px; line-height: 1; }
.settings-link { margin-left: auto; }

.filter-bar { display: flex; flex-wrap: wrap; gap: 8px; padding: 0 24px 8px; align-items: center; }
.filter-search { width: 260px; }
.btn-filter.active { border-color: var(--accent); color: var(--accent); }
.caret { font-size: 11px; color: var(--muted); }
.active-filters { display: flex; flex-wrap: wrap; gap: 6px; align-items: center; padding: 0 24px 8px; }

.mobile-only { display: none !important; }

/* ---------- Tábla ---------- */
.board {
  display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 14px;
  padding: 6px 24px 32px; align-items: start;
}
.column { background: var(--col-bg); border-radius: 12px; padding: 10px; min-width: 0; display: flex; flex-direction: column; }
.col-head { display: flex; align-items: baseline; gap: 8px; padding: 2px 4px 10px; }
.col-title { margin: 0; font-size: 14px; font-weight: 650; text-transform: uppercase; letter-spacing: .04em; color: #475067; }
.col-count { color: var(--muted); font-size: 13px; font-variant-numeric: tabular-nums; }
.cards { display: flex; flex-direction: column; gap: 8px; min-height: 64px; }
.cards:not(:has(.card))::after {
  content: "Nincs feladat"; color: var(--muted); font-size: 13px; text-align: center;
  padding: 20px 0; border: 1px dashed #c9ced6; border-radius: 8px;
}
.col-foot { display: flex; justify-content: center; }
.col-foot:not(:empty) { padding-top: 8px; }
.load-error::before { content: "Nem sikerült betölteni a feladatokat."; grid-column: 1 / -1; color: var(--danger); }

/* ---------- Kártya ---------- */
.card {
  position: relative; background: var(--surface); border-radius: var(--radius);
  box-shadow: var(--shadow); padding: 10px 8px 10px 14px; cursor: pointer;
  user-select: none; -webkit-user-select: none; -webkit-touch-callout: none;
  overflow-wrap: anywhere;
}
.card::before { content: ""; position: absolute; left: 0; top: 0; bottom: 0; width: 4px; border-radius: var(--radius) 0 0 var(--radius); }
.card.prio-high::before { background: var(--prio-high); }
.card.prio-mid::before { background: var(--prio-mid); }
.card.prio-low::before { background: var(--prio-low); }
.card:hover { box-shadow: 0 2px 6px rgba(16, 24, 40, .12); }
.card.pending { opacity: .6; cursor: progress; }
.card-top { display: flex; align-items: flex-start; gap: 4px; }
.card-title { flex: 1; min-width: 0; padding-top: 2px; }
.card-menu-btn {
  flex: none; width: 30px; height: 30px; margin: -4px -2px 0 0;
  border: 0; border-radius: 6px; background: none; color: var(--muted); cursor: pointer; font-size: 18px; line-height: 1;
}
.card-menu-btn:hover { background: #eef0f3; color: var(--text); }
.card-meta { display: flex; flex-wrap: wrap; gap: 5px; margin-top: 8px; align-items: center; }
.due { font-size: 12px; padding: 2px 7px; border-radius: 6px; background: #f1f3f6; color: #4b5565; white-space: nowrap; }
.due-overdue { background: #fde8e8; color: #b42318; font-weight: 600; }
.due-today { background: #ffedd5; color: #c2410c; font-weight: 600; }
.due-soon { background: #fef6c3; color: #8a6100; }

/* Húzás (SortableJS) – rövid animáció */
.card-ghost { opacity: .35; }
.card-chosen { box-shadow: var(--shadow-lg); }
.card-drag, .sortable-fallback { box-shadow: var(--shadow-lg) !important; transform: rotate(1.5deg); pointer-events: none; opacity: .95 !important; }
body.dragging, body.dragging * { cursor: grabbing !important; }

/* ---------- Chipek: témák színesek, személyek semleges szürkék ---------- */
.chip {
  --c: #0891b2;
  display: inline-flex; align-items: center; gap: 2px; max-width: 100%;
  padding: 2px 9px; border-radius: 999px; font-size: 13px; line-height: 20px;
  border: 1px solid transparent; white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.chip-label { overflow: hidden; text-overflow: ellipsis; }
button.chip { cursor: pointer; font-size: 12px; }
.chip-sm { padding: 0 8px; font-size: 12px; }
.chip-topic {
  background: color-mix(in srgb, var(--c) 14%, white);
  color: color-mix(in srgb, var(--c) 70%, black);
  border-color: color-mix(in srgb, var(--c) 30%, white);
}
.chip-person { background: #eef0f3; color: #3d4450; border-color: #dde1e6; }
.chip-plain { background: #fff; color: var(--text); border-color: var(--border); }
.chip.archived { opacity: .6; font-style: italic; }
.chip-x {
  border: 0; background: none; padding: 0 0 0 4px; margin-right: -4px; cursor: pointer;
  color: inherit; opacity: .65; font-size: 16px; line-height: 1;
}
.chip-x:hover { opacity: 1; }
.dot { display: inline-block; width: 10px; height: 10px; border-radius: 50%; flex: none; }
.prio-dot { display: inline-block; width: 10px; height: 10px; border-radius: 3px; flex: none; background: #d0d5dd; }
.prio-dot.prio-high { background: var(--prio-high); }
.prio-dot.prio-mid { background: var(--prio-mid); }
.prio-dot.prio-low { background: var(--prio-low); }

/* ---------- Popover / menü ---------- */
.popover {
  position: absolute; z-index: 50; min-width: 200px; max-width: min(320px, calc(100vw - 16px));
  background: var(--surface); border: 1px solid var(--border); border-radius: 10px;
  box-shadow: var(--shadow-lg); padding: 6px;
}
.filter-pop { width: 280px; }
.filter-options { display: flex; flex-direction: column; gap: 6px; }
.filter-option-list { max-height: 300px; overflow-y: auto; }
.menu-heading { padding: 8px 10px 4px; font-size: 12px; font-weight: 600; color: var(--muted); text-transform: uppercase; letter-spacing: .04em; }
.menu-item {
  display: flex; align-items: center; gap: 8px; width: 100%; min-height: var(--tap); padding: 4px 10px;
  border: 0; border-radius: 6px; background: none; cursor: pointer; text-align: left;
}
.menu-item:hover { background: #f1f3f6; }
.menu-item.checked { font-weight: 600; }
.menu-check { width: 14px; color: var(--accent); flex: none; }
.menu-empty { padding: 10px; color: var(--muted); font-size: 14px; }
.prio-item::after { content: ""; width: 10px; height: 10px; border-radius: 3px; margin-left: auto; background: transparent; }
.prio-item.prio-high::after { background: var(--prio-high); }
.prio-item.prio-mid::after { background: var(--prio-mid); }
.prio-item.prio-low::after { background: var(--prio-low); }

/* ---------- Szerkesztő panel ---------- */
.editor-backdrop { position: fixed; inset: 0; z-index: 30; background: rgba(16, 24, 40, 0); transition: background var(--t); }
.editor-backdrop.open { background: rgba(16, 24, 40, .12); }
.editor {
  position: fixed; z-index: 40; top: 0; right: 0; bottom: 0; width: min(460px, 100vw);
  background: var(--surface); box-shadow: var(--shadow-lg);
  display: flex; flex-direction: column;
  transform: translateX(100%); transition: transform var(--t) ease-out;
}
.editor.open { transform: none; }
.editor-head { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid #eef0f3; }
.editor-close { font-size: 24px; border-color: transparent; }
.save-state { margin-left: auto; font-size: 13px; color: var(--muted); }
.save-state.ok { color: #1f7a3d; }
.save-state.error { color: var(--danger); }
.editor-body { flex: 1; overflow-y: auto; padding: 16px 20px 28px; display: flex; flex-direction: column; gap: 16px; }
.editor-title { font-size: 19px; font-weight: 600; border-color: transparent; padding: 6px 8px; margin: 0 -8px; resize: none; overflow: hidden; }
.editor-title:hover { border-color: var(--border); }
.editor-notes { min-height: 110px; overflow: hidden; }
.field { display: flex; flex-direction: column; gap: 6px; min-width: 0; }
.field-label { display: flex; flex-direction: column; gap: 6px; font-size: 13px; font-weight: 600; color: #475067; }
.field-row { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; }
.date-row { display: flex; gap: 8px; }
.date-row .input { flex: 1; }
.meta-line { margin: 0; font-size: 13px; color: var(--muted); }
.editor-foot { margin-top: 8px; padding-top: 16px; border-top: 1px solid #eef0f3; }

/* ---------- Címke mező ---------- */
.tagfield { position: relative; }
.tf-box {
  display: flex; flex-wrap: wrap; gap: 6px; align-items: center; min-height: var(--tap);
  padding: 4px 6px; border: 1px solid var(--border); border-radius: 8px; background: var(--surface); cursor: text;
}
.tf-box:focus-within { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(47, 91, 211, .15); }
.tf-chips { display: contents; }
.tf-input { flex: 1; min-width: 120px; border: 0; outline: none; padding: 4px; background: none; }
.tf-list {
  position: absolute; z-index: 45; left: 0; right: 0; top: calc(100% + 4px); margin: 0; padding: 4px; list-style: none;
  max-height: 260px; overflow-y: auto; background: var(--surface); border: 1px solid var(--border);
  border-radius: 10px; box-shadow: var(--shadow-lg);
}
.tf-option { display: flex; align-items: center; gap: 8px; min-height: var(--tap); padding: 6px 10px; border-radius: 6px; cursor: pointer; }
.tf-option.active { background: #eef2fc; }
.tf-create { color: var(--accent); font-weight: 600; }

/* ---------- Párbeszédablak ---------- */
.overlay {
  position: fixed; inset: 0; z-index: 60; background: rgba(16, 24, 40, .35);
  display: flex; align-items: center; justify-content: center; padding: 16px;
  animation: fade var(--t) ease-out;
}
.overlay.closing { opacity: 0; transition: opacity 150ms; }
.dialog { width: min(420px, 100%); background: var(--surface); border-radius: 14px; box-shadow: var(--shadow-lg); padding: 20px; }
.dialog-title { margin: 0 0 8px; font-size: 18px; }
.dialog-msg { margin: 0 0 18px; color: #475067; overflow-wrap: anywhere; }
.dialog-actions { display: flex; justify-content: flex-end; gap: 8px; flex-wrap: wrap; }
@keyframes fade { from { opacity: 0; } }

/* ---------- Toast ---------- */
.toasts {
  position: fixed; z-index: 70; left: 50%; bottom: calc(20px + var(--safe-bottom)); transform: translateX(-50%);
  display: flex; flex-direction: column; gap: 8px; width: min(440px, calc(100vw - 32px)); pointer-events: none;
}
.toast { padding: 10px 14px; border-radius: 10px; background: #1f2430; color: #fff; box-shadow: var(--shadow-lg); transition: opacity 300ms; }
.toast-error { background: #9f1c1c; }
.toast-hide { opacity: 0; }

/* ---------- Mobil szűrőlap ---------- */
.sheet {
  position: fixed; inset: 0; z-index: 40; background: var(--surface); display: flex; flex-direction: column;
  transform: translateY(100%); transition: transform var(--t) ease-out;
}
.sheet.open { transform: none; }
.sheet-head { display: flex; align-items: center; justify-content: space-between; padding: 12px 16px; border-bottom: 1px solid #eef0f3; }
.sheet-head h2 { margin: 0; font-size: 18px; }
.sheet-body { flex: 1; overflow-y: auto; padding: 16px 16px calc(24px + var(--safe-bottom)); }
.filter-sheet { display: flex; flex-direction: column; gap: 18px; }
.filter-sheet-group h3 { margin: 0 0 6px; font-size: 13px; text-transform: uppercase; letter-spacing: .04em; color: var(--muted); }
.filter-sheet .filter-option-list { max-height: none; }


/* ---------- Beállítások oldal ---------- */
.page-settings .topbar { gap: 12px; }
.settings { max-width: 760px; margin: 0 auto; padding: 8px 24px 48px; display: flex; flex-direction: column; gap: 18px; }
.settings-card { background: var(--surface); border-radius: 14px; box-shadow: var(--shadow); padding: 18px 20px; }
.settings-card h2 { margin: 0 0 12px; font-size: 17px; }
.settings-add { display: flex; gap: 8px; margin-bottom: 10px; }
.check { display: inline-flex; align-items: center; gap: 6px; min-height: var(--tap); font-size: 14px; color: #475067; cursor: pointer; }
.entity-list { list-style: none; margin: 6px 0 0; padding: 0; display: flex; flex-direction: column; }
.entity-row { display: flex; align-items: center; gap: 8px; padding: 6px 0; border-top: 1px solid #eef0f3; }
.entity-row.archived .entity-name { color: var(--muted); font-style: italic; }
.entity-name { flex: 1; min-width: 0; border-color: transparent; }
.entity-name:hover { border-color: var(--border); }
.entity-count { flex: none; font-size: 13px; color: var(--muted); font-variant-numeric: tabular-nums; }
.entity-empty { padding: 10px 0; }
.tag-archived { flex: none; font-size: 12px; padding: 1px 7px; border-radius: 6px; background: #f1f3f6; color: var(--muted); margin-left: 6px; }
.color-btn { border-color: transparent; }
.dot-lg { width: 18px; height: 18px; }
.palette { display: grid; grid-template-columns: repeat(5, 36px); gap: 8px; padding: 6px; }
.palette-pop { min-width: 0; }
.swatch { width: 36px; height: 36px; border-radius: 50%; border: 2px solid #fff; box-shadow: 0 0 0 1px var(--border); cursor: pointer; }
.swatch.selected { box-shadow: 0 0 0 2px var(--text); }
.menu-item.danger { color: var(--danger); }
.backup-actions { display: flex; flex-wrap: wrap; gap: 8px; }
.muted { color: var(--muted); font-size: 14px; }
.visually-hidden { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0 0 0 0); white-space: nowrap; }
#import-label:focus-within { outline: 2px solid var(--accent); outline-offset: 2px; }

/* ---------- Mobil (< 768 px) ---------- */
@media (max-width: 767.98px) {
  :root { --tap: 44px; }
  body { font-size: 16px; }
  .desktop-only { display: none !important; }
  .mobile-only { display: flex !important; }

  .topbar { padding: 10px 16px 6px; padding-top: max(10px, env(safe-area-inset-top)); }
  .brand { font-size: 18px; }
  /* Gyors rögzítés és szűrő alul, hüvelykujjal elérhetően */
  .actionbar {
    position: fixed; z-index: 20; left: 0; right: 0; bottom: 0; max-width: none;
    padding: 10px 12px calc(10px + var(--safe-bottom));
    background: rgba(255, 255, 255, .96); border-top: 1px solid var(--border);
    -webkit-backdrop-filter: blur(8px); backdrop-filter: blur(8px);
  }
  .quickadd { min-width: 0; }
  .quickadd .input { min-width: 0; }
  .filter-btn { flex: none; padding: 0 12px; }
  .active-filters { padding: 0 16px 6px; }

  .tabs {
    position: sticky; top: 0; z-index: 10; gap: 4px; padding: 6px 12px; background: var(--bg);
    border-bottom: 1px solid var(--border);
  }
  .tab {
    flex: 1 1 0; min-width: 0; min-height: 44px; padding: 4px 2px;
    display: flex; flex-direction: column; align-items: center; justify-content: center; gap: 0;
    border: 0; border-radius: 8px; background: none; color: var(--muted); cursor: pointer; font-size: 13px;
  }
  .tab-label { max-width: 100%; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
  .tab-count { font-size: 12px; font-variant-numeric: tabular-nums; }
  .tab.active { background: var(--surface); color: var(--text); font-weight: 600; box-shadow: var(--shadow); }
  .tab.drop-target { background: #dfe7fb; color: var(--accent); outline: 2px dashed var(--accent); }

  .board { display: block; padding: 10px 12px calc(96px + var(--safe-bottom)); min-height: 60vh; }
  .column { display: none; background: none; padding: 0; }
  .column.active { display: flex; }
  .col-head { display: none; }

  .card { padding: 12px 6px 12px 14px; }
  .card-menu-btn { width: 44px; height: 44px; margin: -10px -4px -8px 0; font-size: 20px; }
  .chip-sm { position: relative; min-height: 30px; min-width: 44px; justify-content: center; padding: 0 10px; font-size: 13px; }
  .chip-sm::after { content: ""; position: absolute; left: 0; right: 0; top: -7px; bottom: -7px; }
  .chip-x { min-width: 44px; min-height: 44px; margin: -6px -12px -6px -6px; font-size: 20px; }
  .chip:has(.chip-x) { overflow: visible; min-height: 34px; padding-right: 12px; }
  .chip-label { min-width: 0; }
  .tf-input { min-height: 44px; }

  .editor { width: 100vw; transform: translateY(100%); }
  .editor.open { transform: none; }
  .editor-backdrop { display: none; }
  .editor-head { padding-top: max(10px, env(safe-area-inset-top)); }
  .editor-body { padding-bottom: calc(28px + var(--safe-bottom)); }
  .field-row { grid-template-columns: 1fr; }
  .filter-search { width: 100%; }
  .settings { padding: 4px 12px 40px; }
  .settings-card { padding: 14px; }
  .settings-add .btn { flex: none; }
  .entity-count { font-size: 12px; }
  .palette { grid-template-columns: repeat(5, 44px); }
  .swatch { width: 44px; height: 44px; }
  .input-sm { min-height: 44px; }
}

@media (prefers-reduced-motion: reduce) {
  * { transition: none !important; animation: none !important; }
}
