/* ─── Variables ─────────────────────────────────────────────────────────────── */
:root {
  --bg: #0a0a0f;
  --bg2: #0f0f17;
  --surface: #13131e;
  --surface2: #1a1a28;
  --border: rgba(255,255,255,0.07);
  --border-hover: rgba(255,255,255,0.14);

  --accent: #a78bfa;
  --accent-dim: rgba(167,139,250,0.15);
  --accent-glow: rgba(167,139,250,0.3);

  --high: #f87171;
  --med: #fbbf24;
  --low: #34d399;

  --text: #e2e8f0;
  --text-muted: #64748b;
  --text-dim: #94a3b8;

  --radius: 12px;
  --radius-lg: 18px;
  --transition: 0.2s cubic-bezier(0.4,0,0.2,1);

  --sidebar-w: 260px;
  --font-display: 'Syne', sans-serif;
  --font-mono: 'DM Mono', monospace;
}

/* ─── Reset ──────────────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
  font-family: var(--font-display);
  background: var(--bg);
  color: var(--text);
  min-height: 100vh;
  overflow-x: hidden;
}

/* ─── Background grid ────────────────────────────────────────────────────────── */
.bg-grid {
  position: fixed; inset: 0; z-index: 0; pointer-events: none;
  background-image:
    linear-gradient(rgba(167,139,250,0.03) 1px, transparent 1px),
    linear-gradient(90deg, rgba(167,139,250,0.03) 1px, transparent 1px);
  background-size: 40px 40px;
}

/* ─── Layout ─────────────────────────────────────────────────────────────────── */
.app {
  position: relative; z-index: 1;
  display: grid;
  grid-template-columns: var(--sidebar-w) 1fr;
  min-height: 100vh;
}

/* ─── Sidebar ────────────────────────────────────────────────────────────────── */
.sidebar {
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  padding: 28px 20px;
  gap: 32px;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.logo {
  display: flex;
  align-items: center;
  gap: 10px;
}

.logo-mark {
  width: 36px; height: 36px;
  background: var(--accent);
  color: var(--bg);
  font-size: 18px;
  font-weight: 800;
  border-radius: 8px;
  display: grid;
  place-items: center;
  flex-shrink: 0;
  box-shadow: 0 0 20px var(--accent-glow);
}

.logo-text {
  font-size: 15px;
  font-weight: 800;
  letter-spacing: 0.15em;
  color: var(--text);
}

/* Nav filters */
.nav-filters {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  border-radius: 10px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
  text-align: left;
  width: 100%;
}

.nav-item:hover { background: var(--surface2); color: var(--text); }
.nav-item.active { background: var(--accent-dim); color: var(--accent); }

.nav-icon { font-size: 16px; }
.nav-count {
  margin-left: auto;
  font-family: var(--font-mono);
  font-size: 11px;
  background: var(--surface2);
  padding: 2px 7px;
  border-radius: 20px;
  color: var(--text-dim);
}
.nav-item.active .nav-count { background: var(--accent-dim); color: var(--accent); }

/* Sections */
.sidebar-section { display: flex; flex-direction: column; gap: 10px; }
.section-label {
  font-size: 10px;
  font-weight: 700;
  letter-spacing: 0.12em;
  color: var(--text-muted);
  text-transform: uppercase;
}

/* Categories */
.categories-list { display: flex; flex-direction: column; gap: 4px; }

.cat-filter {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: 8px;
  background: transparent;
  border: none;
  color: var(--text-dim);
  font-family: var(--font-display);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition);
  width: 100%;
  text-align: left;
}
.cat-filter:hover { background: var(--surface2); color: var(--text); }
.cat-filter.active { background: var(--surface2); color: var(--text); }

.cat-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.btn-new-cat {
  background: transparent;
  border: 1px dashed var(--border-hover);
  color: var(--text-muted);
  font-family: var(--font-display);
  font-size: 12px;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--transition);
  text-align: left;
}
.btn-new-cat:hover { border-color: var(--accent); color: var(--accent); }

/* Priority filters */
.priority-filters {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.priority-chip {
  padding: 5px 11px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  font-family: var(--font-display);
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition);
}
.priority-chip:hover, .priority-chip.active {
  border-color: var(--accent);
  background: var(--accent-dim);
  color: var(--accent);
}

