-- Antigravity Premium Activation Panel Schema
-- Versão 3.5

-- Tabela de Licenças
CREATE TABLE IF NOT EXISTS `licenses` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `license_key` varchar(255) NOT NULL,
  `email` varchar(255) DEFAULT NULL,
  `plan` varchar(50) DEFAULT 'Premium',
  `status` enum('active','expired','blocked') DEFAULT 'active',
  `expires_at` date DEFAULT NULL,
  `hardware_id` varchar(255) DEFAULT NULL,
  `created_at` timestamp NOT NULL DEFAULT CURRENT_TIMESTAMP,
  PRIMARY KEY (`id`),
  UNIQUE KEY `license_key` (`license_key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- Tabela de Configurações
CREATE TABLE IF NOT EXISTS `settings` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `config_key` varchar(100) NOT NULL,
  `config_value` text,
  PRIMARY KEY (`id`),
  UNIQUE KEY `config_key` (`config_key`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- Inserir Token Padrão do Painel
INSERT INTO `settings` (`config_key`, `config_value`) 
VALUES ('admin_token', 'antigravity_2024')
ON DUPLICATE KEY UPDATE `config_value` = VALUES(`config_value`);

-- Inserir Licença de Teste
INSERT INTO `licenses` (`license_key`, `email`, `plan`, `status`, `expires_at`) 
VALUES ('AG-PREMIUM-LIFETIME-2024', 'admin@centraloficial.com', 'Premium', 'active', '2099-12-31')
ON DUPLICATE KEY UPDATE `status` = 'active';
