<?php
defined('BASEPATH') OR exit('No direct script access allowed');

/**
 * Migration 004 — Creative services (6 core offerings)
 * process_steps stored as JSON: [{title, text}, ...]
 */
class Migration_Create_services extends CI_Migration {

	public function up()
	{
		$this->dbforge->add_field(array(
			'id'            => array('type' => 'INT', 'constraint' => 11, 'unsigned' => TRUE, 'auto_increment' => TRUE),
			'slug'          => array('type' => 'VARCHAR', 'constraint' => 160),
			'title'         => array('type' => 'VARCHAR', 'constraint' => 160),
			'icon'          => array('type' => 'VARCHAR', 'constraint' => 60, 'null' => TRUE, 'comment' => 'SVG icon key'),
			'summary'       => array('type' => 'TEXT', 'null' => TRUE),
			'description'   => array('type' => 'LONGTEXT', 'null' => TRUE),
			'for_who'       => array('type' => 'TEXT', 'null' => TRUE),
			'image'         => array('type' => 'VARCHAR', 'constraint' => 255, 'null' => TRUE),
			'process_steps' => array('type' => 'LONGTEXT', 'null' => TRUE, 'comment' => 'JSON array'),
			'cta_label'     => array('type' => 'VARCHAR', 'constraint' => 60, 'default' => 'Work With Us'),
			'meta_title'    => array('type' => 'VARCHAR', 'constraint' => 200, 'null' => TRUE),
			'meta_desc'     => array('type' => 'VARCHAR', 'constraint' => 300, 'null' => TRUE),
			'sort_order'    => array('type' => 'INT', 'constraint' => 5, 'default' => 0),
			'is_active'     => array('type' => 'TINYINT', 'constraint' => 1, 'default' => 1),
			'created_at'    => array('type' => 'DATETIME', 'null' => TRUE),
			'updated_at'    => array('type' => 'DATETIME', 'null' => TRUE),
		));
		$this->dbforge->add_key('id', TRUE);
		$this->dbforge->add_key('slug');
		$this->dbforge->create_table('services', TRUE, array('ENGINE' => 'InnoDB'));

		$now  = date('Y-m-d H:i:s');
		$proc = json_encode(array(
			array('title' => 'Discovery', 'text' => 'We learn your brand, goals and creative ambitions.'),
			array('title' => 'Concept', 'text' => 'We craft a creative direction and present the vision.'),
			array('title' => 'Production', 'text' => 'We assemble talent, crew and resources to execute.'),
			array('title' => 'Delivery', 'text' => 'We deliver polished assets and measure the impact.'),
		));

		$services = array(
			array('talent-management', 'Talent Management & Representation', 'star',
				'We discover, develop and represent exceptional creative talent.',
				'Who it is for: brands seeking authentic faces, and talent seeking professional representation.'),
			array('brand-collaborations', 'Brand Collaborations & Influencer Campaigns', 'handshake',
				'Strategic partnerships that connect brands with the right creators and audiences.',
				'Who it is for: brands launching products, campaigns or seeking influencer reach.'),
			array('creative-direction', 'Creative Direction & Styling', 'palette',
				'End-to-end creative direction that gives every project a distinct, editorial identity.',
				'Who it is for: brands and talent needing a cohesive, elevated visual language.'),
			array('event-production', 'Event Production & Coordination', 'calendar',
				'Fashion events, activations and pop-ups produced from concept to final curtain.',
				'Who it is for: brands and organisers wanting memorable, well-run experiences.'),
			array('content-creation', 'Content Creation & Editorial Shoots', 'camera',
				'High-impact editorial and campaign content built for modern platforms.',
				'Who it is for: brands needing premium imagery, video and editorial content.'),
			array('campaign-casting', 'Campaign Casting & Production Support', 'film',
				'Casting and production support that puts the right people in front of the lens.',
				'Who it is for: agencies and brands running campaigns and productions.'),
		);

		$order = 1;
		foreach ($services as $s)
		{
			$this->db->insert('services', array(
				'slug' => $s[0], 'title' => $s[1], 'icon' => $s[2],
				'summary' => $s[3], 'description' => $s[3].' '.$s[4],
				'for_who' => $s[4], 'process_steps' => $proc,
				'cta_label' => 'Book a Consultation',
				'meta_title' => $s[1].' — Bloom Iris Agency',
				'meta_desc' => $s[3],
				'sort_order' => $order++, 'is_active' => 1, 'created_at' => $now,
			));
		}
	}

	public function down()
	{
		$this->dbforge->drop_table('services', TRUE);
	}
}
