-- ===========================================
-- TaskFlow - Database Setup Script
-- Run this in phpMyAdmin or MySQL CLI
-- ===========================================

CREATE DATABASE IF NOT EXISTS `asana_clone` 
CHARACTER SET utf8mb4 
COLLATE utf8mb4_unicode_ci;

USE `asana_clone`;

-- Companies
CREATE TABLE `companies` (
    `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
    `name` VARCHAR(255) NOT NULL,
    `slug` VARCHAR(255) NOT NULL UNIQUE,
    `logo` VARCHAR(255) NULL,
    `subscription_plan` VARCHAR(255) DEFAULT 'free',
    `description` TEXT NULL,
    `website` VARCHAR(255) NULL,
    `is_active` TINYINT(1) DEFAULT 1,
    `created_at` TIMESTAMP NULL,
    `updated_at` TIMESTAMP NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Users
CREATE TABLE `users` (
    `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
    `company_id` BIGINT UNSIGNED NULL,
    `name` VARCHAR(255) NOT NULL,
    `email` VARCHAR(255) NOT NULL UNIQUE,
    `email_verified_at` TIMESTAMP NULL,
    `password` VARCHAR(255) NOT NULL,
    `avatar` VARCHAR(255) NULL,
    `job_title` VARCHAR(255) NULL,
    `phone` VARCHAR(255) NULL,
    `department` VARCHAR(255) NULL,
    `is_active` TINYINT(1) DEFAULT 1,
    `remember_token` VARCHAR(100) NULL,
    `created_at` TIMESTAMP NULL,
    `updated_at` TIMESTAMP NULL,
    FOREIGN KEY (`company_id`) REFERENCES `companies`(`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Permissions (Spatie)
CREATE TABLE `permissions` (
    `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
    `name` VARCHAR(255) NOT NULL,
    `guard_name` VARCHAR(255) DEFAULT 'web',
    `created_at` TIMESTAMP NULL,
    `updated_at` TIMESTAMP NULL,
    UNIQUE KEY `permissions_name_guard_unique` (`name`, `guard_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Roles (Spatie)
CREATE TABLE `roles` (
    `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
    `name` VARCHAR(255) NOT NULL,
    `guard_name` VARCHAR(255) DEFAULT 'web',
    `created_at` TIMESTAMP NULL,
    `updated_at` TIMESTAMP NULL,
    UNIQUE KEY `roles_name_guard_unique` (`name`, `guard_name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Model Has Permissions
CREATE TABLE `model_has_permissions` (
    `permission_id` BIGINT UNSIGNED NOT NULL,
    `model_type` VARCHAR(255) NOT NULL,
    `model_id` BIGINT UNSIGNED NOT NULL,
    PRIMARY KEY (`permission_id`, `model_id`, `model_type`),
    INDEX `model_has_permissions_model_id_model_type_index` (`model_id`, `model_type`),
    FOREIGN KEY (`permission_id`) REFERENCES `permissions`(`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Model Has Roles
CREATE TABLE `model_has_roles` (
    `role_id` BIGINT UNSIGNED NOT NULL,
    `model_type` VARCHAR(255) NOT NULL,
    `model_id` BIGINT UNSIGNED NOT NULL,
    PRIMARY KEY (`role_id`, `model_id`, `model_type`),
    INDEX `model_has_roles_model_id_model_type_index` (`model_id`, `model_type`),
    FOREIGN KEY (`role_id`) REFERENCES `roles`(`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Role Has Permissions
CREATE TABLE `role_has_permissions` (
    `permission_id` BIGINT UNSIGNED NOT NULL,
    `role_id` BIGINT UNSIGNED NOT NULL,
    PRIMARY KEY (`permission_id`, `role_id`),
    FOREIGN KEY (`permission_id`) REFERENCES `permissions`(`id`) ON DELETE CASCADE,
    FOREIGN KEY (`role_id`) REFERENCES `roles`(`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Teams
CREATE TABLE `teams` (
    `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
    `company_id` BIGINT UNSIGNED NOT NULL,
    `name` VARCHAR(255) NOT NULL,
    `department` VARCHAR(255) NULL,
    `description` TEXT NULL,
    `color` VARCHAR(7) DEFAULT '#6366f1',
    `is_active` TINYINT(1) DEFAULT 1,
    `created_at` TIMESTAMP NULL,
    `updated_at` TIMESTAMP NULL,
    FOREIGN KEY (`company_id`) REFERENCES `companies`(`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Team User Pivot
CREATE TABLE `team_user` (
    `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
    `team_id` BIGINT UNSIGNED NOT NULL,
    `user_id` BIGINT UNSIGNED NOT NULL,
    `role` VARCHAR(255) DEFAULT 'member',
    `created_at` TIMESTAMP NULL,
    `updated_at` TIMESTAMP NULL,
    UNIQUE KEY `team_user_unique` (`team_id`, `user_id`),
    FOREIGN KEY (`team_id`) REFERENCES `teams`(`id`) ON DELETE CASCADE,
    FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Projects
CREATE TABLE `projects` (
    `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
    `team_id` BIGINT UNSIGNED NULL,
    `company_id` BIGINT UNSIGNED NOT NULL,
    `owner_id` BIGINT UNSIGNED NOT NULL,
    `name` VARCHAR(255) NOT NULL,
    `description` TEXT NULL,
    `status` ENUM('not_started','in_progress','on_hold','completed','cancelled') DEFAULT 'not_started',
    `priority` ENUM('low','medium','high','urgent') DEFAULT 'medium',
    `color` VARCHAR(7) DEFAULT '#6366f1',
    `start_date` DATE NULL,
    `due_date` DATE NULL,
    `progress` TINYINT UNSIGNED DEFAULT 0,
    `is_archived` TINYINT(1) DEFAULT 0,
    `created_at` TIMESTAMP NULL,
    `updated_at` TIMESTAMP NULL,
    FOREIGN KEY (`team_id`) REFERENCES `teams`(`id`) ON DELETE SET NULL,
    FOREIGN KEY (`company_id`) REFERENCES `companies`(`id`) ON DELETE CASCADE,
    FOREIGN KEY (`owner_id`) REFERENCES `users`(`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Project User Pivot
CREATE TABLE `project_user` (
    `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
    `project_id` BIGINT UNSIGNED NOT NULL,
    `user_id` BIGINT UNSIGNED NOT NULL,
    `role` VARCHAR(255) DEFAULT 'member',
    `created_at` TIMESTAMP NULL,
    `updated_at` TIMESTAMP NULL,
    UNIQUE KEY `project_user_unique` (`project_id`, `user_id`),
    FOREIGN KEY (`project_id`) REFERENCES `projects`(`id`) ON DELETE CASCADE,
    FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Tasks (with self-referencing parent_id for subtasks)
CREATE TABLE `tasks` (
    `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
    `project_id` BIGINT UNSIGNED NOT NULL,
    `assignee_id` BIGINT UNSIGNED NULL,
    `creator_id` BIGINT UNSIGNED NOT NULL,
    `parent_id` BIGINT UNSIGNED NULL,
    `title` VARCHAR(255) NOT NULL,
    `description` TEXT NULL,
    `status` ENUM('todo','in_progress','review','completed') DEFAULT 'todo',
    `priority` ENUM('low','medium','high','urgent') DEFAULT 'medium',
    `due_date` DATE NULL,
    `start_date` DATE NULL,
    `position` INT UNSIGNED DEFAULT 0,
    `estimated_hours` INT UNSIGNED NULL,
    `is_completed` TINYINT(1) DEFAULT 0,
    `completed_at` TIMESTAMP NULL,
    `created_at` TIMESTAMP NULL,
    `updated_at` TIMESTAMP NULL,
    FOREIGN KEY (`project_id`) REFERENCES `projects`(`id`) ON DELETE CASCADE,
    FOREIGN KEY (`assignee_id`) REFERENCES `users`(`id`) ON DELETE SET NULL,
    FOREIGN KEY (`creator_id`) REFERENCES `users`(`id`) ON DELETE CASCADE,
    FOREIGN KEY (`parent_id`) REFERENCES `tasks`(`id`) ON DELETE SET NULL,
    INDEX `tasks_project_status` (`project_id`, `status`),
    INDEX `tasks_assignee_status` (`assignee_id`, `status`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Tags
CREATE TABLE `tags` (
    `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
    `company_id` BIGINT UNSIGNED NOT NULL,
    `name` VARCHAR(255) NOT NULL,
    `color` VARCHAR(7) DEFAULT '#6366f1',
    `created_at` TIMESTAMP NULL,
    `updated_at` TIMESTAMP NULL,
    FOREIGN KEY (`company_id`) REFERENCES `companies`(`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Task Tag Pivot
CREATE TABLE `tag_task` (
    `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
    `task_id` BIGINT UNSIGNED NOT NULL,
    `tag_id` BIGINT UNSIGNED NOT NULL,
    UNIQUE KEY `task_tag_unique` (`task_id`, `tag_id`),
    FOREIGN KEY (`task_id`) REFERENCES `tasks`(`id`) ON DELETE CASCADE,
    FOREIGN KEY (`tag_id`) REFERENCES `tags`(`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Comments
CREATE TABLE `comments` (
    `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
    `task_id` BIGINT UNSIGNED NOT NULL,
    `user_id` BIGINT UNSIGNED NOT NULL,
    `body` TEXT NOT NULL,
    `mentions` JSON NULL,
    `created_at` TIMESTAMP NULL,
    `updated_at` TIMESTAMP NULL,
    FOREIGN KEY (`task_id`) REFERENCES `tasks`(`id`) ON DELETE CASCADE,
    FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Attachments
CREATE TABLE `attachments` (
    `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
    `task_id` BIGINT UNSIGNED NOT NULL,
    `user_id` BIGINT UNSIGNED NOT NULL,
    `filename` VARCHAR(255) NOT NULL,
    `original_filename` VARCHAR(255) NOT NULL,
    `path` VARCHAR(255) NOT NULL,
    `mime_type` VARCHAR(255) NULL,
    `size` BIGINT UNSIGNED DEFAULT 0,
    `created_at` TIMESTAMP NULL,
    `updated_at` TIMESTAMP NULL,
    FOREIGN KEY (`task_id`) REFERENCES `tasks`(`id`) ON DELETE CASCADE,
    FOREIGN KEY (`user_id`) REFERENCES `users`(`id`) ON DELETE CASCADE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Activities
CREATE TABLE `activities` (
    `id` BIGINT UNSIGNED NOT NULL AUTO_INCREMENT PRIMARY KEY,
    `company_id` BIGINT UNSIGNED NOT NULL,
    `subject_type` VARCHAR(255) NOT NULL,
    `subject_id` BIGINT UNSIGNED NOT NULL,
    `causer_id` BIGINT UNSIGNED NULL,
    `description` VARCHAR(255) NOT NULL,
    `action` VARCHAR(255) NOT NULL,
    `properties` JSON NULL,
    `created_at` TIMESTAMP NULL,
    `updated_at` TIMESTAMP NULL,
    INDEX `activities_subject` (`subject_type`, `subject_id`),
    FOREIGN KEY (`company_id`) REFERENCES `companies`(`id`) ON DELETE CASCADE,
    FOREIGN KEY (`causer_id`) REFERENCES `users`(`id`) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Notifications (Laravel default)
CREATE TABLE `notifications` (
    `id` CHAR(36) NOT NULL PRIMARY KEY,
    `type` VARCHAR(255) NOT NULL,
    `notifiable_type` VARCHAR(255) NOT NULL,
    `notifiable_id` BIGINT UNSIGNED NOT NULL,
    `data` TEXT NOT NULL,
    `read_at` TIMESTAMP NULL,
    `created_at` TIMESTAMP NULL,
    `updated_at` TIMESTAMP NULL,
    INDEX `notifications_notifiable` (`notifiable_type`, `notifiable_id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Sessions
CREATE TABLE `sessions` (
    `id` VARCHAR(255) NOT NULL PRIMARY KEY,
    `user_id` BIGINT UNSIGNED NULL,
    `ip_address` VARCHAR(45) NULL,
    `user_agent` TEXT NULL,
    `payload` LONGTEXT NOT NULL,
    `last_activity` INT NOT NULL,
    INDEX `sessions_user_id_index` (`user_id`),
    INDEX `sessions_last_activity_index` (`last_activity`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- ===========================================
-- SEED DATA
-- ===========================================

-- Insert permissions
INSERT INTO `permissions` (`name`, `guard_name`, `created_at`, `updated_at`) VALUES
('create_project', 'web', NOW(), NOW()),
('edit_project', 'web', NOW(), NOW()),
('delete_project', 'web', NOW(), NOW()),
('create_task', 'web', NOW(), NOW()),
('assign_task', 'web', NOW(), NOW()),
('update_task_status', 'web', NOW(), NOW()),
('comment_task', 'web', NOW(), NOW()),
('manage_users', 'web', NOW(), NOW()),
('manage_teams', 'web', NOW(), NOW()),
('view_reports', 'web', NOW(), NOW());

-- Insert roles
INSERT INTO `roles` (`name`, `guard_name`, `created_at`, `updated_at`) VALUES
('Super Admin', 'web', NOW(), NOW()),
('Company Admin', 'web', NOW(), NOW()),
('Manager', 'web', NOW(), NOW()),
('Team Leader', 'web', NOW(), NOW()),
('Employee', 'web', NOW(), NOW()),
('Viewer', 'web', NOW(), NOW());

-- Super Admin gets all permissions
INSERT INTO `role_has_permissions` (`permission_id`, `role_id`)
SELECT p.id, r.id FROM `permissions` p, `roles` r WHERE r.name = 'Super Admin';

-- Company Admin gets all permissions
INSERT INTO `role_has_permissions` (`permission_id`, `role_id`)
SELECT p.id, r.id FROM `permissions` p, `roles` r WHERE r.name = 'Company Admin';

-- Manager permissions
INSERT INTO `role_has_permissions` (`permission_id`, `role_id`)
SELECT p.id, r.id FROM `permissions` p, `roles` r
WHERE r.name = 'Manager' AND p.name IN ('create_project','edit_project','create_task','assign_task','update_task_status','comment_task','manage_teams','view_reports');

-- Team Leader permissions
INSERT INTO `role_has_permissions` (`permission_id`, `role_id`)
SELECT p.id, r.id FROM `permissions` p, `roles` r
WHERE r.name = 'Team Leader' AND p.name IN ('create_project','edit_project','create_task','assign_task','update_task_status','comment_task','view_reports');

-- Employee permissions
INSERT INTO `role_has_permissions` (`permission_id`, `role_id`)
SELECT p.id, r.id FROM `permissions` p, `roles` r
WHERE r.name = 'Employee' AND p.name IN ('create_task','update_task_status','comment_task');

-- Viewer permissions
INSERT INTO `role_has_permissions` (`permission_id`, `role_id`)
SELECT p.id, r.id FROM `permissions` p, `roles` r
WHERE r.name = 'Viewer' AND p.name IN ('comment_task');

-- Insert company
INSERT INTO `companies` (`name`, `slug`, `subscription_plan`, `description`, `is_active`, `created_at`, `updated_at`)
VALUES ('Acme Corporation', 'acme-corporation', 'enterprise', 'Leading technology and innovation company', 1, NOW(), NOW());

-- Insert users (password is 'password' = $2y$12$...)
-- bcrypt hash for 'password'
SET @pwd = '$2y$12$84gFcISSlrIRsyqEd5eTye0GSDPOrK8i8cB//TMZD9DRYwsE7i24.';

INSERT INTO `users` (`company_id`, `name`, `email`, `password`, `job_title`, `department`, `is_active`, `created_at`, `updated_at`) VALUES
(1, 'Admin User', 'admin@asana.test', @pwd, 'System Administrator', 'IT', 1, NOW(), NOW()),
(1, 'Sarah Manager', 'manager@asana.test', @pwd, 'Project Manager', 'Engineering', 1, NOW(), NOW()),
(1, 'John Leader', 'leader@asana.test', @pwd, 'Team Lead', 'Engineering', 1, NOW(), NOW()),
(1, 'Alice Developer', 'alice@asana.test', @pwd, 'Senior Developer', 'Engineering', 1, NOW(), NOW()),
(1, 'Bob Designer', 'bob@asana.test', @pwd, 'UI/UX Designer', 'Design', 1, NOW(), NOW()),
(1, 'Charlie Viewer', 'viewer@asana.test', @pwd, 'Stakeholder', 'Management', 1, NOW(), NOW());

-- Assign roles to users
INSERT INTO `model_has_roles` (`role_id`, `model_type`, `model_id`) VALUES
(1, 'App\\Models\\User', 1),
(3, 'App\\Models\\User', 2),
(4, 'App\\Models\\User', 3),
(5, 'App\\Models\\User', 4),
(5, 'App\\Models\\User', 5),
(6, 'App\\Models\\User', 6);

-- Insert teams
INSERT INTO `teams` (`company_id`, `name`, `department`, `description`, `color`, `created_at`, `updated_at`) VALUES
(1, 'Engineering', 'Technology', 'Software development team', '#6366f1', NOW(), NOW()),
(1, 'Design', 'Creative', 'UI/UX and graphic design team', '#ec4899', NOW(), NOW()),
(1, 'Marketing', 'Marketing', 'Digital marketing and growth team', '#f59e0b', NOW(), NOW());

-- Team members
INSERT INTO `team_user` (`team_id`, `user_id`, `role`, `created_at`, `updated_at`) VALUES
(1, 2, 'lead', NOW(), NOW()),
(1, 3, 'lead', NOW(), NOW()),
(1, 4, 'member', NOW(), NOW()),
(2, 5, 'lead', NOW(), NOW());

-- Insert tags
INSERT INTO `tags` (`company_id`, `name`, `color`, `created_at`, `updated_at`) VALUES
(1, 'Bug', '#ef4444', NOW(), NOW()),
(1, 'Feature', '#3b82f6', NOW(), NOW()),
(1, 'Urgent', '#f97316', NOW(), NOW()),
(1, 'Design', '#ec4899', NOW(), NOW()),
(1, 'Backend', '#8b5cf6', NOW(), NOW());

-- Insert projects
INSERT INTO `projects` (`company_id`, `team_id`, `owner_id`, `name`, `description`, `status`, `priority`, `color`, `start_date`, `due_date`, `progress`, `created_at`, `updated_at`) VALUES
(1, 1, 2, 'Website Redesign', 'Complete redesign of the company website with modern UI/UX', 'in_progress', 'high', '#6366f1', DATE_SUB(CURDATE(), INTERVAL 14 DAY), DATE_ADD(CURDATE(), INTERVAL 30 DAY), 35, NOW(), NOW()),
(1, 1, 3, 'Mobile App Development', 'Build a cross-platform mobile application', 'not_started', 'medium', '#10b981', DATE_ADD(CURDATE(), INTERVAL 7 DAY), DATE_ADD(CURDATE(), INTERVAL 90 DAY), 0, NOW(), NOW()),
(1, 2, 5, 'Brand Identity Update', 'Update brand guidelines, logo, and design system', 'in_progress', 'medium', '#ec4899', DATE_SUB(CURDATE(), INTERVAL 7 DAY), DATE_ADD(CURDATE(), INTERVAL 21 DAY), 50, NOW(), NOW()),
(1, 3, 2, 'Q1 Marketing Campaign', 'Plan and execute Q1 digital marketing campaign', 'completed', 'high', '#f59e0b', DATE_SUB(CURDATE(), INTERVAL 60 DAY), DATE_SUB(CURDATE(), INTERVAL 5 DAY), 100, NOW(), NOW());

-- Project members
INSERT INTO `project_user` (`project_id`, `user_id`, `role`, `created_at`, `updated_at`) VALUES
(1, 2, 'owner', NOW(), NOW()),
(1, 3, 'member', NOW(), NOW()),
(1, 4, 'member', NOW(), NOW()),
(1, 5, 'member', NOW(), NOW());

-- Insert tasks for Website Redesign project
INSERT INTO `tasks` (`project_id`, `assignee_id`, `creator_id`, `title`, `status`, `priority`, `due_date`, `position`, `is_completed`, `completed_at`, `created_at`, `updated_at`) VALUES
(1, 5, 2, 'Create wireframes', 'completed', 'high', DATE_SUB(CURDATE(), INTERVAL 5 DAY), 0, 1, NOW(), NOW(), NOW()),
(1, 5, 2, 'Design homepage mockup', 'completed', 'high', DATE_SUB(CURDATE(), INTERVAL 2 DAY), 1, 1, NOW(), NOW(), NOW()),
(1, 4, 2, 'Set up Laravel project', 'completed', 'medium', DATE_SUB(CURDATE(), INTERVAL 7 DAY), 2, 1, NOW(), NOW(), NOW()),
(1, 4, 2, 'Implement navigation header', 'in_progress', 'medium', DATE_ADD(CURDATE(), INTERVAL 3 DAY), 3, 0, NULL, NOW(), NOW()),
(1, 4, 2, 'Build hero section', 'in_progress', 'medium', DATE_ADD(CURDATE(), INTERVAL 5 DAY), 4, 0, NULL, NOW(), NOW()),
(1, 5, 2, 'Create about page', 'todo', 'low', DATE_ADD(CURDATE(), INTERVAL 10 DAY), 5, 0, NULL, NOW(), NOW()),
(1, 4, 2, 'Implement contact form', 'todo', 'medium', DATE_ADD(CURDATE(), INTERVAL 12 DAY), 6, 0, NULL, NOW(), NOW()),
(1, 4, 2, 'Add responsive design', 'todo', 'high', DATE_ADD(CURDATE(), INTERVAL 15 DAY), 7, 0, NULL, NOW(), NOW()),
(1, 3, 2, 'Performance optimization', 'todo', 'medium', DATE_ADD(CURDATE(), INTERVAL 20 DAY), 8, 0, NULL, NOW(), NOW()),
(1, 3, 2, 'QA testing', 'review', 'high', DATE_ADD(CURDATE(), INTERVAL 2 DAY), 9, 0, NULL, NOW(), NOW()),
(1, 4, 2, 'Fix header dropdown bug', 'in_progress', 'urgent', DATE_SUB(CURDATE(), INTERVAL 1 DAY), 10, 0, NULL, NOW(), NOW()),
(1, NULL, 2, 'SEO optimization', 'todo', 'low', DATE_ADD(CURDATE(), INTERVAL 25 DAY), 11, 0, NULL, NOW(), NOW());

-- Task tags
INSERT INTO `tag_task` (`task_id`, `tag_id`) VALUES
(11, 3), -- Fix header dropdown bug -> Urgent
(2, 4),  -- Design homepage mockup -> Design
(11, 1); -- Fix header dropdown bug -> Bug

-- Comments
INSERT INTO `comments` (`task_id`, `user_id`, `body`, `created_at`, `updated_at`) VALUES
(1, 2, 'Great progress on this! Let''s make sure we follow the brand guidelines.', NOW(), NOW()),
(1, 5, 'I''ve uploaded the latest wireframes. Please review when you get a chance.', NOW(), NOW());

-- Activities
INSERT INTO `activities` (`company_id`, `subject_type`, `subject_id`, `causer_id`, `action`, `description`, `created_at`, `updated_at`) VALUES
(1, 'App\\Models\\Project', 1, 2, 'created', 'created project "Website Redesign"', NOW(), NOW()),
(1, 'App\\Models\\Task', 1, 4, 'status_changed', 'changed task status to "Completed"', NOW(), NOW()),
(1, 'App\\Models\\Task', 4, 4, 'status_changed', 'started working on "Implement navigation header"', NOW(), NOW()),
(1, 'App\\Models\\Task', 11, 2, 'created', 'created task "Fix header dropdown bug"', NOW(), NOW()),
(1, 'App\\Models\\Project', 3, 5, 'created', 'created project "Brand Identity Update"', NOW(), NOW());
