/* ── Design Tokens ───────────────────────────────────────── */
:root {
    --bg:         #0f0f14;
    --surface:    #1a1a24;
    --surface-2:  #22222f;
    --border:     #2e2e40;
    --primary:    #818cf8;
    --primary-d:  #6366f1;
    --success:    #34d399;
    --danger:     #f87171;
    --warn:       #fbbf24;
    --text:       #e2e8f0;
    --muted:      #64748b;
    --radius:     12px;
}

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

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: flex-start;
    padding: 5rem 1rem 2rem;
}

/* ── Back Link ───────────────────────────────────────────── */
.back-link {
    position: fixed;
    top: 1.5rem; left: 1.5rem;
    text-decoration: none;
    color: var(--muted);
    font-size: 0.9rem;
    font-weight: 500;
    display: flex; align-items: center; gap: 0.5rem;
    transition: color .2s;
    z-index: 10;
}
.back-link:hover { color: var(--text); }

/* ── TS Badge ────────────────────────────────────────────── */
.ts-badge {
    position: fixed;
    top: 1.5rem; right: 1.5rem;
    background: var(--primary-d);
    color: #fff;
    border-radius: 8px;
    width: 40px; height: 40px;
    display: flex; align-items: center; justify-content: center;
    font-size: 0.8rem; font-weight: 700;
    letter-spacing: .05em;
    box-shadow: 0 0 16px rgba(99,102,241,.4);
    z-index: 10;
}

/* ── App Shell ───────────────────────────────────────────── */
.app-container {
    width: 100%; max-width: 520px;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: 20px;
    overflow: hidden;
    box-shadow: 0 25px 60px rgba(0,0,0,.5);
}

/* ── Header ──────────────────────────────────────────────── */
.app-header {
    padding: 2rem 2rem 1.5rem;
    border-bottom: 1px solid var(--border);
    background: linear-gradient(135deg, #1e1e2e 0%, #1a1a2e 100%);
}
.app-header h1 {
    font-size: 1.75rem; font-weight: 700;
    background: linear-gradient(90deg, var(--primary), #c084fc);
    -webkit-background-clip: text; background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: .35rem;
}
.app-header p { color: var(--muted); font-size: 0.875rem; }

/* ── Form ────────────────────────────────────────────────── */
.todo-form {
    display: flex; gap: .6rem; align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border);
}
.todo-input {
    flex: 1; padding: .7rem 1rem;
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: 9999px; color: var(--text);
    font-size: .95rem; font-family: inherit; outline: none;
    transition: border-color .2s, box-shadow .2s;
}
.todo-input::placeholder { color: var(--muted); }
.todo-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(129,140,248,.15);
}
.priority-select {
    padding: .7rem .85rem;
    background: var(--surface-2); border: 1px solid var(--border);
    border-radius: 9999px; color: var(--text);
    font-family: inherit; font-size: .875rem; outline: none;
    cursor: pointer; transition: border-color .2s;
}
.priority-select:focus { border-color: var(--primary); }
.add-btn {
    width: 42px; height: 42px; border-radius: 50%;
    background: var(--primary-d); color: #fff; border: none;
    cursor: pointer; display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem; flex-shrink: 0;
    transition: background .2s, transform .1s, box-shadow .2s;
    box-shadow: 0 4px 12px rgba(99,102,241,.3);
}
.add-btn:hover { background: var(--primary); box-shadow: 0 6px 18px rgba(129,140,248,.4); }
.add-btn:active { transform: scale(.93); }

/* ── Filter ──────────────────────────────────────────────── */
.filter-controls {
    display: flex; gap: 1.5rem;
    padding: .875rem 1.75rem;
    border-bottom: 1px solid var(--border);
    font-size: .875rem;
}
.filter-controls span {
    cursor: pointer; color: var(--muted); font-weight: 500;
    transition: color .2s; padding-bottom: 2px;
}
.filter-controls span:hover { color: var(--text); }
.filter-controls span.active {
    color: var(--primary);
    border-bottom: 2px solid var(--primary);
}

/* ── List ────────────────────────────────────────────────── */
.todo-list {
    list-style: none;
    padding: .5rem .75rem;
    max-height: 340px; overflow-y: auto;
}
.todo-list::-webkit-scrollbar { width: 5px; }
.todo-list::-webkit-scrollbar-track { background: transparent; }
.todo-list::-webkit-scrollbar-thumb { background: var(--border); border-radius: 10px; }

/* ── Todo Item ───────────────────────────────────────────── */
.todo-item {
    display: flex; align-items: center; gap: .75rem;
    padding: .875rem .75rem; border-radius: 10px;
    transition: background .2s; margin-bottom: .25rem;
    animation: fadeUp .25s ease;
}
.todo-item:hover { background: var(--surface-2); }

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(8px); }
    to   { opacity: 1; transform: translateY(0); }
}

/* custom checkbox */
.todo-checkbox { display: none; }
.custom-checkbox {
    width: 22px; height: 22px; flex-shrink: 0;
    border: 2px solid var(--border); border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    cursor: pointer; transition: all .2s;
}
.custom-checkbox i { color: #fff; font-size: .7rem; opacity: 0; transition: opacity .2s; }
.todo-checkbox:checked + .custom-checkbox {
    background: var(--success); border-color: var(--success);
}
.todo-checkbox:checked + .custom-checkbox i { opacity: 1; }

.todo-text {
    flex: 1; font-size: .95rem;
    transition: color .2s, text-decoration .2s;
}
.todo-item.completed .todo-text {
    color: var(--muted); text-decoration: line-through;
}

/* Priority badges */
.priority-badge {
    font-size: .72rem; font-weight: 600; letter-spacing: .04em;
    padding: .2rem .55rem; border-radius: 9999px; text-transform: capitalize;
}
.badge-low    { background: rgba(52,211,153,.15); color: var(--success); }
.badge-medium { background: rgba(251,191,36,.15);  color: var(--warn);    }
.badge-high   { background: rgba(248,113,113,.15); color: var(--danger);  }

.delete-btn {
    background: none; border: none; cursor: pointer;
    color: var(--muted); font-size: 1rem; padding: .4rem;
    opacity: 0; transition: opacity .2s, color .2s;
    display: flex; align-items: center;
}
.todo-item:hover .delete-btn { opacity: 1; }
.delete-btn:hover { color: var(--danger); }

/* Empty state */
.empty-state {
    text-align: center; padding: 3rem 1rem; color: var(--muted);
}
.empty-state i { font-size: 2.5rem; color: var(--border); display: block; margin-bottom: .75rem; }

/* ── Footer ──────────────────────────────────────────────── */
.app-footer {
    display: flex; justify-content: space-between; align-items: center;
    padding: 1.25rem 1.75rem;
    border-top: 1px solid var(--border);
    font-size: .8rem; color: var(--muted);
}
.clear-btn {
    background: none; border: none; cursor: pointer;
    color: var(--muted); font-family: inherit; font-size: .8rem;
    transition: color .2s;
}
.clear-btn:hover { color: var(--danger); }
