export const SimulationStorage = { STORAGE_KEY: 'btc_bot_simulations', getAll() { try { const data = localStorage.getItem(this.STORAGE_KEY); return data ? JSON.parse(data) : []; } catch (e) { console.error('Error reading simulations:', e); return []; } }, save(simulation) { try { const simulations = this.getAll(); simulation.id = simulation.id || 'sim_' + Date.now(); simulation.createdAt = new Date().toISOString(); simulations.push(simulation); localStorage.setItem(this.STORAGE_KEY, JSON.stringify(simulations)); return simulation.id; } catch (e) { console.error('Error saving simulation:', e); return null; } }, delete(id) { try { let simulations = this.getAll(); simulations = simulations.filter(s => s.id !== id); localStorage.setItem(this.STORAGE_KEY, JSON.stringify(simulations)); return true; } catch (e) { console.error('Error deleting simulation:', e); return false; } }, get(id) { return this.getAll().find(s => s.id === id); }, clear() { localStorage.removeItem(this.STORAGE_KEY); } };