// history.js
const HistoryManager = {
    MAX_ITEMS: 20,

    init: function() {
        if (!localStorage.history) {
            localStorage.history = JSON.stringify([]);
        }
    },

    add: function(item) {
        const history = JSON.parse(localStorage.history);
        history.unshift({
            timestamp: new Date().toISOString(),
            ...item
        });
        localStorage.history = JSON.stringify(history.slice(0, this.MAX_ITEMS));
    },

    render: function(container) {
        const history = JSON.parse(localStorage.history);
        container.innerHTML = history.map(item => `
            <div class="history-item">
                <time>${new Date(item.timestamp).toLocaleString()}</time>
                <p>${item.title}</p>
            </div>
        `).join('');
    }
};