/* Sidebar footer */
.sidebar-footer {
  margin-top: auto;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.stats-ring {
  position: relative;
  width: 80px; height: 80px;
}

.ring-svg {
  width: 80px; height: 80px;
  transform: rotate(-90deg);
}

.ring-bg { fill: none; stroke: var(--surface2); stroke-width: 8; }
.ring-fill {
  fill: none;
  stroke: var(--accent);
  stroke-width: 8;
  stroke-linecap: round;
  stroke-dasharray: 201;
  stroke-dashoffset: 201;
  transition: stroke-dashoffset 0.8s cubic-bezier(0.4,0,0.2,1);
  filter: drop-shadow(0 0 6px var(--accent-glow));
}

.ring-label {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center;
}
.ring-label span { font-size: 15px; font-weight: 700; }
.ring-label small { font-size: 9px; color: var(--text-muted); letter-spacing: 0.05em; }

.btn-clear {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  font-family: var(--font-display);
  font-size: 11px;
  padding: 7px 14px;
  border-radius: 8px;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-clear:hover { border-color: var(--high); color: var(--high); }

/* ─── Main ───────────────────────────────────────────────────────────────────── */
.main {
  display: flex;
  flex-direction: column;
  padding: 36px 40px;
  max-width: 900px;
}

.main-header { display: flex; flex-direction: column; gap: 20px; margin-bottom: 32px; }

.header-top { display: flex; align-items: flex-start; justify-content: space-between; }

.page-title {
  font-size: 32px;
  font-weight: 800;
  letter-spacing: -0.02em;
}

.page-sub {
  font-size: 13px;
  color: var(--text-muted);
  font-family: var(--font-mono);
  margin-top: 4px;
}

.btn-add-main {
  display: flex; align-items: center; gap: 8px;
  background: var(--accent);
  color: var(--bg);
  border: none;
  padding: 11px 20px;
  border-radius: var(--radius);
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  box-shadow: 0 0 24px var(--accent-glow);
}
.btn-add-main:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 30px var(--accent-glow);
}
.btn-add-main span { font-size: 18px; line-height: 1; }

/* Search */
.search-bar {
  display: flex;
  align-items: center;
  gap: 12px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 0 16px;
  transition: border-color var(--transition);
}
.search-bar:focus-within { border-color: var(--accent); }

.search-icon { font-size: 20px; color: var(--text-muted); }

.search-bar input {
  background: transparent;
  border: none;
  outline: none;
  color: var(--text);
  font-family: var(--font-display);
  font-size: 14px;
  width: 100%;
  padding: 14px 0;
}
.search-bar input::placeholder { color: var(--text-muted); }

/* ─── Todos ──────────────────────────────────────────────────────────────────── */
.todos-container {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

/* Empty state */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  padding: 80px 0;
  color: var(--text-muted);
}
.empty-icon { font-size: 48px; opacity: 0.3; }
.empty-state p { font-size: 16px; font-weight: 600; }
.empty-state small { font-size: 13px; }

/* Todo item */
.todo-item {
  display: flex;
  align-items: flex-start;
  gap: 14px;
  padding: 16px 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  transition: all var(--transition);
  position: relative;
  overflow: hidden;
  animation: slideIn 0.3s cubic-bezier(0.4,0,0.2,1);
}

@keyframes slideIn {
  from { opacity: 0; transform: translateY(-10px); }
  to   { opacity: 1; transform: translateY(0); }
}

.todo-item::before {
  content: '';
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 3px;
  border-radius: 3px 0 0 3px;
}
.todo-item[data-priority="high"]::before { background: var(--high); }
.todo-item[data-priority="medium"]::before { background: var(--med); }
.todo-item[data-priority="low"]::before { background: var(--low); }

.todo-item:hover { border-color: var(--border-hover); background: var(--surface2); }
.todo-item.completed { opacity: 0.55; }

/* Checkbox */
.todo-check {
  width: 22px; height: 22px; flex-shrink: 0;
  border: 2px solid var(--border-hover);
  border-radius: 7px;
  background: transparent;
  cursor: pointer;
  display: grid;
  place-items: center;
  transition: all var(--transition);
  margin-top: 1px;
}
.todo-check:hover { border-color: var(--accent); }
.todo-item.completed .todo-check {
  background: var(--accent);
  border-color: var(--accent);
}
.todo-check::after {
  content: '✓';
  font-size: 13px;
  color: var(--bg);
  opacity: 0;
  transform: scale(0.5);
  transition: all var(--transition);
}
.todo-item.completed .todo-check::after { opacity: 1; transform: scale(1); }

/* Content */
.todo-content { flex: 1; display: flex; flex-direction: column; gap: 6px; min-width: 0; }

.todo-text {
  font-size: 15px;
  font-weight: 500;
  word-break: break-word;
  transition: all var(--transition);
}
.todo-item.completed .todo-text {
  text-decoration: line-through;
  color: var(--text-muted);
}

.todo-meta { display: flex; align-items: center; gap: 8px; flex-wrap: wrap; }

.prio-badge {
  font-family: var(--font-mono);
  font-size: 10px;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 500;
}
.prio-badge.high { background: rgba(248,113,113,0.15); color: var(--high); }
.prio-badge.medium { background: rgba(251,191,36,0.15); color: var(--med); }
.prio-badge.low { background: rgba(52,211,153,0.15); color: var(--low); }

.cat-badge {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 20px;
  font-weight: 500;
  color: white;
  opacity: 0.85;
}

.todo-date {
  font-family: var(--font-mono);
  font-size: 11px;
  color: var(--text-muted);
  margin-left: auto;
}

/* Actions */
.todo-actions {
  display: flex;
  gap: 6px;
  opacity: 0;
  transition: opacity var(--transition);
  flex-shrink: 0;
}
.todo-item:hover .todo-actions { opacity: 1; }

.action-btn {
  width: 30px; height: 30px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 14px;
  transition: all var(--transition);
}
.action-btn:hover { border-color: var(--border-hover); color: var(--text); }
.action-btn.delete:hover { border-color: var(--high); color: var(--high); background: rgba(248,113,113,0.08); }

/* ─── Modal ──────────────────────────────────────────────────────────────────── */
.modal-overlay {
  position: fixed; inset: 0; z-index: 100;
  background: rgba(0,0,0,0.7);
  backdrop-filter: blur(8px);
  display: grid;
  place-items: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity var(--transition);
}
.modal-overlay.open { opacity: 1; pointer-events: all; }

.modal {
  background: var(--surface);
  border: 1px solid var(--border-hover);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 500px;
  margin: 16px;
  transform: translateY(20px) scale(0.97);
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1);
  box-shadow: 0 24px 80px rgba(0,0,0,0.5);
}
.modal-overlay.open .modal { transform: translateY(0) scale(1); }

