CREATE TABLE IF NOT EXISTS whatsapp_settings (
  id INT AUTO_INCREMENT PRIMARY KEY,
  setting_key VARCHAR(100) NOT NULL UNIQUE,
  setting_value TEXT NULL,
  created_at DATETIME DEFAULT CURRENT_TIMESTAMP,
  updated_at DATETIME NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

INSERT INTO whatsapp_settings (setting_key, setting_value, created_at) VALUES
('enabled','0',NOW()),
('provider','evolution',NOW()),
('instance_name','superfax',NOW()),
('default_department','Suporte Técnico',NOW()),
('default_priority','media',NOW()),
('auto_create_ticket','1',NOW()),
('auto_reply','1',NOW()),
('business_hours','Segunda a sexta, 08:00 às 18:00',NOW()),
('welcome_message','Olá! Você está falando com o atendimento Superfax. Descreva o problema e informe o equipamento, setor ou patrimônio.',NOW()),
('offline_message','Recebemos sua mensagem. Nosso horário de atendimento é {business_hours}. Seu chamado será analisado em breve.',NOW()),
('ticket_created_message','Seu chamado #{ticket_id} foi aberto com sucesso. Nossa equipe técnica irá acompanhar a solicitação.',NOW()),
('footer_message','SUPERFAX HelpDesk Enterprise',NOW())
ON DUPLICATE KEY UPDATE setting_key=setting_key;
