/* ── Design Tokens ── */
:root {
  --bg:          #0f0f1a;
  --bg-card:     #1a1a2e;
  --bg-elevated: #242438;
  --border:      #2e2e4a;
  --text:        #e2e8f0;
  --text-muted:  #94a3b8;
  --accent:      #4f46e5;
  --accent-h:    #6366f1;
  --success:     #22c55e;
  --danger:      #ef4444;
  --warn:        #f59e0b;
  --prio-high:   #ef4444;
  --prio-mid:    #f59e0b;
  --prio-low:    #22c55e;
  --radius:      10px;
  --shadow:      0 4px 24px rgba(0,0,0,.4);
}

/* ── Reset ── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; scroll-behavior: smooth; }
body {
  font-family: system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
  min-height: 100dvh;
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── App Shell ── */
#app { display: flex; flex-direction: column; min-height: 100dvh; }

header.app-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border);
  padding: .75rem 1.25rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  position: sticky; top: 0; z-index: 100;
}
.app-title { font-size: 1.1rem; font-weight: 700; color: var(--accent-h); letter-spacing: -.01em; }
.app-user  { font-size: .8rem; color: var(--text-muted); }
#btn-logout { background: none; border: 1px solid var(--border); color: var(--text-muted); padding: .3rem .7rem; border-radius: 6px; cursor: pointer; font-size: .8rem; transition: .15s; }
#btn-logout:hover { border-color: var(--danger); color: var(--danger); }

main { flex: 1; padding: 1.5rem 1rem; max-width: 800px; margin: 0 auto; width: 100%; }

/* ── Login ── */
#view-login {
  display: flex; align-items: center; justify-content: center;
  min-height: calc(100dvh - 60px);
}
.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 2rem 2.5rem;
  width: 100%; max-width: 400px;
  box-shadow: var(--shadow);
}
.login-card h1 { font-size: 1.5rem; margin-bottom: 1.75rem; text-align: center; }
.login-card .logo { font-size: 3rem; text-align: center; display: block; margin-bottom: .5rem; }

/* ── Forms ── */
.form-group { margin-bottom: 1.25rem; }
.form-group label { display: block; font-size: .85rem; color: var(--text-muted); margin-bottom: .4rem; }
.form-group input[type="email"],
.form-group input[type="password"],
.form-group input[type="text"],
.form-group textarea,
.form-group select,
input[type="search"],
select {
  width: 100%;
  background: var(--bg-elevated);
  border: 1px solid var(--border);
  border-radius: 8px;
  color: var(--text);
  padding: .6rem .9rem;
  font-size: .95rem;
  transition: border-color .15s;
  appearance: none;
}
.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus,
input[type="search"]:focus { outline: none; border-color: var(--accent); }
.form-group textarea { resize: vertical; min-height: 100px; font-family: inherit; }
.form-inline { display: flex; align-items: center; gap: .5rem; }
.form-inline label { display: flex; align-items: center; gap: .5rem; color: var(--text); margin: 0; font-size: .95rem; cursor: pointer; }
.required { color: var(--danger); }

/* Prio selector */
.prio-selector { display: flex; gap: .75rem; flex-wrap: wrap; }
.prio-option {
  display: flex; align-items: center; gap: .4rem;
  cursor: pointer; border: 1px solid var(--border);
  border-radius: 8px; padding: .4rem .8rem;
  font-size: .9rem; transition: .15s;
  flex: 1; min-width: 100px; justify-content: center;
}
.prio-option input[type="radio"] { display: none; }
.prio-option.active, .prio-option:has(input:checked) { border-color: var(--accent); background: rgba(79,70,229,.1); }
.prio-dot { width: 10px; height: 10px; border-radius: 50%; display: inline-block; }
.prio-dot.prio-high { background: var(--prio-high); }
.prio-dot.prio-mid  { background: var(--prio-mid); }
.prio-dot.prio-low  { background: var(--prio-low); }
.prio-high { --item-accent: var(--prio-high); }
.prio-mid  { --item-accent: var(--prio-mid); }
.prio-low  { --item-accent: var(--prio-low); }

.form-actions { display: flex; gap: .75rem; justify-content: flex-end; margin-top: 1.5rem; }