.modal-sm { max-width: 360px; }

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 22px 24px 0;
}
.modal-header h2 { font-size: 18px; font-weight: 700; }

.modal-close {
  width: 30px; height: 30px;
  border-radius: 8px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-muted);
  cursor: pointer;
  display: grid;
  place-items: center;
  font-size: 12px;
  transition: all var(--transition);
}
.modal-close:hover { border-color: var(--high); color: var(--high); }

.modal-body { padding: 24px; display: flex; flex-direction: column; gap: 20px; }
.modal-footer {
  padding: 0 24px 24px;
  display: flex;
  justify-content: flex-end;
  gap: 10px;
}

.field { display: flex; flex-direction: column; gap: 8px; }
.field label { font-size: 12px; font-weight: 600; letter-spacing: 0.06em; color: var(--text-dim); text-transform: uppercase; }

.field input[type="text"] {
  background: var(--surface2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  color: var(--text);
  font-family: var(--font-display);
  font-size: 15px;
  padding: 12px 14px;
  outline: none;
  transition: border-color var(--transition);
}
.field input:focus { border-color: var(--accent); }
.field input::placeholder { color: var(--text-muted); }

/* Priority select in modal */
.priority-select { display: flex; gap: 8px; }
.prio-btn {
  flex: 1; padding: 9px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  font-family: var(--font-display);
  font-size: 13px;
  cursor: pointer;
  transition: all var(--transition);
}
.prio-btn:hover { border-color: var(--border-hover); color: var(--text); }
.prio-btn.active { border-color: var(--accent); background: var(--accent-dim); color: var(--accent); }

/* Cat selector in modal */
.cat-selector { display: flex; flex-wrap: wrap; gap: 8px; }
.cat-sel-btn {
  padding: 6px 12px;
  border-radius: 20px;
  border: 1px solid var(--border);
  background: transparent;
  color: var(--text-dim);
  font-family: var(--font-display);
  font-size: 12px;
  cursor: pointer;
  transition: all var(--transition);
  display: flex; align-items: center; gap: 6px;
}
.cat-sel-btn:hover { border-color: var(--border-hover); color: var(--text); }
.cat-sel-btn.selected { color: white; border-color: transparent; }

/* Color picker */
.color-picker { display: flex; flex-wrap: wrap; gap: 10px; }
.color-opt {
  width: 32px; height: 32px;
  border-radius: 8px;
  border: 2px solid transparent;
  cursor: pointer;
  transition: all var(--transition);
}
.color-opt:hover { transform: scale(1.1); }
.color-opt.active { border-color: white; transform: scale(1.1); }

/* Buttons */
.btn-primary {
  background: var(--accent);
  color: var(--bg);
  border: none;
  padding: 11px 20px;
  border-radius: var(--radius);
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-primary:hover { opacity: 0.9; transform: translateY(-1px); }

.btn-ghost {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-muted);
  padding: 11px 20px;
  border-radius: var(--radius);
  font-family: var(--font-display);
  font-size: 14px;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-ghost:hover { border-color: var(--border-hover); color: var(--text); }

/* ─── Scrollbar ──────────────────────────────────────────────────────────────── */
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--surface2); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }

/* ─── Toast ──────────────────────────────────────────────────────────────────── */
.toast {
  position: fixed;
  bottom: 28px; right: 28px;
  background: var(--surface2);
  border: 1px solid var(--border-hover);
  color: var(--text);
  padding: 12px 18px;
  border-radius: var(--radius);
  font-size: 13px;
  z-index: 999;
  animation: toastIn 0.3s ease, toastOut 0.3s ease 2.5s forwards;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
}

@keyframes toastIn { from { opacity: 0; transform: translateY(12px); } to { opacity: 1; transform: translateY(0); } }
@keyframes toastOut { from { opacity: 1; } to { opacity: 0; } }

/* ─── Responsive ─────────────────────────────────────────────────────────────── */
@media (max-width: 768px) {
  .app { grid-template-columns: 1fr; }
  .sidebar { display: none; }
  .main { padding: 20px; }
  .page-title { font-size: 24px; }
}
