-- Create Enquiries Table
CREATE TABLE IF NOT EXISTS enquiries (
    id INT AUTO_INCREMENT PRIMARY KEY,
    full_name VARCHAR(255) NOT NULL,
    company_name VARCHAR(255) NOT NULL,
    job_title VARCHAR(255),
    country VARCHAR(100) NOT NULL,
    phone VARCHAR(50) NOT NULL,
    email VARCHAR(255) NOT NULL,
    interests TEXT, -- Stores interest categories as JSON or string
    message TEXT,
    status ENUM('pending', 'contacted', 'resolved') DEFAULT 'pending',
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Create Pattern Groups Table
CREATE TABLE IF NOT EXISTS pattern_groups (
    id VARCHAR(50) PRIMARY KEY,
    pattern_family VARCHAR(100) NOT NULL,
    description TEXT, -- Stores pattern descriptions (JSON array)
    tyre_position VARCHAR(255), -- e.g., "A, T, D"
    application VARCHAR(255) -- e.g., "H, R, U"
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;

-- Create Products Table
CREATE TABLE IF NOT EXISTS products (
    id VARCHAR(100) PRIMARY KEY,
    name VARCHAR(255) NOT NULL,
    pattern_group_id VARCHAR(50),
    width INT,
    thickness DECIMAL(10,2),
    rim_diameter INT,
    weight DECIMAL(10,2),
    image_url VARCHAR(255),
    created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
    FOREIGN KEY (pattern_group_id) REFERENCES pattern_groups(id) ON DELETE SET NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
