CREATE TABLE IF NOT EXISTS hyro_leads (
    id BIGINT UNSIGNED NOT NULL AUTO_INCREMENT,

    lead_code VARCHAR(30) NOT NULL,

    request_type VARCHAR(30) NOT NULL DEFAULT 'book_demo',
    product_code VARCHAR(30) NOT NULL,

    company_name VARCHAR(150) NOT NULL,
    contact_name VARCHAR(150) NOT NULL,

    email VARCHAR(190) NOT NULL,
    phone VARCHAR(40) NOT NULL,

    country_code CHAR(2) NOT NULL,
    country_name VARCHAR(100) NOT NULL,
    city VARCHAR(100) DEFAULT NULL,

    preferred_date DATE DEFAULT NULL,
    preferred_time VARCHAR(30) DEFAULT NULL,
    timezone VARCHAR(60) DEFAULT NULL,

    message TEXT DEFAULT NULL,

    source_page VARCHAR(255) DEFAULT NULL,
    source_campaign VARCHAR(100) DEFAULT NULL,

    status VARCHAR(30) NOT NULL DEFAULT 'new',
    assigned_to VARCHAR(100) DEFAULT NULL,

    ip_address VARCHAR(45) DEFAULT NULL,
    user_agent VARCHAR(500) DEFAULT NULL,

    created_at DATETIME NOT NULL,
    updated_at DATETIME NOT NULL,

    PRIMARY KEY (id),
    UNIQUE KEY uq_hyro_leads_lead_code (lead_code),

    KEY idx_hyro_leads_email (email),
    KEY idx_hyro_leads_phone (phone),
    KEY idx_hyro_leads_product (product_code),
    KEY idx_hyro_leads_status (status),
    KEY idx_hyro_leads_created_at (created_at)
)
ENGINE=InnoDB
DEFAULT CHARACTER SET utf8mb4
COLLATE utf8mb4_unicode_ci;