/* ── Buttons ── */
.btn {
  border: none; border-radius: 8px; cursor: pointer;
  padding: .6rem 1.25rem; font-size: .9rem; font-weight: 600;
  transition: .15s; white-space: nowrap;
}
.btn-primary   { background: var(--accent); color: #fff; }
.btn-primary:hover  { background: var(--accent-h); }
.btn-secondary { background: var(--bg-elevated); color: var(--text); border: 1px solid var(--border); }
.btn-secondary:hover { border-color: var(--accent); }
.btn-full { width: 100%; padding: .75rem; font-size: 1rem; }
.btn-icon {
  background: none; border: none; cursor: pointer;
  color: var(--text-muted); font-size: 1.1rem; padding: .3rem .5rem;
  border-radius: 6px; transition: .15s; line-height: 1;
}
.btn-icon:hover      { color: var(--text); background: var(--bg-elevated); }
.btn-delete:hover    { color: var(--danger); }

/* ── Alert / Errors ── */
.alert {
  padding: .75rem 1rem; border-radius: 8px;
  margin-bottom: 1rem; font-size: .9rem;
}
.alert-error   { background: rgba(239,68,68,.12); border: 1px solid rgba(239,68,68,.3); color: #fca5a5; }
.alert-success { background: rgba(34,197,94,.12);  border: 1px solid rgba(34,197,94,.3);  color: #86efac; }

/* ── Toolbar ── */
.todo-toolbar {
  display: flex; gap: .75rem; align-items: center; flex-wrap: wrap;
  margin-bottom: 1.25rem; padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.toolbar-search { flex: 1; min-width: 160px; }
.toolbar-search input { width: 100%; }
.toolbar-filters { display: flex; gap: .5rem; align-items: center; flex-wrap: wrap; }
.toolbar-filters select { width: auto; padding: .5rem .75rem; }
.toolbar-actions { margin-left: auto; }

/* ── Todo List ── */
.todo-list { list-style: none; display: flex; flex-direction: column; gap: .6rem; }

.todo-item {
  display: flex; align-items: flex-start; gap: .75rem;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-left: 3px solid var(--item-accent, var(--border));
  border-radius: var(--radius);
  padding: .85rem 1rem;
  transition: .15s;
}
.todo-item:hover { border-color: var(--accent); background: var(--bg-elevated); }
.todo-item.is-done { opacity: .55; }
.todo-item.is-done .todo-description { text-decoration: line-through; color: var(--text-muted); }

.todo-check {
  flex-shrink: 0; width: 24px; height: 24px;
  border: 2px solid var(--border); border-radius: 6px;
  background: none; cursor: pointer; color: var(--success);
  display: flex; align-items: center; justify-content: center;
  font-size: .85rem; transition: .15s; margin-top: 2px;
}
.todo-check:hover { border-color: var(--success); }
.is-done .todo-check { background: var(--success); border-color: var(--success); color: #fff; }

.todo-body { flex: 1; min-width: 0; }
.todo-description { display: block; font-size: .95rem; word-break: break-word; }
.todo-meta {
  display: flex; flex-wrap: wrap; gap: .5rem;
  align-items: center; margin-top: .35rem;
}
.prio-badge {
  font-size: .72rem; font-weight: 600; padding: .15rem .5rem;
  border-radius: 20px; background: rgba(255,255,255,.07); color: var(--item-accent, var(--text-muted));
}
.cat-badge {
  font-size: .72rem; font-weight: 500; padding: .15rem .5rem;
  border-radius: 20px; background: rgba(99,102,241,.18); color: #a5b4fc;
}
.todo-date { font-size: .75rem; color: var(--text-muted); }
.done-date { color: var(--success); }

.todo-actions { display: flex; gap: .1rem; flex-shrink: 0; }

.empty-state {
  text-align: center; padding: 4rem 1rem; color: var(--text-muted);
}
.empty-icon { font-size: 3.5rem; margin-bottom: .75rem; opacity: .3; }

/* ── Modal / Drawer ── */
.modal-backdrop {
  position: fixed; inset: 0; background: rgba(0,0,0,.6);
  z-index: 200; display: flex; align-items: flex-end;
  justify-content: center;
  animation: fadeIn .15s ease;
}
@media (min-width: 600px) {
  .modal-backdrop { align-items: center; }
}
.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius) var(--radius) 0 0;
  padding: 1.5rem;
  width: 100%; max-width: 520px;
  max-height: 90dvh; overflow-y: auto;
  animation: slideUp .2s ease;
}
@media (min-width: 600px) {
  .modal { border-radius: var(--radius); max-height: 80dvh; }
}
.modal-header {
  display: flex; justify-content: space-between; align-items: center;
  margin-bottom: 1.25rem;
}
.modal-header h2 { font-size: 1.1rem; }

@keyframes fadeIn  { from { opacity: 0 }   to { opacity: 1 } }
@keyframes slideUp { from { transform: translateY(40px) } to { transform: translateY(0) } }

/* ── Loader ── */
.loader {
  display: flex; justify-content: center; padding: 3rem;
  color: var(--text-muted); font-size: .9rem;
}
.spinner {
  width: 22px; height: 22px;
  border: 3px solid var(--border);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin .6s linear infinite;
  margin-right: .75rem;
}
@keyframes spin { to { transform: rotate(360deg) } }

/* ── Responsive ── */
@media (max-width: 480px) {
  main { padding: 1rem .75rem; }
  .login-card { padding: 1.5rem 1.25rem; }
  .toolbar-filters { width: 100%; }
  .toolbar-actions { width: 100%; }
  .toolbar-actions .btn { width: 100%; text-align: center; }
}
