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

/**
 * Migration 003 — Homepage hero carousel slides
 * media_type: image | video (self-hosted MP4) | youtube
 */
class Migration_Create_hero_slides extends CI_Migration {

	public function up()
	{
		$this->dbforge->add_field(array(
			'id'           => array('type' => 'INT', 'constraint' => 11, 'unsigned' => TRUE, 'auto_increment' => TRUE),
			'media_type'   => array('type' => "ENUM('image','video','youtube')", 'default' => 'image'),
			'image'        => array('type' => 'VARCHAR', 'constraint' => 255, 'null' => TRUE, 'comment' => 'Image file OR video poster'),
			'video_file'   => array('type' => 'VARCHAR', 'constraint' => 255, 'null' => TRUE, 'comment' => 'Uploaded MP4'),
			'youtube_id'   => array('type' => 'VARCHAR', 'constraint' => 40,  'null' => TRUE, 'comment' => 'YouTube video ID'),
			'eyebrow'      => array('type' => 'VARCHAR', 'constraint' => 120, 'null' => TRUE),
			'heading'      => array('type' => 'VARCHAR', 'constraint' => 200, 'null' => TRUE),
			'subheading'   => array('type' => 'TEXT', 'null' => TRUE),
			'cta1_label'   => array('type' => 'VARCHAR', 'constraint' => 60, 'null' => TRUE),
			'cta1_url'     => array('type' => 'VARCHAR', 'constraint' => 255, 'null' => TRUE),
			'cta2_label'   => array('type' => 'VARCHAR', 'constraint' => 60, 'null' => TRUE),
			'cta2_url'     => array('type' => 'VARCHAR', 'constraint' => 255, 'null' => TRUE),
			'overlay'      => array('type' => 'TINYINT', 'constraint' => 1, 'default' => 1, 'comment' => 'Dark overlay on/off'),
			'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->create_table('hero_slides', TRUE, array('ENGINE' => 'InnoDB'));

		$now = date('Y-m-d H:i:s');
		$this->db->insert_batch('hero_slides', array(
			array(
				'media_type' => 'image', 'image' => 'hero/hero-1.jpg',
				'eyebrow' => 'CREATIVE AGENCY', 'heading' => 'Where Creative Vision Blooms',
				'subheading' => 'Talent. Campaigns. Experiences. We build creative universes for brands that dare to be unforgettable.',
				'cta1_label' => 'Work With Us', 'cta1_url' => 'contact',
				'cta2_label' => 'Discover Our Work', 'cta2_url' => 'portfolio',
				'overlay' => 1, 'sort_order' => 1, 'is_active' => 1, 'created_at' => $now,
			),
			array(
				'media_type' => 'youtube', 'youtube_id' => 'dQw4w9WgXcQ', 'image' => 'hero/hero-2.jpg',
				'eyebrow' => 'CAMPAIGN REEL', 'heading' => 'Stories That Move Brands Forward',
				'subheading' => 'From editorial shoots to full brand activations — see the work in motion.',
				'cta1_label' => 'View Portfolio', 'cta1_url' => 'portfolio',
				'overlay' => 1, 'sort_order' => 2, 'is_active' => 1, 'created_at' => $now,
			),
			array(
				'media_type' => 'image', 'image' => 'hero/hero-3.jpg',
				'eyebrow' => 'TALENT NETWORK', 'heading' => 'The Faces of Tomorrow',
				'subheading' => 'A curated roster of models, creatives and influencers ready for your next campaign.',
				'cta1_label' => 'Meet the Talent', 'cta1_url' => 'talent',
				'cta2_label' => 'Join the Network', 'cta2_url' => 'apply/talent',
				'overlay' => 1, 'sort_order' => 3, 'is_active' => 1, 'created_at' => $now,
			),
		));
	}

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